fixes
This commit is contained in:
213
build.sh
213
build.sh
@@ -21,133 +21,168 @@ EOF
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
set_basedir() {
|
set_vars() {
|
||||||
|
# Ensure that everything is contained within the project.
|
||||||
|
# We expect that we're going to be running out of [PROJECT]/meta, so we hop up one directory.
|
||||||
BASEDIR=$(realpath "$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")/..")
|
BASEDIR=$(realpath "$(dirname -- "$(realpath -- "${BASH_SOURCE[0]}")")/..")
|
||||||
|
|
||||||
|
# Build toolchain locations
|
||||||
|
GCCDIR="${BASEDIR}/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9"
|
||||||
|
GCCDIR32="${BASEDIR}/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9"
|
||||||
|
CLANGDIR="${BASEDIR}/prebuilts/clang/host/linux-x86/clang-r547379"
|
||||||
|
KERNELBUILDTOOLS="${BASEDIR}/prebuilts/kernel-build-tools/linux-x86"
|
||||||
|
|
||||||
|
# Common options used for `make`, particularly for cross-compile
|
||||||
|
MAKEOPTS=(
|
||||||
|
O="${BASEDIR}/work"
|
||||||
|
ARCH=arm64
|
||||||
|
PATH="${CLANGDIR}/bin:${GCCDIR}/bin:${KERNELBUILDTOOLS}/bin:${PATH}"
|
||||||
|
LD_LIBRARY_PATH="${CLANGDIR}/lib"
|
||||||
|
LLVM=1
|
||||||
|
CROSS_COMPILE="${GCCDIR}/bin/aarch64-linux-android-"
|
||||||
|
CROSS_COMPILE_ARM32="${GCCDIR32}/bin/arm-linux-androideabi-"
|
||||||
|
CLANG_TRIPLE=aarch64-linux-gnu-
|
||||||
|
)
|
||||||
|
|
||||||
|
# Environment tools that are already somewhere in the project so we'll use them instead of adding extra dependencies
|
||||||
|
BUSYBOX="${BASEDIR}/prebuilts/magisk/lib/x86_64/libbusybox.so"
|
||||||
|
MAGISKBOOT="${BASEDIR}/prebuilts/magisk/lib/x86_64/libmagiskboot.so"
|
||||||
|
PYTHON="${BASEDIR}/prebuilts/clang/host/linux-x86/clang-r547379/python3/bin/python3"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_tools() {
|
||||||
|
# Ensure that we have everything we need to work before we get started.
|
||||||
|
TOOLS_NEEDED=()
|
||||||
|
[ ! -x "$(command -v make)" ] && TOOLS_NEEDED+=(make)
|
||||||
|
[ ! -x "$(command -v patch)" ] && TOOLS_NEEDED+=(patch)
|
||||||
|
[ ! -x "$(command -v zip)" ] && TOOLS_NEEDED+=(zip)
|
||||||
|
if [ "${#TOOLS_NEEDED[@]}" -gt 0 ]; then
|
||||||
|
echo "You are missing: ${TOOLS_NEEDED[@]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ensure_repo_initialized() {
|
ensure_repo_initialized() {
|
||||||
if [ ! -d "$BASEDIR/.repo" ]; then
|
# Sync the repo if it's not there.
|
||||||
echo ".dir missing, initializing..."
|
# Mainly used for dev+test, repo should be handled mostly by the user.
|
||||||
pushd "$BASEDIR" > /dev/null
|
if [ ! -d "${BASEDIR}/.repo" ]; then
|
||||||
repo init -u "$BASEDIR/meta" --git-lfs
|
echo ".repo missing, initializing..."
|
||||||
|
pushd "${BASEDIR}" > /dev/null
|
||||||
|
repo init -u "${BASEDIR}/meta" --git-lfs
|
||||||
repo sync
|
repo sync
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
download_magisk() {
|
clean_kernel_source() {
|
||||||
if [ ! -d "$BASEDIR/prebuilts/magisk" ]; then
|
# Reset the kernel source to an unmodified state.
|
||||||
echo "Magisk binaries missing, downloading..."
|
# This is mostly necessary since we apply modifications to the source and it's kinda hard to track them.
|
||||||
mkdir -p "$BASEDIR/prebuilts/magisk"
|
|
||||||
pushd "$BASEDIR/prebuilts/magisk" > /dev/null
|
|
||||||
wget "https://github.com/topjohnwu/Magisk/releases/download/v29.0/Magisk-v29.0.apk" || curl -OL "https://github.com/topjohnwu/Magisk/releases/download/v29.0/Magisk-v29.0.apk"
|
|
||||||
unzip "Magisk-v29.0.apk"
|
|
||||||
popd > /dev/null
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_toolchain_vars() {
|
|
||||||
GCCDIR="$BASEDIR/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9"
|
|
||||||
GCCDIR32="$BASEDIR/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9"
|
|
||||||
CLANGDIR="$BASEDIR/prebuilts/clang/host/linux-x86/clang-r547379"
|
|
||||||
KERNELBUILDTOOLS="$BASEDIR/prebuilts/kernel-build-tools/linux-x86"
|
|
||||||
|
|
||||||
MAKEOPTS=(
|
|
||||||
O="$BASEDIR/work"
|
|
||||||
ARCH=arm64
|
|
||||||
PATH="$CLANGDIR/bin:$GCCDIR/bin:$KERNELBUILDTOOLS/bin:$PATH"
|
|
||||||
LD_LIBRARY_PATH="$CLANGDIR/lib"
|
|
||||||
LLVM=1
|
|
||||||
CROSS_COMPILE="$GCCDIR/bin/aarch64-linux-android-"
|
|
||||||
CROSS_COMPILE_ARM32="$GCCDIR32/bin/arm-linux-androideabi-"
|
|
||||||
CLANG_TRIPLE=aarch64-linux-gnu-
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
prepare_kernel_source() {
|
|
||||||
echo "Preparing source..."
|
echo "Preparing source..."
|
||||||
pushd "$BASEDIR/kernel/oneplus/sm8750" > /dev/null
|
pushd "${BASEDIR}/kernel/oneplus/sm8750" > /dev/null
|
||||||
|
|
||||||
git reset --hard
|
git reset --hard
|
||||||
git clean -fd
|
git clean -fd
|
||||||
ln -s "${BASEDIR}/external/SukiSU-Ultra" "KernelSU"
|
|
||||||
ln -s "${BASEDIR}/external/SukiSU-Ultra/kernel" "drivers/kernelsu"
|
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
add_sukisu() {
|
add_sukisu() {
|
||||||
pushd "$BASEDIR/kernel/oneplus/sm8750" > /dev/null
|
pushd "${BASEDIR}/kernel/oneplus/sm8750" > /dev/null
|
||||||
|
|
||||||
MOD=false
|
ln -sf "${BASEDIR}/external/SukiSU-Ultra" "KernelSU"
|
||||||
grep -q "kernelsu" "drivers/Makefile" || printf "\nobj-\$(CONFIG_KSU) += kernelsu/\n" >> "drivers/Makefile" || echo "[+] Modified Makefile."
|
ln -sf "${BASEDIR}/external/SukiSU-Ultra/kernel" "drivers/kernelsu"
|
||||||
grep -q "source \"drivers/kernelsu/Kconfig\"" "drivers/Kconfig" || sed -i "/endmenu/i\source \"drivers/kernelsu/Kconfig\"" "drivers/Kconfig" && echo "[+] Modified Kconfig."
|
${BUSYBOX} grep -q "kernelsu" "drivers/Makefile" || ${BUSYBOX} printf "\nobj-\$(CONFIG_KSU) += kernelsu/\n" >> "drivers/Makefile" && echo "[+] Modified Makefile."
|
||||||
|
${BUSYBOX} grep -q "source \"drivers/kernelsu/Kconfig\"" "drivers/Kconfig" || ${BUSYBOX} sed -i "/endmenu/i\source \"drivers/kernelsu/Kconfig\"" "drivers/Kconfig" && echo "[+] Modified Kconfig."
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
add_susfs() {
|
add_susfs() {
|
||||||
pushd "$BASEDIR/kernel/oneplus/sm8750" > /dev/null
|
pushd "${BASEDIR}/kernel/oneplus/sm8750" > /dev/null
|
||||||
|
|
||||||
cp "${BASEDIR}/external/susfs4ksu/kernel_patches/fs/"* "fs/"
|
cp "${BASEDIR}/external/susfs4ksu/kernel_patches/fs/"* "fs/" || { echo "Failed to copy fs patches"; exit 1; }
|
||||||
cp "${BASEDIR}/external/susfs4ksu/kernel_patches/include/linux/"* "include/linux/"
|
cp "${BASEDIR}/external/susfs4ksu/kernel_patches/include/linux/"* "include/linux/" || { echo "Failed to copy linux patches"; exit 1; }
|
||||||
patch --fuzz=3 -p1 < "${BASEDIR}/external/susfs4ksu/kernel_patches/50_add_susfs_in_gki-android15-6.6.patch"
|
patch --fuzz=3 -p1 < "${BASEDIR}/external/susfs4ksu/kernel_patches/50_add_susfs_in_gki-android15-6.6.patch" || { echo "Failed to patch kernel source for susfs"; exit 1; }
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_kernel() {
|
configure_kernel() {
|
||||||
pushd "$BASEDIR/kernel/oneplus/sm8750" > /dev/null
|
pushd "${BASEDIR}/kernel/oneplus/sm8750" > /dev/null
|
||||||
|
|
||||||
mkdir -p "$BASEDIR/out"
|
# Ensure that the output directories exist
|
||||||
mkdir -p "$BASEDIR/work"
|
mkdir -p "${BASEDIR}/out"
|
||||||
|
mkdir -p "${BASEDIR}/work"
|
||||||
|
|
||||||
|
# Start by cleaning directories and starting with the GKI config
|
||||||
make ${MAKEOPTS[@]} mrproper
|
make ${MAKEOPTS[@]} mrproper
|
||||||
make ${MAKEOPTS[@]} gki_defconfig
|
make ${MAKEOPTS[@]} gki_defconfig
|
||||||
|
|
||||||
scripts/kconfig/merge_config.sh -m -O "$BASEDIR/work" \
|
# Add customizations specific to our device
|
||||||
"$BASEDIR/work/.config" \
|
scripts/kconfig/merge_config.sh -m -O "${BASEDIR}/work" \
|
||||||
|
"${BASEDIR}/work/.config" \
|
||||||
arch/arm64/configs/vendor/sun_perf.config \
|
arch/arm64/configs/vendor/sun_perf.config \
|
||||||
arch/arm64/configs/vendor/oplus/sun_perf.config
|
arch/arm64/configs/vendor/oplus/sun_perf.config
|
||||||
|
|
||||||
|
# Add further customizations to keep in line with vanilla
|
||||||
|
echo "CONFIG_DODGE_DTB=y" >> "${BASEDIR}/work/.config"
|
||||||
|
echo "CONFIG_OPLUS_DEVICE_DTBS=y" >> "${BASEDIR}/work/.config"
|
||||||
|
echo "CONFIG_COMPAT=y" >> "${BASEDIR}/work/.config"
|
||||||
|
echo "CONFIG_COMPAT_VDSO=y" >> "${BASEDIR}/work/.config"
|
||||||
|
|
||||||
|
# Add custom configurations if we're not looking for the stock configuration
|
||||||
|
if [ "${1}" != "stock" ]; then
|
||||||
if [ -e "${BASEDIR}/.config" ]; then
|
if [ -e "${BASEDIR}/.config" ]; then
|
||||||
echo "Adding custom configuration..."
|
echo "Adding custom configuration..."
|
||||||
scripts/kconfig/merge_config.sh -m -O "${BASEDIR}/work" \
|
scripts/kconfig/merge_config.sh -m -O "${BASEDIR}/work" \
|
||||||
"${BASEDIR}/work/.config" \
|
"${BASEDIR}/work/.config" \
|
||||||
"${BASEDIR}/.config"
|
"${BASEDIR}/.config"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "CONFIG_DODGE_DTB=y" >> "$BASEDIR/work/.config"
|
# Run a final olddefconfig to make sure that the config is complete for non-interactive compile.
|
||||||
echo "CONFIG_OPLUS_DEVICE_DTBS=y" >> "$BASEDIR/work/.config"
|
|
||||||
echo "CONFIG_COMPAT=y" >> "$BASEDIR/work/.config"
|
|
||||||
echo "CONFIG_COMPAT_VDSO=y" >> "$BASEDIR/work/.config"
|
|
||||||
|
|
||||||
make ${MAKEOPTS[@]} olddefconfig
|
make ${MAKEOPTS[@]} olddefconfig
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
build_kernel() {
|
build_kernel() {
|
||||||
pushd "$BASEDIR/kernel/oneplus/sm8750" > /dev/null
|
pushd "${BASEDIR}/kernel/oneplus/sm8750" > /dev/null
|
||||||
|
|
||||||
make ${MAKEOPTS[@]} \
|
make ${MAKEOPTS[@]} \
|
||||||
KCFLAGS="-Wno-error=frame-larger-than=" \
|
KCFLAGS="-Wno-error=frame-larger-than=" \
|
||||||
-j$(nproc) 2>&1 | tee "$BASEDIR/work/build.log"
|
-j"$(${BUSYBOX} nproc)" 2>&1 | ${BUSYBOX} tee "${BASEDIR}/work/build.log"
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_anykernel() {
|
prepare_anykernel() {
|
||||||
echo "Preparing AnyKernel3 package..."
|
echo "Preparing AnyKernel3 package..."
|
||||||
|
|
||||||
|
# Start with a new empty folder
|
||||||
rm -rf "${BASEDIR}/work/AnyKernel3"
|
rm -rf "${BASEDIR}/work/AnyKernel3"
|
||||||
mkdir -p "${BASEDIR}/work/AnyKernel3"
|
mkdir -p "${BASEDIR}/work/AnyKernel3"
|
||||||
|
# Copy down a fresh revision of AK3 (should exclude dotfiles)
|
||||||
cp -ra "${BASEDIR}/external/AnyKernel3/"* "${BASEDIR}/work/AnyKernel3/"
|
cp -ra "${BASEDIR}/external/AnyKernel3/"* "${BASEDIR}/work/AnyKernel3/"
|
||||||
|
# Add in our customized anykernel.sh
|
||||||
cp "${BASEDIR}/meta/anykernel.sh" "${BASEDIR}/work/AnyKernel3/anykernel.sh"
|
cp "${BASEDIR}/meta/anykernel.sh" "${BASEDIR}/work/AnyKernel3/anykernel.sh"
|
||||||
|
# Add in arm64 versions of tools from Magisk project
|
||||||
cp "${BASEDIR}/prebuilts/magisk/lib/arm64-v8a/libbusybox.so" "${BASEDIR}/work/AnyKernel3/tools/busybox"
|
cp "${BASEDIR}/prebuilts/magisk/lib/arm64-v8a/libbusybox.so" "${BASEDIR}/work/AnyKernel3/tools/busybox"
|
||||||
cp "${BASEDIR}/prebuilts/magisk/lib/arm64-v8a/libmagiskboot.so" "${BASEDIR}/work/AnyKernel3/tools/magiskboot"
|
cp "${BASEDIR}/prebuilts/magisk/lib/arm64-v8a/libmagiskboot.so" "${BASEDIR}/work/AnyKernel3/tools/magiskboot"
|
||||||
|
cp "${BASEDIR}/prebuilts/magisk/lib/arm64-v8a/libmagiskpolicy.so" "${BASEDIR}/work/AnyKernel3/tools/magiskpolicy"
|
||||||
|
# Remove unused tools
|
||||||
|
rm -f "${BASEDIR}/work/AnyKernel3/tools/fec"
|
||||||
|
rm -f "${BASEDIR}/work/AnyKernel3/tools/httools_static"
|
||||||
|
rm -f "${BASEDIR}/work/AnyKernel3/tools/lptools_static"
|
||||||
|
rm -f "${BASEDIR}/work/AnyKernel3/tools/snapshotupdater_static"
|
||||||
|
# Ensure the tools are executable
|
||||||
chmod +x "${BASEDIR}/work/AnyKernel3/tools/"*
|
chmod +x "${BASEDIR}/work/AnyKernel3/tools/"*
|
||||||
|
|
||||||
echo "Copying kernel Image..."
|
echo "Copying kernel Image..."
|
||||||
|
if [ ! -f "${BASEDIR}/work/arch/arm64/boot/Image" ]; then
|
||||||
|
echo "Error: Kernel build failed, Image not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
cp "${BASEDIR}/work/arch/arm64/boot/Image" "${BASEDIR}/work/AnyKernel3/"
|
cp "${BASEDIR}/work/arch/arm64/boot/Image" "${BASEDIR}/work/AnyKernel3/"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,24 +200,16 @@ create_flashable_zip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_menuconfig() {
|
run_menuconfig() {
|
||||||
set_basedir
|
set_vars
|
||||||
setup_toolchain_vars
|
|
||||||
|
|
||||||
mkdir -p "$BASEDIR/out"
|
mkdir -p "${BASEDIR}/out"
|
||||||
mkdir -p "$BASEDIR/work"
|
mkdir -p "${BASEDIR}/work"
|
||||||
|
|
||||||
pushd "$BASEDIR/kernel/oneplus/sm8750" > /dev/null
|
pushd "${BASEDIR}/kernel/oneplus/sm8750" > /dev/null
|
||||||
|
|
||||||
echo "Generating base configuration..."
|
echo "Generating base configuration..."
|
||||||
make ${MAKEOPTS[@]} mrproper
|
configure_kernel stock
|
||||||
make ${MAKEOPTS[@]} gki_defconfig
|
|
||||||
|
|
||||||
scripts/kconfig/merge_config.sh -m -O "$BASEDIR/work" \
|
|
||||||
"$BASEDIR/work/.config" \
|
|
||||||
arch/arm64/configs/vendor/sun_perf.config \
|
|
||||||
arch/arm64/configs/vendor/oplus/sun_perf.config
|
|
||||||
|
|
||||||
make ${MAKEOPTS[@]} olddefconfig
|
|
||||||
cp "$BASEDIR/work/.config" "$BASEDIR/work/.config.base"
|
cp "$BASEDIR/work/.config" "$BASEDIR/work/.config.base"
|
||||||
|
|
||||||
if [ -e "${BASEDIR}/.config" ]; then
|
if [ -e "${BASEDIR}/.config" ]; then
|
||||||
@@ -203,12 +230,12 @@ run_menuconfig() {
|
|||||||
extract_custom_config() {
|
extract_custom_config() {
|
||||||
echo "Extracting custom configuration differences..."
|
echo "Extracting custom configuration differences..."
|
||||||
|
|
||||||
if [ ! -f "$BASEDIR/work/.config.base" ]; then
|
if [ ! -f "${BASEDIR}/work/.config.base" ]; then
|
||||||
echo "Warning: No base config found for comparison"
|
echo "Warning: No base config found for comparison"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
> "$BASEDIR/.config"
|
> "${BASEDIR}/.config"
|
||||||
|
|
||||||
declare -A base_configs
|
declare -A base_configs
|
||||||
declare -A current_configs
|
declare -A current_configs
|
||||||
@@ -221,7 +248,7 @@ extract_custom_config() {
|
|||||||
config_name="${BASH_REMATCH[1]#CONFIG_}"
|
config_name="${BASH_REMATCH[1]#CONFIG_}"
|
||||||
base_configs["$config_name"]="$line"
|
base_configs["$config_name"]="$line"
|
||||||
fi
|
fi
|
||||||
done < "$BASEDIR/work/.config.base"
|
done < "${BASEDIR}/work/.config.base"
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
if [[ "$line" =~ ^CONFIG_([^=]+)= ]]; then
|
if [[ "$line" =~ ^CONFIG_([^=]+)= ]]; then
|
||||||
@@ -231,38 +258,33 @@ extract_custom_config() {
|
|||||||
config_name="${BASH_REMATCH[1]#CONFIG_}"
|
config_name="${BASH_REMATCH[1]#CONFIG_}"
|
||||||
current_configs["$config_name"]="$line"
|
current_configs["$config_name"]="$line"
|
||||||
fi
|
fi
|
||||||
done < "$BASEDIR/work/.config"
|
done < "${BASEDIR}/work/.config"
|
||||||
|
|
||||||
for config_name in "${!current_configs[@]}"; do
|
for config_name in "${!current_configs[@]}"; do
|
||||||
if [[ "${base_configs[$config_name]}" != "${current_configs[$config_name]}" ]]; then
|
if [[ "${base_configs[$config_name]}" != "${current_configs[$config_name]}" ]]; then
|
||||||
echo "${current_configs[$config_name]}" >> "$BASEDIR/.config"
|
echo "${current_configs[$config_name]}" >> "${BASEDIR}/.config"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -s "$BASEDIR/.config" ]; then
|
if [ -s "${BASEDIR}/.config" ]; then
|
||||||
sort -o "$BASEDIR/.config" "$BASEDIR/.config"
|
${BUSYBOX} sort -o "${BASEDIR}/.config" "${BASEDIR}/.config"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Custom configuration saved to: $BASEDIR/.config"
|
echo "Custom configuration saved to: ${BASEDIR}/.config"
|
||||||
echo "Changes from base configuration:"
|
echo "Changes from base configuration:"
|
||||||
cat "$BASEDIR/.config"
|
${BUSYBOX} cat "${BASEDIR}/.config"
|
||||||
echo ""
|
echo ""
|
||||||
else
|
else
|
||||||
echo "No configuration changes from base detected."
|
echo "No configuration changes from base detected."
|
||||||
rm -f "$BASEDIR/.config"
|
rm -f "${BASEDIR}/.config"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
download_lineageos_boot() {
|
download_lineageos_boot() {
|
||||||
set_basedir
|
set_vars
|
||||||
|
|
||||||
echo "Fetching latest LineageOS build information for dodge..."
|
echo "Fetching latest LineageOS build information for dodge..."
|
||||||
|
|
||||||
if ! command -v python3 &> /dev/null; then
|
BOOT_URL=$(${BUSYBOX} curl -s "https://download.lineageos.org/api/v2/devices/dodge/builds" | ${PYTHON} -c 'import sys,json;d=json.load(sys.stdin);boot=[f for f in d[0]["files"] if f["filename"]=="boot.img"][0];print(boot["url"])' 2>/dev/null)
|
||||||
echo "Error: python3 is required but not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
BOOT_URL=$(curl -s "https://download.lineageos.org/api/v2/devices/dodge/builds" | python3 -c 'import sys,json;d=json.load(sys.stdin);boot=[f for f in d[0]["files"] if f["filename"]=="boot.img"][0];print(boot["url"])' 2>/dev/null)
|
|
||||||
|
|
||||||
if [ -z "$BOOT_URL" ]; then
|
if [ -z "$BOOT_URL" ]; then
|
||||||
echo "Error: Failed to fetch boot.img URL from LineageOS API"
|
echo "Error: Failed to fetch boot.img URL from LineageOS API"
|
||||||
@@ -272,7 +294,7 @@ download_lineageos_boot() {
|
|||||||
echo "Found boot.img URL: $BOOT_URL"
|
echo "Found boot.img URL: $BOOT_URL"
|
||||||
echo "Downloading boot.img..."
|
echo "Downloading boot.img..."
|
||||||
|
|
||||||
wget -O "${BASEDIR}/stock_boot.img" "$BOOT_URL" || curl -L -o "${BASEDIR}/stock_boot.img" "$BOOT_URL"
|
${BUSYBOX} wget -O "${BASEDIR}/stock_boot.img" "$BOOT_URL" || { echo "Error: Failed to download boot.img"; return 1; }
|
||||||
|
|
||||||
if [ ! -f "${BASEDIR}/stock_boot.img" ]; then
|
if [ ! -f "${BASEDIR}/stock_boot.img" ]; then
|
||||||
echo "Error: Failed to download boot.img"
|
echo "Error: Failed to download boot.img"
|
||||||
@@ -283,8 +305,7 @@ download_lineageos_boot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repack_boot_image() {
|
repack_boot_image() {
|
||||||
set_basedir
|
set_vars
|
||||||
download_magisk
|
|
||||||
|
|
||||||
if [ ! -f "${BASEDIR}/stock_boot.img" ]; then
|
if [ ! -f "${BASEDIR}/stock_boot.img" ]; then
|
||||||
echo "stock_boot.img not found, attempting to download from LineageOS..."
|
echo "stock_boot.img not found, attempting to download from LineageOS..."
|
||||||
@@ -317,11 +338,10 @@ repack_boot_image() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
set_basedir
|
set -e
|
||||||
|
set_vars
|
||||||
ensure_repo_initialized
|
ensure_repo_initialized
|
||||||
download_magisk
|
clean_kernel_source
|
||||||
setup_toolchain_vars
|
|
||||||
prepare_kernel_source
|
|
||||||
add_sukisu
|
add_sukisu
|
||||||
add_susfs
|
add_susfs
|
||||||
configure_kernel
|
configure_kernel
|
||||||
@@ -331,6 +351,9 @@ build() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
# Start by checking if all necessary tools are installed.
|
||||||
|
check_tools
|
||||||
|
|
||||||
local command="${1:-build}"
|
local command="${1:-build}"
|
||||||
|
|
||||||
case "$command" in
|
case "$command" in
|
||||||
|
|||||||
Reference in New Issue
Block a user