From 94112183d2eb3b7c47c6c6d51420e59da78aaf1b Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Wed, 7 Dec 2005 04:03:15 +0000 Subject: [PATCH] * Overhaul the way kernel modules are built. - Recommend linux-image rather than kernel-image for newer kernels. - Always recommend the kernel package; since it's only a recommends, there's no need to special-case the hand-built kernel case. - Be less fragile about how the kernel version is used in prep-modules to support other ways kernel modules are built. (Closes: #341836) - Add Build-Depends and Uploaders to the openafs-modules-source control file. - Remove unused parts of prep-modules and heavily comment it. --- debian/TODO | 7 --- debian/changelog | 11 +++- debian/control.module | 7 ++- debian/control.module-image | 19 ------ debian/genchanges.sh | 11 ++-- debian/kernel-version | 15 +++++ debian/prep-modules | 112 +++++++++++++++++++++++++----------- debian/rules | 25 ++++---- 8 files changed, 123 insertions(+), 84 deletions(-) delete mode 100644 debian/control.module-image create mode 100755 debian/kernel-version diff --git a/debian/TODO b/debian/TODO index 241a2078b..0eaf8717b 100644 --- a/debian/TODO +++ b/debian/TODO @@ -5,13 +5,6 @@ with a style sheet to set off the transcript in a different background color). -* The way the module packages are generated could stand to be simplified - considerably. Much of what prep-modules does is not actually necessary - and just makes the script hard to read. Also, rethink whether both - control.module and control.module-image are needed, and try to use - substvars to handle the control.module variables rather than dynamically - generating the control file. - * Include some of the other random useful AFS programs in openafs-client (scout, vlclient, fstrace, up). diff --git a/debian/changelog b/debian/changelog index bb8929d64..e3e1d433f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,18 @@ openafs (1.4.0-2) unstable; urgency=low + * Overhaul the way kernel modules are built. + - Recommend linux-image rather than kernel-image for newer kernels. + - Always recommend the kernel package; since it's only a recommends, + there's no need to special-case the hand-built kernel case. + - Be less fragile about how the kernel version is used in prep-modules + to support other ways kernel modules are built. (Closes: #341836) + - Add Build-Depends and Uploaders to the openafs-modules-source + control file. + - Remove unused parts of prep-modules and heavily comment it. * Suggest the same PAM settings for pam_krb5 that libpam-krb5 does. * Update uploader address. - -- + -- Russ Allbery Tue, 6 Dec 2005 13:20:05 -0800 openafs (1.4.0-1) unstable; urgency=low diff --git a/debian/control.module b/debian/control.module index 979918b53..66aaad4eb 100644 --- a/debian/control.module +++ b/debian/control.module @@ -2,16 +2,19 @@ Source: openafs Section: net Priority: optional Maintainer: Sam Hartman +Uploaders: Russ Allbery +Build-Depends: debhelper (>= 4.1.16), flex, bison Standards-Version: 3.6.2 Package: openafs-modules-=KVERS Conflicts: openafs-client (<< 1.2.9) Provides: openafs-modules2 Architecture: any -Description: The AFS distributed filesystem- Kernel Module +Recommends: =IMG-=KVERS +Description: AFS distributed filesystem kernel module AFS is a distributed filesystem allowing cross-platform sharing of files among multiple computers. Facilities are provided for access control, authentication, backup and administrative management. . This package provides the compiled AFS kernel module for kernel - =KVERS. + version =KVERS. diff --git a/debian/control.module-image b/debian/control.module-image deleted file mode 100644 index 4070addae..000000000 --- a/debian/control.module-image +++ /dev/null @@ -1,19 +0,0 @@ -Source: openafs -Section: net -Priority: optional -Maintainer: Sam Hartman -Standards-Version: 3.6.2 - -Package: openafs-modules-=KVERS -Conflicts: openafs-client (<< 1.2.9) -Provides: openafs-modules2 -Architecture: any -Recommends: kernel-image-=KVERS (= =KREVS) -Description: The AFS distributed filesystem- Kernel Module - AFS is a distributed filesystem allowing cross-platform sharing of - files among multiple computers. Facilities are provided for access - control, authentication, backup and administrative management. - . - This package provides the compiled AFS kernel module for kernel - =KVERS. - diff --git a/debian/genchanges.sh b/debian/genchanges.sh index fa7f06c70..e38781bcc 100644 --- a/debian/genchanges.sh +++ b/debian/genchanges.sh @@ -2,21 +2,18 @@ # genchanges.sh - generate a changes file for a deb file generated via # the make-kpkg utility -# KSRC KMAINT and KEMAIL are expected to be passed through the environment +# KSRC, KVERS, KMAINT, and KEMAIL are expected to be passed through the +# environment. set -e umask 022 -#KVERS=`cat debian/KVERS` MODVERS=`cat debian/VERSION | sed s/:/\+/` ARCH=`dpkg --print-architecture` mprefix=`grep Package: debian/control.module | cut -d' ' -f 2 | cut -d= -f 1` - -# the changes file's name chfile="$KSRC/../$mprefix${KVERS}${INT_SUBARCH}_${MODVERS}_${ARCH}.changes" dpkg-genchanges -b ${KMAINT:+-m"$KMAINT <$KEMAIL>"} -u"$KSRC/.." \ - -cdebian/control > "$chfile" -#pgp -fast ${KMAINT:+-u"$KMAINT"} < "$chfile.pt" > "$chfile" -rm "$chfile.pt" || true + -cdebian/control > "$chfile" +#debsign "$chfile" diff --git a/debian/kernel-version b/debian/kernel-version new file mode 100755 index 000000000..093e7d91c --- /dev/null +++ b/debian/kernel-version @@ -0,0 +1,15 @@ +#!/usr/bin/perl +# +# Extract the kernel version from the kernel version header file. Takes the +# kernel source path as its only argument. If the version header couldn't be +# found, print nothing and exit quietly. + +my $ksrc = shift; +unless ($ksrc && open (VERSION, "$ksrc/include/linux/version.h")) { + exit 0; +} +my $line = ; +if ($line =~ /"(.+)"/) { + print "$1\n"; +} +exit 0; diff --git a/debian/prep-modules b/debian/prep-modules index c90c75f3d..e036bae68 100644 --- a/debian/prep-modules +++ b/debian/prep-modules @@ -1,53 +1,95 @@ #! /bin/sh +# +# Prepares to build kernel modules. This script figures out and munges +# version strings. The goal is: +# +# * Set the package name to openafs-modules-$(KVERS) where $(KVERS) is the +# major kernel revision plus the debian subrevision and whatever +# architecture string is appropriate if building against the stock Debian +# kernels. $(KVERS) should be identical to the version component contained +# in the Debian kernel package names. +# +# * Make the package recommend either kernel-image-$(KVERS) or +# linux-image-$(KVERS) as appropriate for the kernel version that we're +# building against. Use recommend rather than depends since the user may +# have built their own kernel outside of the Debian package infrastructure. +# +# * Save the version number of the binary package in debian/VERSION for later +# use by dh_gencontrol. This will be the version number of the source +# package followed by a + and the version number of the kernel package that +# we're building against. If the kernel package version contains an epoch, +# try to hack our way into doing the right thing by using that epoch number +# as our own. This isn't quite the right thing, but seems reasonably good. +# +# This script generates debian/control from debian/control.module using sed. +# Unfortunately, substvars cannot be used since the name of the package is +# modified and substvars happens too late. It also outputs debian/VERSION, +# containing the version of the binary package. set -e -if [ $# -ne 2 ]; then - echo Usage: $0 kernelsource-location control-template - exit 1 +if [ "$#" -ne 1 ]; then + echo Usage: $0 kernelsource-location + exit 1 fi +# We can get the kernel version from one of three places. If KVERS and KDREV +# are both already set in the environment (which will be the case when invoked +# by make-kpkg or module-assistant), use them. Otherwise, if we have a kernel +# source directory that contains debian/changelog (generated by make-kpkg), +# parse that file to find the version information. Finally, if neither works, +# extract the kernel version from the kernel headers, append INT_SUBARCH to +# that version if it's available, and assume a kernel package revision of -0 +# if none is provided. +# +# Set the variables $afs_kvers, which will hold the revision of the kernel, +# and $afs_kdrev, which will hold the version of the kernel package that we're +# building against. changelog="$1/debian/changelog" if [ -n "$KVERS" ] && [ -n "$KDREV" ]; then - linuxversion=$KVERS${INT_SUBARCH} - kernversion=$KDREV - -elif [ ! -f $changelog ]; then - linuxversion=`perl -e '$_ = <>; $_ =~ m/"(.+)"/; print "$1\n";' < $1/include/linux/version.h` - - if [ -z "$KDREV" ]; then - kernversion=$linuxversion-0 - else - linuxversion=${linuxversion}${INT_SUBARCH} - kernversion=$KDREV - fi - + afs_kvers="${KVERS}${INT_SUBARCH}" + afs_kdrev="${KDREV}" +elif [ ! -f "$changelog" ] ; then + afs_kvers=`sh debian/kernel-version` + if [ -z "$KDREV" ] ; then + afs_kdrev="${afs_kvers}-0" + else + afs_kvers="${afs_kvers}${INT_SUBARCH}" + afs_kdrev="${KDREV}" + fi else - linuxversion=`head -1 $changelog | \ - sed -e 's/.*source-\([^ ]*\) (\([^)]*\)).*/\1/'` - kernversion=`head -1 $changelog | \ - sed -e 's/.*source-\([^ ]*\) (\([^)]*\)).*/\2/'` + afs_kvers=`head -1 "$changelog" \ + | sed -e 's/.*source-\([^ ]*\) (\([^)]*\)).*/\1/'` + afs_kdrev=`head -1 "$changelog" \ + | sed -e 's/.*source-\([^ ]*\) (\([^)]*\)).*/\2/'` fi -pkgversion=`head -1 debian/changelog | \ - sed -e 's/.*(\([^)]*\)).*/\1/'` - -pkgupversion=`echo $pkgversion | cut -d- -f 1` -pkgupversion2=`perl -e "\"$pkgupversion\" =~ /(.*?)(\d+)\D*$/;"'printf $1 . ($2+1);'` +# Determine the kernel package name. For right now, assume linux-image for +# 2.6.12 and later, and kernel-image for anything earlier. If this doesn't +# work for someone, please submit a bug with the details. -sed -e s/=KVERS/$linuxversion/g -e s/=KREVS/$kernversion/g -e s/=AVERS/$pkgupversion/g -e s/=2AVERS/$pkgupversion2/g $2 - -mprefix=`grep Package: $2 | cut -d' ' -f 2 | cut -d= -f 1` +if dpkg --compare-versions "$afs_kvers" ge "2.6.12" ; then + afs_image=linux-image +else + afs_image=kernel-image +fi -rm -f debian/tmp/usr/share/doc/$mprefix$linuxversion +# Generate the control file from the template. +sed -e "s/=KVERS/${afs_kvers}/g" -e "s/=IMG/${afs_image}/g" \ + debian/control.module > debian/control -epochversion=`echo $kernversion | sed -n -e 's/^\([0-9]*\):.*/\1/p' -e 's/.*//'` -kernversion="$pkgversion+`echo $kernversion | sed -e 's/^[0-9]*://'`" +# Now, calcuate the binary package version. Extract the epoch from the kernel +# package revision and add it to the beginning of the binary package version +# if present. Then, concatenate the source version, '+', and the kernel +# package revision without the epoch. -if [ -n "$epochversion" ]; then - kernversion=$epochversion:$kernversion +afs_version=`head -1 debian/changelog | sed -e 's/.*(\([^)]*\)).*/\1/'` +afs_epoch=`echo ${afs_kdrev} | sed -n -e 's/^\([0-9]*\):.*/\1/p'` +afs_version="${afs_version}+`echo ${afs_kdrev} | sed -e 's/^[0-9]*://'`" +if [ -n "$afs_epoch" ] ; then + afs_version="${afs_epoch}:${afs_version}" fi -echo "$kernversion" > debian/VERSION -echo "$linuxversion" > debian/KVERS + +echo "$afs_version" > debian/VERSION diff --git a/debian/rules b/debian/rules index f37d2df9b..b0bd6e095 100755 --- a/debian/rules +++ b/debian/rules @@ -27,15 +27,16 @@ endif ifndef KPKG_DEST_DIR KPKG_DEST_DIR = .. endif -KVERS := `perl -e '$$_ = <>; $$_ =~ m/"(.+)"/; print "$$1\n";' $(KSRC)/include/linux/version.h 2> /dev/null` -SYS_NAME := $(shell KVERS=$(KVERS) sh debian/sysname) +KVERS := $(shell perl debian/kernel-version $(KSRC)) export KSRC export KVERS export KPKG_DEST_DIR -package = openafs -srcpkg = openafs-modules-source -modulepkg := $(shell echo openafs-modules-$(KVERS)${INT_SUBARCH}) +SYS_NAME := $(shell KSRC="$(KSRC)" KVERS="$(KVERS)" sh debian/sysname) + +package = openafs +srcpkg = openafs-modules-source +modulepkg := openafs-modules-$(KVERS)${INT_SUBARCH} moduledir := debian/$(modulepkg)/lib/modules/$(KVERS)/fs # These packages have lintian overrides. @@ -224,8 +225,7 @@ kdist_image: build-modules-stamp $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean kdist: build-modules-stamp - $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules KERNEL_DEPENDS=y \ - binary-modules + $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules binary-modules KSRC="$(KSRC)" KMAINT="$(KMAINT)" KEMAIL="$(KEMAIL)" \ sh -v debian/genchanges.sh $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean @@ -238,11 +238,11 @@ kdist_clean: configure-modules: configure-modules-stamp configure-modules-stamp: @if test x"$(SYS_NAME)" = x"UNKNOWN" ; then exit 1 ; fi -ifeq ($(KERNEL_DEPENDS),y) - sh debian/prep-modules $(KSRC) debian/control.module > debian/control -else - sh debian/prep-modules $(KSRC) debian/control.module-image > debian/control -endif + @if test x"$(KVERS)" = x ; then \ + echo 'No version in $(KSRC)/include/linux/version.h' >&2 ; \ + exit 1 ; \ + fi + sh debian/prep-modules $(KSRC) -ln -s @sys/dest dest -ln -s $(SYS_NAME) @sys sh configure --with-afs-sysname=$(SYS_NAME) \ @@ -267,7 +267,6 @@ install-modules: build-modules-stamp -a ! -f $(moduledir)/openafs.mp.o ; then \ ln $(moduledir)/openafs.o $(moduledir)/openafs.mp.o || exit 1 ; \ fi - rm -rf debian/$(modulepkg)/usr/include binary-modules: install-modules dh_testdir -- 2.39.5