99 lines
4.2 KiB
Bash
Executable File
99 lines
4.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
. ./scripts/colors.sh
|
|
. ./scripts/funcs.sh
|
|
. ./scripts/config.sh
|
|
|
|
#--------------- Building Linux Kernel ---------------------
|
|
kernel() {
|
|
print_info "** Building Linux Kernel"
|
|
[ -d $build/kernel ] && return 0
|
|
mkdir -p $build/kernel
|
|
cd $build/kernel
|
|
print_info "** Extracting Linux Kernel"
|
|
tar -xf $root/downloads/linux-$KERNEL_VERSION.tar.xz
|
|
check $? "Extract Linux Kernel"
|
|
cd linux-$KERNEL_VERSION
|
|
print_info "** Configuring Linux Kernel"
|
|
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- mrproper
|
|
cp $root/board/${BOARD_NAME}/linux-$KERNEL_VERSION.config .config
|
|
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- oldconfig
|
|
check $? "Configure Linux Kernel"
|
|
print_info "** Building Linux Kernel"
|
|
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- $makeflags
|
|
check $? "Build Linux Kernel"
|
|
KIMAGE=zImage
|
|
[ "$ARCH" = "arm64" ] && KIMAGE=Image
|
|
ls -lh arch/$ARCH/boot/$KIMAGE
|
|
} # kernel
|
|
#-----------------------------------------------------------
|
|
|
|
#----------- Build and Install kernel modules --------------
|
|
kernel_modules() {
|
|
print_info "** Building Linux Kernel modules"
|
|
[ -d $rootfspath/usr/lib/modules ] && return 0
|
|
cd $build/kernel/linux-$KERNEL_VERSION
|
|
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- modules
|
|
check $? "Build Linux Kernel modules"
|
|
print_info "** Installing Linux Kernel modules into rootfs path"
|
|
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- INSTALL_MOD_PATH=$rootfspath modules_install
|
|
for i in $(find $rootfspath | grep .ko); do
|
|
gzip -9 $i;
|
|
done
|
|
check $? "Install Linux Kernel modules"
|
|
} # kernel_modules
|
|
#-----------------------------------------------------------
|
|
|
|
#--------------- Building Linux Kernel with rootfs ---------
|
|
kernel_with_rootfs() {
|
|
print_info "** Building Linux Kernel with rootfs"
|
|
if [ ! -d $out ]; then
|
|
mkdir -pv $out
|
|
fi
|
|
cd $build/kernel/linux-$KERNEL_VERSION
|
|
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE- CONFIG_INITRAMFS_SOURCE=$rootfspath $makeflags # &>> fulllogfile
|
|
check $? "Build Linux Kernel with rootfs"
|
|
print_info "** Installing Linux Kernel into images path"
|
|
# make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE INSTALL_MOD_PATH=$rootfspath modules_install # &>> $fulllogfile
|
|
# rm -v $rootfspath/usr/lib/modules/6.1.91/{source,build}
|
|
KIMAGE=zImage
|
|
[ "$ARCH" = "arm64" ] && KIMAGE=Image
|
|
cp -v arch/$ARCH/boot/$KIMAGE $sdroot/boot
|
|
check $? "Install Linux Kernel into images path"
|
|
}
|
|
#-----------------------------------------------------------
|
|
|
|
kernel_headers() {
|
|
srcurl=https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${KERNEL_VERSION}.tar.xz
|
|
print_info "** Building Linux Kernel headers"
|
|
[ -d $build/kernel-headers ] && return 0
|
|
[ ! -d $build/kernel-headers ] && mkdir $build/kernel-headers
|
|
cd $build/kernel-headers
|
|
if [ "${BOARD_NAME}" = "orangepi_zero_2w" ]; then
|
|
if [ ! -f $root/downloads/linux-orangepi-orange-pi-6.1-sun50iw9.tar.xz ]; then
|
|
print_info "** Downloading https://gitea.home.com:3000/api/packages/TolaMironcenko/generic/linux/orangepi-orange-pi-6.1-sun50iw9/linux-orangepi-orange-pi-6.1-sun50iw9.tar.xz"
|
|
cd $root/downloads
|
|
wget https://gitea.home.com:3000/api/packages/TolaMironcenko/generic/linux/orangepi-orange-pi-6.1-sun50iw9/linux-orangepi-orange-pi-6.1-sun50iw9.tar.xz
|
|
check $? "download https://gitea.home.com:3000/api/packages/TolaMironcenko/generic/linux/orangepi-orange-pi-6.1-sun50iw9/linux-orangepi-orange-pi-6.1-sun50iw9.tar.xz"
|
|
cd -
|
|
fi
|
|
tar -xf $root/downloads/linux-orangepi-orange-pi-6.1-sun50iw9.tar.xz
|
|
check $? "Extract Linux Kernel"
|
|
else
|
|
if [ ! -f $root/downloads/linux-${KERNEL_VERSION}.tar.xz ]; then
|
|
print_info "** Downloading $srcurl"
|
|
cd $root/downloads
|
|
wget $srcurl
|
|
check $? "download $srcurl"
|
|
cd -
|
|
fi
|
|
tar -xf $root/downloads/linux-$KERNEL_VERSION.tar.xz
|
|
check $? "Extract Linux Kernel"
|
|
fi
|
|
cd linux-$KERNEL_VERSION
|
|
make ARCH=$ARCH headers
|
|
check $? "Build kernel headers"
|
|
make INSTALL_HDR_PATH=$rootfspath/usr headers_install
|
|
check $? "Install kernel headers to rootfs"
|
|
}
|