]>
Commit | Line | Data |
---|---|---|
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. | |
13 | CHANNEL="${CHANNEL:-beta}" # either beta or nightly | |
14 | DIST="${DIST:-experimental}" # which suite to put in debian/changelog | |
15 | DEBDIR="${DEBDIR:-}" # where is the debian/ directory? defaults to this script | |
16 | NOREMOTE="${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 |
18 | NOCLOBBER="${NOCLOBBER:-true}" # don't rebuild if we already have the .dsc |
19 | DPUT_HOST="${DPUT_HOST}" # optional host dput the resulting .dsc to | |
7135a866 | 20 | ARCHES="amd64 arm64 i386" |
6935ded2 XL |
21 | |
22 | do_temporary_fixups() { | |
23 | # patches needed to subsequent versions go here | |
d0162c9c | 24 | local verprefix="${1%.0-beta.?}" |
10110266 XL |
25 | verprefix="${verprefix%.0-nightly}" |
26 | ( cd debian/patches | |
27 | local f | |
28 | for 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 | |
33 | done ) | |
6935ded2 | 34 | case "$1" in |
89fb5abf XL |
35 | "1.14."*|"1.15."*) |
36 | dquilt delete ignore-stdcall-test-on-arm64.patch | |
6935ded2 XL |
37 | ;; |
38 | esac | |
39 | } | |
40 | ||
41 | abort() { local x="$1"; shift; echo >&2 "$@"; exit "$x"; } | |
42 | ||
43 | dquilt() { | |
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 | ||
51 | HOST="https://static.rust-lang.org" | |
52 | BASENAME="rustc-$CHANNEL-src.tar.gz" | |
53 | JQUERY="https://code.jquery.com/jquery-2.1.4.js" | |
54 | ||
55 | SCRIPTDIR="$(dirname "$0")" | |
56 | DEBDIR="$(readlink -f ${DEBDIR:-$SCRIPTDIR})" | |
57 | echo "using DEBDIR=$DEBDIR as debian tree to copy into upstream tarball" | |
58 | test "$PWD" = "${PWD#$DEBDIR}" || abort 1 "must run from outside DEBDIR" | |
59 | test -d "$DEBDIR" || abort 1 "DEBDIR not a directory: $DEBDIR" | |
60 | ||
61 | set -x | |
62 | set -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" |
68 | MODDATE1="$(grep "^/dist/$BASENAME," index.txt \ | |
69 | | cut -d, -f3 | sed -e 's/\(.*\)-\(.*\)-\(.*\)T.*/\1\2\3/')" | |
6935ded2 XL |
70 | MODDATE2="$(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 | ||
74 | rm -rf "rustc-$CHANNEL" | |
75 | tar xf "$BASENAME" | |
76 | ||
77 | cd "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 | |
86 | NEWUPSTR="$(echo "$CFG_RELEASE.$MODDATE2+dfsg1" | sed -e 's/-beta/~beta/' -e 's/-nightly/~~nightly/')" | |
3fb9dbb3 XL |
87 | if $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" | |
91 | fi | |
6935ded2 | 92 | cp -a "$DEBDIR" . |
d2ab4198 | 93 | mk-origtargz --repack --compression xz -v "$NEWUPSTR" "../$BASENAME" |
6935ded2 XL |
94 | cd .. |
95 | ||
96 | rm -rf "rustc-$CHANNEL" "rustc-$NEWUPSTR" | |
d2ab4198 | 97 | tar xf "rustc_$NEWUPSTR.orig.tar.xz" |
6935ded2 XL |
98 | mv "rustc-$CHANNEL" "rustc-$NEWUPSTR" |
99 | ||
100 | libstd_ver() { | |
101 | dpkg-parsechangelog --show-field Version | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/' | |
102 | } | |
103 | ||
104 | cd "rustc-$NEWUPSTR" | |
105 | cp -a "$DEBDIR" . | |
7135a866 | 106 | |
6935ded2 XL |
107 | OLD_LIBVER="$(libstd_ver)" |
108 | dch -D "$DIST" -v "$NEWUPSTR-1" "Team upload." | |
109 | dch -a "Switch to $CHANNEL channel." | |
110 | NEW_LIBVER="$(libstd_ver)" | |
7135a866 XL |
111 | do_temporary_fixups "$CFG_RELEASE" |
112 | mkdir -p ../"dl_${CFG_RELEASE}" | |
113 | ln -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 | |
116 | rm -f dl | |
117 | cp -al ../"dl_${CFG_RELEASE}" dl | |
118 | # set build-dep arch exceptions | |
119 | deb_bd_arch_ex="$(echo "$ARCHES" | sed -e 's/\S*/!\0/g')" | |
1d2f4d69 | 120 | sed -e 's/rustc (\(.*\))\( *\[\(.*\)\]\)\?/rustc (\1) ['"$deb_bd_arch_ex"']/g' -i debian/control |
7135a866 | 121 | |
f01597dc | 122 | rm -f debian/missing-sources/jquery-* |
6935ded2 XL |
123 | cp "../$(basename "$JQUERY")" debian/missing-sources |
124 | sed -i -e "s/$OLD_LIBVER/$NEW_LIBVER/" "debian/control" | |
125 | sed -i -e 's/\(RELEASE_CHANNEL := \)\(.*\)/\1'"$CHANNEL"'/g' debian/rules | |
7135a866 XL |
126 | sed -i -e 's/^update .*/update '"$OLD_LIBVER $NEW_LIBVER"'/' debian/update-version.sh |
127 | ( cd debian && bash ./update-version.sh ) | |
128 | ||
6935ded2 XL |
129 | while dquilt push; do dquilt refresh; done |
130 | dquilt pop -a | |
131 | rm -rf .pc | |
132 | dpkg-buildpackage -d -S | |
133 | cd .. | |
134 | ||
3fb9dbb3 XL |
135 | if test -n "$DPUT_HOST"; then |
136 | dput "$DPUT_HOST" "rustc_$NEWUPSTR-1_source.changes" | |
137 | else | |
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\`" | |
141 | fi |