]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
* Overhaul the way kernel modules are built.
authorRuss Allbery <rra@debian.org>
Wed, 7 Dec 2005 04:03:15 +0000 (04:03 +0000)
committerRuss Allbery <rra@debian.org>
Wed, 7 Dec 2005 04:03:15 +0000 (04:03 +0000)
    - 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
debian/changelog
debian/control.module
debian/control.module-image [deleted file]
debian/genchanges.sh
debian/kernel-version [new file with mode: 0755]
debian/prep-modules
debian/rules

index 241a2078bd5e00cdb27790276fdc7b8bd3faa50a..0eaf8717bcabaa69ef908156ba26a715856e5756 100644 (file)
@@ -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).
 
index bb8929d644eadab7b968de60f2621aa548965da0..e3e1d433f737485062962ed53a0b8f32f2297e4e 100644 (file)
@@ -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 <rra@debian.org>  Tue,  6 Dec 2005 13:20:05 -0800
 
 openafs (1.4.0-1) unstable; urgency=low
 
index 979918b5329190b271783298e4f6893d3315bd2f..66aaad4ebb2031f0ad8e75604120af4d502401f8 100644 (file)
@@ -2,16 +2,19 @@ Source: openafs
 Section: net
 Priority: optional
 Maintainer: Sam Hartman <hartmans@debian.org>
+Uploaders: Russ Allbery <rra@debian.org>
+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 (file)
index 4070add..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Source: openafs
-Section: net
-Priority: optional
-Maintainer: Sam Hartman <hartmans@debian.org>
-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.
index fa7f06c701cf77928c5131af12ce0389cfaa9445..e38781bccc4e36e11e85e742c26750fce0ae6933 100644 (file)
@@ -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 (executable)
index 0000000..093e7d9
--- /dev/null
@@ -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 = <VERSION>;
+if ($line =~ /"(.+)"/) {
+    print "$1\n";
+}
+exit 0;
index c90c75f3d97bad0a66b442ddba6dc01d0adf04b4..e036bae68f66138644be8d9d3da680e5848aecf7 100644 (file)
@@ -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
index f37d2df9b8d603f1b8c94823d3ff11eb1ffafc7b..b0bd6e095c1518523ac881e3cb46d6568a9d46a4 100755 (executable)
@@ -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