Skip to content

Commit 5a3ae1a

Browse files
authored
Merge pull request #13422 from ethereum/cleanup-z3-script
Cleanup static z3 script to work similar to release_ppa
2 parents f0d1dda + c5e9b6e commit 5a3ae1a

File tree

3 files changed

+60
-39
lines changed

3 files changed

+60
-39
lines changed

scripts/common.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,28 @@ else
4040
function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; }
4141
fi
4242

43+
function checkDputEntries
44+
{
45+
local pattern="$1"
46+
grep "${pattern}" /etc/dput.cf --quiet || \
47+
fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in release_ppa.sh for more information)."
48+
}
49+
50+
function sourcePPAConfig
51+
{
52+
[[ "$LAUNCHPAD_KEYID" == "" && "$LAUNCHPAD_EMAIL" == "" ]] || fail
53+
54+
# source keyid and email from .release_ppa_auth
55+
if [[ -e .release_ppa_auth ]]
56+
then
57+
# shellcheck source=/dev/null
58+
source "${REPO_ROOT}/.release_ppa_auth"
59+
fi
60+
61+
[[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \
62+
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)."
63+
}
64+
4365
function printStackTrace
4466
{
4567
printWarning ""

scripts/deps-ppa/static_z3.sh

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
## This is used to package .deb packages and upload them to the launchpad
44
## ppa servers for building.
55
##
6-
## The gnupg key for "[email protected]" has to be present in order to sign
7-
## the package.
8-
##
96
## It will clone the Z3 git from github on the specified version tag,
107
## create a source archive and push it to the ubuntu ppa servers.
118
##
@@ -16,18 +13,35 @@
1613
## method = ftp
1714
## incoming = ~ethereum/cpp-build-deps
1815
## login = anonymous
19-
16+
##
17+
## To interact with launchpad, you need to set the variables $LAUNCHPAD_EMAIL
18+
## and $LAUNCHPAD_KEYID in the file .release_ppa_auth in the root directory of
19+
## the project to your launchpad email and pgp keyid.
20+
## This could for example look like this:
21+
##
22+
23+
## LAUNCHPAD_KEYID=123ABCFFFFFFFF
2024
##
2125
##############################################################################
2226

23-
set -ev
27+
set -e
2428

25-
keyid=70D110489D66E2F6
26-
2729
packagename=z3-static
28-
version=4.8.17
30+
version="$1"
31+
32+
REPO_ROOT="$(dirname "$0")/../.."
33+
34+
# shellcheck source=/dev/null
35+
source "${REPO_ROOT}/scripts/common.sh"
36+
37+
[[ $version != "" ]] || fail "Usage: $0 <version-without-leading-v>"
38+
39+
sourcePPAConfig
40+
41+
# Sanity check
42+
checkDputEntries "\[cpp-build-deps\]"
2943

30-
DISTRIBUTIONS="focal impish jammy kinetic"
44+
DISTRIBUTIONS="focal jammy kinetic"
3145

3246
for distribution in $DISTRIBUTIONS
3347
do
@@ -40,7 +54,7 @@ pparepo=cpp-build-deps
4054
ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files
4155

4256
# Fetch source
43-
git clone --branch z3-${version} https://github.com/Z3Prover/z3.git
57+
git clone --branch "z3-${version}" https://github.com/Z3Prover/z3.git
4458
cd z3
4559

4660
debversion="${version}"
@@ -50,11 +64,11 @@ CMAKE_OPTIONS="-DZ3_BUILD_LIBZ3_SHARED=OFF -DCMAKE_BUILD_TYPE=Release"
5064
# gzip will create different tars all the time and we are not allowed
5165
# to upload the same file twice with different contents, so we only
5266
# create it once.
53-
if [ ! -e /tmp/${packagename}_${debversion}.orig.tar.gz ]
67+
if [ ! -e "/tmp/${packagename}_${debversion}.orig.tar.gz" ]
5468
then
55-
tar --exclude .git -czf /tmp/${packagename}_${debversion}.orig.tar.gz .
69+
tar --exclude .git -czf "/tmp/${packagename}_${debversion}.orig.tar.gz" .
5670
fi
57-
cp /tmp/${packagename}_${debversion}.orig.tar.gz ../
71+
cp "/tmp/${packagename}_${debversion}.orig.tar.gz" ../
5872

5973
# Create debian package information
6074

@@ -209,7 +223,7 @@ echo "3.0 (quilt)" > debian/source/format
209223
chmod +x debian/rules
210224

211225
versionsuffix=1ubuntu0~${distribution}
212-
EMAIL="$email" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}"
226+
EMAIL="$LAUNCHPAD_EMAIL" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}"
213227

214228
# build source package
215229
# If packages is rejected because original source is already present, add
@@ -226,26 +240,26 @@ cd ..
226240
orig="${packagename}_${debversion}.orig.tar.gz"
227241
# shellcheck disable=SC2012
228242
orig_size=$(ls -l "$orig" | cut -d ' ' -f 5)
229-
orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
230-
orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
231-
orig_md5=$(md5sum $orig | cut -d ' ' -f 1)
243+
orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
244+
orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)
245+
orig_md5=$(md5sum "$orig" | cut -d ' ' -f 1)
232246

233-
if wget --quiet -O $orig-tmp "$ppafilesurl/$orig"
247+
if wget --quiet -O "$orig-tmp" "$ppafilesurl/$orig"
234248
then
235249
echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
236-
mv $orig-tmp $orig
250+
mv "${orig}-tmp" "$orig"
237251
# shellcheck disable=SC2012
238252
new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5)
239-
new_sha1=$(sha1sum $orig | cut -d ' ' -f 1)
240-
new_sha256=$(sha256sum $orig | cut -d ' ' -f 1)
241-
new_md5=$(md5sum $orig | cut -d ' ' -f 1)
253+
new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1)
254+
new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1)
255+
new_md5=$(md5sum "$orig" | cut -d ' ' -f 1)
242256
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
243257
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
244258
fi
245259
)
246260

247261
# sign the package
248-
debsign --re-sign -k "${keyid}" "../${packagename}_${debversion}-${versionsuffix}_source.changes"
262+
debsign --re-sign -k "${LAUNCHPAD_KEYID}" "../${packagename}_${debversion}-${versionsuffix}_source.changes"
249263

250264
# upload
251265
dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes"

scripts/release_ppa.sh

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ set -e
4747

4848
REPO_ROOT="$(dirname "$0")/.."
4949

50-
# for the "fail" function
5150
# shellcheck source=scripts/common.sh
5251
source "${REPO_ROOT}/scripts/common.sh"
5352

@@ -62,15 +61,7 @@ is_release() {
6261
[[ "${branch}" =~ ^v[0-9]+(\.[0-9]+)*$ ]]
6362
}
6463

65-
# source keyid and email from .release_ppa_auth
66-
if [[ -e .release_ppa_auth ]]
67-
then
68-
# shellcheck source=/dev/null
69-
source "${REPO_ROOT}/.release_ppa_auth"
70-
fi
71-
72-
[[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \
73-
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)."
64+
sourcePPAConfig
7465

7566
packagename=solc
7667

@@ -79,12 +70,6 @@ static_build_distribution=focal
7970

8071
DISTRIBUTIONS="focal jammy kinetic"
8172

82-
function checkDputEntries {
83-
local pattern="$1"
84-
grep "${pattern}" /etc/dput.cf --quiet || \
85-
fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in ${0} for more information)."
86-
}
87-
8873
if is_release
8974
then
9075
DISTRIBUTIONS="$DISTRIBUTIONS STATIC"

0 commit comments

Comments
 (0)