Skip to contentSkip to conversation

rootfs.py: Allow to override postinst-intercepts location

PATCH In review Martin Jansa 2 participants 5 messages Sep 10, 2015 – Sep 15, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 rootfs.py: Allow to override postinst-intercepts location

* useful when we need to overlay/extend intercept scripts from oe-core

---
 meta/lib/oe/rootfs.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta/lib/oe/rootfs.py +4 -2
index e86480c..d2de2c6 100644
@@ -114,6 +114,9 @@ class Rootfs(object):
         pre_process_cmds = self.d.getVar("ROOTFS_PREPROCESS_COMMAND", True)
         post_process_cmds = self.d.getVar("ROOTFS_POSTPROCESS_COMMAND", True)
 
+        postinst_intercepts_dir = self.d.getVar("POSTINST_INTERCEPTS_DIR", True)
+        if not postinst_intercepts_dir:
+            postinst_intercepts_dir = self.d.expand("${COREBASE}/scripts/postinst-intercepts")
         intercepts_dir = os.path.join(self.d.getVar('WORKDIR', True),
                                       "intercept_scripts")
 
@@ -123,8 +126,7 @@ class Rootfs(object):
 
         bb.utils.mkdirhier(self.deploy_dir_image)
 
-        shutil.copytree(self.d.expand("${COREBASE}/scripts/postinst-intercepts"),
-                        intercepts_dir)
+        shutil.copytree(postinst_intercepts_dir, intercepts_dir)
 
         shutil.copy(self.d.expand("${COREBASE}/meta/files/deploydir_readme.txt"),
                     self.deploy_dir_image +
Signature · 1 line
2.5.1
#1 lore raw

PATCH 2/3 rootfs.py: show intercept script output in log.do_rootfs

* without this the output wasn't shown anywhere even when the bb.warn says:
"See log for details!"

---
 meta/lib/oe/rootfs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oe/rootfs.py +1 -1
index d2de2c6..15ad642 100644
@@ -229,7 +229,7 @@ class Rootfs(object):
             bb.note("> Executing %s intercept ..." % script)
 
             try:
-                subprocess.check_output(script_full)
+                subprocess.check_call(script_full)
             except subprocess.CalledProcessError as e:
                 bb.warn("The postinstall intercept hook '%s' failed (exit code: %d)! See log for details!" %
                         (script, e.returncode))
Signature · 1 line
2.5.1
#2 lore raw

Re: [fido][PATCH 2/3] rootfs.py: show intercept script output in log.do_rootfs

Quoted 5 lines · Martin Jansa

* without this the output wasn't shown anywhere even when the bb.warn says:
"See log for details!"

Patch queued in my joshuagl/fido-next tree - thanks!

Joshua

http://cgit.openembedded.org/openembedded-core-contrib/log/?h=joshuagl/
fido-next

Quoted 18 lines
---
 meta/lib/oe/rootfs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oe/rootfs.py +1 -1
index d2de2c6..15ad642 100644
@@ -229,7 +229,7 @@ class Rootfs(object):
             bb.note("> Executing %s intercept ..." % script)
 
             try:
-                subprocess.check_output(script_full)
+                subprocess.check_call(script_full)
             except subprocess.CalledProcessError as e:
                 bb.warn("The postinstall intercept hook '%s' failed

(exit code: %d)! See log for details!" %
(script, e.returncode))

#3 lore raw

PATCH 3/3 postinst_intercept: allow to pass variables with spaces

In reply to Martin Jansa

* trying to pass foo="a b" through postinst_intercept ends with the actual script header to containing:
b
foo=a
which fails because "b" command doesn't exist.

---
 scripts/postinst-intercepts/postinst_intercept | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/postinst-intercepts/postinst_intercept +1 -1
index a257198..b18e806 100755
@@ -48,7 +48,7 @@ if [ -n "$pkgs_line" ]; then
 		sed -i -e "s/##PKGS:.*/\0${package_name} /" $intercept_script
 	fi
 else
-	for var in $@; do
+	for var in "$@"; do
 		sed -i -e "\%^#\!/bin/.*sh%a $var" $intercept_script
 	done
 	echo "##PKGS: ${package_name} " >> $intercept_script
Signature · 1 line
2.5.1
#4 lore raw

Re: [fido][PATCH 3/3] postinst_intercept: allow to pass variables with spaces

Quoted 7 lines · Martin Jansa

* trying to pass foo="a b" through postinst_intercept ends with the actual script header to containing:
b
foo=a
which fails because "b" command doesn't exist.

Patch queued in my joshuagl/fido-next tree - thanks!

Joshua

http://cgit.openembedded.org/openembedded-core-contrib/log/?h=joshuagl/
fido-next

Quoted 19 lines
---
 scripts/postinst-intercepts/postinst_intercept | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/postinst-intercepts/postinst_intercept +0 -0
index a257198..b18e806 100755
@@ -48,7 +48,7 @@ if [ -n "$pkgs_line" ]; then
 		sed -i -e "s/##PKGS:.*/\0${package_name} /"

$intercept_script

scripts/postinst-intercepts/postinst_intercept +1 -1
 	fi
 else
-	for var in $@; do
+	for var in "$@"; do
 		sed -i -e "\%^#\!/bin/.*sh%a $var" $intercept_script
 	done
 	echo "##PKGS: ${package_name} " >> $intercept_script