Hi,
Here is a fix to opkgc-0.6.1 so if fully works under Centos 6.3 (and CentOS-5.x
as well of course).
What does it addresses?
1/ Includes a needed patch not yet in svn: (see
http://www.mail-archive.com/oscar-devel@lists.sourceforge.net/msg09108.html for
the FIX and
http://www.mail-archive.com/oscar-devel@lists.sourceforge.net/msg09107.html for
the description of the problem)
2/ It enables some debugging outputs in the spec file template if -v flag is
used.
3/ It fixes multiple copies of the same script and fixes unpackaged scripts.
4/ Added some code comments to easy algorythms reading/understanding.
Appliying this patch will result in a fully functional opkgc that works with
actual packages (old api naming schem and new api scheme (as described in the
opkg manual).
I've successfully built (and verified package file lists) for all oscar
packages on CentOS-5.8 and CentOS-6.3 and everything seems ok, no duplicated
scripts (no more script dir in /var/lib/oscar/pacakge/<pkg_name>). generated
rpms are now compliant with the api described in opkg manual.
--
Olivier LAHAYE
CEA DRT/LIST/DCSI/DIR
Index: opkgc/trunk/ChangeLog
===================================================================
--- opkgc/trunk/ChangeLog (révision 9456)
+++ opkgc/trunk/ChangeLog (copie de travail)
@@ -4,6 +4,9 @@
* When generating RPMs, do not fail if files are installed but unpackaged
(we copy some files we do not actually need).
* Code clean-up.
+ * Better rpm requirements processing msg09108 from Olivier LAHAYE
+ * Fix scripts files enumeration so there a no missing files an no
+ duplicate
0.6.0:
* On Debian, put the scripts in the correct OPKG packages (correctly deal
Index: opkgc/trunk/src/OpkgcLib/Rpm.py
===================================================================
--- opkgc/trunk/src/OpkgcLib/Rpm.py (révision 9456)
+++ opkgc/trunk/src/OpkgcLib/Rpm.py (copie de travail)
@@ -65,39 +65,46 @@
nc['name'] = "OPKG::%s" % c['name']
deps.append(nc)
- if len(deps) != 0:
+ if len(deps) != 0: # if there are some dependancies
archout = ""
- if arch != None:
+ if arch != None: # if there is a specific arch, report it
archout += "%%if %%{_build_arch} == %s\n" % arch
- archout += "%s: " % self.dependsName[relation]
- pkg_d = {}
- ver_d = {}
+ pkg_d = {} # memory for processed deps
+ ver_d = {} # flags for each filters. (if not in: create section)
+ version=-1 # no version for generic requirements.
for i, d in enumerate(deps):
- if len(d) != 0:
- xs = d['dist']
- for x in xs:
- if x['version'] != None:
+ if len(d) != 0: # non empty deps
+ xs = d['dist'] # dependancy filter (os, version, ...)
+ for x in xs: # scann all filters for this "requires"
+ if x['version'] != None: # filter exists
xx = x['version']
- if xx not in ver_d:
- ver_d[xx] = 1
- xx = self.replace_comp_sign(xx)
+ if xx != version and version != -1:
+ archout += "\n%endif\n"
+ archout += "%endif\n"
+ version = xx # keep version tracking so we can add endif when changing.
+ if xx not in ver_d: # 1st time we see this version => create section
+ ver_d[xx] = 1 # remember section created
+ xx = self.replace_comp_sign(xx) # convert comparison sign
archout += "\n%%if %%{%s}" % distro_d[x['name']]
archout += "\n%%define is_version %%(test %%{vtag} %s && echo 1 || echo 0)" % xx
archout += "\n%if %{is_version}\n"
archout += "%s: " % self.dependsName[relation]
+ else:
+ archout += ', ' # section exists, jsut add a ","
+ if len(pkg_d) == 0: # 1st relation:
+ archout += "%s: " % self.dependsName[relation]
+ elif version == -1: # still processing generic requirements
+ archout += ', ' # section exists, jsut add a ","
+ pkg_d[self.formatPkg(d)] = 1 # package processed
archout += self.formatPkg(d)
- if ((len(deps) > 1) and (i < len(deps) - 1)):
- archout += ', '
- elif self.formatPkg(d) not in pkg_d and len(ver_d) != 0:
- pkg_d[self.formatPkg(d)] = 1
- archout += "\n%endif\n"
- archout += "%endif\n"
+ if version != -1:
+ archout += "\n%endif\n"
+ archout += "%endif\n"
archout += "\n"
- if arch != None:
+ if arch != None: # OL: Still usefull?
archout += "%endif\n"
archout += "\n"
out += archout
-
return out
def formatPkg(self, p):
Index: opkgc/trunk/src/OpkgcLib/OpkgDescription.py
===================================================================
--- opkgc/trunk/src/OpkgcLib/OpkgDescription.py (révision 9456)
+++ opkgc/trunk/src/OpkgcLib/OpkgDescription.py (copie de travail)
@@ -83,7 +83,7 @@
files.extend(self.getScripts())
files.extend(self.getDocFiles())
files.extend(self.getTestingFiles())
-
+
configFile = OpkgFile(self.getPackageName(), "config.xml")
configFile['dest'] = os.path.join("var", "lib", "oscar", "packages", self.getPackageName())
files.append(configFile)
@@ -96,26 +96,6 @@
configuratorFile = OpkgFile(self.getPackageName(), configuratorPath)
configuratorFile['dest'] = os.path.join("var", "lib", "oscar", "packages", self.getPackageName())
files.append(configuratorFile)
-
- # [GVALLEE] we also need to make sure the following scripts are
- # included.
- # [20090330] I fixed a bug that may prevent previous code to do that.
- # So maybe the following code is not necessary anymore.
- scripts = ["api-pre-install", "api-post-install", "api-pre-uninstall", "api-post-uninstall", "server-pre-install", "server-post-install", "server-pre-uninstall", "server-post-uninstall", "client-pre-install", "client-post-install", "client-pre-uninstall", "client-post-uninstall", "api-post-clientdef", "api-post-image", ""]
- for scriptPath in scripts:
- if os.path.exists(os.path.join(self.opkgdir, "scripts", scriptPath)):
- scriptFile = OpkgFile(self.getPackageName(), os.path.join("scripts",scriptPath))
- scriptFile['dest'] = os.path.join("var", "lib", "oscar", "packages", self.getPackageName())
- # By default, we set the part of the script to Unknown
- scriptFile['part'] = "Unknowm"
- if scriptPath.startswith ("api"):
- scriptFile['part'] = "api"
- if scriptPath.startswith ("server"):
- scriptFile['part'] = "server"
- if scriptPath.startswith ("client"):
- scriptFile['part'] = "client"
- files.append(scriptFile)
-
return files
def getVersion(self, part=None):
@@ -181,7 +161,7 @@
for a in arch:
Logger().debug ("-> Arch " + a)
for d in dists:
- Logger().debug ("-> Dist " + d)
+ Logger().debug ("-> Dist " + d['name'])
l = self.xmldoc.findall('serverDeps/requires/filters/arch')
Logger().info("Number of arch filters: %d" % len(l))
return arch
@@ -376,7 +356,7 @@
def __init__(self, pkg, filename):
UserDict.__init__(self)
self['pkg'] = pkg
- self['part'] = 'api'
+ self['part'] = 'api' # By default: part = api
# path relative to opkg
self['orig'] = filename
self['basename'] = os.path.basename(filename)
@@ -402,13 +382,13 @@
OpkgFile.__init__(self, pkg, filename)
self['native'] = self.__isNative__()
- part = self.__extract__('part')
+ part = self.__extract__('part') # api|client|server
if part:
self['part'] = part
else:
- self['part'] = 'api'
- self['time'] = self.__extract__('time')
- self['action'] = self.__extract__('action')
+ self['part'] = 'api' # Unknown part => api (OL: redundant with __init__)
+ self['time'] = self.__extract__('time') # pre|post
+ self['action'] = self.__extract__('action') # install|uninstall
self['dest'] = os.path.join("var", "lib", "oscar", "packages", pkg)
def __isNative__(self):
@@ -416,9 +396,9 @@
{pre|post}{inst|rm} scripts
name: basename of the script
"""
- return self.scriptRe.match(self['basename'])
+ return self.scriptRe.match(self['basename']) # Matches pkg name at the beginning of the script name or None
- def __extract__(self, group):
+ def __extract__(self, group): # group = part|time|action
m = self.scriptRe.match(self['basename'])
if m:
return m.group(group)
Index: opkgc/trunk/templates/rpm/opkg.spec.tmpl
===================================================================
--- opkgc/trunk/templates/rpm/opkg.spec.tmpl (révision 9456)
+++ opkgc/trunk/templates/rpm/opkg.spec.tmpl (copie de travail)
@@ -1,6 +1,10 @@
# -*- Mode: rpm-spec -*-
#
-%define _unpackaged_files_terminate_build 0
+#from OpkgcLib.Logger import *
+
+#if Logger().isDebug()
+ #silent $sys.stderr.write("[DEBUG] Cheetah compil: generating opkg-" + $name + ".spec\n")
+#end if
Summary: $summary
Name: opkg-$name
Version: $version('upstream')
@@ -57,9 +61,15 @@
%build
+#if Logger().isDebug()
+ #silent $sys.stderr.write("[DEBUG] %install: step generation\n")
+#end if
%install
rm -fr \$RPM_BUILD_ROOT
#for $f in $filelist
+#if Logger().isDebug()
+ #silent $sys.stderr.write(" %install: Need to copy: " + str($f.orig) + "\n")
+#end if
mkdir -p \$RPM_BUILD_ROOT/$f.dest
cp -r $f.orig \$RPM_BUILD_ROOT/$f.dest/
#end for
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oscar-devel mailing list
Oscar-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oscar-devel