summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xg_common/common.ebuild (renamed from g_cran/cran.ebuild)6
-rw-r--r--g_common/g_common.py62
-rw-r--r--g_cran/g_cran.py13
-rw-r--r--setup.py7
4 files changed, 58 insertions, 30 deletions
diff --git a/g_cran/cran.ebuild b/g_common/common.ebuild
index ac4d286..1904c57 100755
--- a/g_cran/cran.ebuild
+++ b/g_common/common.ebuild
@@ -10,12 +10,12 @@ this_repo="${this_dirname}/../../"
#discover category, package name and version
cat_pn_pvr=$(echo $this_file|/bin/sed -r 's$.+?/([A-Za-z0-9+_.-]+)/([A-Za-z0-9+_-]+)/\2-([0-9]+(\.[0-9]+)*[a-z]?((_alpha|_beta|_pre|_rc|_p)[0-9]*)*(-r[0-9]*)?)\.ebuild$\1/\2 \3$')
-#this reads in metadata from g-cran
+#this reads in metadata from g-common
{ while read -r line
do
export "$line"
done
-} < <(/usr/bin/g-cran $this_repo package $cat_pn_pvr || die);
+} < <(/usr/bin/g-common $this_repo package $cat_pn_pvr || die);
for phase in $GCOMMON_PHASES
do
@@ -23,5 +23,5 @@ do
done
function exec_phase() {
- /usr/bin/g-cran $this_repo $1 || die
+ /usr/bin/g-common $this_repo $1 || die
}
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__
diff --git a/g_cran/g_cran.py b/g_cran/g_cran.py
index 6898109..d005d38 100644
--- a/g_cran/g_cran.py
+++ b/g_cran/g_cran.py
@@ -35,17 +35,6 @@ def list_packages(repo_location):
for package in packages:
print 'dev-R/'+package.ebuild_vars['pn'],package.ebuild_vars['pv']
-#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):
- packages=read_packages(os.path.join(repo_location,REPO_MYDIR,'PACKAGES'),repo_location)
- ebuild_file=os.path.join(os.path.dirname(__file__),'cran.ebuild')
- for package in packages:
- 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):
defined_phases=[]
@@ -90,8 +79,6 @@ def main():
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:"
diff --git a/setup.py b/setup.py
index e38682e..8af5737 100644
--- a/setup.py
+++ b/setup.py
@@ -10,5 +10,10 @@ setup(name='G-CRAN',
url='http://git.overlays.gentoo.org/gitweb/?p=proj/g-cran.git ',
packages=['g_cran','g_common'],
scripts=['bin/g-cran','bin/g-common'],
- package_data={'g_cran':['cran.ebuild','convert_packages_rds.R']},
+ 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/',['g_common/common.ebuild']),
+ ]
)