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.
This commit is contained in:
Henrik Grimler 2021-08-16 12:13:40 +02:00
parent 854bd813f4
commit bd6bc93daf

View File

@ -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