Skip to content

Instantly share code, notes, and snippets.

@utkustnr
Last active July 31, 2025 09:37
Show Gist options
  • Save utkustnr/7df7d35bbc1187c257d04214d5324dc3 to your computer and use it in GitHub Desktop.
Save utkustnr/7df7d35bbc1187c257d04214d5324dc3 to your computer and use it in GitHub Desktop.
lahaina kernel scripts
#!/bin/bash
VARIANT="a73xq"
STAT="clean"
SHOW_HELP=0
isUN1CA=0
while (( $# )); do
case $1 in
-h|--help) SHOW_HELP=1 ;;
-a|--a52sxq) VARIANT=a52sxq ;;
-3|--a73xq) VARIANT=a73xq ;;
-m|--m52xq) VARIANT=m52xq ;;
-c|--clean) STAT=clean ;;
-d|--dirty) STAT=dirty ;;
-r|--regen) STAT=regen ;;
-s|--silent) STAT=silent ;;
-p|--purge) STAT=purge ;;
-u|--unica) isUN1CA=1 ;;
*) echo "Unknown option: $1" >&2; exit 1 ;;
esac
shift
done
if (( "$SHOW_HELP" )); then
echo "Usage: build.sh [options]"
echo "Options:"
echo "-h, --help Show this help message"
echo "-3, --a73xq Selects A73 as the target [default]"
echo "-2, --a52sxq Selects A52s as the target"
echo "-m, --m52xq Selects M52 as the target"
echo "-c, --clean Makes sure to clean up before building [default]"
echo "-d, --dirty Does not clean up before building"
echo "-r, --regen Does not build but regenerates defconfig, needs you to specify target."
echo "-s, --silent Runs the script silent for the make command"
echo "-p, --purge Cleans up out dir without deleting zip files and stock images"
echo "-u, --unica Enables UN1CA integration, requires you to set UN1CA folder path."
exit 0
fi
JOBS=32
################################################ Base Vars
export USR_NAME="$(whoami)"
export SRC_DIR="$(pwd)"
export OUT_DIR="$SRC_DIR/out"
export TC_DIR="/home/$USR_NAME/toolchains"
export SRC_BRANCH=$(git rev-parse --abbrev-ref HEAD)
#UN1CAPATH="$(find "/home/$USR_NAME" -maxdepth 3 -type d -name "UN1CA" 2>/dev/null | head -n 1)"
################################################
################################################ Remote Locations
MODPROBE_URL="https://gist.githubusercontent.com/utkustnr/8bd6cd7a48846d34c959424558be4ae1/raw/vendor_modprobe.sh"
UPDATER_URL="https://gist.githubusercontent.com/utkustnr/8bd6cd7a48846d34c959424558be4ae1/raw/update-binary"
AVBTOOL_URL="https://android.googlesource.com/platform/external/avb/+/refs/heads/main/avbtool.py?format=TEXT"
MAGISKBOOT_URL="https://github.com/topjohnwu/Magisk/releases/download/v29.0/Magisk-v29.0.apk"
# LOS
API_URL="https://download.lineageos.org/api/v2/devices/$VARIANT/builds"
# OUI
A73REPO="https://api.github.com/repos/ngdplnk/proprietary_vendor_samsung_a73xq/releases/latest"
A52SREPO="https://api.github.com/repos/RisenID/proprietary_vendor_samsung_a52sxq/releases/latest"
M52REPO="https://api.github.com/repos/ngdplnk/proprietary_vendor_samsung_m52xq/releases/latest"
################################################
################################################ Toolchains
# toggle this between 1,2,3 to make your toolchain happy
# 1 post 5.4-full-llvm
# 2 pre 5.4-full-llvm
# 3 snapdragon toolchain
LLVM=1
AOSPTC_URL=""
# LTS | the one samsung used
#AOSPTC_URL="https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/android11-qpr3-release/clang-r383902b1.tar.gz"
# main | latest stable one from google
AOSPTC_URL="https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/main/clang-r530567.tar.gz"
# staging | latest **broken** one from google
#AOSPTC_URL="https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/main/clang-r547379.tar.gz"
CLANGVER=$(echo "$AOSPTC_URL" | grep -o 'clang-r[0-9]*')
export CLANG_PREBUILT_BIN="$TC_DIR/$CLANGVER/bin/"
export PATH=$TC_DIR:$CLANG_PREBUILT_BIN:$PATH
################################################
ENVIRONMENT() {
local DEVICE=$1
VARIANT=$DEVICE
echo "--------------------------------"
echo "------Setting GKI variables-----"
echo "--------------------------------"
export BRANCH=android11
export KMI_GENERATION=2
export DEPMOD=depmod
export KCFLAGS="${KCFLAGS} -D__ANDROID_COMMON_KERNEL__"
export STOP_SHIP_TRACEPRINTK=1
export IN_KERNEL_MODULES=1
export DO_NOT_STRIP_MODULES=1
echo ""
echo "KMI Branch: $BRANCH"
echo "KMI Gen: $KMI_GENERATION"
echo ""
echo "--------------------------------"
echo "-----Setting make variables-----"
echo "--------------------------------"
if [ "$LLVM" = 1 ]; then
export LLVM=1
MAKE_PARAMS="$SRC_DIR \
O=$OUT_DIR \
ARCH=arm64 \
LLVM=1"
elif [ "$LLVM" = 2 ]; then
export ARCH=arm64
export LLVM=1
MAKE_PARAMS="$SRC_DIR \
O=$OUT_DIR \
ARCH=$ARCH \
CC=clang \
LD=ld.lld \
NM=llvm-nm \
OBJCOPY=llvm-objcopy \
CLANG_TRIPLE=aarch64-linux-gnu- \
LLVM=1 \
LLVM_IAS=1 \
CROSS_COMPILE=$CLANG_PREBUILT_BIN/llvm-"
elif [ "$LLVM" = 3 ]; then
MAKE_PARAMS="$SRC_DIR \
O=$OUT_DIR \
ARCH=$ARCH \
CC=clang \
LD=ld.lld \
AR=llvm-ar \
NM=llvm-nm \
STRIP=llvm-strip \
OBJCOPY=llvm-objcopy \
OBJDUMP=llvm-objdump \
OBJSIZE=llvm-size \
READELF=llvm-readelf \
HOSTCXX=clang++ \
HOSTAR=llvm-ar \
HOSTLD=ld.lld \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=$CLANG_PREBUILT_BIN/llvm-"
fi
echo ""
echo "With: $(clang --version | head -n 1)"
echo "aka. $CLANGVER"
echo ""
if [[ (( $isUN1CA )) && -d "$UN1CAPATH/out/fw" ]]; then
MODEL=$(case "$VARIANT" in a73xq) echo "A736B" ;; a52sxq) echo "A528B" ;; m52xq) echo "M526B" ;; esac)
BOOTIMG="$(find "$UN1CAPATH/out/fw/" -type f -name "boot.img" | grep "$MODEL" | head -n 1)"
VBOOTIMG="$(find "$UN1CAPATH/out/fw/" -type f -name "vendor_boot.img" | grep "$MODEL" | head -n 1)"
fi
echo "--------------------------------"
echo "----Setting device variables----"
echo "--------------------------------"
if [[ "$SRC_BRANCH" == lineage* ]]; then
BRAND="aosp"
RIO_VAR="A"
RIO_VARIANT="AOSP"
KRNL_VER="103"
GKI=0
if [ "$VARIANT" = "a73xq" ]; then
RP_REV="SRPUH27A001"
DEFCONF="vendor/lineage-a73xq_defconfig"
elif [ "$VARIANT" = "a52sxq" ]; then
RP_REV="SRPUE26A001"
DEFCONF="vendor/lineage-a52sxq_defconfig"
elif [ "$VARIANT" = "m52xq" ]; then
RP_REV="SRPUF17B001"
DEFCONF="vendor/lineage-m52xq_defconfig"
fi
JSON=$(curl -s "$API_URL" | jq -c '.[0]')
BOOT_URL=$(echo "$JSON" | jq -r '.files[] | select(.filename == "boot.img").url')
BOOT_SHA=$(echo "$JSON" | jq -r '.files[] | select(.filename == "boot.img").sha1')
VBOOT_URL=$(echo "$JSON" | jq -r '.files[] | select(.filename == "vendor_boot.img").url')
VBOOT_SHA=$(echo "$JSON" | jq -r '.files[] | select(.filename == "vendor_boot.img").sha1')
else
BRAND="OneUI"
RIO_VAR="O"
RIO_VARIANT="OneUI"
KRNL_VER="225"
GKI=1
DEFCONF="rio_defconfig"
if [ "$VARIANT" = "a73xq" ]; then
RP_REV="SRPUH27A001"
FRAG="a73xq.config"
TAR_NAME="$(curl -s $A73REPO | jq -r '.assets[] | select(.name | test(".*_kernel.tar$")) | .name')"
TAR_URL="$(curl -s $A73REPO | jq -r '.assets[] | select(.name | test(".*_kernel.tar$")) | .browser_download_url')"
elif [ "$VARIANT" = "a52sxq" ]; then
RP_REV="SRPUE26A001"
FRAG="a52sxq.config"
TAR_NAME="$(curl -s $A52SREPO | jq -r '.assets[] | select(.name | test(".*_kernel.tar$")) | .name')"
TAR_URL="$(curl -s $A52SREPO | jq -r '.assets[] | select(.name | test(".*_kernel.tar$")) | .browser_download_url')"
elif [ "$VARIANT" = "m52xq" ]; then
RP_REV="SRPUF17B001"
FRAG="m52xq.config"
TAR_NAME="$(curl -s $M52REPO | jq -r '.assets[] | select(.name | test(".*_kernel.tar$")) | .name')"
TAR_URL="$(curl -s $M52REPO | jq -r '.assets[] | select(.name | test(".*_kernel.tar$")) | .browser_download_url')"
fi
fi
echo ""
echo "For: $VARIANT"
echo "With: $DEFCONF + $FRAG"
echo ""
}
SET_DIRS() {
if [ $STAT != "dirty" ]; then
echo "--------------------------------"
echo "---Cleaning up out directory----"
echo "--------------------------------"
find "$OUT_DIR" -mindepth 1 -maxdepth 1 \
! -name "tmp" \
! -name "zip" \
! -name ".config" \
-exec rm -rf {} \;
rm -rf $OUT_DIR/zip/images/*
rm -rf $OUT_DIR/zip/vendor/lib/modules/*
echo ""
echo "rm -rf'd out dir"
echo ""
fi
echo "--------------------------------"
echo "------Creating directories------"
echo "--------------------------------"
mkdir -p "$OUT_DIR/tmp/img" \
"$OUT_DIR/zip/images" \
"$OUT_DIR/zip/vendor/lib/modules" \
"$OUT_DIR/zip/vendor/bin" \
"$OUT_DIR/zip/META-INF/com/google/android"
echo ""
echo "mkdir out, tmp, zip dirs"
echo ""
[ $STAT = "purge" ] && exit 1
}
FETCH_TOOLS() {
if [ ! -d "$CLANG_PREBUILT_BIN" ]; then
echo "--------------------------------"
echo "-------Fetching Toolchain-------"
echo "--------------------------------"
mkdir -p "$TC_DIR/$CLANGVER" && cd "$TC_DIR/$CLANGVER"
wget $AOSPTC_URL -P $TC_DIR
tar xf $TC_DIR/$CLANGVER.tar.gz -C "$TC_DIR/$CLANGVER"
echo ""
echo "toolchain fetched"
echo ""
fi
cd "$SRC_DIR"
if [[ ! -f $TC_DIR/avbtool || ! -f $TC_DIR/magiskboot ]]; then
echo "--------------------------------"
echo "---------Fetching Tools---------"
echo "--------------------------------"
curl -s $AVBTOOL_URL | base64 --decode > "$TC_DIR/avbtool" && chmod +x "$TC_DIR/avbtool"
wget $MAGISKBOOT_URL -P "$TC_DIR" -O "$TC_DIR/magisk.apk"
unzip -p "$TC_DIR/magisk.apk" "lib/x86_64/libmagiskboot.so" > "$TC_DIR/magiskboot" && chmod +x "$TC_DIR/magiskboot"
echo ""
echo "avbtool and magiskboot fetched"
echo ""
fi
}
FETCH_IMAGES() {
if (( $isUN1CA )); then
echo "--------------------------------"
echo "------UN1CA Build Detected------"
echo "--------------------------------"
if [[ "$SRC_BRANCH" == lineage* ]]; then
echo ""
echo "Blud are you high?"
echo "Lineage kernel with un1ca?"
echo "Its your funeral..."
sleep 2
echo "nah /jk switch branches lil bro"
echo ""
exit 1
fi
if [[ -f "$BOOTIMG" && -f "$VBOOTIMG" ]]; then
cp "$BOOTIMG" "$OUT_DIR/tmp/"
cp "$VBOOTIMG" "$OUT_DIR/tmp/"
echo ""
echo "boot.img and vendor_boot.img copied from UN1CA dir"
echo ""
else
echo ""
echo "UN1CA haven't extracted firmwares yet"
echo "Unset un1ca path or run these in UN1CA"
echo ". buildenv.sh $VARIANT"
echo "run_cmd download_fw"
echo "run_cmd extract_fw"
echo ""
exit 1
fi
else
if [[ "$SRC_BRANCH" == lineage* ]]; then
echo "--------------------------------"
echo "----Fetching Lineage Images-----"
echo "--------------------------------"
b="$OUT_DIR/tmp/boot.img"
[ -f "$b" ] && [ "$(sha1sum "$b" | awk '{print $1}')" = "$BOOT_SHA" ] || { wget "$BOOT_URL" -O "$b" || exit 1; }
echo ""
echo "boot.img fetched from lineage"
echo ""
vb="$OUT_DIR/tmp/vendor_boot.img"
[ -f "$vb" ] && [ "$(sha1sum "$vb" | awk '{print $1}')" = "$VBOOT_SHA" ] || { wget "$VBOOT_URL" -O "$vb" || exit 1; }
echo ""
echo "vendor_boot.img fetched from lineage"
echo ""
else
echo "--------------------------------"
echo "-----Fetching OneUI Images------"
echo "--------------------------------"
s="$OUT_DIR/tmp/$TAR_NAME"
[ ! -f "$s" ] && { echo "Downloading $TAR_NAME from $TAR_URL" && wget -q "$TAR_URL" -O "$s" || exit 1; }
tar -xf $s -C $OUT_DIR/tmp/
lz4 -qdf $OUT_DIR/tmp/boot.img.lz4
lz4 -qdf $OUT_DIR/tmp/vendor_boot.img.lz4
rm -rf $OUT_DIR/tmp/*.lz4
echo ""
echo "boot.img and vendor_boot.img fetched"
echo ""
fi
fi
}
BUILD_KERNEL() {
echo "--------------------------------"
echo "-----Kernel Build Starting------"
echo "--------------------------------"
START=$(date +%s)
COMREV=$(git rev-parse --verify HEAD --short)
export LOCALVERSION="-$BRANCH-$KMI_GENERATION-$COMREV-rio-$VARIANT"
echo ""
echo "UNAME : 5.4.x$LOCALVERSION"
echo ""
[ $STAT = regen ] && make -j$JOBS -C $MAKE_PARAMS $DEFCONF \
&& cat "$OUT_DIR/.config" > "$SRC_DIR/arch/arm64/configs/$DEFCONF" \
&& exit 0
#( [ $STAT = silent ] && exec >/dev/null; make -j$JOBS -C $MAKE_PARAMS vendor/a73xq_eur_open_defconfig )
( [ $STAT = silent ] && exec >/dev/null; make -j$JOBS -C $MAKE_PARAMS $DEFCONF $FRAG )
#( [ $STAT = silent ] && exec >/dev/null; make -j$JOBS -C $MAKE_PARAMS $DEFCONF )
( [ $STAT = silent ] && exec >/dev/null; make -j$JOBS -C $MAKE_PARAMS )
echo ""
echo "Build took: $(date -u -d @$(($(date +%s) - START)) +'%T')"
echo ""
}
BUILD_MODULES() {
echo "--------------------------------"
echo "-----Module Build Starting------"
echo "--------------------------------"
START=$(date +%s)
rm -rf $OUT_DIR/modules/* $OUT_DIR/zip/vendor/lib/modules/*
( [ $STAT = silent ] && exec >/dev/null; make -j$JOBS -C $MAKE_PARAMS INSTALL_MOD_PATH=modules INSTALL_MOD_STRIP=1 modules_install )
find "$OUT_DIR/modules" -name '*.ko' -exec cp '{}' "$OUT_DIR/zip/vendor/lib/modules" \;
cp $OUT_DIR/modules/lib/modules/*/modules.alias "$OUT_DIR/zip/vendor/lib/modules/modules.alias"
cp $OUT_DIR/modules/lib/modules/*/modules.dep "$OUT_DIR/zip/vendor/lib/modules/modules.dep"
cp $OUT_DIR/modules/lib/modules/*/modules.softdep "$OUT_DIR/zip/vendor/lib/modules/modules.softdep"
cp $OUT_DIR/modules/lib/modules/*/modules.order "$OUT_DIR/zip/vendor/lib/modules/modules.load"
sed -i 's/\(kernel\/[^: ]*\/\)\([^: ]*\.ko\)/\/vendor\/lib\/modules\/\2/g' "$OUT_DIR/zip/vendor/lib/modules/modules.dep"
sed -i 's/.*\///g' "$OUT_DIR/zip/vendor/lib/modules/modules.load"
echo ""
echo "Modules took: $(date -u -d @$(($(date +%s) - START)) +'%T')"
echo ""
}
REPACK() {
local IMG=$1
echo ""
echo "-Repacking $IMG"
cd "$OUT_DIR/tmp/img"
avbtool erase_footer --image ../${IMG}.img
( [ $STAT = silent ] && exec >/dev/null 2>&1
[ ${IMG} = boot ] && magiskboot unpack ../${IMG}.img
[ ${IMG} = vendor_boot ] && magiskboot unpack -h ../${IMG}.img )
[ -f header ] && sed -i "1 c\\name=$RP_REV" $OUT_DIR/tmp/img/header
[ -f kernel ] && rm -rf $OUT_DIR/tmp/img/kernel && cp "$OUT_DIR/arch/arm64/boot/Image" $OUT_DIR/tmp/img/kernel
[ -f dtb ] && rm -rf $OUT_DIR/tmp/img/dtb && cp "$OUT_DIR/arch/arm64/boot/dts/vendor/qcom/yupik.dtb" $OUT_DIR/tmp/img/dtb
[[ $GKI = 1 && ${IMG} = vendor_boot ]] && MAKE_GKI
( [ $STAT = silent ] && exec >/dev/null 2>&1; magiskboot repack ../${IMG}.img $OUT_DIR/zip/images/${IMG}.img )
cd "$SRC_DIR"
rm -rf $OUT_DIR/tmp/img/*
}
MAKE_GKI() {
echo "--------------------------------"
echo "-----------GKI: TRUE------------"
echo "Packing kernel modules into vendor_boot"
echo "--------------------------------"
mkdir -p "$OUT_DIR/tmp/img/ramdisk" && cd "$OUT_DIR/tmp/img/ramdisk"
echo ""
echo "Unpacking ramdisk"
echo ""
cpio -idm < ../ramdisk.cpio
sudo chown -R $USR_NAME:$USR_NAME .
rm -rf lib/modules/5.4-gki/*
find "$OUT_DIR/zip/vendor/lib/modules" -name '*.ko' -exec cp '{}' "$OUT_DIR/tmp/img/ramdisk/lib/modules" \;
tee lib/modules/modules.alias < $OUT_DIR/zip/vendor/lib/modules/modules.alias > /dev/null
tee lib/modules/modules.dep.temp < $OUT_DIR/zip/vendor/lib/modules/modules.dep > /dev/null
tee lib/modules/modules.softdep < $OUT_DIR/zip/vendor/lib/modules/modules.softdep > /dev/null
tee lib/modules/modules.load < $OUT_DIR/zip/vendor/lib/modules/modules.load > /dev/null
sed 's|/vendor||g' lib/modules/modules.dep.temp | tee lib/modules/modules.dep > /dev/null
rm -rf lib/modules/modules.dep.temp ../ramdisk.cpio
if [ $VARIANT = "a73xq" ]; then
echo ""
echo "Adding A73 touchscreen blobs"
echo ""
mkdir -p lib/firmware/tsp_synaptics
cp -rf $SRC_DIR/firmware/tsp_synaptics/s3908_a73xq* lib/firmware/tsp_synaptics/
if [[ "$SRC_BRANCH" != lineage* ]]; then
echo ""
echo "Adding more fs types to A73 fstab"
echo ""
sed -i \
-e '/^system[[:space:]]\+\/system[[:space:]]\+\(erofs\|f2fs\)/d' \
-e '/^\(system[[:space:]]\+\/system[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(vendor[[:space:]]\+\/vendor[[:space:]]\+\)f2fs\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(product[[:space:]]\+\/product[[:space:]]\+\)f2fs\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(odm[[:space:]]\+\/odm[[:space:]]\+\)f2fs\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' first_stage_ramdisk/fstab.qcom
fi
elif [ $VARIANT = "a52sxq" ]; then
echo ""
echo "Adding A52s touchscreen blobs"
echo ""
mkdir -p lib/firmware/tsp_stm
cp -rf $SRC_DIR/firmware/tsp_stm/fts5cu56a_a52sxq* lib/firmware/tsp_stm/
if [[ "$SRC_BRANCH" != lineage* ]]; then
echo ""
echo "Adding more fs types to A52s fstab"
echo ""
sed -i \
-e '/^\(system[[:space:]]\+\/system[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(vendor[[:space:]]\+\/vendor[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(product[[:space:]]\+\/product[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(odm[[:space:]]\+\/odm[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' first_stage_ramdisk/fstab.qcom
fi
elif [ $VARIANT = "m52xq" ]; then
echo ""
echo "Adding M52 touchscreen blobs"
echo ""
mkdir -p lib/firmware/abov lib/firmware/tsp_synaptics
cp -rf $SRC_DIR/firmware/abov/a96t356_m52xq* lib/firmware/abov/
cp -rf $SRC_DIR/firmware/tsp_synaptics/s3908_m52xq* lib/firmware/tsp_synaptics/
if [[ "$SRC_BRANCH" != lineage* ]]; then
echo ""
echo "Adding more fs types to M52 fstab"
echo ""
sed -i \
-e '/^system[[:space:]]\+\/system[[:space:]]\+\(erofs\|f2fs\)/d' \
-e '/^\(system[[:space:]]\+\/system[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(vendor[[:space:]]\+\/vendor[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(product[[:space:]]\+\/product[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' \
-e '/^\(odm[[:space:]]\+\/odm[[:space:]]\+\)ext4\([[:space:]].*\)$/s//\1ext4\2\n\1erofs\2\n\1f2fs\2/' first_stage_ramdisk/fstab.qcom
fi
fi
sudo chown -R root:root .
sudo find . -type d -exec chmod 755 '{}' \;
sudo find . -type f -exec chmod 644 '{}' \;
sudo find . -exec setfattr -n security.selinux -v "u:object_r:rootfs:s0" '{}' \;
echo ""
echo "Repacking ramdisk"
echo ""
sudo find . -print0 | cpio --null -o -H newc --owner root:root > ../ramdisk.cpio
cd ..
sudo rm -rf "$OUT_DIR/tmp/img/ramdisk"
}
CREATE_ZIP() {
echo "--------------------------------"
echo "----Generating Flashable Zip----"
echo "--------------------------------"
touch "$OUT_DIR/zip/META-INF/com/google/android/update-binary" "$OUT_DIR/zip/META-INF/com/google/android/updater-script"
echo "# Dummy file; update-binary is a shell script." > "$OUT_DIR/zip/META-INF/com/google/android/updater-script"
curl -s $MODPROBE_URL > "$OUT_DIR/zip/vendor/bin/vendor_modprobe.sh"
curl -s $UPDATER_URL > "$OUT_DIR/zip/META-INF/com/google/android/update-binary"
cd "$OUT_DIR/zip"
# IS KSU
[[ "$SRC_BRANCH" == *ksu ]] &&\
zip -r -9 RIO_$(date +%Y%m%d)_KSU_$VARIANT.zip images META-INF
# IS SUSFS
[[ "$SRC_BRANCH" == *sus ]] &&\
zip -r -9 RIO_$(date +%Y%m%d)_SUS_$VARIANT.zip images META-INF
# IS LINEAGE
[[ "$SRC_BRANCH" == lineage* ]] &&\
zip -r -9 RIO_$(date +%Y%m%d)_LOS_$VARIANT.zip images META-INF
# IS NEITHER
[[ "$SRC_BRANCH" != *ksu && "$SRC_BRANCH" != *sus && $GKI = 0 ]] &&\
zip -r -9 RIO_$(date +%Y%m%d)_$VARIANT.zip images META-INF vendor
# IS NEITHER BUT GKI
[[ "$SRC_BRANCH" != *ksu && "$SRC_BRANCH" != *sus && $GKI = 1 ]] &&\
zip -r -9 RIO_$(date +%Y%m%d)_GKI_$VARIANT.zip images META-INF vendor
cd "$SRC_DIR"
mv $OUT_DIR/zip/*.zip $SRC_DIR/../
}
PUSH2UN1CA() {
local UN1CA=$1
echo "--------------------------------"
echo "----Pushing kernel to UN1CA-----"
echo "--------------------------------"
cd "$SRC_DIR"
[ ! -d "$UN1CA/out/work_dir/kernel" ] && echo "UN1CA hasn't created work_dir yet." && exit 1
echo ""
echo "Replacing boot, dtbo and vendor_boot."
echo ""
cp -f "$OUT_DIR/zip/images/boot.img" "$UN1CA/out/work_dir/kernel/boot.img"
cp -f "$OUT_DIR/zip/images/dtbo.img" "$UN1CA/out/work_dir/kernel/dtbo.img"
cp -f "$OUT_DIR/zip/images/vendor_boot.img" "$UN1CA/out/work_dir/kernel/vendor_boot.img"
}
BUILD() {
local DEVICE=$1
ENVIRONMENT $DEVICE
SET_DIRS
FETCH_TOOLS
FETCH_IMAGES
BUILD_KERNEL
BUILD_MODULES
REPACK boot
cp "$OUT_DIR/arch/arm64/boot/dtbo.img" "$OUT_DIR/zip/images/dtbo.img"
REPACK vendor_boot
CREATE_ZIP
(( $isUN1CA )) && PUSH2UN1CA $UN1CAPATH
echo ""
echo "Script finished."
echo "Zip location: $(dirname $(pwd))"
echo ""
}
BUILD_ALL() {
rm "$OUT_DIR/.config"
BUILD "a73xq"
rm "$OUT_DIR/.config"
BUILD "a52sxq"
rm "$OUT_DIR/.config"
BUILD "m52xq"
}
BUILD_TARGET() {
rm "$OUT_DIR/.config"
BUILD "$VARIANT"
}
BUILD_TARGET
#BUILD_ALL
#!/bin/bash
tag="LA.UM.9.14.r1-23100-LAHAINA.QSSI14.0"
#git clone https://git.codelinaro.org/clo/la/kernel/msm-5.4.git -b $tag && cd msm-5.4
#git remote add a73xq https://github.com/utkustnr/android_kernel_samsung_a73xq.git
#git remote add los https://github.com/Simon1511/android_kernel_samsung_sm7325.git
#git fetch --all
git subtree add --prefix arch/arm64/boot/dts/vendor/ https://github.com/AdarshGrewal/android_kernel_qcom_devicetree.git 131cb8768239bd4b960af22a023b1af10ae18659
git subtree add --prefix arch/arm64/boot/dts/vendor/qcom/camera/ https://github.com/MotorolaMobilityLLC/kernel-camera-devicetree.git 19431df3ca6fcf35cf2a962f94e970c47481b88b
git subtree add --prefix arch/arm64/boot/dts/vendor/qcom/display/ https://github.com/MotorolaMobilityLLC/kernel-display-devicetree.git 3d5509a108052daad9d4c96e9341388ec705d8ee
git subtree add --prefix drivers/staging/fw-api/ https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/fw-api.git $tag
git subtree add --prefix drivers/staging/qca-wifi-host-cmn/ https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/qca-wifi-host-cmn.git $tag
git subtree add --prefix drivers/staging/qcacld-3.0/ https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/qcacld-3.0.git $tag
git subtree add --prefix techpack/audio/ https://git.codelinaro.org/clo/la/platform/vendor/opensource/audio-kernel.git $tag
git subtree add --prefix techpack/camera/ https://git.codelinaro.org/clo/la/platform/vendor/opensource/camera-kernel.git $tag
git subtree add --prefix techpack/dataipa/ https://git.codelinaro.org/clo/la/platform/vendor/opensource/dataipa.git $tag
git subtree add --prefix techpack/datarmnet-ext/ https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/datarmnet-ext.git $tag
git subtree add --prefix techpack/datarmnet/ https://git.codelinaro.org/clo/la/platform/vendor/qcom/opensource/datarmnet.git $tag
git subtree add --prefix techpack/display/ https://git.codelinaro.org/clo/la/platform/vendor/opensource/display-drivers.git $tag
git subtree add --prefix techpack/video/ https://git.codelinaro.org/clo/la/platform/vendor/opensource/video-driver.git $tag
#tar -xzf Kernel.tar.gz -C ./
#tar -xzf Platform.tar.gz -C ../temp && cp -rf ../temp/vendor/qcom/opensource/* ./techpack/ && rm -rf ../temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment