2021-06-15 10:26:26 +02:00
|
|
|
#!/bin/bash
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2020-06-08 11:36:26 +02:00
|
|
|
set -e
|
2024-06-28 09:46:11 +02:00
|
|
|
#set -x
|
2020-06-08 11:36:26 +02:00
|
|
|
|
2016-09-16 22:47:02 +02:00
|
|
|
CWD=$(pwd)
|
2023-08-25 13:26:59 +02:00
|
|
|
PRGNAM=$(basename "$CWD")
|
2024-07-25 09:15:47 +02:00
|
|
|
BUILD=${BUILD:-20}
|
2023-10-02 09:54:10 +02:00
|
|
|
BRANCH=${BRANCH:-stable} # stable ; mainline
|
2016-09-16 22:47:02 +02:00
|
|
|
ARCH=$(uname -m)
|
|
|
|
|
2020-06-25 11:23:11 +02:00
|
|
|
TAG=gwh
|
2016-09-16 22:47:02 +02:00
|
|
|
TMP=/tmp/$TAG
|
|
|
|
PKG=$TMP/pkg-$PRGNAM
|
|
|
|
OUTPUT=/tmp
|
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
NUMJOBS=${NUMJOBS:-$(nproc)}
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2023-04-18 13:12:36 +02:00
|
|
|
CONFIG=${CONFIG:-""}
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2023-08-25 13:26:59 +02:00
|
|
|
REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/_repositories/$PRGNAM}
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2020-08-24 15:56:53 +02:00
|
|
|
VERSION=${VERSION:-$(curl https://www.kernel.org/feeds/kdist.xml | grep -o "[0-9.rc-]*: $BRANCH" | head -n1 | cut -d: -f1)}
|
2020-06-09 10:29:47 +02:00
|
|
|
|
2023-08-25 13:26:59 +02:00
|
|
|
mkdir -p "$REPOSITORY"
|
|
|
|
|
|
|
|
rm -fr "$PKG"
|
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
mkdir -p "$PKG/usr/src/"
|
2024-06-28 09:46:11 +02:00
|
|
|
if [ "$BRANCH" == "stable" ]; then
|
|
|
|
SRC_URL="https://cdn.kernel.org/pub/linux/kernel/v$(echo "$VERSION" | cut -d. -f1).x"
|
2020-06-09 10:29:47 +02:00
|
|
|
else
|
2024-06-28 09:46:11 +02:00
|
|
|
SRC_URL="https://git.kernel.org/torvalds/t"
|
2020-06-09 10:29:47 +02:00
|
|
|
fi
|
2020-08-24 15:56:53 +02:00
|
|
|
|
2024-06-28 09:46:11 +02:00
|
|
|
[ ! -e "$REPOSITORY"/linux-"$VERSION".tar.gz ] && wget -c "$SRC_URL/linux-$VERSION.tar.gz" -O "$REPOSITORY/linux-$VERSION.tar.gz"
|
|
|
|
tar xf "$REPOSITORY/linux-$VERSION.tar.gz" -C "$PKG/usr/src/"
|
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
cd "$PKG/usr/src/" || exit 1
|
2024-06-28 09:46:11 +02:00
|
|
|
mv "linux-$VERSION" "linux-gwh"
|
|
|
|
cd "linux-gwh" || exit 1
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2023-04-18 13:12:36 +02:00
|
|
|
if [ -n "$CONFIG" ] && [ -e "$CONFIG" ]; then
|
|
|
|
cat "$CONFIG" > .config
|
|
|
|
fi
|
|
|
|
if [ ! -f .config ]; then
|
|
|
|
zcat /proc/config.gz > .config
|
2016-09-16 22:47:02 +02:00
|
|
|
fi
|
2023-08-25 13:26:59 +02:00
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
make oldconfig "$@"
|
2020-06-09 10:29:47 +02:00
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
make -j"$NUMJOBS"
|
|
|
|
make modules -j"$NUMJOBS"
|
|
|
|
make modules_install INSTALL_MOD_PATH="$PKG"
|
2016-09-16 22:47:02 +02:00
|
|
|
|
2020-09-10 13:26:38 +02:00
|
|
|
if [ -z "${HEADERS_ARCH}" ]; then
|
|
|
|
case "$(uname -m)" in
|
|
|
|
i?86) HEADERS_ARCH=x86 ;;
|
|
|
|
x86_64) HEADERS_ARCH=x86 ;;
|
2020-10-25 14:18:51 +01:00
|
|
|
aarch64) HEADERS_ARCH=arm64 ;;
|
2020-09-10 13:26:38 +02:00
|
|
|
# Use uname -m for all other archs:
|
|
|
|
*) HEADERS_ARCH=$(uname -m) ;;
|
|
|
|
esac
|
|
|
|
fi
|
2023-08-25 13:26:59 +02:00
|
|
|
|
2020-09-10 13:26:38 +02:00
|
|
|
# Generate the kernel headers and clean them up:
|
|
|
|
( echo "Generating headers from the Linux kernel source tree in ${KERNEL_SOURCE}:"
|
2022-12-21 12:25:39 +01:00
|
|
|
make headers_install ARCH="${HEADERS_ARCH}" INSTALL_HDR_PATH="$PKG/usr"
|
|
|
|
cd "$PKG/usr/include" || exit 1
|
2020-09-10 13:26:38 +02:00
|
|
|
# You won't want these files. The ones in libdrm work better.
|
|
|
|
rm -rf drm
|
|
|
|
# This next part seems pretty much cosmetic, but since we've been doing this
|
|
|
|
# for a long time (and others also do), we'll stick with it:
|
2022-12-21 12:25:39 +01:00
|
|
|
mv asm "asm-${HEADERS_ARCH}"
|
|
|
|
ln -sf "asm-${HEADERS_ARCH}" asm
|
2020-09-10 13:26:38 +02:00
|
|
|
# Remove unneeded dotfiles:
|
|
|
|
find . -name ".??*" -exec rm -f {} \+
|
|
|
|
)
|
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
VERSION=$(basename "$(find "$PKG/lib/modules/" -type d -maxdepth 1 -mindepth 1 | head -n1)")
|
2020-08-10 21:42:27 +02:00
|
|
|
|
2024-06-28 09:46:11 +02:00
|
|
|
cd ..
|
|
|
|
mv "$PKG/usr/src/linux-gwh" "$PKG/usr/src/linux-${VERSION}"
|
|
|
|
cd "$PKG/usr/src/linux-${VERSION}" || exit 1
|
|
|
|
|
2024-05-27 10:32:40 +02:00
|
|
|
# Fix build and source symlinks if they are pointing into $TMP:
|
2024-06-28 09:46:11 +02:00
|
|
|
( cd "$PKG"/lib/modules/"${VERSION}"
|
|
|
|
target=$(readlink build)
|
|
|
|
if echo "$target" | grep -q "^$PKG/" ; then
|
|
|
|
rm -f build
|
|
|
|
ln -sf "/usr/src/linux-${VERSION}" build
|
|
|
|
fi
|
2024-05-27 10:32:40 +02:00
|
|
|
)
|
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
mkdir -p "$PKG/boot/"
|
2024-06-28 09:46:11 +02:00
|
|
|
cp System.map "$PKG/boot/System.map-$VERSION"
|
|
|
|
cp .config "$PKG/boot/config-$VERSION"
|
|
|
|
cp "arch/${ARCH}/boot/bzImage" "$PKG/boot/vmlinuz-$VERSION"
|
2022-07-08 22:36:47 +02:00
|
|
|
|
2022-12-12 22:59:17 +01:00
|
|
|
make clean
|
2022-07-08 22:36:47 +02:00
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
mkdir -p "$PKG/install"
|
|
|
|
cat <<EOF > "$PKG/install/doinst.sh"
|
2022-07-08 22:36:47 +02:00
|
|
|
echo -n "updating grub... "
|
|
|
|
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
|
|
|
|
echo OK
|
|
|
|
|
2022-12-12 22:59:17 +01:00
|
|
|
echo -n "building initrd… "
|
2024-09-30 09:31:41 +02:00
|
|
|
# cd /
|
|
|
|
# UCODE=""
|
|
|
|
# [ -e /boot/intel-ucode.cpio ] && UCODE="-P /boot/intel-ucode.cpio"
|
|
|
|
# eval "\$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -k $VERSION -r | sed "s|/boot/initrd.gz|/boot/initrd-${VERSION}.gz|") \${UCODE}"
|
|
|
|
dracut --hostonly --force --kver "$VERSION" "/boot/initrd-$VERSION.img"
|
2022-12-12 22:59:17 +01:00
|
|
|
echo "OK"
|
2022-07-08 22:36:47 +02:00
|
|
|
|
2022-12-12 22:59:17 +01:00
|
|
|
grub-mkconfig -o /boot/grub/grub.cfg
|
2022-07-08 22:36:47 +02:00
|
|
|
EOF
|
2020-08-24 15:56:53 +02:00
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
cat <<EOF > "$PKG/install/slack-desc"
|
2020-08-10 21:42:27 +02:00
|
|
|
$PRGNAM: $PRGNAM (kernel)
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: Linux is a clone of the operating system Unix, written from scratch by
|
|
|
|
$PRGNAM: Linus Torvalds with assistance from a loosely-knit team of hackers
|
|
|
|
$PRGNAM: across the Net. It aims towards POSIX and Single UNIX Specification
|
|
|
|
$PRGNAM: compliance.
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: It has all the features you would expect in a modern fully-fledged Unix
|
|
|
|
$PRGNAM:
|
|
|
|
$PRGNAM: http://www.kernel.org
|
|
|
|
$PRGNAM:
|
2016-09-16 22:47:02 +02:00
|
|
|
EOF
|
|
|
|
|
2022-12-21 12:25:39 +01:00
|
|
|
cd "$PKG" || exit 1
|
|
|
|
rm -f "$PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la"
|
2023-08-15 15:36:52 +02:00
|
|
|
/sbin/makepkg --linkadd y --prepend --chown n "$OUTPUT/$PRGNAM-$(echo "$VERSION" | tr - _)-$ARCH-$BUILD$TAG.txz"
|