On Tuesday 23 March 2010 14:12:36 Pierre-Yves wrote:
> > > If I am not asking too much it would be nice if r2rpm could fetch the
> > > sources directly from CRAN if we pass only the package name (or with a
> > > special option for that matter).
> >
> > I have this idea in my mind for some time, I will look into this :-)
>
> Ok this is implemented in the new release (0.2)
> sources:
> https://fedorahosted.org/releases/r/2/r2spec/R2spec-3.0.0pre2.tar.gz
> src.rpm:
> https://fedorahosted.org/releases/r/2/r2spec/R2spec-3.0.0-0.2.fc12.src.rpm
> rpm:
> https://fedorahosted.org/releases/r/2/r2spec/R2spec-3.0.0-0.2.fc12.noarch.r
> pm
>
> As you see I changed the release number so I believe rpm will complain.
>
> The -p option works for cran, bioconductor and the
> r-forge.r-project.org.
>
> I'll look into %{_specdir} and %{_sourcedir} for the release 0.3 ;-)
>
> For the rest, does it work properly for you ?
OK, I am catching on all the mail after a busy week. I have not yet tried to
apply the latest version 0.3 here are my comments from previous versions.
I had to use the following patch.
Some notes on the elements of the diff:
* emacs refuses to address the UTF-8 encoding it only recognizes utf-8. That
is why I have changed it for every file I had to edit.
* in R2spec I have the following snippet:
- self.version = self.file['version']
+ self.version = self.file['version'].replace("-",".")
The purpose as we have discussed before is to harmonize the versions used
where in R the - (dash?) and point are equal as far as the package version is
concerned.
As you can imagine I got an error with a package that has this version.
(mAr_1.1-2.tar.gz)
It would be easier to coerce the author to change the name but this only works
for my wife, not necessarily for all the other R packages authors. :-)
* in RPackage.py I have delegated to rpm the interpretation of rpm macros
using a pipe. The only exception to this rule is the %{name} macro that is not
set at that time.
> Thanks for the feed back,
>
> Pierre
Other than those issues pointed the package works really well, it is nice to
set back and watch it do all the work. :-)
--
José Abílio
diff --git a/devel/r2spec/Build.py b/devel/r2spec/Build.py
index 9dfe578..da42c29 100644
--- a/devel/r2spec/Build.py
+++ b/devel/r2spec/Build.py
@@ -1,4 +1,4 @@
-#-*- coding: UTF-8 -*-
+#-*- coding: utf-8 -*-
#***********************************************
# R2rpm
diff --git a/devel/r2spec/Description.py b/devel/r2spec/Description.py
index bdc1b77..eaeab70 100644
--- a/devel/r2spec/Description.py
+++ b/devel/r2spec/Description.py
@@ -1,4 +1,4 @@
-#-*- coding: UTF-8 -*-
+#-*- coding: utf-8 -*-
#**********************************************
# R2spec
@@ -31,7 +31,7 @@ class Description:
''' Set the version of the package '''
# Retrieve the Version number
try:
- self.version = self.file['version']
+ self.version = self.file['version'].replace("-",".")
except KeyError, err:
print "No version set"
self.version = ""
diff --git a/devel/r2spec/R2rpm.py b/devel/r2spec/R2rpm.py
index 60bc994..7f1735c 100644
--- a/devel/r2spec/R2rpm.py
+++ b/devel/r2spec/R2rpm.py
@@ -1,4 +1,4 @@
-#-*- coding: UTF-8 -*-
+#-*- coding: utf-8 -*-
#***********************************************
# R2rpm
@@ -61,11 +61,9 @@ class R2rpm:
# Generate the spec file
r = RPackage()
- specdir = r.getRPMTopDirectory()
- if specdir != None:
- os.chdir(specdir + "/SPECS/")
# Enforce the copyfile and the force option
specname = R2spec().main(source, url, bioc, cran, rforge, rproject, True, name, email, True)
+ specdir = r.getRPMTopDirectory("_specdir", specname)
specname = specname + ".spec"
self.build.append(specname)
diff --git a/devel/r2spec/RPackage.py b/devel/r2spec/RPackage.py
index 7526aa8..69c34d8 100644
--- a/devel/r2spec/RPackage.py
+++ b/devel/r2spec/RPackage.py
@@ -1,4 +1,4 @@
-#-*- coding: UTF-8 -*-
+#-*- coding: utf-8 -*-
#**********************************************
# R2spec
@@ -14,6 +14,7 @@
from Packager import *
from Description import *
from Spec import *
+from subprocess import Popen, PIPE
import os, sys, re, datetime
@@ -247,28 +248,27 @@ class RPackage:
spec.writeSpec(specname)
spec.writeOut()
- def getRPMTopDirectory(self):
- try:
- f = open(os.path.expanduser("~")+"/.rpmmacros", "r")
- rpm = f.read()
- f.close()
- try:
- topdir = re.compile('%_topdir(.*)').findall(rpm)[0].strip()
- topdir = topdir.replace('%(echo $HOME)', os.path.expanduser("~"))
- except IndexError, err:
- print 'No %_topdir defined in ~/.rpmmacros'
- topdir = None
- except IOError, err:
- print 'Cannot read the file .rpmmacros'
- print err
-
- return topdir
+ def getRPMTopDirectory(self, tag, name = None):
+ ''' Parses the rpm macros to get directory locations '''
+ dirname = Popen(["rpm", "-E", '%' + tag], stdout=PIPE).stdout.read()[:-1]
+ specname = name
+ if self.name:
+ specname = "R-" + self.name
+
+ if specname:
+ dirname = dirname.replace("%{name}", specname)
+ dirname = dirname.replace("%name", specname)
+
+ for i in range(10):
+ print "#"*80
+ print dirname
+ return dirname
def moveSource(self, copyFile):
''' Moves the tarball to where it should be to build the RPM '''
- topdir = self.getRPMTopDirectory()
+ topdir = self.getRPMTopDirectory("_srcrpmdir")
+
if topdir != None:
- topdir = topdir+"/SOURCES/"
if copyFile == False:
text = "Do you want to copy the source (" + self.source + ") to " + topdir + "? Y/N [Y]\n"
answer = raw_input(text)
_______________________________________________
r-devel mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/r-devel