Commit 5aea05f9 authored by David Spencer's avatar David Spencer

Initial code drop.

parents
linux-stable
pkg
# Dave's Unofficial Slackbuilt Kernels
This is an experimental system for automatic building and Slackware packaging
of vanilla stable Linux kernels.
The idea is that every time a new kernel of the 4.4 long term support series is
released, unofficial packages for Slackware can be automatically built and
published within hours of the release.
Of course, the big problem is trust. Why should anybody trust an unofficial
set of kernel packages from me?
To solve that problem, the kernel packages are reproducibly built. You can use
this SlackBuild to build your own packages independently, and your packages
should be absolutely identical to my packages. For a discussion of the concept
of reproducible building, see https://reproducible-builds.org/
Reproducible building of the Linux kernel is performed by setting the kbuild
variables KBUILD_BUILD_USER, KBUILD_BUILD_HOST and KBUILD_BUILD_TIMESTAMP as
described in https://www.kernel.org/doc/Documentation/kbuild/kbuild.txt
Reproducible packaging for Slackware is performed by a modified version of
makepkg that is included in this repository. The modifications are:
* sort the symlinks section of doinst.sh so they appear in a consistent order
* support the 'SOURCE_DATE_EPOCH' environment variable to ensure all build
artifacts in the package have a consistent date-time
* make the tar-1.13 command read a sorted list of files so they are packaged
in a consistent order
At the moment this is experimental, automation via 'cron' is not yet implemented
and only the x86_64 'generic' kernel is supported.
#!/bin/sh
# Dave's Unofficial Slackbuilt Kernel
# Copyright 2016 David Spencer, Baildon, West Yorkshire, U.K.
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 'generic' or 'huge'
KERNNAME=${KERNNAME:-generic}
# The 'kernel series' to be built
KERNSERIES=${KERNSERIES:-4.4}
# Upstream branches are named like this:
KERNBRANCH=${KERNBRANCH:-linux-$KERNSERIES.y}
# You can specify a suffix for the kernel version
LOCALVERSION=${LOCALVERSION:-}
# ensure it has one prefix hyphen
[ -n "${LOCALVERSION}" ] && LOCALVERSION="-${LOCALVERSION##-}"
# To use a specific kernel config file, pass its path in $CONFIG
CONFIG=${CONFIG:-}
ARCH=${ARCH:-$(uname -m)}
BUILD=${BUILD:-1}
TAG=${TAG:-_dusk}
SMPSUFFIX=""
CONFSUFFIX=""
case $ARCH in
i586) KERNARCH=x86 ; SLKARCH=i586 ;;
i686) KERNARCH=x86 ; SLKARCH=i686 ; SMPSUFFIX="-smp" ;;
arm*) KERNARCH=arm ; SLKARCH=arm ;;
x86_64) KERNARCH=x86 ; SLKARCH=x86_64 ; CONFSUFFIX=".x64" ;;
*) KERNARCH=$ARCH; SLKARCH=$ARCH ;;
esac
unset ARCH
export LC_COLLATE=C
CWD=$(pwd)
TMP=${TMP:-/tmp}
OUTPUT=${OUTPUT:-$CWD/pkg}
mkdir -p $TMP $OUTPUT
cd $TMP
set -eu
cd $CWD/linux-stable
if [ ! -d .git ]; then
echo "Not a git repository: $(pwd)"
exit 1
fi
git fetch --all
git checkout -f origin/$KERNBRANCH
git clean -fxd
# Get $VERSION, $PATCHLEVEL, $SUBLEVEL, $EXTRAVERSION from kernel source Makefile
head -4 Makefile | sed 's/ *= */=/' > $TMP/versionvars
. $TMP/versionvars
rm $TMP/versionvars
KERNVER="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}${LOCALVERSION}"
SLKVER=$(echo "$KERNVER" | tr - _)
git checkout -f v${VERSION}.${PATCHLEVEL}.${SUBLEVEL}
export SOURCE_DATE_EPOCH="$(git log -n 1 --format=%ct)"
find . -print0 | xargs -0r touch --no-dereference --date="@${SOURCE_DATE_EPOCH}"
# Find the kernel config
if [ -n "${CONFIG:=}" ]; then
if [ ! -f "$CONFIG" ]; then
echo "No kernel config found (looking for $CONFIG)"
exit 1
fi
else
# let's try to find one in this order:
for CONFIG in \
"$CWD/${SLKARCH}/config-${KERNNAME}${SMPSUFFIX}-${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}${SMPSUFFIX}${CONFSUFFIX}" \
$(printf "$CWD/${SLKARCH}/config-${KERNNAME}${SMPSUFFIX}-${VERSION}.${PATCHLEVEL}.%s${SMPSUFFIX}${CONFSUFFIX} " $(seq ${SUBLEVEL} -1 0)) \
"$CWD/${SLKARCH}/config-${KERNNAME}${SMPSUFFIX}-${VERSION}.${PATCHLEVEL}${SMPSUFFIX}${CONFSUFFIX}" \
"$CWD/${SLKARCH}/config-${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}${CONFSUFFIX}" \
$(printf "$CWD/${SLKARCH}/config-${VERSION}.${PATCHLEVEL}.%s${CONFSUFFIX} " $(seq $SUBLEVEL -1 0)) \
"$CWD/${SLKARCH}/config-${VERSION}.${PATCHLEVEL}${CONFSUFFIX}"
do
[ -f "$CONFIG" ] && break
done
if [ ! -f "$CONFIG" ]; then
echo "No kernel config found (looking for $CWD/config-$SLKARCH/config[-${KERNNAME}${SMPSUFFIX}]-${VERSION}.${PATCHLEVEL}[.${SUBLEVEL}${SMPSUFFIX}${EXTRAVERSION}${CONFSUFFIX}])"
exit 1
fi
fi
echo "Using kernel config $CONFIG"
cat "$CONFIG" > .config
KERNARGS="${NUMJOBS:-} LOCALVERSION=$LOCALVERSION KBUILD_BUILD_HOST=${TAG##_} KBUILD_BUILD_USER=${TAG##_} KBUILD_BUILD_TIMESTAMP=@$SOURCE_DATE_EPOCH"
make silentoldconfig $KERNARGS
#------------------------------------------------------------------------------
PRGNAM=kernel-${KERNNAME}${SMPSUFFIX}
#------------------------------------------------------------------------------
PKG=$TMP/package-$PRGNAM
rm -rf $PKG
mkdir -p $PKG
make bzImage $KERNARGS
mkdir -p $PKG/boot
cp arch/${KERNARCH}/boot/bzImage $PKG/boot/vmlinuz-${KERNNAME}${SMPSUFFIX}-${KERNVER}
ln -s vmlinuz-${KERNNAME}${SMPSUFFIX}-${KERNVER} $PKG/boot/vmlinuz-${KERNNAME}
ln -s vmlinuz-${KERNNAME}${SMPSUFFIX}-${KERNVER} $PKG/boot/vmlinuz
cp System.map $PKG/boot/System.map-${KERNNAME}${SMPSUFFIX}-${KERNVER}
ln -s System.map-${KERNNAME}${SMPSUFFIX}-${KERNVER} $PKG/boot/System.map
cat .config > $PKG/boot/config-${KERNNAME}${SMPSUFFIX}-${KERNVER}
ln -s config-${KERNNAME}${SMPSUFFIX}-${KERNVER} $PKG/boot/config
mkdir -p $PKG/install
cat $CWD/$SLKARCH/$PRGNAM-slack-desc > $PKG/install/slack-desc
cd $PKG
$CWD/makepkg -l y -c n $OUTPUT/$PRGNAM-$SLKVER-$SLKARCH-$BUILD$TAG.${PKGTYPE:-txz}
#------------------------------------------------------------------------------
PRGNAM=kernel-modules${SMPSUFFIX}
#------------------------------------------------------------------------------
PKG=$TMP/package-$PRGNAM
rm -rf $PKG
mkdir -p $TMP $PKG
cd $CWD/linux-stable
make modules $KERNARGS
mkdir -p $PKG/lib/modules/${KERNVER}
make modules_install KDIR=$(pwd) INSTALL_MOD_PATH=$PKG $KERNARGS
rm $PKG/lib/modules/${KERNVER}/build
ln -s /usr/src/linux-${KERNVER} $PKG/lib/modules/${KERNVER}/build
rm $PKG/lib/modules/${KERNVER}/source
ln -s /usr/src/linux-${KERNVER} $PKG/lib/modules/${KERNVER}/source
mkdir -p $PKG/install
cat $CWD/$SLKARCH/$PRGNAM-slack-desc > $PKG/install/slack-desc
# Write out the doinst.sh:
cat << EOF > $PKG/install/doinst.sh
# A good idea whenever kernel modules are added or changed:
if [ -x sbin/depmod ]; then
chroot . /sbin/depmod -a ${KERNVER} 1> /dev/null 2> /dev/null
fi
EOF
cd $PKG
$CWD/makepkg -l y -c n $OUTPUT/$PRGNAM-$SLKVER-$SLKARCH-$BUILD$TAG.${PKGTYPE:-txz}
#------------------------------------------------------------------------------
PRGNAM=kernel-headers${SMPSUFFIX}
#------------------------------------------------------------------------------
PKG=$TMP/package-$PRGNAM
rm -rf $PKG
mkdir -p $TMP $PKG
cd $CWD/linux-stable
make headers_install INSTALL_HDR_PATH=$PKG/usr $KERNARGS
find $PKG/usr -type f -name '.*' -delete
mkdir -p $PKG/install
cat $CWD/$SLKARCH/$PRGNAM-slack-desc > $PKG/install/slack-desc
cd $PKG
$CWD/makepkg -l y -c n $OUTPUT/$PRGNAM-$SLKVER-$SLKARCH-$BUILD$TAG.${PKGTYPE:-txz}
#------------------------------------------------------------------------------
PRGNAM=kernel-source${SMPSUFFIX}
#------------------------------------------------------------------------------
PKG=$TMP/package-$PRGNAM
rm -rf $PKG
mkdir -p $TMP $PKG
mkdir -p $PKG/usr/src/linux-$KERNVER
cd $CWD/linux-stable
make clean $KERNARGS
make prepare $KERNARGS
cp -a \
* \
.gitignore .config .mailmap \
$PKG/usr/src/linux-$KERNVER
ln -s linux-$KERNVER $PKG/usr/src/linux
mkdir -p $PKG/install
cat $CWD/$SLKARCH/$PRGNAM-slack-desc > $PKG/install/slack-desc
cd $PKG
$CWD/makepkg -l y -c n $OUTPUT/$PRGNAM-$SLKVER-noarch-$BUILD$TAG.${PKGTYPE:-txz}
This diff is collapsed.
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
kernel-generic: kernel-generic (a general purpose SMP Linux kernel)
kernel-generic: ** UNOFFICIAL VERSION **
kernel-generic:
kernel-generic: This is a Linux kernel with built-in support for most disk
kernel-generic: controllers. To use filesystems, or to load support for a SCSI or
kernel-generic: other controller, then you'll need to load one or more kernel
kernel-generic: modules using an initial ramdisk, or initrd. For more information
kernel-generic: about creating an initrd, see the README.initrd file in the /boot
kernel-generic: directory.
kernel-generic:
kernel-generic: SMP is "Symmetric multiprocessing", or multiple CPU/core support.
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
kernel-headers: kernel-headers (Linux kernel include files)
kernel-headers: ** UNOFFICIAL VERSION **
kernel-headers:
kernel-headers: These are the include files from the Linux kernel.
kernel-headers:
kernel-headers: You'll need these to compile most system software for Linux.
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
kernel-headers:
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in. You must
# make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
kernel-modules: kernel-modules (Linux kernel modules)
kernel-modules: ** UNOFFICIAL VERSION **
kernel-modules:
kernel-modules: Kernel modules are pieces of code that can be loaded and unloaded into
kernel-modules: the kernel upon demand. They extend the functionality of the kernel
kernel-modules: without the need to reboot the system. These modules provide support
kernel-modules: for hardware such as USB devices, RAID controllers, network
kernel-modules: interfaces, and display devices, or add other additional capabilities
kernel-modules: to the kernel.
kernel-modules:
kernel-modules:
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|' on
# the right side marks the last column you can put a character in. You must make
# exactly 11 lines for the formatting to be correct. It's also customary to
# leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
kernel-source: kernel-source (Linux kernel source)
kernel-source: ** UNOFFICIAL VERSION **
kernel-source:
kernel-source: Source code for Linus Torvalds' Linux kernel.
kernel-source:
kernel-source: This is the complete and unmodified source code for the Linux kernel.
kernel-source:
kernel-source:
kernel-source:
kernel-source:
kernel-source:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment