summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAuke Booij (tulcod) <auke@tulcod.com>2010-07-30 15:42:16 +0200
committerAuke Booij (tulcod) <auke@tulcod.com>2010-07-30 15:42:16 +0200
commit896ab04348509da537a51adb2fc94dcb613dc936 (patch)
tree7fdf3a1ef78723dd78dab8016c478547c2c16ecb
parentSome actions should work now. Proper configuration not included, stay tuned. (diff)
downloadg-cran-896ab04348509da537a51adb2fc94dcb613dc936.tar.gz
g-cran-896ab04348509da537a51adb2fc94dcb613dc936.tar.bz2
g-cran-896ab04348509da537a51adb2fc94dcb613dc936.zip
Even more actions should be working now. Added config file support.
-rw-r--r--g_common/g_common.py48
-rw-r--r--setup.py2
2 files changed, 33 insertions, 17 deletions
diff --git a/g_common/g_common.py b/g_common/g_common.py
index b72961d..e4932b9 100644
--- a/g_common/g_common.py
+++ b/g_common/g_common.py
@@ -1,5 +1,5 @@
#!/usr/bin/python
-import getopt, sys, os, string, urllib, re, configparser
+import getopt, sys, os, string, urllib, re, configparser, subprocess
import settings
#__doc__="Usage: "+sys.argv[0]+" <local repository directory> <action> [<action arguments>...]"
@@ -31,13 +31,20 @@ def read_repo_config(repo_location):
return read_config(hidden_conffile)
#sync a local repository's PACKAGES file
-def action_sync(repo_location,remote_uri=None):
- repo_conf=read_repo_config(repo_location)
- driver_conf=read_driver_config(repo_conf['driver'])
+def action_sync(repo_location,driver,remote_uri):
+ if driver=None:
+ repo_conf=read_repo_config(repo_location)
+ driver=repo_conf['driver']
+ driver_conf=read_driver_config(driver)
if remote_uri is None:
remote_uri=repo_conf['uri']
#todo write repo.cfg
+
+ cfg_file=open(os.path.join(repo_location,MYDIR,"repo.cfg"),"w")
+ cfg_file.write('driver='+driver)
+ cfg_file.write('uri='+remote_uri)
+ cfg_file.close()
return verbose_system(driver_conf['exec']+" "+repo_location+" sync "+remote_uri)
@@ -67,13 +74,16 @@ def list_packages(repo_location):
def generate_tree(repo_location):
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'])
+
+ ebuild_file=COMMON_EBUILD_FILE #get from settings
+
+ packages_list_pipe=subprocess.Popen(fixme,shell=True,stdout=subprocess.PIPE)
+ os.waitpid(process.pid,0)
+ for line in packages_list_pipe.stdout:
+ category=line[:line.find("/")]
+ package=line[line.find("/")+1:line.find(" ")]
+ version=line[line.find(" ")+1:]
+ ebuild_dir=os.path.join(repo_location,category,package)
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'))
@@ -100,12 +110,18 @@ def main():
action=arguments[1]
repo_location=os.path.abspath(arguments[0])
if action=='sync':
- if len(arguments)<3:
+ if len(arguments)<2 or 'help' in arguments:
print "The 'sync' action takes the following parameters:"
- print " * remote_repository_uri"
+ print " * [driver]"
+ print " * [remote_repository_uri]"
sys.exit(1)
- remote_repo=arguments[2]
- action_sync(repo_location,remote_repo)
+ driver=None
+ remote_repo=None
+ if len(arguments)>2:
+ driver=arguments[2]
+ if len(arguments)>3:
+ remote_repo=arguments[2]
+ action_sync(repo_location,driver,remote_repo)
elif action=='list-categories':
list_categories(repo_location)
elif action=='list-packages':
@@ -113,7 +129,7 @@ def main():
elif action=='generate-tree':
generate_tree(repo_location)
elif action=='package':
- if len(arguments)<3:
+ if len(arguments)<3 or 'help' in arguments:
print "The 'package' action takes the following parameters:"
print " * category/package_name"
print " * [version]"
diff --git a/setup.py b/setup.py
index 8af5737..4e5c149 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,7 @@ setup(name='G-CRAN',
package_data={'g_cran':['convert_packages_rds.R']},
data_files=[
#('/etc/g-common/',['g_common/']),
- ('/usr/share/g-common/drivers/',['g_cran/g_cran.cfg']),
+ ('/usr/share/g-common/drivers/',['g_cran/g-cran.cfg']),
('/usr/share/g-common/',['g_common/common.ebuild']),
]
)