summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'g_common/g_common.py')
-rw-r--r--g_common/g_common.py62
1 files changed, 49 insertions, 13 deletions
diff --git a/g_common/g_common.py b/g_common/g_common.py
index f7c483b..b72961d 100644
--- a/g_common/g_common.py
+++ b/g_common/g_common.py
@@ -4,6 +4,10 @@ import settings
#__doc__="Usage: "+sys.argv[0]+" <local repository directory> <action> [<action arguments>...]"
+def verbose_system(command):
+ print command
+ return os.system(command)
+
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']
@@ -23,34 +27,66 @@ def read_driver_config(driver_name):
#read g-common config for a repo
def read_repo_config(repo_location):
- hidden_conffile=os.path.join(repo_location,settings.MYDIR,'conf')
+ hidden_conffile=os.path.join(repo_location,settings.MYDIR,'repo.cfg')
return read_config(hidden_conffile)
#sync a local repository's PACKAGES file
-def action_sync(repo_location,remote_uri):
- #todo
- raise NotImplementedError
+def action_sync(repo_location,remote_uri=None):
+ repo_conf=read_repo_config(repo_location)
+ driver_conf=read_driver_config(repo_conf['driver'])
+
+ if remote_uri is None:
+ remote_uri=repo_conf['uri']
+ #todo write repo.cfg
+
+ return verbose_system(driver_conf['exec']+" "+repo_location+" sync "+remote_uri)
#list categories in this repositorie
def list_categories(repo_location):
- #todo
- raise NotImplementedError
+ repo_conf=read_repo_config(repo_location)
+ driver_conf=read_driver_config(repo_conf['driver'])
+
+ if remote_uri is None:
+ remote_uri=repo_conf['uri']
+
+ return verbose_system(driver_conf['exec']+" "+repo_location+" list-categories")
#idem ditto
def list_packages(repo_location):
- #todo
- raise NotImplementedError
+ repo_conf=read_repo_config(repo_location)
+ driver_conf=read_driver_config(repo_conf['driver'])
+
+ if remote_uri is None:
+ remote_uri=repo_conf['uri']
+
+ return verbose_system(driver_conf['exec']+" "+repo_location+" list-packages")
-#generate a tree of ebuilds... note that we only link ebuild files
-#metadata.xml and Manifest and whatnot is not generated
+
+#generate a tree of ebuilds... note that we only link ebuild files, instead of generating them
+#we will, however, generate metadata.xml and Manifest files
def generate_tree(repo_location):
- #todo
+ repo_conf=read_repo_config(repo_location)
+ driver_conf=read_driver_config(repo_conf['driver'])
+ #todo list packages
raise NotImplementedError
+ packages=[]
+ ebuild_file=COMMON_EBUILD_FILE
+ for package in packages:
+ #todo
+ ebuild_dir=os.path.join(repo_location,'dev-R',package.ebuild_vars['pn'])
+ if not os.path.exists(ebuild_dir):
+ os.makedirs(ebuild_dir)
+ os.symlink(ebuild_file,os.path.join(ebuild_dir,package.ebuild_vars['pn']+'-'+package.ebuild_vars['pv']+'.ebuild'))
#list package details, in PMS's format
def action_package(repo_location,package_name):
- #todo
- raise NotImplementedError
+ repo_conf=read_repo_config(repo_location)
+ driver_conf=read_driver_config(repo_conf['driver'])
+
+ if remote_uri is None:
+ remote_uri=repo_conf['uri']
+
+ return verbose_system(driver_conf['exec']+" "+repo_location+" package "+package_name)
def usage():
print __doc__