[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 |
---|
| 19 | tag=$(gettag $dist) |
---|
[23139] | 20 | : ${DEBATHENA_APT=/mit/debathena/apt} |
---|
[24683] | 21 | : ${DEBATHENA_RELEASE=production} |
---|
[24680] | 22 | export DEBATHENA_APT |
---|
| 23 | export DEBATHENA_RELEASE |
---|
[23627] | 24 | pkgfiles="$DEBATHENA_APT/dists/$dist/openafs/binary-$arch/Packages.gz $DEBATHENA_APT/dists/${dist}-proposed/openafs/binary-$arch/Packages.gz" |
---|
[23037] | 25 | |
---|
[24689] | 26 | if [ "$DEBATHENA_RELEASE" = "production" ]; then |
---|
| 27 | apt_release="" |
---|
| 28 | else |
---|
| 29 | apt_release="$DEBATHENA_RELEASE" |
---|
| 30 | fi |
---|
| 31 | |
---|
[23037] | 32 | do_binary=no |
---|
| 33 | do_upload=no |
---|
| 34 | for 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 |
---|
| 48 | done |
---|
| 49 | |
---|
[23083] | 50 | sid=$(schroot -b -c "$chroot") || exit 1 |
---|
[23037] | 51 | trap 'schroot -e -c "$sid"' EXIT |
---|
[23040] | 52 | sch() { schroot -r -c "$sid" -- "$@"; } # Run in the chroot |
---|
| 53 | schq() { schroot -q -r -c "$sid" -- "$@"; } # Run in the chroot quietly |
---|
| 54 | schr() { schroot -r -c "$sid" -u root -- "$@"; } # Run in the chroot as root |
---|
[23117] | 55 | schr apt-get -qq -y update || exit 3 |
---|
[23037] | 56 | |
---|
[23141] | 57 | afsv=$(schq apt-cache show --no-all-versions openafs-modules-source | \ |
---|
| 58 | sed -n 's/^Version: // p') |
---|
| 59 | |
---|
[23037] | 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. |
---|
[23040] | 79 | pkgs=$(sch apt-cache search --names-only '^linux-image-' | awk '{print $1}') |
---|
[23037] | 80 | |
---|
| 81 | # Identify the metapackages which depend directly on actual kernel |
---|
| 82 | # images, as well as the header packages corresponding to those |
---|
| 83 | # dependencies. |
---|
| 84 | metareg='linux-meta\|linux-latest.*' |
---|
| 85 | mpkgs= |
---|
| 86 | headers= |
---|
| 87 | for pkg in $pkgs; do |
---|
[23040] | 88 | info=$(schq apt-cache show --no-all-versions "$pkg") |
---|
[23037] | 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') |
---|
[23040] | 98 | depsrc=$(schq apt-cache show --no-all-versions "$dep" \ |
---|
[23037] | 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/') |
---|
[23040] | 108 | hdrinfo=$(schq apt-cache show "$hdr" 2>/dev/null) |
---|
[23037] | 109 | if [ -z "$hdrinfo" ]; then |
---|
| 110 | continue |
---|
| 111 | fi |
---|
| 112 | |
---|
| 113 | mpkgs="$mpkgs $pkg" |
---|
| 114 | headers="$headers $hdr" |
---|
| 115 | done |
---|
| 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. |
---|
| 120 | for hdr in $headers; do |
---|
[23141] | 121 | hdrv=$(schq apt-cache show --no-all-versions "$hdr" | \ |
---|
| 122 | sed -n 's/^Version: // p') |
---|
| 123 | |
---|
[23037] | 124 | # Check if we already have one. |
---|
| 125 | module=$(echo "$hdr" | sed -e 's/^linux-headers/openafs-modules/') |
---|
[23627] | 126 | if zcat $pkgfiles | \ |
---|
[23141] | 127 | dpkg-awk -f - "Package:^$module\$" "Version:^$(quote "$afsv+$hdrv")\$" | \ |
---|
| 128 | grep -q .; then |
---|
[23037] | 129 | echo "*** Already exists: $dist_arch $module" |
---|
| 130 | continue |
---|
| 131 | fi |
---|
| 132 | |
---|
[23140] | 133 | if fgrep -qx "$dist_arch $hdr" failed.log; then |
---|
[23037] | 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-//') |
---|
[23040] | 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 \ |
---|
[23037] | 146 | "/usr/src/openafs-modules-${kversion}_${afsv}+${hdrv}_$arch.changes.pt" |
---|
[23139] | 147 | here=$(readlink -f .) |
---|
[23146] | 148 | schr sh -xec " |
---|
[23037] | 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 |
---|
[23146] | 155 | export ARCH=x86_64 |
---|
[23037] | 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" |
---|
[23040] | 172 | schr sh -c "cp /usr/src/openafs-modules* $dist_arch" |
---|
[23037] | 173 | else |
---|
| 174 | echo "*** Failed build: $dist_arch $module" |
---|
| 175 | echo "$dist_arch $hdr" >> failed.log |
---|
| 176 | fi |
---|
[23040] | 177 | schr sh -c "rm -f /usr/src/openafs-modules*" |
---|
[23037] | 178 | fi |
---|
| 179 | |
---|
| 180 | # Upload the module if requested, if we successfully built one. |
---|
| 181 | if [ yes = "$do_upload" ]; then |
---|
[23142] | 182 | ch="$dist_arch/${module}_${afsv}+${hdrv}_$arch.changes" |
---|
| 183 | if [ -e "$ch" ]; then |
---|
[23037] | 184 | echo "*** Uploading: $dist_arch $module" |
---|
[24689] | 185 | dareprepro -C openafs include "${dist}${apt_release}" $ch |
---|
[23037] | 186 | else |
---|
| 187 | echo "*** No module: $dist_arch $module" |
---|
| 188 | fi |
---|
| 189 | fi |
---|
| 190 | done |
---|
| 191 | |
---|
| 192 | if [ 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 |
---|
| 197 | fi |
---|
| 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. |
---|
| 203 | for image_mpkg in $mpkgs; do |
---|
[23040] | 204 | info=$(schq apt-cache show --no-all-versions "$image_mpkg") |
---|
[23037] | 205 | ver=$(echo "$info" | sed -ne 's/^Version: //p') |
---|
| 206 | afs_mpkg=$(echo "$image_mpkg" | sed -e 's/^linux-image/openafs-modules/') |
---|
[25145] | 207 | hdr_mpkg=$(echo "$image_mpkg" | sed -e 's/^linux-image/linux-headers/') |
---|
[23037] | 208 | |
---|
[25108] | 209 | # Check if we have dkms |
---|
[25110] | 210 | if schq apt-cache show openafs-modules-dkms > /dev/null 2>&1; then |
---|
[25108] | 211 | # epoch |
---|
| 212 | ver=1:1.0 |
---|
| 213 | fi |
---|
| 214 | |
---|
[23037] | 215 | # Check if we already have an up-to-date OpenAFS metapackage. |
---|
[25169] | 216 | if zcat $pkgfiles \ |
---|
[23141] | 217 | | dpkg-awk -f - "Package:^$(quote $afs_mpkg)\$" -- Version \ |
---|
[25169] | 218 | | sed -ne 's/^Version: //p' \ |
---|
| 219 | | fgrep -qx "$ver$tag"; then |
---|
[23037] | 220 | echo "*** Already up to date: $dist_arch $afs_mpkg" |
---|
| 221 | continue |
---|
| 222 | fi |
---|
| 223 | |
---|
| 224 | # Check if we have an OpenAFS module package, either in the apt |
---|
| 225 | # repository or in the build directory. |
---|
[25108] | 226 | case $ver in |
---|
| 227 | 1:*) |
---|
| 228 | # using dkms |
---|
| 229 | ;; |
---|
| 230 | *) |
---|
| 231 | dep=$(echo "$info" | sed -ne 's/^Depends:.*\(linux-image-[^ ,]*\).*$/\1/p') |
---|
| 232 | module=$(echo "$dep" | sed -e 's/^linux-image/openafs-modules/') |
---|
| 233 | if ! zcat $pkgfiles | fgrep -qx "Package: $module"; then |
---|
| 234 | ch=$(ls "$dist_arch/$module"_*.changes 2>/dev/null) |
---|
| 235 | if [ -z "$ch" ]; then |
---|
| 236 | echo "*** No module: $dist_arch $afs_mpkg" |
---|
| 237 | continue |
---|
| 238 | fi |
---|
| 239 | fi |
---|
| 240 | ;; |
---|
| 241 | esac |
---|
[23037] | 242 | |
---|
| 243 | # Build the metapackage if requested. |
---|
| 244 | if [ yes = "$do_binary" ]; then |
---|
| 245 | echo "*** Creating: $dist_arch $afs_mpkg" |
---|
| 246 | mkdir -p "meta/$dist_arch" |
---|
[25108] | 247 | case $ver in |
---|
| 248 | 1:*) |
---|
| 249 | # using dkms |
---|
| 250 | cat > meta/$dist_arch/$afs_mpkg.equivs <<EOF |
---|
[23037] | 251 | Section: openafs |
---|
| 252 | Priority: extra |
---|
| 253 | Standards-Version: 3.6.2 |
---|
| 254 | |
---|
| 255 | Package: $afs_mpkg |
---|
| 256 | Version: $ver$tag |
---|
[23378] | 257 | Maintainer: Debathena Project <debathena@mit.edu> |
---|
[25145] | 258 | Depends: openafs-modules-dkms, $image_mpkg, $hdr_mpkg |
---|
[25108] | 259 | Copyright: ../common/copyright |
---|
| 260 | Readme: ../common/README.in |
---|
| 261 | Description: Transitional package to install dkms |
---|
| 262 | Kernel specific openafs module packages are replaced with dkms |
---|
| 263 | modules. |
---|
| 264 | EOF |
---|
| 265 | ;; |
---|
| 266 | *) |
---|
| 267 | cat > meta/$dist_arch/$afs_mpkg.equivs <<EOF |
---|
| 268 | Section: openafs |
---|
| 269 | Priority: extra |
---|
| 270 | Standards-Version: 3.6.2 |
---|
| 271 | |
---|
| 272 | Package: $afs_mpkg |
---|
| 273 | Version: $ver$tag |
---|
| 274 | Maintainer: Debathena Project <debathena@mit.edu> |
---|
[23037] | 275 | Depends: $module, $image_mpkg (= $ver) |
---|
| 276 | Copyright: ../common/copyright |
---|
| 277 | Readme: ../common/README.in |
---|
| 278 | Description: Metapackage to enforce OpenAFS modules for kernel |
---|
[25085] | 279 | This package prevents automatic upgrades of the $img_mpkg |
---|
| 280 | kernel until there is a corresponding openafs-modules Debathena |
---|
| 281 | package available. |
---|
[23037] | 282 | EOF |
---|
[25108] | 283 | ;; |
---|
| 284 | esac |
---|
[23040] | 285 | schr apt-get -y install equivs |
---|
[23083] | 286 | (cd "meta/$dist_arch" && sch equivs-build -a "$arch" "$afs_mpkg.equivs") \ |
---|
| 287 | || exit 1 |
---|
[23037] | 288 | fi |
---|
| 289 | |
---|
| 290 | if [ yes = "$do_upload" ]; then |
---|
[25141] | 291 | deb=meta/$dist_arch/${afs_mpkg}_${ver/*:/}${tag}_${arch}.deb |
---|
[23037] | 292 | if [ -e "$deb" ]; then |
---|
| 293 | echo "*** Uploading: $dist_arch $afs_mpkg" |
---|
[24689] | 294 | dareprepro includedeb "${dist}${apt_release}" "$deb" |
---|
[23037] | 295 | else |
---|
| 296 | echo "*** No package: $dist_arch $afs_mpkg" |
---|
| 297 | fi |
---|
| 298 | fi |
---|
| 299 | done |
---|