-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_kernel.sh
executable file
·67 lines (54 loc) · 1.66 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
67
#!/bin/bash
# Set Default Path
TOP_DIR=$PWD
KERNEL_PATH=$TOP_DIR/kernel
# TODO: Set toolchain and root filesystem path
TOOLCHAIN="$TOP_DIR/arm-2009q3/bin/arm-none-eabi-"
ROOTFS_PATH="$TOP_DIR/initramfs"
KERNEL_NAME="Homura-Note"
CONFIG_FILE="$KERNEL_PATH/arch/arm/configs/Homura_Note_defconfig"
export LOCALVERSION="-$KERNEL_NAME"
export KBUILD_BUILD_VERSION="Note5a"
export WHOAMI_MOD="Homura"
export HOSTNAME_MOD="Akemi"
TAR_NAME="$KERNEL_NAME-$KBUILD_BUILD_VERSION.tar"
ZIP_NAME="$KERNEL_NAME-$KBUILD_BUILD_VERSION.zip"
CWM_ZIP="Note.cwmzip"
cd $KERNEL_PATH
make -j8 clean
# Copy Kernel Configuration File
cp -f $CONFIG_FILE $KERNEL_PATH/.config
make -j8 -C $KERNEL_PATH oldconfig || exit -1
# Build Kernel
find -name '*.ko' -exec cp -av {} $ROOTFS_PATH/lib/modules/ \;
cd $TOP_DIR
make -j8 -C $KERNEL_PATH ARCH=arm CROSS_COMPILE=$TOOLCHAIN CONFIG_INITRAMFS_SOURCE="$ROOTFS_PATH" || exit -1
cd $KERNEL_PATH
find -name '*.ko' -exec cp -av {} $ROOTFS_PATH/lib/modules/ \;
cd $TOP_DIR
make -j8 -C $KERNEL_PATH ARCH=arm CROSS_COMPILE=$TOOLCHAIN CONFIG_INITRAMFS_SOURCE="$ROOTFS_PATH" || exit -1
# Copy Kernel Image
cp -f $KERNEL_PATH/arch/arm/boot/zImage .
rm $TAR_NAME.md5
rm $ZIP_NAME
# Create Odin File
tar --format=ustar -cf $TAR_NAME zImage
md5sum -t $TAR_NAME >> $TAR_NAME
mv $TAR_NAME $TAR_NAME.md5
# Create CWM File
mv zImage ./Auto-sign/zImage
cd Auto-sign
cp $CWM_ZIP $ZIP_NAME
zip $ZIP_NAME zImage
java -jar signapk.jar testkey.x509.pem testkey.pk8 $ZIP_NAME ../$ZIP_NAME
rm $ZIP_NAME
mv zImage $ROOTFS_PATH
# Make Clean
cd $ROOTFS_PATH/lib/modules/
rm *
cd $KERNEL_PATH
make -j8 clean
# Heimdall Flash!
cd $ROOTFS_PATH
sudo heimdall flash --kernel zImage --verbose
rm zImage