build-package: mv termux_step_handle_buildarch to scripts/build/
This commit is contained in:
parent
063eaac334
commit
8ae7c5ef86
@ -31,34 +31,7 @@ source scripts/build/termux_step_handle_arguments.sh
|
||||
source scripts/build/termux_step_setup_variables.sh
|
||||
|
||||
# Save away and restore build setups which may change between builds.
|
||||
termux_step_handle_buildarch() {
|
||||
# If $TERMUX_PREFIX already exists, it may have been built for a different arch
|
||||
local TERMUX_ARCH_FILE=/data/TERMUX_ARCH
|
||||
if [ -f "${TERMUX_ARCH_FILE}" ]; then
|
||||
local TERMUX_PREVIOUS_ARCH
|
||||
TERMUX_PREVIOUS_ARCH=$(cat $TERMUX_ARCH_FILE)
|
||||
if [ "$TERMUX_PREVIOUS_ARCH" != "$TERMUX_ARCH" ]; then
|
||||
local TERMUX_DATA_BACKUPDIRS=$TERMUX_TOPDIR/_databackups
|
||||
mkdir -p "$TERMUX_DATA_BACKUPDIRS"
|
||||
local TERMUX_DATA_PREVIOUS_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_PREVIOUS_ARCH
|
||||
local TERMUX_DATA_CURRENT_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_ARCH
|
||||
# Save current /data (removing old backup if any)
|
||||
if test -e "$TERMUX_DATA_PREVIOUS_BACKUPDIR"; then
|
||||
termux_error_exit "Directory already exists"
|
||||
fi
|
||||
if [ -d /data/data ]; then
|
||||
mv /data/data "$TERMUX_DATA_PREVIOUS_BACKUPDIR"
|
||||
fi
|
||||
# Restore new one (if any)
|
||||
if [ -d "$TERMUX_DATA_CURRENT_BACKUPDIR" ]; then
|
||||
mv "$TERMUX_DATA_CURRENT_BACKUPDIR" /data/data
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Keep track of current arch we are building for.
|
||||
echo "$TERMUX_ARCH" > $TERMUX_ARCH_FILE
|
||||
}
|
||||
source scripts/build/termux_step_handle_buildarch.sh
|
||||
|
||||
# Function to get TERMUX_PKG_VERSION from build.sh
|
||||
source scripts/termux_extract_dep_info.sh
|
||||
|
28
scripts/build/termux_step_handle_buildarch.sh
Normal file
28
scripts/build/termux_step_handle_buildarch.sh
Normal file
@ -0,0 +1,28 @@
|
||||
termux_step_handle_buildarch() {
|
||||
# If $TERMUX_PREFIX already exists, it may have been built for a different arch
|
||||
local TERMUX_ARCH_FILE=/data/TERMUX_ARCH
|
||||
if [ -f "${TERMUX_ARCH_FILE}" ]; then
|
||||
local TERMUX_PREVIOUS_ARCH
|
||||
TERMUX_PREVIOUS_ARCH=$(cat $TERMUX_ARCH_FILE)
|
||||
if [ "$TERMUX_PREVIOUS_ARCH" != "$TERMUX_ARCH" ]; then
|
||||
local TERMUX_DATA_BACKUPDIRS=$TERMUX_TOPDIR/_databackups
|
||||
mkdir -p "$TERMUX_DATA_BACKUPDIRS"
|
||||
local TERMUX_DATA_PREVIOUS_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_PREVIOUS_ARCH
|
||||
local TERMUX_DATA_CURRENT_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_ARCH
|
||||
# Save current /data (removing old backup if any)
|
||||
if test -e "$TERMUX_DATA_PREVIOUS_BACKUPDIR"; then
|
||||
termux_error_exit "Directory already exists"
|
||||
fi
|
||||
if [ -d /data/data ]; then
|
||||
mv /data/data "$TERMUX_DATA_PREVIOUS_BACKUPDIR"
|
||||
fi
|
||||
# Restore new one (if any)
|
||||
if [ -d "$TERMUX_DATA_CURRENT_BACKUPDIR" ]; then
|
||||
mv "$TERMUX_DATA_CURRENT_BACKUPDIR" /data/data
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Keep track of current arch we are building for.
|
||||
echo "$TERMUX_ARCH" > $TERMUX_ARCH_FILE
|
||||
}
|
Loading…
Reference in New Issue
Block a user