summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create.py
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 /scripts/lib/recipetool/create.py
parent43a135b0c8f9f9ab2f48f739ab134390e862c0cc (diff)
downloadpoky-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>
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-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):
234 if deps: 234 if deps:
235 values['DEPENDS'] = ' '.join(deps) 235 values['DEPENDS'] = ' '.join(deps)
236 236
237 def genfunction(self, outlines, funcname, content, python=False, forcespace=False): 237 @staticmethod
238 def genfunction(outlines, funcname, content, python=False, forcespace=False):
238 if python: 239 if python:
239 prefix = 'python ' 240 prefix = 'python '
240 else: 241 else:
@@ -460,8 +461,8 @@ def create_recipe(args):
460 461
461 if pkgfile: 462 if pkgfile:
462 if pkgfile.endswith(('.deb', '.ipk')): 463 if pkgfile.endswith(('.deb', '.ipk')):
463 stdout, _ = bb.process.run('ar x %s control.tar.gz' % pkgfile, cwd=tmpfdir) 464 stdout, _ = bb.process.run('ar x %s' % pkgfile, cwd=tmpfdir)
464 stdout, _ = bb.process.run('tar xf control.tar.gz ./control', cwd=tmpfdir) 465 stdout, _ = bb.process.run('tar xf control.tar.gz', cwd=tmpfdir)
465 values = convert_debian(tmpfdir) 466 values = convert_debian(tmpfdir)
466 extravalues.update(values) 467 extravalues.update(values)
467 elif pkgfile.endswith(('.rpm', '.srpm')): 468 elif pkgfile.endswith(('.rpm', '.srpm')):
@@ -722,6 +723,15 @@ def create_recipe(args):
722 if not bbclassextend: 723 if not bbclassextend:
723 lines_after.append('BBCLASSEXTEND = "native"') 724 lines_after.append('BBCLASSEXTEND = "native"')
724 725
726 postinst = ("postinst", extravalues.pop('postinst', None))
727 postrm = ("postrm", extravalues.pop('postrm', None))
728 preinst = ("preinst", extravalues.pop('preinst', None))
729 prerm = ("prerm", extravalues.pop('prerm', None))
730 funcs = [postinst, postrm, preinst, prerm]
731 for func in funcs:
732 if func[1]:
733 RecipeHandler.genfunction(lines_after, 'pkg_%s_${PN}' % func[0], func[1])
734
725 outlines = [] 735 outlines = []
726 outlines.extend(lines_before) 736 outlines.extend(lines_before)
727 if classes: 737 if classes:
@@ -1058,6 +1068,25 @@ def convert_debian(debpath):
1058 varname = value_map.get(key, None) 1068 varname = value_map.get(key, None)
1059 if varname: 1069 if varname:
1060 values[varname] = value 1070 values[varname] = value
1071 postinst = os.path.join(debpath, 'postinst')
1072 postrm = os.path.join(debpath, 'postrm')
1073 preinst = os.path.join(debpath, 'preinst')
1074 prerm = os.path.join(debpath, 'prerm')
1075 sfiles = [postinst, postrm, preinst, prerm]
1076 for sfile in sfiles:
1077 if os.path.isfile(sfile):
1078 logger.info("Converting %s file to recipe function..." %
1079 os.path.basename(sfile).upper())
1080 content = []
1081 with open(sfile) as f:
1082 for line in f:
1083 if "#!/" in line:
1084 continue
1085 line = line.rstrip("\n")
1086 if line.strip():
1087 content.append(line)
1088 if content:
1089 values[os.path.basename(f.name)] = content
1061 1090
1062 #if depends: 1091 #if depends:
1063 # values['DEPENDS'] = ' '.join(depends) 1092 # values['DEPENDS'] = ' '.join(depends)