standard_build/build_kernel.sh

65 lines
1.1 KiB
Bash
Raw Normal View History

2024-11-08 14:50:39 +08:00
#!/bin/bash
2024-11-27 11:30:36 +08:00
PACKAGE_CONFIG=${PACKAGE_CONFIG:-package.config}
. ${PACKAGE_CONFIG}
2024-11-08 14:50:39 +08:00
CUR_DIR=`dirname $(realpath $0)`
2024-11-27 11:30:36 +08:00
2024-11-08 14:50:39 +08:00
if [ ! -e "${CROSS_COMPILE}gcc" ]; then
CROSS_COMPILE=aarch64-linux-gnu-
fi
FOLDER_NAME=${FOLDER_NAME:build}
FOLDER="`pwd`/${FOLDER_NAME}/"
KBUILD_BUILD_USER=acosail
KBUILD_BUILD_HOST=acosail
ARCH=arm64
export ARCH CROSS_COMPILE KBUILD_BUILD_USER KBUILD_BUILD_HOST
PARAMS="-C ${SRC} INSTALL_MOD_STRIP=1 O=${FOLDER} -j${CORES}"
echo "build kernel"
if [ ! -d "${FOLDER}" ]; then
mkdir ${FOLDER}
cp $CUR_DIR/conf/${CONFIG_NAME} ${FOLDER}.config
fi
CMD=
if [ "_$1" == "_deb" ]; then
echo "build debs"
CMD=bindeb-pkg
RET=$?
elif [ "_$1" == "_menu" ]; then
CMD=menuconfig
elif [ "_$1" == "_c" ]; then
CMD=
elif [ "_$1" == "_mrproper" ]; then
CMD=mrproper
else
CMD=targz-pkg
fi
make ${PARAMS} ${CMD}
RET=$?
if [ "$RET" -eq 0 ]; then
if [ "_${CMD}" == "_targz-pkg" ]; then
echo "copy kernel tar file to images/"
2024-11-08 19:01:39 +08:00
cp ${FOLDER}linux-5.15.80.bpo*.tar.gz $CUR_DIR/images/linux-5.15.0+-arm64.tar.gz
2024-11-08 14:50:39 +08:00
fi
cd $CUR_DIR
echo "current version:"
cat ${FOLDER}/include/config/kernel.release
echo "done"
else
echo "kernel build error!"
fi
exit $RET