Commit | Line | Data |
---|---|---|
b7cfede0 BK |
1 | #! /bin/sh |
2 | # | |
3 | # Prepares to build kernel modules. This script figures out and munges | |
4 | # version strings. The goal is: | |
5 | # | |
6 | # * Set the package name to openafs-modules-$(KVERS) where $(KVERS) is the | |
7 | # major kernel revision plus the debian subrevision and whatever | |
8 | # architecture string is appropriate if building against the stock Debian | |
9 | # kernels. $(KVERS) should be identical to the version component contained | |
10 | # in the Debian kernel package names (in other words, the ABI version, not | |
11 | # the package version).. | |
12 | # | |
13 | # * Make the package recommend linux-image-$(KVERS) as appropriate for the | |
14 | # kernel version that we're building against. Use recommend rather than | |
15 | # depends since the user may have built their own kernel outside of the | |
16 | # Debian package infrastructure. | |
17 | # | |
18 | # * Save the version number of the binary package in debian/VERSION for later | |
19 | # use by dh_gencontrol. This will be the version number of the source | |
20 | # package followed by a + and the version number of the kernel package that | |
21 | # we're building against. If the kernel package version contains an epoch, | |
22 | # try to hack our way into doing the right thing by using that epoch number | |
23 | # as our own. This isn't quite the right thing, but seems reasonably good. | |
24 | # | |
25 | # This script generates debian/control from debian/control.module using sed. | |
26 | # Unfortunately, substvars cannot be used since the name of the package is | |
27 | # modified and substvars happens too late. It also outputs debian/VERSION, | |
28 | # containing the version of the binary package. | |
29 | ||
30 | set -e | |
31 | ||
32 | if [ "$#" -ne 1 ]; then | |
33 | echo "Usage: $0 <kernel-source-location>" >&2 | |
34 | exit 1 | |
35 | fi | |
36 | ||
37 | # We can get the kernel version from one of three places. If KVERS and KDREV | |
38 | # are both already set in the environment (which will be the case when invoked | |
39 | # by make-kpkg or module-assistant), use them. Otherwise, if we have a kernel | |
40 | # source directory that contains debian/changelog (generated by make-kpkg), | |
41 | # parse that file to find the version information. Finally, if neither works, | |
42 | # extract the kernel version from the kernel headers, append INT_SUBARCH to | |
43 | # that version if it's available, and assume a kernel package revision of -0 | |
44 | # if none is provided. | |
45 | # | |
46 | # Set the variables $afs_kvers, which will hold the revision of the kernel, | |
47 | # and $afs_kdrev, which will hold the version of the kernel package that we're | |
48 | # building against. | |
49 | ||
50 | changelog="$1/debian/changelog" | |
51 | if [ -n "$KVERS" ] && [ -n "$KDREV" ]; then | |
52 | afs_kvers="${KVERS}${INT_SUBARCH}" | |
53 | afs_kdrev="${KDREV}" | |
54 | elif [ ! -f "$changelog" ] ; then | |
55 | if [ -n "$KVERS" ] ; then | |
56 | afs_kvers="$KVERS" | |
57 | else | |
58 | afs_kvers=`perl debian/kernel-version "$1"` | |
59 | fi | |
60 | if [ -z "$KDREV" ] ; then | |
61 | afs_kdrev="${afs_kvers}-0" | |
62 | else | |
63 | afs_kvers="${afs_kvers}${INT_SUBARCH}" | |
64 | afs_kdrev="${KDREV}" | |
65 | fi | |
66 | else | |
67 | if [ -n "$KVERS" ] ; then | |
68 | afs_kvers="$KVERS" | |
69 | else | |
70 | afs_kvers=`head -1 "$changelog" \ | |
71 | | sed -e 's/.*source-\([^ ]*\) (\([^)]*\)).*/\1/'` | |
72 | fi | |
73 | afs_kdrev=`head -1 "$changelog" \ | |
74 | | sed -e 's/.*source-\([^ ]*\) (\([^)]*\)).*/\2/'` | |
75 | fi | |
76 | ||
77 | # Generate the control file from the template. | |
78 | ||
79 | sed -e "s/=KVERS/${afs_kvers}/g" debian/control.in > debian/control | |
80 | ||
81 | # Now, calcuate the binary package version. Extract the epoch from the kernel | |
82 | # package revision and add it to the beginning of the binary package version | |
83 | # if present. Then, concatenate the source version, '+', and the kernel | |
84 | # package revision without the epoch. | |
85 | ||
86 | afs_version=`head -1 debian/changelog | sed -e 's/.*(\([^)]*\)).*/\1/'` | |
87 | afs_epoch=`echo ${afs_kdrev} | sed -n -e 's/^\([0-9]*\):.*/\1/p'` | |
88 | afs_version="${afs_version}+`echo ${afs_kdrev} | sed -e 's/^[0-9]*://'`" | |
89 | if [ -n "$afs_epoch" ] ; then | |
90 | afs_version="${afs_epoch}:${afs_version}" | |
91 | fi | |
92 | ||
93 | echo "$afs_version" > debian/VERSION |