1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 """babtools_gentoo: Some tools for working with Gentoo.
22
23
24 Usage:
25 - babtools_gentoo.py cmd [OPTIONS]
26
27 for default usage, or
28
29 - babtools_gentoo.py --help
30
31 for getting help
32
33
34 Avaible commands:
35 - ebuild_to_local CP
36
37 CP (cathegory/package) in the simple form dev-lang/python or similar. CPVs (cathegory/package-version) aren't supported, yet.
38
39 - ebuild_download_to_local CP URL
40
41 Download an ebuild from bugs.gentoo.org to the local portage tree.
42
43 - emerge_from_pypi PACKAGE
44
45 Create an ebuild from a project in PyPI, put it into package.keywords and install it.
46 Honors package.keywords directories.
47 It only puts the directly named PACKAGE into package.keywords as dev-python/PACKAGE
48 but doesn't put the dependencies into package.keywords.
49
50
51 Examples:
52 - sudo babtools_gentoo.py ebuild_to_local dev-lang/python
53
54 copy dev-lang/python into the local overlay
55
56 - sudo babtools_gentoo.py ebuild_download_to_local games-rpg/vegastrike http://bugs.gentoo.org/attachment.cgi?id=151789
57
58 Download the ebuild for games-rpg/vegastrike from bugs.gentoo.org and digest it.
59
60 - sudo babtools_gentoo.py emerge_from_pypi magma
61
62 Create an ebuild for "magma" from the PyPI and emerge it.
63
64
65 Source URL (Mercurial): U{http://freehg.org/u/ArneBab/babtools_gentoo/}
66
67 PyPI URL: U{http://pypi.python.org/pypi/babtools_gentoo}
68 """
69
71 """Display help and a list of commands."""
72
73 print __doc__.split("\n\n")[1]
74
75 print ""
76 print ""
77 list_commands()
78
79 print ""
80 print ""
81 print_examples()
82
84 """List avaible commands."""
85
86 print __doc__.split("\n\n")[2]
87
89 """List avaible commands."""
90
91 print __doc__.split("\n\n")[3]
92
93
94
96 from doctest import testmod
97 testmod()
98
99 if __name__ == "__main__":
100
101 from sys import argv
102
103 if len(argv) == 1:
104 print "We need a command as argument, for example 'ebuild_to_local'."
105 print_help()
106
107 elif argv[1] == "help" or argv[1] == "--help" or argv[1] == "-h":
108 print_help()
109
110
111 elif argv[1] == "ebuild_to_local" and len(argv) == 2:
112 print "'ebuild_to_local' needs a valid package atom as argument (like dev-lang/python)."
113
114
115
116
117 elif argv[1] == "ebuild_to_local" and len(argv) == 3:
118 from portage_functions import copy_ebuild_to_local_overlay
119 copy_ebuild_to_local_overlay(argv[2])
120
121
122
123 elif argv[1] == "ebuild_download_to_local":
124 if len(argv) < 4:
125 print_help()
126 else:
127 from portage_functions import download_ebuild_to_local_overlay
128 download_ebuild_to_local_overlay(CP=argv[2], URL=argv[3])
129
130
131
132 elif argv[1] == "emerge_from_pypi":
133 if len(argv) < 3:
134 print_help()
135 else:
136 from portage_functions import emerge_from_pypi
137 emerge_from_pypi(PACKAGE=argv[2])
138 else:
139 print "command not recognized:", argv[1]
140 print_help()
141
142
143