summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAuke Booij (tulcod) <auke@tulcod.com>2010-07-15 09:50:59 +0200
committerAuke Booij (tulcod) <auke@tulcod.com>2010-07-15 10:21:53 +0200
commit62238b0f1901fdb0602254da581e435515e04e9e (patch)
treeaf9de8d5e3a6c90125f6eae4fee3433d7720e877
parentSet HOMEPAGE to remote repository URI (diff)
downloadg-cran-62238b0f1901fdb0602254da581e435515e04e9e.tar.gz
g-cran-62238b0f1901fdb0602254da581e435515e04e9e.tar.bz2
g-cran-62238b0f1901fdb0602254da581e435515e04e9e.zip
Adding support for CRAN's serialized package database
-rw-r--r--g_cran/convert_packages_rds.R5
-rw-r--r--g_cran/cran_read.py13
-rw-r--r--g_cran/g_cran.py11
-rw-r--r--setup.py2
4 files changed, 26 insertions, 5 deletions
diff --git a/g_cran/convert_packages_rds.R b/g_cran/convert_packages_rds.R
new file mode 100644
index 0000000..61c3494
--- /dev/null
+++ b/g_cran/convert_packages_rds.R
@@ -0,0 +1,5 @@
+args<-commandArgs(TRUE)
+rdsfile<-args[1]
+packagesfile<-args[2]
+packages <- .readRDS(rdsfile)
+write.dcf(packages,packagesfile)
diff --git a/g_cran/cran_read.py b/g_cran/cran_read.py
index 63c25ed..8e8f840 100644
--- a/g_cran/cran_read.py
+++ b/g_cran/cran_read.py
@@ -150,10 +150,17 @@ def pmsify_package_data(data,remote_repository):
e_vars['rdepend']=deps
e_vars['iuse']="doc"
- e_vars['homepage']=remote_repository
+ try:
+ uri_regex="([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?)(?:\?((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?(?:#((?:[a-z0-9-._~!$&'()*+,;=:/?@]|%[0-9A-F]{2})*))?"
+ find_first_url=re.finditer(uri_regex,data['url'])
+ e_vars['homepage']=find_first_url.next().group(0)
+ except: #error processing url from data['url']
+ e_vars['homepage']=remote_repository
e_vars['keywords']="~x86 ~amd64"
- if 'description' in data:
- e_vars['description']=data['description'].strip().replace('\n',' ')
+ if 'title' in data:
+ e_vars['description']=data['title'].strip().replace('\n',' ')
+ elif 'description' in data:
+ e_vars['description']=data['description'].split('. ')[0].strip().replace('\n',' ') #first sentence
else:
e_vars['description']=e_vars['pn']
if 'license' in data: #fixme parse license data
diff --git a/g_cran/g_cran.py b/g_cran/g_cran.py
index 51fa588..6898109 100644
--- a/g_cran/g_cran.py
+++ b/g_cran/g_cran.py
@@ -12,7 +12,16 @@ def action_sync(repo_location,remote_uri):
if not os.path.isdir(os.path.join(repo_location, REPO_MYDIR)):
os.mkdir(os.path.join(repo_location,REPO_MYDIR))
packages_filename=os.path.join(repo_location, REPO_MYDIR, 'PACKAGES')
- urllib.urlretrieve(remote_uri+'/src/contrib/PACKAGES',packages_filename)
+ packages_rds_filename=os.path.join(repo_location, REPO_MYDIR, 'packages.rds')
+ try:
+ #we first try to get a serialized full database... this works for CRAN
+ urllib.urlretrieve(remote_uri+'/web/packages/packages.rds',packages_rds_filename)
+ R_script=os.path.join(os.path.dirname(__file__),'convert_packages_rds.R')
+ returncode=os.system('R --quiet --file='+R_script+' --args '+packages_rds_filename+' '+packages_filename)
+ if returncode:
+ raise RuntimeError('Could not convert packages.rds')
+ except:
+ urllib.urlretrieve(remote_uri+'/src/contrib/PACKAGES',packages_filename)
repo_file=open(os.path.join(repo_location,REPO_MYDIR,'remote_uri'),'w')
repo_file.write(remote_uri)
diff --git a/setup.py b/setup.py
index 8fb2bcb..69e8228 100644
--- a/setup.py
+++ b/setup.py
@@ -10,5 +10,5 @@ setup(name='G-CRAN',
url='http://git.overlays.gentoo.org/gitweb/?p=proj/g-cran.git ',
packages=['g_cran'],
scripts=['bin/g-cran'],
- package_data={'g_cran':['cran.ebuild',]},
+ package_data={'g_cran':['cran.ebuild','convert_packages_rds.R']},
)