]> git.proxmox.com Git - rustc.git/blame - debian/build-preview-dsc.sh
Run dh_missing in dh_installchangelogs to make sure it runs after both dh_install...
[rustc.git] / debian / build-preview-dsc.sh
CommitLineData
6935ded2 1#!/bin/sh
0b7e4a70
XL
2# NOTE: this script very likely does not work any more, don't try to use it
3# unless you're very familiar with the rest of the packaging.
4#
6935ded2
XL
5# Build a Debian source package out of an existing unpacked rustc deb source,
6# and the official rust preview releases.
7#
8# infinity0 occasionally makes, builds and uploads them here:
735037f5
XL
9# https://launchpad.net/~infinity0/+archive/ubuntu/rust-nightly
10# https://launchpad.net/~infinity0/+archive/ubuntu/rust-beta
6935ded2
XL
11
12# You can set these env vars to tweak the behaviour of this script.
13CHANNEL="${CHANNEL:-beta}" # either beta or nightly
14DIST="${DIST:-experimental}" # which suite to put in debian/changelog
15DEBDIR="${DEBDIR:-}" # where is the debian/ directory? defaults to this script
16NOREMOTE="${NOREMOTE:-false}" # e.g. if you have already downloaded all necessary files
d7338b7c 17# note that we already use "wget -N" to avoid redundant downloads
3fb9dbb3
XL
18NOCLOBBER="${NOCLOBBER:-true}" # don't rebuild if we already have the .dsc
19DPUT_HOST="${DPUT_HOST}" # optional host dput the resulting .dsc to
7135a866 20ARCHES="amd64 arm64 i386"
6935ded2
XL
21
22do_temporary_fixups() {
23# patches needed to subsequent versions go here
d0162c9c 24local verprefix="${1%.0-beta.?}"
10110266
XL
25verprefix="${verprefix%.0-nightly}"
26( cd debian/patches
27local f
28for f in *; do
29 fb="${f%.patch}"
30 fb="${fb%.diff}"
31 # if an updated patch exists, use it
32 if test -f "${fb}_${verprefix}"*; then mv "${fb}_${verprefix}"* "$f"; fi
33done )
6935ded2 34case "$1" in
89fb5abf
XL
35"1.14."*|"1.15."*)
36 dquilt delete ignore-stdcall-test-on-arm64.patch
6935ded2
XL
37 ;;
38esac
39}
40
41abort() { local x="$1"; shift; echo >&2 "$@"; exit "$x"; }
42
43dquilt() {
44 QUILT_PATCHES="debian/patches" \
45 QUILT_PATCH_OPTS="--reject-format=unified" \
46 QUILT_DIFF_ARGS="-p ab --no-timestamps --no-index --color=auto" \
47 QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" \
48 quilt "$@"
49}
50
51HOST="https://static.rust-lang.org"
52BASENAME="rustc-$CHANNEL-src.tar.gz"
53JQUERY="https://code.jquery.com/jquery-2.1.4.js"
54
55SCRIPTDIR="$(dirname "$0")"
56DEBDIR="$(readlink -f ${DEBDIR:-$SCRIPTDIR})"
57echo "using DEBDIR=$DEBDIR as debian tree to copy into upstream tarball"
58test "$PWD" = "${PWD#$DEBDIR}" || abort 1 "must run from outside DEBDIR"
59test -d "$DEBDIR" || abort 1 "DEBDIR not a directory: $DEBDIR"
60
61set -x
62set -e
63
64$NOREMOTE || wget -N "$HOST/dist/$BASENAME"
65$NOREMOTE || wget -N "$HOST/dist/$BASENAME.asc"
3fb9dbb3 66$NOREMOTE || gpg2 -v "$BASENAME.asc"
d7338b7c
XL
67$NOREMOTE || wget -N "$HOST/dist/index.txt"
68MODDATE1="$(grep "^/dist/$BASENAME," index.txt \
69 | cut -d, -f3 | sed -e 's/\(.*\)-\(.*\)-\(.*\)T.*/\1\2\3/')"
6935ded2
XL
70MODDATE2="$(TZ=UTC stat "$BASENAME" -c %y | sed -e 's/\(.*\)-\(.*\)-\([0-9]*\) .*$/\1\2\3/')"
71$NOREMOTE || test "$MODDATE1" = "$MODDATE2" || abort 2 "file mod times don't match, try again"
72$NOREMOTE || wget -N "$JQUERY"
73
74rm -rf "rustc-$CHANNEL"
75tar xf "$BASENAME"
76
77cd "rustc-$CHANNEL"
78{
79 echo "CFG_RELEASE_CHANNEL=$CHANNEL"
80 echo "CFG_HASH_COMMAND=md5sum | cut -c1-8"
81 sed -n -e '/^CFG_RELEASE/,/^##/{/^CFG_INFO/d;p}' mk/main.mk
82 echo "all:"
83 echo " @echo export CFG_RELEASE=\$(CFG_RELEASE)"
84} | make -f - > ./envvars
85. ./envvars
86NEWUPSTR="$(echo "$CFG_RELEASE.$MODDATE2+dfsg1" | sed -e 's/-beta/~beta/' -e 's/-nightly/~~nightly/')"
3fb9dbb3
XL
87if $NOCLOBBER && test -f "../rustc_$NEWUPSTR-1.dsc"; then
88 cd ..
89 rm -rf "rustc-$CHANNEL"
90 abort 0 "already have rustc_$NEWUPSTR-1.dsc; set NOCLOBBER=false if you want to force"
91fi
6935ded2 92cp -a "$DEBDIR" .
d2ab4198 93mk-origtargz --repack --compression xz -v "$NEWUPSTR" "../$BASENAME"
6935ded2
XL
94cd ..
95
96rm -rf "rustc-$CHANNEL" "rustc-$NEWUPSTR"
d2ab4198 97tar xf "rustc_$NEWUPSTR.orig.tar.xz"
6935ded2
XL
98mv "rustc-$CHANNEL" "rustc-$NEWUPSTR"
99
100libstd_ver() {
101 dpkg-parsechangelog --show-field Version | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/'
102}
103
104cd "rustc-$NEWUPSTR"
105cp -a "$DEBDIR" .
7135a866 106
6935ded2
XL
107OLD_LIBVER="$(libstd_ver)"
108dch -D "$DIST" -v "$NEWUPSTR-1" "Team upload."
109dch -a "Switch to $CHANNEL channel."
110NEW_LIBVER="$(libstd_ver)"
7135a866
XL
111do_temporary_fixups "$CFG_RELEASE"
112mkdir -p ../"dl_${CFG_RELEASE}"
113ln -sf ../"dl_${CFG_RELEASE}" dl
114# TODO: don't do this if orig-dl already exists
115$NOREMOTE || upstream_bootstrap_arch="$ARCHES" debian/rules source_orig-dl
116rm -f dl
117cp -al ../"dl_${CFG_RELEASE}" dl
118# set build-dep arch exceptions
119deb_bd_arch_ex="$(echo "$ARCHES" | sed -e 's/\S*/!\0/g')"
1d2f4d69 120sed -e 's/rustc (\(.*\))\( *\[\(.*\)\]\)\?/rustc (\1) ['"$deb_bd_arch_ex"']/g' -i debian/control
7135a866 121
f01597dc 122rm -f debian/missing-sources/jquery-*
6935ded2
XL
123cp "../$(basename "$JQUERY")" debian/missing-sources
124sed -i -e "s/$OLD_LIBVER/$NEW_LIBVER/" "debian/control"
125sed -i -e 's/\(RELEASE_CHANNEL := \)\(.*\)/\1'"$CHANNEL"'/g' debian/rules
7135a866
XL
126sed -i -e 's/^update .*/update '"$OLD_LIBVER $NEW_LIBVER"'/' debian/update-version.sh
127( cd debian && bash ./update-version.sh )
128
6935ded2
XL
129while dquilt push; do dquilt refresh; done
130dquilt pop -a
131rm -rf .pc
132dpkg-buildpackage -d -S
133cd ..
134
3fb9dbb3
XL
135if test -n "$DPUT_HOST"; then
136 dput "$DPUT_HOST" "rustc_$NEWUPSTR-1_source.changes"
137else
138 set +x
139 echo "Source package built, but there is NO GUARANTEE THAT IT WORKS!"
140 echo "You should now try to build it with \`sudo cowbuilder --build rustc_$NEWUPSTR-1.dsc\`"
141fi