From bd6bc93daf6fa1963cea646f2846e42b9f0d9c74 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Mon, 16 Aug 2021 12:13:40 +0200 Subject: [PATCH] termux_step_start_build: strip prefixed ./ if found All, or at least most, of our debs contain "./" as a folder. This causes problems when extracting on some systems, as ./ then is the system root directory /, and tar cannot change the permissions of this folder. Trying to build on arch for example gives: tar: .: Cannot change mode to rwxr-xr-x: Operation not permitted tar: Exiting with failure status due to previous errors The issue appeared on arch somewhat recently, maybe with tar 1.33. To avoid having to rebuild all packages we now handle both data.tar.xz types, with prefixed ./, and without. Also remove some indentation levels while we are at it. --- scripts/build/termux_step_start_build.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/build/termux_step_start_build.sh b/scripts/build/termux_step_start_build.sh index ffcdb5232..2e2fdbbcd 100644 --- a/scripts/build/termux_step_start_build.sh +++ b/scripts/build/termux_step_start_build.sh @@ -79,15 +79,23 @@ termux_step_start_build() { echo "Download of $PKG@$DEP_VERSION from $TERMUX_REPO_URL failed, building instead" TERMUX_BUILD_IGNORE_LOCK=true ./build-package.sh -I "${PKG_DIR}" continue - else - if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then - if [ ! "$TERMUX_QUIET_BUILD" = true ]; then echo "extracting $PKG..."; fi - ( - cd $TERMUX_COMMON_CACHEDIR-$DEP_ARCH - ar x ${PKG}_${DEP_VERSION}_${DEP_ARCH}.deb data.tar.xz - tar -xf data.tar.xz --no-overwrite-dir -C / - ) + fi + if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then + if [ ! "$TERMUX_QUIET_BUILD" = true ]; then + echo "extracting $PKG..." fi + ( + cd $TERMUX_COMMON_CACHEDIR-$DEP_ARCH + ar x ${PKG}_${DEP_VERSION}_${DEP_ARCH}.deb data.tar.xz + if tar -tf data.tar.xz|grep "^./$">/dev/null; then + # Strip prefixed ./, to avoid possible + # permission errors from tar + tar -xf data.tar.xz --strip-components=1 \ + --no-overwrite-dir -C / + else + tar -xf data.tar.xz --no-overwrite-dir -C / + fi + ) fi mkdir -p $TERMUX_BUILT_PACKAGES_DIRECTORY