1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/usr/bin/python
import getopt, sys, os, string, urllib, re, configparser
import settings
#__doc__="Usage: "+sys.argv[0]+" <local repository directory> <action> [<action arguments>...]"
def list_configured_drivers():
#all .cfg files which end in .cfg as they should
return [x[:-len('.cfg')] for x in os.listdir(settings.GLOBAL_CONF_DIR) if x[-len('.cfg'):]=='.cfg']
#read key=value file to dict
def read_config(conf_file,defaults={}):
return configparser.ConfigParser(conf_file,defaults).items('DEFAULTS')
#returns dict of key=value config file
def read_driver_config(driver_name):
conffile=os.path.join('/etc/g-common',driver_name+'.cfg')
return read_config(conffile,{
#'name':None,
#'executable':None,
})
return configs #dict
#read g-common config for a repo
def read_repo_config(repo_location):
hidden_conffile=os.path.join(repo_location,settings.MYDIR,'conf')
return read_config(hidden_conffile)
#sync a local repository's PACKAGES file
def action_sync(repo_location,remote_uri):
#todo
raise NotImplementedError
#list categories in this repositorie
def list_categories(repo_location):
#todo
raise NotImplementedError
#idem ditto
def list_packages(repo_location):
#todo
raise NotImplementedError
#generate a tree of ebuilds... note that we only link ebuild files
#metadata.xml and Manifest and whatnot is not generated
def generate_tree(repo_location):
#todo
raise NotImplementedError
#list package details, in PMS's format
def action_package(repo_location,package_name):
#todo
raise NotImplementedError
def usage():
print __doc__
def main():
arguments=sys.argv[1:]
#print options, arguments
if len(arguments)<2: #we need at least a local repository location and an action
usage()
sys.exit(0)
action=arguments[1]
repo_location=os.path.abspath(arguments[0])
if action=='sync':
if len(arguments)<3:
print "The 'sync' action takes the following parameters:"
print " * remote_repository_uri"
sys.exit(1)
remote_repo=arguments[2]
action_sync(repo_location,remote_repo)
elif action=='list-categories':
list_categories(repo_location)
elif action=='list-packages':
list_packages(repo_location)
elif action=='generate-tree':
generate_tree(repo_location)
elif action=='package':
if len(arguments)<3:
print "The 'package' action takes the following parameters:"
print " * category/package_name"
print " * [version]"
sys.exit(1)
package_name=arguments[2]
action_package(repo_location,package_name)
elif action=='usage':
usage()
elif action in pms_phases:
#todo
raise NotImplementedError
elif action in actions_wanted:
raise NotImplementedError
else:
usage()
sys.exit(0)
if __name__ == "__main__":
main()
|