MAJOR="4" MINOR="19" RELEASE="13" VERSION="$MAJOR.$MINOR.$RELEASE" SRCDIR="linux-$VERSION" TARBALL="linux-$VERSION.tar.xz" URL="https://www.kernel.org/pub/linux/kernel/v$MAJOR.x" SHA256SUM="f50a77fc40e13fc406791346fa91926394205874cd50246c7c2374006bacc0c2" DEPENDS="initrd" get_linux_cpu() { case "$TARGET" in i*86-*) echo "x86" ;; x86_64-*) echo "x86_64" ;; arm-*) echo "arm" ;; *) echo "don't know how to map $TARGET to Linux arch" >&2 exit 1 ;; esac } prepare() { return } build() { local INITRDDIR="$PKGDEPLOYDIR/initrd" local INITRDLIST="$INITRDDIR/initrd.list" local LINUX_CPU=$(get_linux_cpu) pkg install -omLD -R "$REPODIR" -r "$INITRDDIR" initrd pkg install -R "$REPODIR" -r "$INITRDDIR" -l initrd initrd > "$INITRDLIST" export KBUILD_OUTPUT="$PKGBUILDDIR" make -C "$1" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" CROSS_COMPILE="${TARGET}-" mrproper cat_file_override "linux.config" > "$PKGBUILDDIR/.config" sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_CROSS_COMPILE=.*,CONFIG_CROSS_COMPILE="'$TARGET'-",' sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_INITRAMFS_SOURCE=.*,CONFIG_INITRAMFS_SOURCE="'$INITRDLIST'",' sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_LOCALVERSION=.*,CONFIG_LOCALVERSION="-'${OS_NAME}-${OS_RELEASE}'",' make -C "$1" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" CROSS_COMPILE="${TARGET}-" oldconfig make -C "$1" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" CROSS_COMPILE="${TARGET}-" -j $NUMJOBS $LINUX_TGT rm -rf "$INITRDDIR" } deploy() { local SOURCE="$1" local LINUX_CPU=$(get_linux_cpu) local target mkdir -p "$PKGDEPLOYDIR/boot" "$PKGDEPLOYDIR/lib/modules" for target in $LINUX_TGT; do case $target in *Image) cp "arch/$LINUX_CPU/boot/$target" "$PKGDEPLOYDIR/boot/vmlinuz" echo "dir boot 0755 0 0" >> "$PKGDEPLOYDIR/$PKGNAME.files" echo "file boot/vmlinuz 0755 0 0" >> "$PKGDEPLOYDIR/$PKGNAME.files" ;; modules) export KBUILD_OUTPUT="$PKGBUILDDIR" make -C "$SOURCE" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" CROSS_COMPILE="${TARGET}-" INSTALL_MOD_PATH="$PKGDEPLOYDIR" modules_install echo "dir lib 0755 0 0" >> "$PKGDEPLOYDIR/$PKGNAME.files" echo "dir lib/modules 0755 0 0" >> "$PKGDEPLOYDIR/$PKGNAME.files" find -H "$PKGDEPLOYDIR/lib" -type d -printf "dir %p 0%m 0 0\\n" |\ tail -n +2 | sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/$PKGNAME.files" find -H "$PKGDEPLOYDIR/lib" -type l -printf "slink %p 0%m 0 0 %l\\n" |\ sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/$PKGNAME.files" find -H "$PKGDEPLOYDIR/lib" -type f -printf "file %p 0%m 0 0\\n" |\ sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/$PKGNAME.files" ;; esac done cp $SCRIPTDIR/pkg/$PKGNAME/*.desc "$PKGDEPLOYDIR" } check_update() { curl --silent -L https://www.kernel.org/feeds/kdist.xml | \ grep -o "[0-9.]*: longterm" | grep -o "[0-9.]*" | \ verson_find_greatest "$VERSION" }