[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.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
howtos:kernel:using_slackwares_kernel_build_scripts [2019/04/23 05:17 (UTC)] divehowtos: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 mirror. This contains the +any mirror of Slackware -current. This contains the 64 and 32 bit generic and 
-64 and 32 bit generic and huge configs, and a kernel source +huge configs, and a kernel source tarball. The 14.2 source directories have a 
-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 then run the build script. 
-OUTPUT in the environment, and then run the build script. +This will build and install a set of kernel packages, using the newest version 
-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 version source archive found in the current +the kernel version.
-directory. There is no need to manually set the kernel +
-version.+
  
-By exporting a few options the build routine can be changed, +By exporting a few variables the build routine can be changed, such as:
-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 the existing symlinks in /boot if we 
-symlinks in /boot from being clobbered.+are making a custom kernel.
  
 For this example I will build packages for linux-5.0.8, with For this example I will build packages for linux-5.0.8, with
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 if unsetauto from $TMP, recipe and version. E.G.: 
-void__. No kidding.\\  +${TMP}/output-x86_64-${VERSION}
-Default: unset+
  
 **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/kernel-configs/ and +After placing the relevant configs in k/kernel-configs/ and the kernel source 
-the kernel source tarball in k/, it is only necessary to set +tarball in k/, it is only necessary to export any variables we want in the 
-and export OUTPUT in the environment and then run the build +environment and then run the build script. Make sure the $OUTPUT directory 
-script. Make sure the $OUTPUT directory exists, or create it. +exists if you set one, or create it.  You may also want to export 
-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>It's worth repeating - if $OUTPUT is not set +Examples to set $OUTPUT in the environment:
-then the packages will be deleted when the build script +
-attempts to move them.</note>+
  
 In bourne type shells (sh, bash, ksh, zsh, ash etc): In bourne type shells (sh, bash, ksh, zsh, ash etc):
Line 340: Line 336:
 </code> </code>
  
-== The Build ==+=== The Build ===
  
 Then run the build script: Then run the build script:
Line 378: Line 374:
 highlighting, like vim, for example.</note> highlighting, like vim, for example.</note>
  
-== 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 ====+==== Setup Script ====
  
-setup.sh:+An example setup.sh:
  
 <code bash> <code bash>
 #!/bin/sh #!/bin/sh
  
-# setup.sh script for build-all-kernels.sh+# setup script for build-all-kernels.sh
  
-########### MANDATORY SETTINGS ##########+# The is an example kernel package build script. 
 + 
 +########### SETTINGS ########## 
 +export OUTPUT=/home/kernels/$LOCALVERSION
 LOCALVERSION=jabberwok LOCALVERSION=jabberwok
 CONFIG_SUFFIX=.x64 CONFIG_SUFFIX=.x64
-export OUTPUT=/home/kernels/$LOCALVERSION 
-########### OPTIONALSETTINGS ############ 
-export TMP=/mnt/tmpfs 
-export NUMJOBS=-j1 
 export INSTALL_PACKAGES=NO export INSTALL_PACKAGES=NO
-############# END OF SETTINGS ###########+#export TMP=/mnt/tmpfs 
 +#export NUMJOBS=-j1 
 +####### END OF SETTINGS ######
  
 set -e set -e
  
-# Bail out if OUTPUT is not set. +mkdir -"$OUTPUT"
-if [ -z "$OUTPUT" ]; then +
- printf "%s\n" "Error: \$OUTPUT is not set." +
- exit 1 +
-fi+
  
-mkdir -p "$OUTPUT"+# From build-all-kernels.sh. 
 +VERSION=$(/bin/ls -1 linux-*.tar.?z | sort -V | tail -n 1 \ 
 + | rev | cut -f 3- -d . | cut -f 1 -d - | rev) 
 +OLD_CONFIG=$(/bin/ls -1 kernel-configs/config-generic-*${CONFIG_SUFFIX} \ 
 + | sort -V | tail -n 1 | rev | cut -f 2- -d . | cut -f 1 -d - | rev)
  
-# Taken from build-all-kernels.sh. 
-VERSION=$(/bin/ls -t1 linux-*.tar.?z | head -n 1 | rev | cut -f 3- -d . | cut -f 1 -d - | rev) 
 # Bail out if no VERSION found. # Bail out if no VERSION found.
 if [ -z "$VERSION" ]; then if [ -z "$VERSION" ]; then
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/config-generic-*${CONFIG_SUFFIX} \ +OLD_CONFIG=$(/bin/ls -kernel-configs/config-generic-*${CONFIG_SUFFIX} \ 
-  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/$GENERIC_CONFIG ]; then if ! [ -e kernel-configs/$GENERIC_CONFIG ]; then
  printf "\n%s\n" "Copying generic kernel config:"  printf "\n%s\n" "Copying generic kernel config:"
- cp -v kernel-configs/config-generic-${OLD_VERSION}${CONFIG_SUFFIX} \+ cp -v kernel-configs/config-generic-${OLD_CONFIG}${CONFIG_SUFFIX} \
  kernel-configs/$GENERIC_CONFIG  kernel-configs/$GENERIC_CONFIG
 fi fi
Line 453: Line 448:
 if ! [ -e kernel-configs/$HUGE_CONFIG ]; then if ! [ -e kernel-configs/$HUGE_CONFIG ]; then
  printf "\n%s\n" "Copying huge kernel config:"  printf "\n%s\n" "Copying huge kernel config:"
- cp -v kernel-configs/config-huge-${OLD_VERSION}${CONFIG_SUFFIX} \+ cp -v kernel-configs/config-huge-${OLD_CONFIG}${CONFIG_SUFFIX} \
  kernel-configs/$HUGE_CONFIG  kernel-configs/$HUGE_CONFIG
 fi fi
Line 468: Line 463:
  
 # ONLY if we use a custom $TMP. # ONLY if we use a custom $TMP.
-sed -i "s,/tmp/package-kernel-source/,$TMP/package-kernel-source/,g"+sed -i "s,/tmp/package-kernel-source/,$TMP/package-kernel-source/,g"
-  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 variables at the top of the script+  * 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 are unset it will bail out with an +If $VERSION is unset it will bail out with an error.
-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 source archive. The configs are +$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: 
 + 
 +/boot/vmlinuz-<type>-<local version>-<version>-<local version> 
 + 
 +Without a local version, e.g. an upgrade to a stock kernel, it would be: 
 + 
 +/boot/vmlinuz-<type>-<version> 
 + 
 +However, if the /boot symlinks are created then only: 
 + 
 +/boot/vmlinuz 
 + 
 +This saves having to re-edit /etc/lilo.conf whenever we upgrade. 
 + 
 +Example using a local version: 
 + 
 +<code> 
 +image = /boot/vmlinuz-generic-jabberwok-5.0.8-jabberwok 
 +  initrd = /boot/initrd-5.0.8-jabberwok.gz 
 +  root = /dev/sda2 
 +  label = 5.0.8-jabberwok 
 +  read-only 
 +</code> 
 + 
 +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 -current, albeit 
-Slackware releases, albeit with a few tweaks added, so it +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 script:+Link to example scripts:
  
 http://tty1.uk/scripts/kernel/ http://tty1.uk/scripts/kernel/
 +
 +Consider these as works in progress, so they may be updated from time to time.
  
 ====== Sources ====== ====== Sources ======
 howtos:kernel:using_slackwares_kernel_build_scripts ()