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