source: trunk/debathena/third/openafs/debathenify-openafs @ 23758

Revision 23758, 8.6 KB checked in by broder, 15 years ago (diff)
Update debathenified packages to check for exact version matches. Previously, these packages wouldn't check the release-specific tag, so that if the tag changed (i.e. from ~ubuntu9.04~0.1 to ~ubuntu9.04 when Jaunty released), debathenified packages wouldn't get rebuilt.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3quote() {
4  echo "$1" | sed 's/[^[:alnum:]]/\\&/g'
5}
6
7fail() {
8  echo "$@" >&2
9  exit 1
10}
11
12dist_arch=$1; shift
13a=
14if [ "$1" = "-A" ]; then a=-A; shift; fi
15chroot=$dist_arch-sbuild
16dist=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\1/')
17arch=$(echo "$dist_arch" | sed 's/^\(.*\)-\([^-]*\)$/\2/')
18. /mit/debathena/bin/debian-versions.sh
19tag=$(gettag $dist)
20: ${DEBATHENA_APT=/mit/debathena/apt}
21pkgfiles="$DEBATHENA_APT/dists/$dist/openafs/binary-$arch/Packages.gz $DEBATHENA_APT/dists/${dist}-proposed/openafs/binary-$arch/Packages.gz"
22
23: ${release=-proposed}
24
25do_binary=no
26do_upload=no
27for arg; do
28  case $arg in
29  source)
30    ;;
31  binary)
32    do_binary=yes
33    ;;
34  upload)
35    do_upload=yes
36    ;;
37  *)
38    fail "Usage: $0 DIST_ARCH [-A] source|binary|upload ..."
39    ;;
40  esac
41done
42
43sid=$(schroot -b -c "$chroot") || exit 1
44trap 'schroot -e -c "$sid"' EXIT
45sch() { schroot -r -c "$sid" -- "$@"; }           # Run in the chroot
46schq() { schroot -q -r -c "$sid" -- "$@"; }       # Run in the chroot quietly
47schr() { schroot -r -c "$sid" -u root -- "$@"; }  # Run in the chroot as root
48schr apt-get -qq -y update || exit 3
49
50afsv=$(schq apt-cache show --no-all-versions openafs-modules-source | \
51  sed -n 's/^Version: // p')
52
53# Get all of the packages named linux-image-*.  This list includes
54# three types of packages:
55#  - Actual kernel images (e.g. linux-image-2.6.24-19-generic)
56#  - Metapackages (e.g. linux-image-generic) which are used to keep
57#    kernel images up to date
58#  - Meta-metapackages which depend on other metapackages; these
59#    exist for transitional reasons or to provide more generic names
60#    (e.g. linux-image-amd64 depends on linux-image-2.6-amd64 in
61#    lenny)
62#
63# We can distinguish actual kernel images from metapackages by looking
64# at the source package; actual images will have the source "linux"
65# (Ubuntu) or "linux-2.6" (Debian) while both kinds of metapackages
66# will have the source "linux-meta" (Ubuntu) or "linux-latest-2.6"
67# (Debian).
68#
69# To distinguish metapackages from meta-metapackages, we need to look
70# at whether the package's linux-image-* dependency is an actual
71# kernel image or a metapackage.
72pkgs=$(sch apt-cache search --names-only '^linux-image-' | awk '{print $1}')
73
74# Identify the metapackages which depend directly on actual kernel
75# images, as well as the header packages corresponding to those
76# dependencies.
77metareg='linux-meta\|linux-latest.*'
78mpkgs=
79headers=
80for pkg in $pkgs; do
81  info=$(schq apt-cache show --no-all-versions "$pkg")
82
83  # Disregard if this is not a metapackage.
84  src=$(echo "$info" | sed -ne 's/^Source: //p')
85  if [ $(expr "$src" : "$metareg") = 0 ]; then
86    continue
87  fi
88
89  # Disregard if this package's linux-image dependency is a metapackage.
90  dep=$(echo "$info" | sed -ne 's/^Depends:.*\(linux-image-[^ ,]*\).*$/\1/p')
91  depsrc=$(schq apt-cache show --no-all-versions "$dep" \
92    | sed -ne 's/^Source: //p')
93  if [ $(expr "$depsrc" : "$metareg") != 0 ]; then
94    continue
95  fi
96
97  # Find the corresponding linux-headers package.  If there isn't one,
98  # this is probably an Ubuntu linux-image-debug metapackage and we
99  # can ignore it.
100  hdr=$(echo "$dep" | sed -e 's/image/headers/')
101  hdrinfo=$(schq apt-cache show "$hdr" 2>/dev/null)
102  if [ -z "$hdrinfo" ]; then
103    continue
104  fi
105
106  mpkgs="$mpkgs $pkg"
107  headers="$headers $hdr"
108done
109
110# For each header package found, attempt to build and/or upload
111# (according to the command-line arguments) a corresponding
112# openafs-modules package if one does not already exist.
113for hdr in $headers; do
114  hdrv=$(schq apt-cache show --no-all-versions "$hdr" | \
115    sed -n 's/^Version: // p')
116
117  # Check if we already have one.
118  module=$(echo "$hdr" | sed -e 's/^linux-headers/openafs-modules/')
119  if zcat $pkgfiles | \
120     dpkg-awk -f - "Package:^$module\$" "Version:^$(quote "$afsv+$hdrv")\$" | \
121     grep -q .; then
122    echo "*** Already exists: $dist_arch $module"
123    continue
124  fi
125
126  if fgrep -qx "$dist_arch $hdr" failed.log; then
127    echo "*** Prior build failure: $dist_arch $module"
128    continue
129  fi
130
131  # Attempt to build the module if requested.
132  if [ yes = "$do_binary" ]; then
133    echo "*** Building: $dist_arch $module"
134    kversion=$(echo "$hdr" | sed 's/^linux-headers-//')
135    schr apt-get -y install module-assistant "$hdr"
136    schr m-a -i -t -l "$kversion" get openafs
137    schr m-a -i -t -l "$kversion" unpack openafs
138    schr touch \
139      "/usr/src/openafs-modules-${kversion}_${afsv}+${hdrv}_$arch.changes.pt"
140    here=$(readlink -f .)
141    schr sh -xec "
142      eval \"\$(dpkg-architecture)\"
143      if [ \"\$DEB_HOST_ARCH\" != amd64 ] && \
144        fgrep -x CONFIG_X86_64=y '/lib/modules/$kversion/build/.config'; then
145        apt-get -y install binutils-multiarch util-linux
146        type linux64 >/dev/null || apt-get -y install linux32
147        export KPKG_ARCH=amd64
148        export ARCH=x86_64
149        export PERSONALITY=linux64
150        export PATH=$here/hacked-arch:\$PATH
151      fi
152      if ! [ -e /usr/src/modules/openafs/debian/genchanges* ]; then
153        install -m a=rx,u+w $here/genchanges.sh \
154          /usr/src/modules/openafs/debian/
155      fi
156      if [ lenny = \"$dist\" ]; then
157        install -m a=rx,u+w $here/genchanges.sh \
158          /usr/src/modules/openafs/debian/genchanges
159      fi
160      $PERSONALITY SIGNCHANGES=1 module-assistant -i -t -l '$kversion' \
161        auto-build openafs" </dev/null
162    if [ $? -eq 0 ]; then
163      echo "*** Successful build: $dist_arch $module"
164      mkdir -p "$dist_arch"
165      schr sh -c "cp /usr/src/openafs-modules* $dist_arch"
166    else
167      echo "*** Failed build: $dist_arch $module"
168      echo "$dist_arch $hdr" >> failed.log
169    fi
170    schr sh -c "rm -f /usr/src/openafs-modules*"
171  fi
172
173  # Upload the module if requested, if we successfully built one.
174  if [ yes = "$do_upload" ]; then
175    ch="$dist_arch/${module}_${afsv}+${hdrv}_$arch.changes"
176    if [ -e "$ch" ]; then
177      echo "*** Uploading: $dist_arch $module"
178      reprepro --ignore=wrongdistribution -Vb "$DEBATHENA_APT" -C openafs \
179        include "${dist}${release}" $ch
180    else
181      echo "*** No module: $dist_arch $module"
182    fi
183  fi
184done
185
186if [ dapper = "$dist" ]; then
187  # Dapper's equivs-build doesn't handle --arch correctly, so we can't
188  # easily synthesize architecture-specific metapackages.
189  echo "*** Skipping metapackage creation on dapper"
190  exit
191fi
192
193# For each upstream metapackage found, if we have an appropriate
194# OpenAFS module, create and/or upload a metapackage tying the OpenAFS
195# module to the current version of the upstream metapackage, if one
196# does not already exist at the current version.
197for image_mpkg in $mpkgs; do
198  info=$(schq apt-cache show --no-all-versions "$image_mpkg")
199  ver=$(echo "$info" | sed -ne 's/^Version: //p')
200  afs_mpkg=$(echo "$image_mpkg" | sed -e 's/^linux-image/openafs-modules/')
201
202  # Check if we already have an up-to-date OpenAFS metapackage.
203  repover=$(zcat $pkgfiles \
204    | dpkg-awk -f - "Package:^$(quote $afs_mpkg)\$" -- Version \
205    | sed -e 's/^Version: //')
206  if [ "x$repover" = "x$ver$tag" ]; then
207    echo "*** Already up to date: $dist_arch $afs_mpkg"
208    continue
209  fi
210
211  # Check if we have an OpenAFS module package, either in the apt
212  # repository or in the build directory.
213  dep=$(echo "$info" | sed -ne 's/^Depends:.*\(linux-image-[^ ,]*\).*$/\1/p')
214  module=$(echo "$dep" | sed -e 's/^linux-image/openafs-modules/')
215  if ! zcat $pkgfiles | fgrep -qx "Package: $module"; then
216    ch=$(ls "$dist_arch/$module"_*.changes 2>/dev/null)
217    if [ -z "$ch" ]; then
218      echo "*** No module: $dist_arch $afs_mpkg"
219      continue
220    fi
221  fi
222
223  # Build the metapackage if requested.
224  if [ yes = "$do_binary" ]; then
225    echo "*** Creating: $dist_arch $afs_mpkg"
226    mkdir -p "meta/$dist_arch"
227    cat > meta/$dist_arch/$afs_mpkg.equivs <<EOF
228Section: openafs
229Priority: extra
230Standards-Version: 3.6.2
231
232Package: $afs_mpkg
233Version: $ver$tag
234Maintainer: Debathena Project <debathena@mit.edu>
235Depends: $module, $image_mpkg (= $ver)
236Copyright: ../common/copyright
237Readme: ../common/README.in
238Description: Metapackage to enforce OpenAFS modules for kernel
239 This package prevents automatic upgrades of the $ktype generic until
240 there is a corresponding openafs-modules Debathena package available.
241EOF
242    schr apt-get -y install equivs
243    (cd "meta/$dist_arch" && sch equivs-build -a "$arch" "$afs_mpkg.equivs") \
244      || exit 1
245  fi
246
247  if [ yes = "$do_upload" ]; then
248    deb=meta/$dist_arch/${afs_mpkg}_${ver}${tag}_${arch}.deb
249    if [ -e "$deb" ]; then
250      echo "*** Uploading: $dist_arch $afs_mpkg"
251      reprepro -Vb "$DEBATHENA_APT" --ignore=wrongdistribution includedeb \
252        "${dist}${release}" "$deb"
253    else
254      echo "*** No package: $dist_arch $afs_mpkg"
255    fi
256  fi
257done
Note: See TracBrowser for help on using the repository browser.