-
Notifications
You must be signed in to change notification settings - Fork 18
/
build_kernel.sh
executable file
·66 lines (53 loc) · 1.41 KB
/
build_kernel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
export KERNELDIR=`readlink -f .`
export RAMFS_SOURCE=`readlink -f $KERNELDIR/ramdisk`
export PARTITION_SIZE=134217728
export OS="11.0.0"
export SPL="2021-11"
echo "kerneldir = $KERNELDIR"
echo "ramfs_source = $RAMFS_SOURCE"
RAMFS_TMP="/tmp/arter97-op9-ramdisk"
echo "ramfs_tmp = $RAMFS_TMP"
cd $KERNELDIR
if [[ "${1}" == "skip" ]] ; then
echo "Skipping Compilation"
else
echo "Compiling kernel"
cp defconfig .config
make "$@" || exit 1
fi
echo "Building new ramdisk"
#remove previous ramfs files
rm -rf '$RAMFS_TMP'*
rm -rf $RAMFS_TMP
rm -rf $RAMFS_TMP.cpio
#copy ramfs files to tmp directory
cp -axpP $RAMFS_SOURCE $RAMFS_TMP
cd $RAMFS_TMP
#clear git repositories in ramfs
find . -name .git -exec rm -rf {} \;
find . -name EMPTY_DIRECTORY -exec rm -rf {} \;
$KERNELDIR/ramdisk_fix_permissions.sh 2>/dev/null
cd $KERNELDIR
rm -rf $RAMFS_TMP/tmp/*
cd $RAMFS_TMP
find . | fakeroot cpio -H newc -o | pigz > $RAMFS_TMP.cpio.gz
ls -lh $RAMFS_TMP.cpio.gz
cd $KERNELDIR
echo "Making new boot image"
mkbootimg \
--kernel $KERNELDIR/arch/arm64/boot/Image.gz \
--ramdisk $RAMFS_TMP.cpio.gz \
--pagesize 4096 \
--os_version $OS \
--os_patch_level $SPL \
--header_version 3 \
-o $KERNELDIR/boot.img
GENERATED_SIZE=$(stat -c %s boot.img)
if [[ $GENERATED_SIZE -gt $PARTITION_SIZE ]]; then
echo "boot.img size larger than partition size!" 1>&2
exit 1
fi
echo "done"
ls -al boot.img
echo ""