2016-08-05 15:56:42 +00:00
#!/usr/bin/env bash
##############################################################################
## This is used to package .deb packages and upload them to the launchpad
## ppa servers for building.
##
2019-07-15 10:45:36 +00:00
## You can pass a branch name as argument to this script (which, if no argument is given,
## will default to "develop").
2016-08-08 17:01:10 +00:00
##
2020-05-24 17:41:15 +00:00
## If the given branch is "release", the resulting package will be uploaded to
2019-07-15 10:45:36 +00:00
## ethereum/ethereum PPA, or ethereum/ethereum-dev PPA otherwise.
2016-08-08 17:01:10 +00:00
##
2016-08-05 15:56:42 +00:00
## It will clone the Solidity git from github, determine the version,
## create a source archive and push it to the ubuntu ppa servers.
2017-07-03 18:39:12 +00:00
##
2022-08-09 15:12:40 +00:00
## 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
##
## Additionally the following entries in /etc/dput.cf are required:
2017-07-03 18:39:12 +00:00
##
## [ethereum-dev]
## fqdn = ppa.launchpad.net
## method = ftp
## incoming = ~ethereum/ethereum-dev
## login = anonymous
2018-09-03 13:01:15 +00:00
##
2017-07-03 18:39:12 +00:00
## [ethereum]
## fqdn = ppa.launchpad.net
## method = ftp
## incoming = ~ethereum/ethereum
## login = anonymous
2018-12-12 08:40:23 +00:00
##
## [ethereum-static]
## fqdn = ppa.launchpad.net
## method = ftp
## incoming = ~ethereum/ethereum-static
## login = anonymous
2016-08-05 15:56:42 +00:00
##
##############################################################################
2022-08-09 15:12:40 +00:00
set -e
REPO_ROOT = " $( dirname " $0 " ) /.. "
# for the "fail" function
# shellcheck source=scripts/common.sh
source " ${ REPO_ROOT } /scripts/common.sh "
2016-08-05 15:56:42 +00:00
2016-08-08 17:01:10 +00:00
if [ -z " $1 " ]
then
branch = develop
else
branch = $1
fi
2019-07-15 10:45:36 +00:00
is_release( ) {
2022-06-15 15:48:06 +00:00
[ [ " ${ branch } " = ~ ^v[ 0-9] +( \. [ 0-9] +) *$ ] ]
2019-07-15 10:45:36 +00:00
}
2022-08-09 15:12:40 +00:00
# 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). "
2016-08-05 15:56:42 +00:00
packagename = solc
2022-08-09 15:12:40 +00:00
# This needs to be a still active release
2022-08-10 18:02:12 +00:00
static_build_distribution = focal
2018-12-12 08:40:23 +00:00
2022-08-10 18:02:12 +00:00
DISTRIBUTIONS = "focal jammy kinetic"
2019-01-22 17:22:54 +00:00
2022-08-09 15:12:40 +00:00
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). "
}
2019-07-15 10:45:36 +00:00
if is_release
2019-01-22 17:22:54 +00:00
then
DISTRIBUTIONS = " $DISTRIBUTIONS STATIC "
2022-08-09 15:12:40 +00:00
# Sanity checks
checkDputEntries "\[ethereum\]"
checkDputEntries "\[ethereum-static\]"
else
# Sanity check
checkDputEntries "\[ethereum-dev\]"
2019-01-22 17:22:54 +00:00
fi
for distribution in $DISTRIBUTIONS
2016-08-05 15:56:42 +00:00
do
cd /tmp/
2020-12-11 17:19:53 +00:00
rm -rf " $distribution "
mkdir " $distribution "
cd " $distribution "
2016-08-05 15:56:42 +00:00
2020-12-11 17:19:53 +00:00
if [ " $distribution " = STATIC ]
2017-08-24 10:04:12 +00:00
then
2018-12-12 08:40:23 +00:00
pparepo = ethereum-static
2019-02-06 14:46:59 +00:00
SMTDEPENDENCY = ""
2020-12-17 15:09:23 +00:00
CMAKE_OPTIONS = "-DSOLC_LINK_STATIC=On -DCMAKE_EXE_LINKER_FLAGS=-static"
2017-08-24 10:04:12 +00:00
else
2019-07-15 10:45:36 +00:00
if is_release
2018-12-12 08:40:23 +00:00
then
pparepo = ethereum
2019-07-15 10:45:36 +00:00
else
pparepo = ethereum-dev
2018-12-12 08:40:23 +00:00
fi
2020-12-11 17:19:53 +00:00
if [ " $distribution " = focal ]
2020-02-12 17:42:45 +00:00
then
2020-05-13 16:09:48 +00:00
SMTDEPENDENCY = " libz3-static-dev,
2020-04-17 12:32:38 +00:00
libcvc4-dev,
"
2020-12-11 17:19:53 +00:00
elif [ " $distribution " = disco ]
2019-06-03 16:27:29 +00:00
then
SMTDEPENDENCY = " libz3-static-dev,
2020-04-17 12:32:38 +00:00
libcvc4-dev,
"
2019-06-03 16:27:29 +00:00
else
SMTDEPENDENCY = " libz3-static-dev,
2020-04-17 12:32:38 +00:00
"
2019-06-03 16:27:29 +00:00
fi
2018-12-12 08:40:23 +00:00
CMAKE_OPTIONS = ""
2017-08-24 10:04:12 +00:00
fi
2018-12-12 08:40:23 +00:00
ppafilesurl = https://launchpad.net/~ethereum/+archive/ubuntu/${ pparepo } /+files
2017-08-24 10:04:12 +00:00
2016-08-05 15:56:42 +00:00
# Fetch source
2017-08-24 10:04:12 +00:00
git clone --depth 2 --recursive https://github.com/ethereum/solidity.git -b " $branch "
2016-08-05 15:56:42 +00:00
mv solidity solc
2021-04-20 12:12:07 +00:00
# Fetch dependencies
2016-11-08 15:41:25 +00:00
mkdir -p ./solc/deps/downloads/ 2>/dev/null || true
2020-07-10 17:42:24 +00:00
wget -O ./solc/deps/downloads/jsoncpp-1.9.3.tar.gz https://github.com/open-source-parsers/jsoncpp/archive/1.9.3.tar.gz
2022-07-05 19:30:02 +00:00
wget -O ./solc/deps/downloads/range-v3-0.12.0.tar.gz https://github.com/ericniebler/range-v3/archive/0.12.0.tar.gz
2021-10-11 12:52:07 +00:00
wget -O ./solc/deps/downloads/fmt-8.0.1.tar.gz https://github.com/fmtlib/fmt/archive/8.0.1.tar.gz
2016-11-08 15:41:25 +00:00
2016-08-05 15:56:42 +00:00
# Determine version
cd solc
2020-12-11 17:19:53 +00:00
version = $( " $( dirname " $0 " ) /get_version.sh " )
2017-06-30 10:30:57 +00:00
commithash = $( git rev-parse --short= 8 HEAD)
commitdate = $( git show --format= %ci HEAD | head -n 1 | cut - -b1-10 | sed -e 's/-0?/./' | sed -e 's/-0?/./' )
2016-08-05 15:56:42 +00:00
2016-08-23 14:45:08 +00:00
echo " $commithash " > commit_hash.txt
2019-07-15 10:45:36 +00:00
if is_release
2016-08-08 17:01:10 +00:00
then
debversion = " $version "
2016-08-23 14:45:08 +00:00
echo -n > prerelease.txt # proper release
2019-07-15 10:45:36 +00:00
else
debversion = " $version ~develop- $commitdate - $commithash "
2016-08-08 17:01:10 +00:00
fi
# 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.
2020-12-11 17:19:53 +00:00
if [ ! -e " /tmp/ ${ packagename } _ ${ debversion } .orig.tar.gz " ]
2016-08-08 17:01:10 +00:00
then
2020-12-11 17:19:53 +00:00
tar --exclude .git -czf " /tmp/ ${ packagename } _ ${ debversion } .orig.tar.gz " .
2016-08-08 17:01:10 +00:00
fi
2020-12-11 17:19:53 +00:00
cp " /tmp/ ${ packagename } _ ${ debversion } .orig.tar.gz " ../
2016-08-05 15:56:42 +00:00
# Create debian package information
mkdir debian
echo 9 > debian/compat
cat <<EOF > debian/control
Source: solc
Section: science
Priority: extra
Maintainer: Christian ( Buildserver key) <builds@ethereum.org>
2019-02-06 14:46:59 +00:00
Build-Depends: ${ SMTDEPENDENCY } debhelper ( >= 9.0.0) ,
2016-08-05 15:56:42 +00:00
cmake,
2019-12-11 14:29:19 +00:00
g++ ( >= 5.0) ,
2016-08-05 15:56:42 +00:00
git,
libgmp-dev,
libboost-all-dev,
automake,
libtool,
2016-10-20 09:58:25 +00:00
scons
2016-08-05 15:56:42 +00:00
Standards-Version: 3.9.5
Homepage: https://ethereum.org
Vcs-Git: git://github.com/ethereum/solidity.git
Vcs-Browser: https://github.com/ethereum/solidity
Package: solc
2020-09-02 16:26:05 +00:00
Architecture: any-amd64
2016-08-05 15:56:42 +00:00
Multi-Arch: same
2016-10-20 09:58:25 +00:00
Depends: \$ { shlibs:Depends} , \$ { misc:Depends}
2016-08-10 19:03:33 +00:00
Conflicts: libethereum ( <= 1.2.9)
2016-08-05 15:56:42 +00:00
Description: Solidity compiler.
The commandline interface to the Solidity smart contract compiler.
EOF
cat <<EOF > debian/rules
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets by Bill Allombert 2001
# Uncomment this to turn on verbose mode.
export DH_VERBOSE = 1
# This has to be exported to make some magic below work.
export DH_OPTIONS
%:
2016-08-07 21:57:34 +00:00
dh \$ @ --buildsystem= cmake #--with sphinxdoc
2016-08-05 15:56:42 +00:00
override_dh_auto_test:
2016-08-07 21:57:34 +00:00
#override_dh_installdocs:
# make -C docs html
# dh_installdocs docs/_build/html
2016-08-05 15:56:42 +00:00
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params= --ignore-missing-info
2018-01-16 15:16:14 +00:00
override_dh_auto_configure:
2020-01-15 12:27:07 +00:00
dh_auto_configure -- -DTESTS= OFF ${ CMAKE_OPTIONS }
2016-08-05 15:56:42 +00:00
EOF
cat <<EOF > debian/copyright
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: solc
Source: https://github.com/ethereum/solidity
Files: *
Copyright: 2014-2016 Ethereum
License: GPL-3.0+
Files: debian/*
Copyright: 2016 Ethereum
License: GPL-3.0+
License: GPL-3.0+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
( at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3" .
EOF
cat <<EOF > debian/changelog
solc ( 0.0.1-0ubuntu1) saucy; urgency = low
* Initial release.
-- Christian <build@ethereum.org> Mon, 03 Feb 2016 14:50:20 +0000
EOF
echo docs > debian/docs
mkdir debian/source
echo "3.0 (quilt)" > debian/source/format
chmod +x debian/rules
2016-08-10 19:03:33 +00:00
versionsuffix = 0ubuntu1~${ distribution }
2016-08-05 15:56:42 +00:00
# bump version / add entry to changelog
2022-08-09 15:12:40 +00:00
EMAIL = " $LAUNCHPAD_EMAIL " dch -v " 1: ${ debversion } - ${ versionsuffix } " " git build of ${ commithash } "
2016-08-05 15:56:42 +00:00
# build source package
# If packages is rejected because original source is already present, add
# -sd to remove it from the .changes file
2017-07-03 18:39:12 +00:00
# -d disables the build dependencies check
debuild -S -d -sa -us -uc
2016-08-05 15:56:42 +00:00
# prepare .changes file for Launchpad
2020-12-11 17:19:53 +00:00
if [ " $distribution " = STATIC ]
2018-12-12 08:40:23 +00:00
then
2020-12-11 17:19:53 +00:00
sed -i -e " s/UNRELEASED/ ${ static_build_distribution } / " -e s/urgency= medium/urgency= low/ ../*.changes
2018-12-12 08:40:23 +00:00
else
2020-12-11 17:19:53 +00:00
sed -i -e " s/UNRELEASED/ ${ distribution } / " -e s/urgency= medium/urgency= low/ ../*.changes
2018-12-12 08:40:23 +00:00
fi
2016-08-05 15:56:42 +00:00
# check if ubuntu already has the source tarball
(
cd ..
2020-12-11 17:19:53 +00:00
orig = " ${ packagename } _ ${ debversion } .orig.tar.gz "
2020-12-12 02:44:54 +00:00
# shellcheck disable=SC2012
2020-12-11 17:19:53 +00:00
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)
2016-08-05 15:56:42 +00:00
2020-12-11 17:19:53 +00:00
if wget --quiet -O " $orig -tmp " " $ppafilesurl / $orig "
2016-08-05 15:56:42 +00:00
then
echo "[WARN] Original tarball found in Ubuntu archive, using it instead"
2020-12-11 17:19:53 +00:00
mv " $orig -tmp " " $orig "
2020-12-12 02:44:54 +00:00
# shellcheck disable=SC2012
2020-12-12 01:59:25 +00:00
new_size = $( ls -l ./*.orig.tar.gz | cut -d ' ' -f 5)
2020-12-11 17:19:53 +00:00
new_sha1 = $( sha1sum " $orig " | cut -d ' ' -f 1)
new_sha256 = $( sha256sum " $orig " | cut -d ' ' -f 1)
new_md5 = $( md5sum " $orig " | cut -d ' ' -f 1)
2020-12-12 01:59:25 +00:00
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
2016-08-05 15:56:42 +00:00
fi
)
# sign the package
2022-08-09 15:12:40 +00:00
debsign --re-sign -k " ${ LAUNCHPAD_KEYID } " " ../ ${ packagename } _ ${ debversion } - ${ versionsuffix } _source.changes "
2016-08-05 15:56:42 +00:00
# upload
2020-12-11 17:19:53 +00:00
dput " ${ pparepo } " " ../ ${ packagename } _ ${ debversion } - ${ versionsuffix } _source.changes "
2016-08-05 15:56:42 +00:00
done