aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephano Cetola <stephano.cetola@linux.intel.com>2016-11-15 09:03:00 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-23 11:10:14 +0000
commit8b686f281c07dd473bb56b85633392457afde975 (patch)
treeee2fba29d60daaa95d56206f72aba3fb44d9de4b
parent43a135b0c8f9f9ab2f48f739ab134390e862c0cc (diff)
downloadopenembedded-core-contrib-8b686f281c07dd473bb56b85633392457afde975.tar.gz
recipetool: add postinst to .deb import
The .deb import feature did not import postinst, postrm, preinst, or prerm functions. This change checks to see if those files exist, and if so, adds the appropriate functions. [ YOCTO #10421 ] (From OE-Core rev: ebb73aa6ad920bfd6a23f8c20105d6bcf07dd3d5) Signed-off-by: Stephano Cetola <stephano.cetola@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/recipetool/create.py35
1 files changed, 32 insertions, 3 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index cb1c80434c..ab265318e5 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -234,7 +234,8 @@ class RecipeHandler(object):
if deps:
values['DEPENDS'] = ' '.join(deps)
- def genfunction(self, outlines, funcname, content, python=False, forcespace=False):
+ @staticmethod
+ def genfunction(outlines, funcname, content, python=False, forcespace=False):
if python:
prefix = 'python '
else:
@@ -460,8 +461,8 @@ def create_recipe(args):
if pkgfile:
if pkgfile.endswith(('.deb', '.ipk')):
- stdout, _ = bb.process.run('ar x %s control.tar.gz' % pkgfile, cwd=tmpfdir)
- stdout, _ = bb.process.run('tar xf control.tar.gz ./control', cwd=tmpfdir)
+ stdout, _ = bb.process.run('ar x %s' % pkgfile, cwd=tmpfdir)
+ stdout, _ = bb.process.run('tar xf control.tar.gz', cwd=tmpfdir)
values = convert_debian(tmpfdir)
extravalues.update(values)
elif pkgfile.endswith(('.rpm', '.srpm')):
@@ -722,6 +723,15 @@ def create_recipe(args):
if not bbclassextend:
lines_after.append('BBCLASSEXTEND = "native"')
+ postinst = ("postinst", extravalues.pop('postinst', None))
+ postrm = ("postrm", extravalues.pop('postrm', None))
+ preinst = ("preinst", extravalues.pop('preinst', None))
+ prerm = ("prerm", extravalues.pop('prerm', None))
+ funcs = [postinst, postrm, preinst, prerm]
+ for func in funcs:
+ if func[1]:
+ RecipeHandler.genfunction(lines_after, 'pkg_%s_${PN}' % func[0], func[1])
+
outlines = []
outlines.extend(lines_before)
if classes:
@@ -1058,6 +1068,25 @@ def convert_debian(debpath):
varname = value_map.get(key, None)
if varname:
values[varname] = value
+ postinst = os.path.join(debpath, 'postinst')
+ postrm = os.path.join(debpath, 'postrm')
+ preinst = os.path.join(debpath, 'preinst')
+ prerm = os.path.join(debpath, 'prerm')
+ sfiles = [postinst, postrm, preinst, prerm]
+ for sfile in sfiles:
+ if os.path.isfile(sfile):
+ logger.info("Converting %s file to recipe function..." %
+ os.path.basename(sfile).upper())
+ content = []
+ with open(sfile) as f:
+ for line in f:
+ if "#!/" in line:
+ continue
+ line = line.rstrip("\n")
+ if line.strip():
+ content.append(line)
+ if content:
+ values[os.path.basename(f.name)] = content
#if depends:
# values['DEPENDS'] = ' '.join(depends)