[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/24 11:37 (UTC)] – script edit 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 should be found in the k/ +The Slackware kernel build scripts can be found in the k/ source directory on 
-source directory on any mirror for Slackware -current. This +any mirror of Slackware -current. This contains the 64 and 32 bit generic and 
-contains the 64 and 32 bit generic and huge configs, and a +huge configs, and a kernel source tarball. The 14.2 source directories have a 
-kernel source tarball. The 14.2 source directories have a +different setup, but the scripts in -current can be used for 14.2.
-different setup, so this is aimed at using -current scripts.+
  
 There isn't a firmware build script in there so I won't be There isn't a firmware build script in there so I won't be
Line 47: 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. If the version isn't what you expect, you may +
-need to remove the other files, leaving the one you need.+
  
-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 64: 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 115: 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 301: 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 344: Line 336:
 </code> </code>
  
-== The Build ==+=== The Build ===
  
 Then run the build script: Then run the build script:
Line 382: 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 406: Line 398:
 recreate your initrd and rerun lilo. recreate your initrd and rerun lilo.
  
-==== The Setup Script ====+==== Setup Script ====
  
-local-version-setup.sh:+An example setup.sh:
  
 <code bash> <code bash>
Line 417: Line 409:
 # The is an example kernel package build script. # The is an example kernel package build script.
  
-########### MANDATORY SETTINGS ##########+########### SETTINGS ########## 
 +export OUTPUT=/home/kernels/$LOCALVERSION
 LOCALVERSION=jabberwok LOCALVERSION=jabberwok
 CONFIG_SUFFIX=.x64 CONFIG_SUFFIX=.x64
-export OUTPUT=/home/kernels/$LOCALVERSION +export INSTALL_PACKAGES=NO
-########### OPTIONALSETTINGS ############+
 #export TMP=/mnt/tmpfs #export TMP=/mnt/tmpfs
 #export NUMJOBS=-j1 #export NUMJOBS=-j1
-export INSTALL_PACKAGES=NO +####### END OF SETTINGS ######
-############# END OF SETTINGS ###########+
  
 set -e set -e
- 
-# Bail out if OUTPUT is not set. 
-if [ -z "$OUTPUT" ]; then 
- printf "%s\n" "Error: \$OUTPUT is not set." 
- exit 1 
-fi 
  
 mkdir -p "$OUTPUT" mkdir -p "$OUTPUT"
  
-Taken from build-all-kernels.sh.+From build-all-kernels.sh.
 VERSION=$(/bin/ls -1 linux-*.tar.?z | sort -V | tail -n 1 \ VERSION=$(/bin/ls -1 linux-*.tar.?z | sort -V | tail -n 1 \
  | rev | cut -f 3- -d . | cut -f 1 -d - | rev)  | 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)
  
 # Bail out if no VERSION found. # Bail out if no VERSION found.
Line 449: 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 -1 kernel-configs/config-generic-*${CONFIG_SUFFIX} \+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)  | sort -V | tail -n 1 | rev | cut -f 2- -d . | cut -f 1 -d - | rev)
  
Line 455: Line 442:
 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 461: 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 489: 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 local-version-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 511: Line 496:
 ==== Lilo ==== ==== Lilo ====
  
-Example section for /etc/lilo.conf:+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> <code>
Line 521: Line 520:
 </code> </code>
  
-The image name should be formatted like: +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 
-/boot/vmlinuz-<type>-<local version>-<version>-<local version>+installed.
  
 ==== Final Thoughts ==== ==== Final Thoughts ====
Line 532: 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 scripts: 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 ()