Last active
July 15, 2021 10:56
-
-
Save mwhudson/65e4ea998f347bbc7d69111b1ac37371 to your computer and use it in GitHub Desktop.
scripts for updating rustc/cargo in ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
series=$1 | |
source=$(dpkg-parsechangelog -SSource) | |
version=$(dpkg-parsechangelog -SVersion) | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
if [ $(echo $branch | cut -d- -f1) != "merge" ]; then | |
echo "wrong branch" | |
exit 1 | |
fi | |
VER=$(echo $branch | cut -d- -f2) | |
MAJOR=$(echo $VER | cut -d. -f1) | |
MINOR=$(echo $VER | cut -d. -f2) | |
OMINOR=$((MINOR-1)) | |
oseries=$series | |
while :; do | |
if git rev-parse $oseries-$MAJOR.$OMINOR >/dev/null 2>/dev/null; then | |
OBRANCH=$oseries-$MAJOR.$OMINOR | |
break | |
elif [ "${OMINOR}" = "0" ]; then | |
oseries=merge | |
OMINOR=$((MINOR-1)) | |
else | |
OMINOR=$((OMINOR-1)) | |
fi | |
done | |
RANGE=${2-merge-$MAJOR.$OMINOR..$oseries-$MAJOR.$OMINOR} | |
P="$(echo -e 'next command: ')" | |
e () { | |
q="$(printf " %q" "$@")" | |
echo -e '\033[01;32m' | |
read -er -a n -i "${q# }" -p "$P" | |
echo -e '\033[00m' | |
eval "${n[@]}" | |
} | |
l () { | |
echo + "$@" | |
eval "$@" | |
} | |
e git checkout -b $series-$MAJOR.$MINOR merge-$MAJOR.$MINOR | |
rm -f ../hashlist | |
for h in $(git rev-list --reverse $RANGE); do | |
commit=$(git log -1 --pretty=format:%s $h) | |
case "$commit" in | |
releasing*|reconstruct*|*'Backport to'*) | |
continue;; | |
esac | |
git log --oneline -1 $h | sed -e 's/^/p /' >> ../hashlist | |
done | |
vim ../hashlist | |
if [ "$LPBUG" = "none" ]; then | |
git commit --allow-empty -m " * Backport to ${series^}." | |
else | |
git commit --allow-empty -m " * Backport to ${series^}. (LP: #$LPBUG)" | |
fi | |
for ah in $(awk '{ print $1 "-" $2 }' ../hashlist); do | |
echo $ah | |
a=${ah%-*} | |
h=${ah#*-} | |
commit=$(git log -1 --pretty=format:%s $h) | |
git cherry-pick --allow-empty $h || bash | |
if [ $a = "r" ]; then | |
git commit --amend --allow-empty | |
fi | |
if git diff-tree --no-commit-id --name-only -r HEAD | grep -q ^debian/patches; then | |
while ! quilt push -a; do | |
bash | |
done | |
quilt refresh | |
quilt pop -a | |
if ! git diff --exit-code > /dev/null; then | |
l git commit --amend --no-edit --all | |
fi | |
fi | |
done | |
git log --oneline merge-$MAJOR.$MINOR..HEAD | |
e dch -b -v $version~$(ubuntu-distro-info --series=$series --release | awk '{ print $1 }').1 '' --release-heuristic log -D UNRELEASED | |
e /snap/git-ubuntu/current/usr/bin/git-ubuntu.reconstruct-changelog merge-$MAJOR.$MINOR | |
git diff | |
e git commit -am reconstruct-changelog | |
e rustbuild.sh --test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux | |
tarball=$1 | |
#tmpdir=$(mktemp -d) | |
#cleanup () { rm -rf $tmpdir; } | |
#trap cleanup EXIT | |
tmpdir=../my-uupdate-work | |
rm -rf $tmpdir | |
mkdir $tmpdir | |
mkdir $tmpdir/unpacked | |
for tarball; do | |
subdir= | |
if [ ${tarball#*=} != $tarball ]; then | |
subdir=${tarball%=*} | |
fi | |
mkdir -p $tmpdir/unpacked/$subdir | |
tar -C $tmpdir/unpacked/$subdir -xf ${tarball#*=} --strip-components=1 | |
done | |
index_file=$(realpath .git/my-uupdate-index) | |
rm -f $index_file | |
GIT_INDEX_FILE=$index_file GIT_WORK_TREE=$tmpdir/unpacked git add -A -f | |
tmp_tree=$(GIT_INDEX_FILE=$index_file git write-tree) | |
git ls-tree ${tmp_tree} > $tmpdir/tree | |
deb_sha=$(git ls-tree HEAD^{tree} | awk '{ if ($4 == "debian") { print $3; } }') | |
echo -e "040000 tree $deb_sha\tdebian" >> $tmpdir/tree | |
new_tree=$(cat $tmpdir/tree | git mktree) | |
echo "Update upstream source from '$(for tarball; do echo -n $(basename $tarball); done)'" > $tmpdir/commit-msg | |
commit=$(git commit-tree -p HEAD -F $tmpdir/commit-msg ${new_tree}) | |
git merge $commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
P="$(echo -e 'next command: ')" | |
e () { | |
q="$(printf " %q" "$@")" | |
echo -e '\033[01;32m' | |
read -er -a n -i "${q# }" -p "$P" | |
echo -e '\033[00m' | |
eval "${n[@]}" | |
} | |
if ! git diff --exit-code HEAD; then | |
echo "discard above changes?" | |
e git reset --hard | |
fi | |
source=$(dpkg-parsechangelog -SSource) | |
version=$(dpkg-parsechangelog -SVersion) | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
debdiff=true | |
dput=dput-wrap.pl | |
remote=origin | |
if [ $1 == "--test" ]; then | |
release=no | |
N=${2-1} | |
elif [ $1 == "--release" ]; then | |
release=yes | |
else | |
echo "must pass --test or --release" | |
exit 1 | |
fi | |
case $release in | |
yes) | |
dest=ubuntu | |
;; | |
no) | |
dest=ppa:mwhudson/devirt | |
;; | |
esac | |
series=${series+${series}} | |
if [[ $branch =~ ubuntu/([a-z]*)-.* ]]; then | |
SERIES=${BASH_REMATCH[1]} | |
elif [[ $branch =~ ubuntu/([a-z]*) ]]; then | |
SERIES=${BASH_REMATCH[1]} | |
fi | |
case $source in | |
casper) | |
remote=origin | |
if [ $branch = "main" ]; then | |
series=$(distro-info -d) | |
fi | |
;; | |
glibc) | |
debdiff=false | |
;; | |
cargo|rustc) | |
remote=foundations | |
series=$(echo $branch | cut -d- -f1) | |
if [ $series = "merge" ]; then | |
series=$(distro-info -d) | |
fi | |
dput=dput | |
debdiff=false | |
case $release in | |
yes) | |
if [ $series != $(distro-info -d) ]; then | |
dest=ppa:ubuntu-mozilla-security/rust-updates | |
fi | |
;; | |
no) | |
#v=$(echo $branch | cut -d- -f2) | |
#dest=ppa:mwhudson/rust-$v | |
dest=ppa:mwhudson/rust-stuff | |
;; | |
esac | |
;; | |
livecd-rootfs) | |
case $release in | |
yes) | |
if [ "${SERIES-}" = "master" ]; then | |
SERIES=$(distro-info -d) | |
fi | |
;; | |
no) | |
for s in $(distro-info -a); do | |
if echo $branch | grep -q $s; then | |
series=$s | |
break | |
fi | |
done | |
if [ -z "$series" ]; then | |
series=$(distro-info -d) | |
fi | |
;; | |
esac | |
;; | |
ubiquity) | |
case $release in | |
no) | |
remote=mwhudson | |
series=$(distro-info -d) | |
;; | |
yes) | |
if distro-info --supported | grep -q '^'$branch'$'; then | |
series=$branch | |
fi | |
;; | |
esac | |
;; | |
golang-*) | |
case $branch in | |
golang-*) | |
if [ $release = "yes" ]; then | |
dest=ftp-master | |
fi | |
;; | |
ubuntu-*) | |
remote=mwhudson | |
;; | |
esac | |
debdiff=false | |
series=$(echo $branch | cut -d- -f1) | |
if [ $series = "ubuntu" ]; then | |
series=$(distro-info -d) | |
fi | |
;; | |
docker.io|containerd|runc) | |
debdiff=false | |
series=$branch | |
if [ $series = ubuntu ]; then | |
series=$(distro-info -d) | |
fi | |
;; | |
*) | |
if [ $branch = ubuntu/devel ]; then | |
series=$(distro-info -d) | |
fi | |
esac | |
series=${SERIES-$series} | |
if [ -z "$release" ] || [ -z "$series" ]; then | |
echo "don't know how to compute remote/series for $source" | |
exit 1 | |
fi | |
if [ $release = no ]; then | |
e dch -b -v ${version}~ppa${N} "" | |
version=${version}~ppa${N} | |
fi | |
e dch -D $series -r "" | |
git diff | |
if [ $debdiff = true ]; then | |
oversion=$(dpkg-parsechangelog -o 1 -c1 -SVersion) | |
odsc=${source}_${oversion}.dsc | |
if [ ! -e ../$odsc ]; then | |
(cd ../ && chdist apt-get $series source $source=$oversion) | |
fi | |
e dpkg-buildpackage -S -nc | |
debdiff | colordiff | less -RXF | |
fi | |
if [ $release = yes ]; then | |
e debcommit -a -r --sign-tag | |
tag=$(git tag --contains HEAD) | |
fi | |
if [ $debdiff = false ]; then | |
e dpkg-buildpackage -nc -S --hook-done="$dput $dest ../%p_%s_source.changes" | |
else | |
e $dput $dest ../${source}_${version#*:}_source.changes | |
fi | |
if [ $release = yes ]; then | |
e git push $remote $branch:$branch $tag | |
else | |
e git reset --hard | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment