You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
230 lines
6.3 KiB
230 lines
6.3 KiB
8 years ago
|
#!/bin/sh
|
||
|
set -e
|
||
8 years ago
|
|
||
7 years ago
|
# This is a SlackBuild script for building as-original-as-possible kernel packages.
|
||
|
# It combines existing SlackBuilds and other files in the slackware source tree with vanilla SlackBuild conventions in a way that is clean and functional.
|
||
|
# Unlike the "official" method of building a Slackware kernel, it builds and installs everything in $TMP, so it doesn't taint the host system, and you can build it as a regular user under fakeroot, if you wanted to.
|
||
|
# This often means that the $PKG directory is used as an intermediate directory to run a SlackBuild in, and that said SlackBuilds may need to be modified to run properly in $PKG.
|
||
|
|
||
|
# This script is tailored for x86_64. i?86 support is untested, and would need more modifications (such as building the -smp kernels and fixing $TMP in the packaging SlackBuilds).
|
||
|
# Other architectures can be added, provided the source tree for them is anywhere close to the original slackware tree.
|
||
|
|
||
|
# This SlackBuild should be placed in the "source/k" directory of the source DVD.
|
||
|
# However, this directory doesn't contain all the files we need, as they're scattered all throughout the slackware tree.
|
||
|
|
||
|
# This code may help prepare the source directory:
|
||
|
if [ "$1" = prepare ]; then
|
||
|
shift
|
||
|
|
||
|
if [ $# -lt 3 ]; then
|
||
|
echo Usage: $0 prepare \<source\> \<install\> \<output\> 1>&2
|
||
|
echo e.g. $0 prepare /mnt/tmp/slackware-14.2-source-dvd/source /mnt/tmp/slackware64-14.2-install-dvd/slackware64 ./kernel 1>&2
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
SOURCE=$1
|
||
|
INSTALL=$2
|
||
|
OUT=$3
|
||
|
|
||
|
# Copy the "source/k" directory
|
||
|
cp -aT $SOURCE/k $OUT
|
||
|
|
||
|
# Copy the "source/d/kernel-headers" and "source/a/kernel-firmware" directories into it
|
||
|
cp -at $OUT $SOURCE/d/kernel-headers $SOURCE/a/kernel-firmware
|
||
|
|
||
|
# Copy "slackware*/k/kernel-source-*-noarch-*.txt" to use as slack-desc for kernel-source into it
|
||
|
mkdir -p $OUT/kernel-source
|
||
|
cp -aT $INSTALL/k/kernel-source-*-noarch-*.txt $OUT/kernel-source/slack-desc
|
||
|
|
||
|
# Copy the SlackBuild
|
||
|
cp -at $OUT $0
|
||
|
|
||
|
exit
|
||
|
fi
|
||
|
|
||
8 years ago
|
PKGNAM=${PKGNAM:-linux}
|
||
7 years ago
|
BASEVER=${BASEVER:-4.4.14}
|
||
|
VERSION=${VERSION:-$BASEVER}
|
||
8 years ago
|
ARCH=${ARCH:-x86_64}
|
||
|
KARCH=${KARCH:-x86}
|
||
7 years ago
|
BUILD=${BUILD:-1}
|
||
8 years ago
|
|
||
|
CWD=$(pwd)
|
||
|
TMP=${TMP:-/tmp/kernel}
|
||
|
|
||
|
NUMJOBS=${NUMJOBS:-" -j7 "}
|
||
|
|
||
|
export VERSION ARCH BUILD TMP
|
||
|
|
||
7 years ago
|
# Extract the kernel source
|
||
8 years ago
|
mkdir -p $TMP
|
||
|
cd $TMP
|
||
|
rm -rf $PKGNAM-$BASEVER $PKGNAM-$VERSION
|
||
|
tar xvf $CWD/$PKGNAM-$BASEVER.tar.xz
|
||
|
|
||
7 years ago
|
# Rename the kernel source directory to the proper VERSION
|
||
|
# This is useful if you're applying stable patches and the actual VERSION is different from the one the tarball is named after
|
||
|
if [ "$BASEVER" != "$VERSION" ]; then
|
||
|
mv $PKGNAM-$BASEVER $PKGNAM-$VERSION
|
||
|
fi
|
||
8 years ago
|
|
||
7 years ago
|
# Apply patches
|
||
|
cd $PKGNAM-$VERSION
|
||
|
#xzcat $CWD/patch-x.x.xx.xz | patch -p1 --verbose
|
||
|
|
||
|
|
||
|
#
|
||
8 years ago
|
# Build kernel-headers
|
||
7 years ago
|
#
|
||
8 years ago
|
cd $TMP/$PKGNAM-$VERSION
|
||
7 years ago
|
|
||
|
# Install the kernel headers
|
||
|
PKG=$TMP/package-kernel-headers
|
||
8 years ago
|
rm -rf $PKG
|
||
|
mkdir -p $PKG/usr
|
||
|
make $NUMJOBS INSTALL_HDR_PATH=$PKG/usr headers_install
|
||
|
|
||
7 years ago
|
# Apply some modifications that are present in the original kernel-headers package
|
||
8 years ago
|
find $PKG/usr -type f -a ! -name '*.h' -delete
|
||
|
rm -rf $PKG/usr/include/drm
|
||
7 years ago
|
mv $PKG/usr/include/asm $PKG/usr/include/asm-$KARCH
|
||
|
ln -sf asm-$KARCH $PKG/usr/include/asm
|
||
8 years ago
|
|
||
7 years ago
|
# Install the slack-desc
|
||
8 years ago
|
mkdir -p $PKG/install
|
||
|
cat $CWD/kernel-headers/slack-desc > $PKG/install/slack-desc
|
||
|
|
||
7 years ago
|
# Create the package
|
||
8 years ago
|
cd $PKG
|
||
7 years ago
|
/sbin/makepkg -l y -c n $TMP/kernel-headers-$(echo $VERSION | tr - _)-$KARCH-$BUILD.txz
|
||
|
|
||
8 years ago
|
|
||
7 years ago
|
#
|
||
8 years ago
|
# Build kernel-huge
|
||
7 years ago
|
#
|
||
8 years ago
|
cd $TMP/$PKGNAM-$VERSION
|
||
7 years ago
|
|
||
|
# Build the kernel image
|
||
8 years ago
|
make $NUMJOBS mrproper
|
||
|
cat $CWD/config-$ARCH/config-huge-* > .config
|
||
|
make $NUMJOBS oldconfig
|
||
|
make $NUMJOBS bzImage
|
||
|
|
||
7 years ago
|
# Prepare the directory to run the packaging SlackBuild in
|
||
|
PKG=$TMP/kernel-huge
|
||
8 years ago
|
rm -rf $PKG
|
||
|
mkdir -p $PKG
|
||
|
cp arch/$KARCH/boot/bzImage $PKG
|
||
|
cp System.map $PKG
|
||
|
cp .config $PKG/config
|
||
7 years ago
|
|
||
|
# Copy the packaging SlackBuild
|
||
7 years ago
|
cp -aT $CWD/packaging-$ARCH/kernel-huge $PKG
|
||
8 years ago
|
|
||
7 years ago
|
# Run the packaging SlackBuild
|
||
8 years ago
|
cd $PKG
|
||
|
./kernel-huge.SlackBuild
|
||
|
|
||
7 years ago
|
|
||
|
#
|
||
8 years ago
|
# Build kernel-generic
|
||
7 years ago
|
#
|
||
8 years ago
|
cd $TMP/$PKGNAM-$VERSION
|
||
7 years ago
|
|
||
|
# Build the kernel image
|
||
8 years ago
|
make $NUMJOBS mrproper
|
||
|
cat $CWD/config-$ARCH/config-generic-* > .config
|
||
|
make $NUMJOBS oldconfig
|
||
|
make $NUMJOBS bzImage
|
||
|
|
||
7 years ago
|
# Prepare the directory to run the packaging SlackBuild in
|
||
|
PKG=$TMP/kernel-generic
|
||
8 years ago
|
rm -rf $PKG
|
||
|
mkdir -p $PKG
|
||
|
cp arch/$KARCH/boot/bzImage $PKG
|
||
|
cp System.map $PKG
|
||
|
cp .config $PKG/config
|
||
7 years ago
|
|
||
|
# Copy the packaging SlackBuild
|
||
7 years ago
|
cp -aT $CWD/packaging-$ARCH/kernel-generic $PKG
|
||
8 years ago
|
|
||
7 years ago
|
# Run the packaging SlackBuild
|
||
8 years ago
|
cd $PKG
|
||
|
./kernel-generic.SlackBuild
|
||
|
|
||
7 years ago
|
|
||
|
#
|
||
8 years ago
|
# Build kernel-modules
|
||
7 years ago
|
#
|
||
8 years ago
|
cd $TMP/$PKGNAM-$VERSION
|
||
7 years ago
|
|
||
|
# Build the kernel modules with the already-present kernel-generic config
|
||
8 years ago
|
make $NUMJOBS modules
|
||
|
|
||
7 years ago
|
# Prepare the directory to run the packaging SlackBuild in
|
||
|
PKG=$TMP/kernel-modules
|
||
8 years ago
|
rm -rf $PKG
|
||
|
mkdir -p $PKG
|
||
|
make $NUMJOBS INSTALL_MOD_PATH=$PKG modules_install
|
||
|
|
||
7 years ago
|
# Point the build and source links to the proper source directory in /usr/src, as packaged in kernel-source
|
||
|
rm -f $PKG/lib/modules/$VERSION/build $PKG/lib/modules/$VERSION/source
|
||
8 years ago
|
ln -s /usr/src/$PKGNAM-$VERSION $PKG/lib/modules/$VERSION/build
|
||
|
ln -s /usr/src/$PKGNAM-$VERSION $PKG/lib/modules/$VERSION/source
|
||
|
|
||
7 years ago
|
# Copy the packaging SlackBuild
|
||
7 years ago
|
cp -aT $CWD/packaging-$ARCH/kernel-modules $PKG
|
||
7 years ago
|
|
||
|
# Prefix absolute module paths in the SlackBuild with $CWD, since we installed the modules there
|
||
7 years ago
|
sed -i -e 's@/lib/modules/@$CWD&@' $PKG/kernel-modules.SlackBuild
|
||
8 years ago
|
|
||
7 years ago
|
# Run the packaging SlackBuild
|
||
8 years ago
|
cd $PKG
|
||
|
KERNELRELEASE=$VERSION ./kernel-modules.SlackBuild
|
||
|
|
||
7 years ago
|
|
||
|
#
|
||
8 years ago
|
# Build kernel-source
|
||
7 years ago
|
#
|
||
8 years ago
|
cd $TMP/$PKGNAM-$VERSION
|
||
7 years ago
|
|
||
|
# Cleanup the source directory that was prepared and built with the kernel-generic config
|
||
8 years ago
|
make $NUMJOBS clean
|
||
|
make $NUMJOBS prepare
|
||
|
rm .version .config.old
|
||
|
|
||
7 years ago
|
# Install the kernel source
|
||
|
PKG=$TMP/package-kernel-source
|
||
8 years ago
|
rm -rf $PKG
|
||
|
mkdir -p $PKG/usr/src
|
||
|
ln -s $PKGNAM-$VERSION $PKG/usr/src/$PKGNAM
|
||
7 years ago
|
|
||
|
# Install the slack-desc
|
||
8 years ago
|
mkdir -p $PKG/install
|
||
|
cat $CWD/kernel-source/slack-desc > $PKG/install/slack-desc
|
||
|
|
||
7 years ago
|
# Create the package
|
||
8 years ago
|
cd $PKG
|
||
|
mv $TMP/$PKGNAM-$VERSION usr/src
|
||
7 years ago
|
/sbin/makepkg -l y -c n $TMP/kernel-source-$(echo $VERSION | tr - _)-noarch-$BUILD.txz
|
||
8 years ago
|
|
||
|
|
||
7 years ago
|
#
|
||
|
# Build kernel-firmware
|
||
|
#
|
||
8 years ago
|
cd $TMP
|
||
7 years ago
|
|
||
|
# Prepare the directory to run the packaging SlackBuild in
|
||
|
PKG=$TMP/kernel-firmware
|
||
8 years ago
|
rm -rf $PKG
|
||
|
mkdir -p $PKG
|
||
7 years ago
|
cp -aT $CWD/kernel-firmware $PKG
|
||
8 years ago
|
|
||
7 years ago
|
# Use --depth=1 to cause git to not to download the entire history
|
||
|
sed -i -e 's/git clone/& --depth=1/' $PKG/kernel-firmware.SlackBuild
|
||
|
|
||
|
# Run the packaging SlackBuild
|
||
|
cd $PKG
|
||
|
unset VERSION # The script uses `date` to make a $VERSION
|
||
8 years ago
|
./kernel-firmware.SlackBuild
|