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

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