Cleanup static z3 script to work similar to release_ppa

This commit is contained in:
Marenz 2022-08-22 16:09:38 +02:00
parent 22a0c46eae
commit 0475ec81f0
3 changed files with 59 additions and 38 deletions

View File

@ -40,6 +40,28 @@ else
function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; } function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; }
fi 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 function printStackTrace
{ {
printWarning "" printWarning ""

View File

@ -3,9 +3,6 @@
## This is used to package .deb packages and upload them to the launchpad ## This is used to package .deb packages and upload them to the launchpad
## ppa servers for building. ## 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, ## 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. ## create a source archive and push it to the ubuntu ppa servers.
## ##
@ -16,16 +13,33 @@
## method = ftp ## method = ftp
## incoming = ~ethereum/cpp-build-deps ## incoming = ~ethereum/cpp-build-deps
## login = anonymous ## 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 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 <version-without-leading-v>"
sourcePPAConfig
# Sanity check
checkDputEntries "\[cpp-build-deps\]"
DISTRIBUTIONS="focal impish jammy kinetic" DISTRIBUTIONS="focal impish jammy kinetic"
@ -40,7 +54,7 @@ pparepo=cpp-build-deps
ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files
# Fetch source # 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 cd z3
debversion="${version}" 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 # 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 # to upload the same file twice with different contents, so we only
# create it once. # create it once.
if [ ! -e /tmp/${packagename}_${debversion}.orig.tar.gz ] if [ ! -e "/tmp/${packagename}_${debversion}.orig.tar.gz" ]
then then
tar --exclude .git -czf /tmp/${packagename}_${debversion}.orig.tar.gz . tar --exclude .git -czf "/tmp/${packagename}_${debversion}.orig.tar.gz" .
fi fi
cp /tmp/${packagename}_${debversion}.orig.tar.gz ../ cp "/tmp/${packagename}_${debversion}.orig.tar.gz" ../
# Create debian package information # Create debian package information
@ -209,7 +223,7 @@ echo "3.0 (quilt)" > debian/source/format
chmod +x debian/rules chmod +x debian/rules
versionsuffix=1ubuntu0~${distribution} 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 # build source package
# If packages is rejected because original source is already present, add # If packages is rejected because original source is already present, add
@ -226,26 +240,26 @@ cd ..
orig="${packagename}_${debversion}.orig.tar.gz" orig="${packagename}_${debversion}.orig.tar.gz"
# shellcheck disable=SC2012 # shellcheck disable=SC2012
orig_size=$(ls -l "$orig" | cut -d ' ' -f 5) orig_size=$(ls -l "$orig" | cut -d ' ' -f 5)
orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1) orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1) orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)
orig_md5=$(md5sum $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 then
echo "[WARN] Original tarball found in Ubuntu archive, using it instead" echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
mv $orig-tmp $orig mv "${orig}-tmp" "$orig"
# shellcheck disable=SC2012 # shellcheck disable=SC2012
new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5) new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5)
new_sha1=$(sha1sum $orig | cut -d ' ' -f 1) new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
new_sha256=$(sha256sum $orig | cut -d ' ' -f 1) new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)
new_md5=$(md5sum $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" ./*.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 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 fi
) )
# sign the package # 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 # upload
dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes"

View File

@ -47,7 +47,6 @@ set -e
REPO_ROOT="$(dirname "$0")/.." REPO_ROOT="$(dirname "$0")/.."
# for the "fail" function
# shellcheck source=scripts/common.sh # shellcheck source=scripts/common.sh
source "${REPO_ROOT}/scripts/common.sh" source "${REPO_ROOT}/scripts/common.sh"
@ -62,15 +61,7 @@ is_release() {
[[ "${branch}" =~ ^v[0-9]+(\.[0-9]+)*$ ]] [[ "${branch}" =~ ^v[0-9]+(\.[0-9]+)*$ ]]
} }
# source keyid and email from .release_ppa_auth sourcePPAConfig
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)."
packagename=solc packagename=solc
@ -79,12 +70,6 @@ static_build_distribution=focal
DISTRIBUTIONS="focal jammy kinetic" 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 if is_release
then then
DISTRIBUTIONS="$DISTRIBUTIONS STATIC" DISTRIBUTIONS="$DISTRIBUTIONS STATIC"