utils: create_cmdline_shebang_wrapper whitespace and sed refactor
PATCH 1/3 utils: create_cmdline_shebang_wrapper whitespace and sed refactor
Correct whitespace to match the rest of the code in utils. Refactored sed expression with a simpler equivalent.
--- meta/classes/utils.bbclass | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
meta/classes/utils.bbclass +5 -5
@@ -188,7 +188,7 @@ create_cmdline_shebang_wrapper () { # Create a wrapper script where commandline options are needed # # These are useful to work around shebang relocation issues, where shebangs are too - # long or have arguments in them, thus preventing them from using the /usr/bin/env + # long or have arguments in them, thus preventing them from using the /usr/bin/env # shebang # # Usage: create_cmdline_wrapper FILENAME <extra-options>
@@ -198,10 +198,10 @@ create_cmdline_shebang_wrapper () { echo "Generating wrapper script for $cmd" - # Strip #! and get remaining interpreter + arg - argument="$(basename "$(head -n1 $cmd | sed -e 's|#![ ]*||g' )")" - # strip the shebang from the real script as we do not want it to be usable anyway - tail -n +2 $cmd > $cmd.real + # Strip #! and get remaining interpreter + arg + argument="$(sed -ne 's/^#! *//p;q' $cmd)" + # strip the shebang from the real script as we do not want it to be usable anyway + tail -n +2 $cmd > $cmd.real cmdname=$(basename $cmd) dirname=$(dirname $cmd) cmdoptions=$@
Signature · 1 line
2.25.1
PATCH 2/3 oeqa/sysroot.py: Check bitbake return status
bitbake ran but we incorrectly did not assert the exit status needs to be non 0. Now all sysroot tests commands expected to fail are verified to do so.
--- meta/lib/oeqa/selftest/cases/sysroot.py | 5 +++++ 1 file changed, 5 insertions(+)
meta/lib/oeqa/selftest/cases/sysroot.py +5 -0
@@ -45,6 +45,7 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]" res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) + self.assertTrue(res.status != 0) def test_sysroot_la(self): """
@@ -57,10 +58,12 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" res = bitbake("sysroot-la-test -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) self.assertTrue('[la]' in res.output, msg=res.output) + self.assertTrue(res.status != 0) res = bitbake("sysroot-la-test-native -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) self.assertTrue('[la]' in res.output, msg=res.output) + self.assertTrue(res.status != 0) def test_sysroot_pkgconfig(self): """
@@ -73,7 +76,9 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" res = bitbake("sysroot-pc-test -c populate_sysroot", ignore_status=True) self.assertTrue('[pkgconfig]' in res.output, msg=res.output) self.assertTrue(expected in res.output, msg=res.output) + self.assertTrue(res.status != 0) res = bitbake("sysroot-pc-test-native -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) self.assertTrue('[pkgconfig]' in res.output, msg=res.output) + self.assertTrue(res.status != 0)
Signature · 1 line
2.25.1
Re: [OE-core] [PATCH 2/3] oeqa/sysroot.py: Check bitbake return status
Quoted 14 lines · Paulo Neves
bitbake ran but we incorrectly did not assert the exit status needs to be non 0. Now all sysroot tests commands expected to fail are verified to do so.
Signed-off-by Paulo Neves <[email protected]>--- meta/lib/oeqa/selftest/cases/sysroot.py | 5 +++++ 1 file changed, 5 insertions(+)meta/lib/oeqa/selftest/cases/sysroot.py +0
-0
meta/lib/oeqa/selftest/cases/sysroot.py TESTSTRING:pn-sysroot-test-arch2 = "%s" · line 51
Quoted 7 lines
meta/lib/oeqa/selftest/cases/sysroot.py +1
-0@@ -45,6 +45,7 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]" res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) + self.assertTrue(res.status != 0) def test_sysroot_la(self): """
I did have a question on this patch. Wouldn't it be simpler to remove the "ignore_status=True" from the bitbake() call?
Cheers,
Richard
Re: [OE-core] [PATCH 2/3] oeqa/sysroot.py: Check bitbake return status
Quoted 20 lines · Richard Purdie
Quoted 19 lines · Paulo Neves
bitbake ran but we incorrectly did not assert the exit status needs to be non 0. Now all sysroot tests commands expected to fail are verified to do so.
Signed-off-by Paulo Neves <[email protected]>--- meta/lib/oeqa/selftest/cases/sysroot.py | 5 +++++ 1 file changed, 5 insertions(+)meta/lib/oeqa/selftest/cases/sysroot.py +1
-0@@ -45,6 +45,7 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]" res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) + self.assertTrue(res.status != 0)
Quoted 8 lines
meta/lib/oeqa/selftest/cases/sysroot.py TESTSTRING:pn-sysroot-test-arch2 = "%s" · line 51
Quoted 2 lines
meta/lib/oeqa/selftest/cases/sysroot.py +0
-0def test_sysroot_la(self): """I did have a question on this patch. Wouldn't it be simpler to remove the "ignore_status=True" from the
bitbake()call?Cheers,
Richard
You are right. I guess the assert is more explicit and with the removal of the ignore_status it becomes implicit. Let me know if you want me to remove the assert and the ignore status and will submit a v2.
Paulo Neves
Re: [OE-core] [PATCH 2/3] oeqa/sysroot.py: Check bitbake return status
Quoted 26 lines · Paulo Neves
Quoted 25 lines · Richard Purdie
Quoted 14 lines · Paulo Neves
bitbake ran but we incorrectly did not assert the exit status needs to be non 0. Now all sysroot tests commands expected to fail are verified to do so.
Signed-off-by Paulo Neves <[email protected]>--- meta/lib/oeqa/selftest/cases/sysroot.py | 5 +++++ 1 file changed, 5 insertions(+)meta/lib/oeqa/selftest/cases/sysroot.py +0
-0meta/lib/oeqa/selftest/cases/sysroot.py TESTSTRING:pn-sysroot-test-arch2 = "%s" · line 51
Quoted 7 lines
meta/lib/oeqa/selftest/cases/sysroot.py +1
-0@@ -45,6 +45,7 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]" res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) + self.assertTrue(res.status != 0) def test_sysroot_la(self): """I did have a question on this patch. Wouldn't it be simpler to remove the "ignore_status=True" from the
bitbake()call?
Quoted 6 lines
Quoted 3 lines
Cheers,
Richard
You are right. I guess the assert is more explicit and with the removal of the
ignore_statusit becomes implicit. Let me know if you want me to remove the assert and the ignore status and will submit a v2.
Please, I think that would be cleaner.
Cheers,
Richard
Re: [OE-core] [PATCH 2/3] oeqa/sysroot.py: Check bitbake return status
After re-thinking this is the correct version of the patch. We need to ignore_status because we are asserting that it actually fails. Otherwise the bitbake() will fail the test on the desired failure.
Paulo Neves
Quoted 38 lines · Richard Purdie
Quoted 26 lines · Paulo Neves
Quoted 25 lines · Richard Purdie
Quoted 14 lines · Paulo Neves
bitbake ran but we incorrectly did not assert the exit status needs to be non 0. Now all sysroot tests commands expected to fail are verified to do so.
Signed-off-by Paulo Neves <[email protected]>--- meta/lib/oeqa/selftest/cases/sysroot.py | 5 +++++ 1 file changed, 5 insertions(+)meta/lib/oeqa/selftest/cases/sysroot.py +0
-0meta/lib/oeqa/selftest/cases/sysroot.py TESTSTRING:pn-sysroot-test-arch2 = "%s" · line 51
Quoted 7 lines
meta/lib/oeqa/selftest/cases/sysroot.py +1
-0@@ -45,6 +45,7 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]" res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True) self.assertTrue(expected in res.output, msg=res.output) + self.assertTrue(res.status != 0) def test_sysroot_la(self): """I did have a question on this patch. Wouldn't it be simpler to remove the "ignore_status=True" from the
bitbake()call?Quoted 6 lines
Quoted 3 lines
Cheers,
Richard
You are right. I guess the assert is more explicit and with the removal of the
ignore_statusit becomes implicit. Let me know if you want me to remove the assert and the ignore status and will submit a v2.Please, I think that would be cleaner.
Cheers,
Richard
PATCH 3/3 utils: create_cmdline_shebang_wrapper preserve permission and ownership
In reply to Paulo NevesThe .real command was not given the same permissions and ownership as the original pre-wrap file and this is now fixed.
A situation where the original pre-wrap file did not have write permissions would cause a failure in the wrapping is also fixed.
Test update also included.
--- .../wrapper/cmdline-shebang-wrapper-test.bb | 11 ++++++++++- meta/classes/utils.bbclass | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-)
meta-selftest/recipes-test/wrapper/cmdline-shebang-wrapper-test.bb +10 -1
@@ -8,7 +8,10 @@ SRC_URI += "file://test.awk" EXCLUDE_FROM_WORLD = "1" do_install() { install -d ${D}${bindir} - install -m 0755 ${WORKDIR}/test.awk ${D}${bindir}/test + # was not able to make ownership preservation check + install -m 0400 ${WORKDIR}/test.awk ${D}${bindir}/test + + perm_old="$(stat --format='%a' ${D}${bindir}/test)" sed -i -e 's|@AWK_BIN@|${bindir}/awk|g' ${D}${bindir}/test create_cmdline_shebang_wrapper ${D}${bindir}/test if [ $(${D}${bindir}/test) != "Don't Panic!" ]; then
@@ -16,6 +19,12 @@ do_install() { else bbnote "Wrapper is good" fi + + perm_new="$(stat --format='%a' ${D}${bindir}/test.real)" + + if [ "$perm_new" != "$perm_old" ]; then + bbfatal "Wrapper permissions for ${D}${bindir}/test.real not preserved. Found $perm_new but expected $perm_old" + fi } BBCLASSEXTEND = "native"
meta/classes/utils.bbclass +3 -0
@@ -202,6 +202,9 @@ create_cmdline_shebang_wrapper () { argument="$(sed -ne 's/^#! *//p;q' $cmd)" # strip the shebang from the real script as we do not want it to be usable anyway tail -n +2 $cmd > $cmd.real + chown --reference=$cmd $cmd.real + chmod --reference=$cmd $cmd.real + rm -f $cmd cmdname=$(basename $cmd) dirname=$(dirname $cmd) cmdoptions=$@
Signature · 1 line
2.25.1