[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
howtos:kernel:using_slackwares_kernel_build_scripts [2019/04/23 05:17 (UTC)] – dive | howtos:kernel:using_slackwares_kernel_build_scripts [2019/04/24 15:37 (UTC)] – dive | ||
---|---|---|---|
Line 31: | Line 31: | ||
(A recipe dictates the arch of the package set.) | (A recipe dictates the arch of the package set.) | ||
- | The Slackware kernel build scripts can be found in the k/ | + | The Slackware kernel build scripts can be found in the k/ source directory on |
- | source directory on any Slackware | + | any mirror |
- | 64 and 32 bit generic and huge configs, and a kernel source | + | huge configs, and a kernel source tarball. |
- | tarball. There isn't a firmware build script in there so I | + | different setup, but the scripts in -current can be used for 14.2. |
- | won't be looking at making a package for that. | + | |
+ | There isn't a firmware build script in there so I won't be | ||
+ | looking at making a package for that. | ||
The build routine looks like this: | The build routine looks like this: | ||
Line 44: | Line 46: | ||
* Loop to the next package... | * Loop to the next package... | ||
- | At its simplest, you can mirror the k/ directory, export | + | At its simplest, you can mirror the k/ directoryand |
- | OUTPUT in the environment, | + | This will build and install a set of kernel packages, using the newest |
- | This will build and install a set of kernel packages, using | + | source archive found in the current directory. There is no need to manually set |
- | the highest | + | the kernel version. |
- | directory. There is no need to manually set the kernel | + | |
- | version. | + | |
- | By exporting a few options | + | By exporting a few variables |
- | such as: | + | |
* The local version (explanation below.) | * The local version (explanation below.) | ||
Line 60: | Line 59: | ||
* Whether the packages are installed on the build system. | * Whether the packages are installed on the build system. | ||
- | Some minor tweaking of the scripts is necessary if we change | + | Some minor tweaking of the scripts is necessary if we change the default build |
- | the default build directory, and to stop the existing | + | directory, and we may not want to clobber |
- | symlinks in /boot from being clobbered. | + | are making a custom kernel. |
For this example I will build packages for linux-5.0.8, | For this example I will build packages for linux-5.0.8, | ||
Line 111: | Line 110: | ||
**OUTPUT:** | **OUTPUT:** | ||
- | **Mandatory**. Where the build script will move the | + | Optional. Where the build script will move the |
- | completed packages to. This is the most important variable. | + | completed packages to.\\ |
- | If this isn't set then the packages will be __lost in the | + | Default |
- | void__. No kidding.\\ | + | ${TMP}/ |
- | Default: | + | |
**INSTALL_PACKAGES: | **INSTALL_PACKAGES: | ||
Line 166: | Line 164: | ||
Note that I am using the -current source folder here because | Note that I am using the -current source folder here because | ||
- | it contains the newest configs, and they are closest to my | + | it contains the newest configs, and they are closest to the |
target kernel version. | target kernel version. | ||
Line 297: | Line 295: | ||
(The generic script is also used to make the huge kernel.) | (The generic script is also used to make the huge kernel.) | ||
- | == The Variables == | + | === The Variables |
- | After placing the relevant configs in k/ | + | After placing the relevant configs in k/ |
- | the kernel source tarball in k/, it is only necessary to set | + | tarball in k/, it is only necessary to export |
- | and export | + | environment and then run the build script. Make sure the $OUTPUT directory |
- | script. Make sure the $OUTPUT directory exists, or create it. | + | exists |
- | You may also want to export INSTALL_PACKAGES=NO if you don't | + | INSTALL_PACKAGES=NO if you don't want to install the packages as they are being |
- | want to install the packages as they are being built. | + | built. |
- | <note warning> | + | Examples to set $OUTPUT |
- | then the packages will be deleted when the build script | + | |
- | attempts to move them.</ | + | |
In bourne type shells (sh, bash, ksh, zsh, ash etc): | In bourne type shells (sh, bash, ksh, zsh, ash etc): | ||
Line 340: | Line 336: | ||
</ | </ | ||
- | == The Build == | + | === The Build === |
Then run the build script: | Then run the build script: | ||
Line 378: | Line 374: | ||
highlighting, | highlighting, | ||
- | == Not Only But Also == | + | === Not Only But Also === |
In addition to the packages being created, we also have the | In addition to the packages being created, we also have the | ||
Line 402: | Line 398: | ||
recreate your initrd and rerun lilo. | recreate your initrd and rerun lilo. | ||
- | ==== The Setup Script ==== | + | ==== A Setup Script ==== |
- | setup.sh: | + | An example |
<code bash> | <code bash> | ||
#!/bin/sh | #!/bin/sh | ||
- | # setup.sh script for build-all-kernels.sh | + | # setup script for build-all-kernels.sh |
- | ########### | + | # The is an example kernel package build script. |
+ | |||
+ | ########### SETTINGS ########## | ||
+ | export OUTPUT=/ | ||
LOCALVERSION=jabberwok | LOCALVERSION=jabberwok | ||
CONFIG_SUFFIX=.x64 | CONFIG_SUFFIX=.x64 | ||
- | export OUTPUT=/ | ||
- | ########### OPTIONALSETTINGS ############ | ||
- | export TMP=/ | ||
- | export NUMJOBS=-j1 | ||
export INSTALL_PACKAGES=NO | export INSTALL_PACKAGES=NO | ||
- | ############# END OF SETTINGS | + | #export TMP=/ |
+ | #export NUMJOBS=-j1 | ||
+ | ####### END OF SETTINGS ###### | ||
set -e | set -e | ||
- | # Bail out if OUTPUT is not set. | + | mkdir -p " |
- | if [ -z " | + | |
- | printf " | + | |
- | exit 1 | + | |
- | fi | + | |
- | mkdir -p "$OUTPUT" | + | # From build-all-kernels.sh. |
+ | VERSION=$(/bin/ls -1 linux-*.tar.? | ||
+ | | rev | cut -f 3- -d . | cut -f 1 -d - | rev) | ||
+ | OLD_CONFIG=$(/ | ||
+ | | sort -V | tail -n 1 | rev | cut -f 2- -d . | cut -f 1 -d - | rev) | ||
- | # Taken from build-all-kernels.sh. | ||
- | VERSION=$(/ | ||
# Bail out if no VERSION found. | # Bail out if no VERSION found. | ||
if [ -z " | if [ -z " | ||
Line 441: | Line 436: | ||
GENERIC_CONFIG=config-generic-${VERSION}${CONFIG_SUFFIX} | GENERIC_CONFIG=config-generic-${VERSION}${CONFIG_SUFFIX} | ||
HUGE_CONFIG=config-huge-${VERSION}${CONFIG_SUFFIX} | HUGE_CONFIG=config-huge-${VERSION}${CONFIG_SUFFIX} | ||
- | OLD_VERSION=$(/bin/ls -t1 kernel-configs/ | + | OLD_CONFIG=$(/bin/ls -1 kernel-configs/ |
- | | head -n 1 | rev | cut -f 2- -d . | cut -f 1 -d - | rev) | + | | sort -V | tail -n 1 | rev | cut -f 2- -d . | cut -f 1 -d - | rev) |
# copy configs if they don't exist already for the version | # copy configs if they don't exist already for the version | ||
if ! [ -e kernel-configs/ | if ! [ -e kernel-configs/ | ||
printf " | printf " | ||
- | cp -v kernel-configs/ | + | cp -v kernel-configs/ |
kernel-configs/ | kernel-configs/ | ||
fi | fi | ||
Line 453: | Line 448: | ||
if ! [ -e kernel-configs/ | if ! [ -e kernel-configs/ | ||
printf " | printf " | ||
- | cp -v kernel-configs/ | + | cp -v kernel-configs/ |
kernel-configs/ | kernel-configs/ | ||
fi | fi | ||
Line 468: | Line 463: | ||
# ONLY if we use a custom $TMP. | # ONLY if we use a custom $TMP. | ||
- | sed -i " | + | # sed -i " |
- | kernel-modules.SlackBuild | + | # kernel-modules.SlackBuild |
# Speed up find - optional tweak. | # Speed up find - optional tweak. | ||
Line 481: | Line 476: | ||
In a nutshell: | In a nutshell: | ||
- | * Set the mandatory | + | * Set the variables at the top of the script. |
- | * Set any optional variables you want. | + | |
* sh setup.sh | * sh setup.sh | ||
- | If $OUTPUT or $VERSION | + | If $VERSION |
- | error. | + | |
Tweaks in a nutshell: | Tweaks in a nutshell: | ||
Line 495: | Line 488: | ||
* The hard-coded /tmp path is replaced. Only needed if setting $TMP. | * The hard-coded /tmp path is replaced. Only needed if setting $TMP. | ||
- | $VERSION is found automatically from the newest | + | $VERSION is found automatically from the highest version |
- | found in a similar way. They will be created if none are found for $VERSION. | + | source archive. The configs are found in a similar way. They |
+ | will be created if none are found for $VERSION. If the | ||
+ | versions aren't what you expect, you may need to remove the | ||
+ | other files, leaving the ones you need. | ||
+ | |||
+ | ==== Lilo ==== | ||
+ | |||
+ | When using a local version the image name would be formatted like: | ||
+ | |||
+ | / | ||
+ | |||
+ | Without a local version, e.g. an upgrade to a stock kernel, it would be: | ||
+ | |||
+ | / | ||
+ | |||
+ | However, if the /boot symlinks are created then only: | ||
+ | |||
+ | / | ||
+ | |||
+ | This saves having to re-edit / | ||
+ | |||
+ | Example using a local version: | ||
+ | |||
+ | < | ||
+ | image = / | ||
+ | initrd = / | ||
+ | root = /dev/sda2 | ||
+ | label = 5.0.8-jabberwok | ||
+ | read-only | ||
+ | </ | ||
+ | |||
+ | Substitute the initrd file name for your own. I tend to name them after the | ||
+ | specific kernel they were made for, which is helpful with more than one kernel | ||
+ | installed. | ||
==== Final Thoughts ==== | ==== Final Thoughts ==== | ||
Line 505: | Line 531: | ||
it shows enough to get started. | it shows enough to get started. | ||
- | This is the way that the kernel packages are made in | + | This is the way that the kernel packages are made in Slackware |
- | Slackware | + | with a few tweaks added, so it has does have a history of reliability behind |
- | has does have a history of reliability behind it. | + | it. |
- | Link to example | + | Link to example |
http:// | http:// | ||
+ | |||
+ | Consider these as works in progress, so they may be updated from time to time. | ||
====== Sources ====== | ====== Sources ====== |