From 0475ec81f03e4cd06cb372a5abcfd1bcb8c27c59 Mon Sep 17 00:00:00 2001 From: Marenz Date: Mon, 22 Aug 2022 16:09:38 +0200 Subject: [PATCH] Cleanup static z3 script to work similar to release_ppa --- scripts/common.sh | 22 +++++++++++++ scripts/deps-ppa/static_z3.sh | 58 ++++++++++++++++++++++------------- scripts/release_ppa.sh | 17 +--------- 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/scripts/common.sh b/scripts/common.sh index 1ea0e1fc1..98f63ecb8 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -40,6 +40,28 @@ else function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; } fi +function checkDputEntries +{ + local pattern="$1" + grep "${pattern}" /etc/dput.cf --quiet || \ + fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in release_ppa.sh for more information)." +} + +function sourcePPAConfig +{ + [[ "$LAUNCHPAD_KEYID" == "" && "$LAUNCHPAD_EMAIL" == "" ]] || fail + + # source keyid and email from .release_ppa_auth + if [[ -e .release_ppa_auth ]] + then + # shellcheck source=/dev/null + source "${REPO_ROOT}/.release_ppa_auth" + fi + + [[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \ + fail "Error: Couldn't find variables \$LAUNCHPAD_KEYID or \$LAUNCHPAD_EMAIL in sourced file .release_ppa_auth (check top comment in $0 for more information)." +} + function printStackTrace { printWarning "" diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index a2a632cc2..e2a5cb640 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -3,9 +3,6 @@ ## This is used to package .deb packages and upload them to the launchpad ## ppa servers for building. ## -## The gnupg key for "builds@ethereum.org" has to be present in order to sign -## the package. -## ## It will clone the Z3 git from github on the specified version tag, ## create a source archive and push it to the ubuntu ppa servers. ## @@ -16,16 +13,33 @@ ## method = ftp ## incoming = ~ethereum/cpp-build-deps ## login = anonymous - +## +## To interact with launchpad, you need to set the variables $LAUNCHPAD_EMAIL +## and $LAUNCHPAD_KEYID in the file .release_ppa_auth in the root directory of +## the project to your launchpad email and pgp keyid. +## This could for example look like this: +## +## LAUNCHPAD_EMAIL=your-launchpad-email@ethereum.org +## LAUNCHPAD_KEYID=123ABCFFFFFFFF ## ############################################################################## -set -ev +set -e -keyid=70D110489D66E2F6 -email=builds@ethereum.org packagename=z3-static -version=4.8.17 +version="$1" + +REPO_ROOT="$(dirname "$0")/../.." + +# shellcheck source=/dev/null +source "${REPO_ROOT}/scripts/common.sh" + +[[ $version != "" ]] || fail "Usage: $0 " + +sourcePPAConfig + +# Sanity check +checkDputEntries "\[cpp-build-deps\]" DISTRIBUTIONS="focal impish jammy kinetic" @@ -40,7 +54,7 @@ pparepo=cpp-build-deps ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files # Fetch source -git clone --branch z3-${version} https://github.com/Z3Prover/z3.git +git clone --branch "z3-${version}" https://github.com/Z3Prover/z3.git cd z3 debversion="${version}" @@ -50,11 +64,11 @@ CMAKE_OPTIONS="-DZ3_BUILD_LIBZ3_SHARED=OFF -DCMAKE_BUILD_TYPE=Release" # gzip will create different tars all the time and we are not allowed # to upload the same file twice with different contents, so we only # create it once. -if [ ! -e /tmp/${packagename}_${debversion}.orig.tar.gz ] +if [ ! -e "/tmp/${packagename}_${debversion}.orig.tar.gz" ] then - tar --exclude .git -czf /tmp/${packagename}_${debversion}.orig.tar.gz . + tar --exclude .git -czf "/tmp/${packagename}_${debversion}.orig.tar.gz" . fi -cp /tmp/${packagename}_${debversion}.orig.tar.gz ../ +cp "/tmp/${packagename}_${debversion}.orig.tar.gz" ../ # Create debian package information @@ -209,7 +223,7 @@ echo "3.0 (quilt)" > debian/source/format chmod +x debian/rules versionsuffix=1ubuntu0~${distribution} -EMAIL="$email" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}" +EMAIL="$LAUNCHPAD_EMAIL" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}" # build source package # If packages is rejected because original source is already present, add @@ -226,26 +240,26 @@ cd .. orig="${packagename}_${debversion}.orig.tar.gz" # shellcheck disable=SC2012 orig_size=$(ls -l "$orig" | cut -d ' ' -f 5) -orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1) -orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1) -orig_md5=$(md5sum $orig | cut -d ' ' -f 1) +orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) +orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) +orig_md5=$(md5sum "$orig" | cut -d ' ' -f 1) -if wget --quiet -O $orig-tmp "$ppafilesurl/$orig" +if wget --quiet -O "$orig-tmp" "$ppafilesurl/$orig" then echo "[WARN] Original tarball found in Ubuntu archive, using it instead" - mv $orig-tmp $orig + mv "${orig}-tmp" "$orig" # shellcheck disable=SC2012 new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5) - new_sha1=$(sha1sum $orig | cut -d ' ' -f 1) - new_sha256=$(sha256sum $orig | cut -d ' ' -f 1) - new_md5=$(md5sum $orig | cut -d ' ' -f 1) + new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) + new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) + new_md5=$(md5sum "$orig" | cut -d ' ' -f 1) sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" ./*.dsc sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" ./*.changes fi ) # sign the package -debsign --re-sign -k "${keyid}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" +debsign --re-sign -k "${LAUNCHPAD_KEYID}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" # upload dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index 6e3eae01c..ac0a68988 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -47,7 +47,6 @@ set -e REPO_ROOT="$(dirname "$0")/.." -# for the "fail" function # shellcheck source=scripts/common.sh source "${REPO_ROOT}/scripts/common.sh" @@ -62,15 +61,7 @@ is_release() { [[ "${branch}" =~ ^v[0-9]+(\.[0-9]+)*$ ]] } -# source keyid and email from .release_ppa_auth -if [[ -e .release_ppa_auth ]] -then - # shellcheck source=/dev/null - source "${REPO_ROOT}/.release_ppa_auth" -fi - -[[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \ - fail "Error: Couldn't find variables \$LAUNCHPAD_KEYID or \$LAUNCHPAD_EMAIL in sourced file .release_ppa_auth (check top comment in $0 for more information)." +sourcePPAConfig packagename=solc @@ -79,12 +70,6 @@ static_build_distribution=focal DISTRIBUTIONS="focal jammy kinetic" -function checkDputEntries { - local pattern="$1" - grep "${pattern}" /etc/dput.cf --quiet || \ - fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in ${0} for more information)." -} - if is_release then DISTRIBUTIONS="$DISTRIBUTIONS STATIC"