Last active
May 9, 2018 02:56
-
-
Save ChronoMonochrome/235e8c9f828578062b5aea16957c6a3f to your computer and use it in GitHub Desktop.
mk_kernel_l90.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TOP=/media/system1/root/CM14 | |
SOURCE=$TOP/kernel/lge/msm8226 | |
OUT=$TOP/out/target/product/w7 | |
OBJ=$OUT/obj/KERNEL_OBJ | |
GCC=/media/system1/root/l90/gcc-prebuilts/bin/arm-gnu-linux-androideabi- | |
do_kern_build() { | |
JOB_NUM=8 | |
VERBOSE=0 | |
[ ! -z $1 ] && JOB_NUM=$1 | |
[ ! -z $2 ] && VERBOSE=$2 | |
rm -fr $OUT/arch/arm/boot $OUT/dt.img $OUT/boot.img $OUT/ramdisk.img $OUT/kernel | |
make -C $SOURCE O=$OBJ ARCH=arm CROSS_COMPILE=" $GCC" w7ds_lineageos_defconfig | |
make -j$JOB_NUM V=$VERBOSE -C $SOURCE O=$OBJ ARCH=arm CROSS_COMPILE=" $GCC" | |
cp $OBJ/arch/arm/boot/zImage $OUT/kernel | |
$TOP/out/host/linux-x86/bin/mkbootfs $OUT/root | gzip -9 > $OUT/ramdisk.img | |
$TOP/out/host/linux-x86/bin/dtbToolCM -o $OUT/dt.img -s 2048 -p $OBJ/scripts/dtc/ $OBJ/arch/arm/boot/ | |
$TOP/out/host/linux-x86/bin/mkbootimg --kernel $OUT/kernel \ | |
--ramdisk $OUT/ramdisk.img --cmdline \ | |
"console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 msm_rtb.filter=0x37 androidboot.hardware=qcom androidboot.selinux=permissive" \ | |
--base 0x00000000 --pagesize 2048 --dt $OUT/dt.img --ramdisk_offset 0x01000000 --tags_offset 0x00000100 \ | |
--output $OUT/boot.img | |
size=$(for i in $OUT/boot.img; do stat --format "%s" "$i" | tr -d '\n'; echo +; done; echo 0); | |
total=$(( $( echo "$size" ) )); | |
printname=$(echo -n "$OUT/boot.img" | tr " " +); | |
img_blocksize=135168; | |
twoblocks=$((img_blocksize * 2)); | |
onepct=$(((((17301504 / 100) - 1) / img_blocksize + 1) * img_blocksize)); | |
reserve=$((twoblocks > onepct ? twoblocks : onepct)); | |
maxsize=$((17301504 - reserve)); | |
echo "$printname maxsize=$maxsize blocksize=$img_blocksize total=$total reserve=$reserve"; | |
if [ "$total" -gt "$maxsize" ]; then | |
echo "error: $printname too large ($total > [17301504 - $reserve])"; | |
false; | |
elif [ "$total" -gt $((maxsize - 32768)) ]; then | |
echo "WARNING: $printname approaching size limit ($total now; limit $maxsize)"; | |
fi | |
cp $OUT/boot.img . | |
VERSION=$(git -C $SOURCE describe --tags | head -n 1) | |
zip -9r cm14_kernel-$VERSION.zip boot.img system/ META-INF/ | |
} | |
do_kern_build $1 $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good Job!