Pmbootstrap: building kernel: make[2]: execvp: ./sync-check.sh: Permission denied

Created on 29 Nov 2017  路  20Comments  路  Source: postmarketOS/pmbootstrap

I am trying to update the linux-postmarketos-mainline package to the latest mainline release (currently 4.15-rc1), but doing so seems to break the build.
The code is available on my fork.

Last lines of the log:

  CC       /home/pmos/build/src/build/tools/objtool/str_error_r.o
  LD       /home/pmos/build/src/build/tools/objtool/objtool-in.o
make[4]: execvp: ./sync-check.sh: Permission denied
make[4]: *** [Makefile:47: /home/pmos/build/src/build/tools/objtool/objtool] Error 127
make[3]: *** [Makefile:63: objtool] Error 2
make[2]: *** [/home/pmos/build/src/linux-4.14/Makefile:1628: tools/objtool] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:146: sub-make] Error 2
make: *** [Makefile:24: __sub-make] Error 2
>>> ERROR: linux-postmarketos-mainline: all failed

Full log file: mainline.txt

bug upstream

All 20 comments

I did the changes locally:

diff --git a/aports/main/linux-postmarketos-mainline/APKBUILD b/aports/main/linux-postmarketos-mainline/APKBUILD
index 53d9705..9c2c0e0 100644
--- a/aports/main/linux-postmarketos-mainline/APKBUILD
+++ b/aports/main/linux-postmarketos-mainline/APKBUILD
@@ -3,7 +3,7 @@ _config="config-${_flavor}.${CARCH}"

 pkgname=linux-${_flavor}

-pkgver=4.14_rc7
+pkgver=4.15_rc1
 _pkgver=${pkgver/_/-}
 _kernver=${pkgver%_rc*}
 _mainver=${_kernver%.*}
@@ -25,7 +25,6 @@ source="
        config-${_flavor}.armhf
        config-${_flavor}.aarch64
        config-${_flavor}.x86_64
-       001-sony-amami-dts.patch
 "

 subpackages="$pkgname-dev::$CBUILD_ARCH"
@@ -171,10 +170,9 @@ dev() {
        ln -sf /usr/src/linux-headers-${_abi_release} \
                "$subpkgdir"/lib/modules/${_abi_release}/build
 }
-sha512sums="a557c2f0303ae618910b7106ff63d9978afddf470f03cb72aa748213e099a0ecd5f3119aea6cbd7b61df30ca6ef3ec57044d524b7babbaabddf8b08b8bafa7d2  linux-4.13.tar.xz
-ec42158f59f105995a3ccde025085343b5e6ba60de778c14cacf9aa34c40ae2e23058a03a1e6545f174c694620bbb0e423947f784c43e1474adfdcb7f866b3b6  linux-v4.13-v4.14-rc1.patch
-f120fc30e759c5c1dfd391c13bfdfa05675fbef02afdad3dce0fd22f02455f4d2ed545c1d4bddf2ada26827f5d54adc6813e2f927df3ebe18cd78ad1c99e0098  linux-v4.14-rc1-v4.14-rc7.patch
+sha512sums="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8  linux-4.14.tar.xz
+ede06f733521cc274456f62b01441ec6194425c0455d937db9324275978fc855372aefbf19d895e8bfbe11dcfe2145dff672c9c3b693315fb9c8e14b280fd43a  linux-v4.14-v4.15-rc1.patch
+cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e  linux-v4.15-rc1-v4.15-rc1.patch
 a75225750193cf31c8b6c15e7748699f842ecadc9ed573f0b10f42bb5343b4e092bcb65b359d170a42a102a4ddfe09d63c1d67550f4b99c29295fa22e1d7b995  config-postmarketos-mainline.armhf
 6310035a0a4c028cc98cab92919cca54be9b79ee9fe63211e7a05876d7befdbd8506a2f80548e228e014e99b0f91f63946352789d8d2f2134c66914163f66ab3  config-postmarketos-mainline.aarch64
-3d42c60061d12a436d19ffdf00623ea71ca31f16f690ae82ebf872d35177c283b4038cd5e270f4e610d6cf6861cef73ac63c995f1f4cfe9d6f2a4a8648ba28fb  config-postmarketos-mainline.x86_64
-e34315167868c2539b2cb548b4305a5e16527b8d5b39843945bf3b0c2a67d70f7d9c93443bac2d28a744aa85012c241c68c5a4f09f0ad3e35ba8945bdaed2e2d  001-sony-amami-dts.patch"
+3d42c60061d12a436d19ffdf00623ea71ca31f16f690ae82ebf872d35177c283b4038cd5e270f4e610d6cf6861cef73ac63c995f1f4cfe9d6f2a4a8648ba28fb  config-postmarketos-mainline.x86_64"

And everything works fine. I've spotted that you forgot to end the string in https://github.com/limiter121/pmbootstrap/commit/3f41f2fe458c3937f72ecb566ba002d22a8b0481 in the last line (deleted the " but didn't add it in the previous line) so that could be the issue.

@z3ntu Oops, I had that fixed locally but forgot to push it. Also ran pmbootstrap zap, however it is still not working - same error. Could it have something to do with the build env (Ubuntu 17.10) ?

@z3ntu: thanks for confirming, that it's working on your machine.

@limiter121: we need to find out why the sync-check.sh script can not get executed on your system.

Some ideas:

  • It might be a binfmt problem? (see https://github.com/postmarketOS/pmbootstrap/issues/834#issuecomment-340081602 - although pmbootstrap zap does a shutdown implicitly and should therefore have resolved it.)
  • Is your disk full?
  • What happens when you try to execute the file manually after a failed build?
pmbootstrap chroot
su - pmos
cd /home/pmos/build/src/build/tools/objtool/
./sync-check.sh

@ollieparanoid

  • pmbootstrap shutdown & pmbootstrap zap did not solve the problem, same error
  • The disk is not full
  • The file actually seems to be located at /home/pmos/build/src/linux-4.14/tools/objtool/sync-check.sh. Executing it gives the same permission error as during the build.
ubuntu:~/build/src/build/tools/objtool$ ./sync-check.sh
-ash: ./sync-check.sh: not found
ubuntu:~/build/src/build/tools/objtool$ cd /home/pmos/build/src/linux-
4.14/tools/objtool/
ubuntu:~/build/src/linux-4.14/tools/objtool$ ./sync-check.sh 
-ash: ./sync-check.sh: Permission denied
ubuntu:~/build/src/linux-4.14/tools/objtool$ ls -l | grep *.sh
-rw-r--r--    1 pmos     pmos           584 Nov 30 20:10 sync-check.sh

More questions:

  • Which filesystem do you use for your work folder?
  • Which OS do you run?
  • Maybe this is SELinux related?
  • Can you execute any other shell script? You could create one by yourself by installing vim or nano (apk add vim in the chroot)
  • If by work folder you mean where the pmbootstrap source & chroots are, then ext4
  • Ubuntu 17.10 in a VM (Linux ubuntu 4.13.0-17-generic #20-Ubuntu SMP Mon Nov 6 10:04:08 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux)
  • SELinux is not installed, it is just vanilla Ubuntu
  • I can execute shell scripts if they have the right permissions
ubuntu:~$ cat test.sh
#!/bin/bash
echo "Hello, World!"
ubuntu:~$ ./test.sh 
-ash: ./test.sh: Permission denied
ubuntu:~$ chmod +x test.sh 
ubuntu:~$ ./test.sh 
Hello, World!

Yes with work folder I mean the one with the chroots (the one you choose in pmbootstrap init).
Thanks for the information! But can you also execute scripts in the chroot?

pmbootstrap chroot
apk add nano
su - user
echo 'echo test' > /tmp/test.sh
chmod +x /tmp/test.sh
/tmp/test.sh

They were ran in the chroot.

Sorry, I've gotten confused with the ubuntu:~$ - but that's just the hostname.
It's interesting that regular scripts are actually working, but this one is not. Does it not have the executable bit set after the extraction?

If that does not help, another idea: Ubuntu uses AppArmor instead of SELinux, but it's enabled by default and that might be related. Could you test if it works with AppArmor disabled?

Yes, it is not executable after extraction (-rw-r--r-- 1 pmos pmos 584 Nov 30 20:10 sync-check.sh inside chroot).

I'll try to test it with AppArmor disabled.

Tried with AppArmor disabled, same error.

I also tried to see if the file has execute permissions (by manually extracting the kernel archive and applying the patch, via patch -s -p1 -N -i ../linux-v4.14-v4.15-rc1.patch) and it does not.
So the problem could be with how the patch is applied or even with the patch itself.

@z3ntu Can you confirm that the file sync-check.sh has execute permissions for you ? Try running this in the chroot: ls -l /home/pmos/build/src/linux-4.14/tools/objtool/ | grep .sh

As a workaround, I could make a temporary patch that sets the correct permissions for this file.

luca@g550jk /m/h/p/pmbootstrap> ./pmbootstrap.py build linux-postmarketos-mainline --arch=armhf --force
[09:04:54] (native) install abuild build-base ccache
[09:04:56] (native) install bash bc elfutils-dev gmp-dev installkernel libressl-dev linux-headers perl postmarketos-mkinitfs sed
[09:05:11] (native) install gcc-armhf g++-armhf ccache-cross-symlinks
[09:05:12] (native) build armhf/linux-postmarketos-mainline-4.15_rc1-r2.apk
[09:07:05] Done
luca@g550jk /m/h/p/pmbootstrap> ./pmbootstrap.py chroot
[09:09:07] (native) % sh
/ # ls -l /home/pmos/build/src/linux-4.14/tools/objtool/ | grep .sh
-rw-r--r--    1 pmos     pmos           584 Dec  1 08:05 sync-check.sh

@z3ntu Thanks for testing ! Weird that the build is working for you and not complaining about permissions, even though the file is not executable. What OS are you building on ?

Arch Linux

Just tried building on a fresh Ubuntu 16.04.3 install and still get the same permission error 馃槥

That is super weird. I have not tested this yet, but you could also try to use another tar that Alpine provides instead of the busybox one. And if nothing else helps it, you could simply make the file executable in the prepare() step.

Finally managed to fix the build (thanks @ollieparanoid for the prepare() idea !). Also submitted a PR.

https://www.spinics.net/lists/stable/msg207366.html

Also, you can use git apply. Reportedly, it should work in this case, even outside of git repo.

Meanwhile I was able to reproduce the issue at one point. But I didn't have a good solution to it.

@pfactum: thanks for linking to the thread! I think this is the answer (from greg k-h):

Be careful with 'patch', odds are it is not keeping the permissions that git is telling it to use.

As the source is built outside of a git repository (so we can't use git apply to apply the patch from what I've read and from experimenting), I think the easy way is using the chmod +x in the prepare like it's already done in #967.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ata2001 picture ata2001  路  4Comments

cmdr2 picture cmdr2  路  7Comments

MartijnBraam picture MartijnBraam  路  6Comments

ata2001 picture ata2001  路  3Comments

zenety picture zenety  路  5Comments