Repository navigation
Expand file tree
/
Copy pathmk-ppa-source
More file actions
executable file
·111 lines (104 loc) · 4.9 KB
/
Copy pathmk-ppa-source
File metadata and controls
executable file
·111 lines (104 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
# --------------------------------------------------------------------------- #
# Source package of SMS++ for a PPA #
# #
# Builds the Debian source package of a release of the umbrella, for one #
# or more Ubuntu series, out of the release tarball and of the debian/ #
# directory of this repository, and uploads it to the PPA with --upload. #
# #
# Usage: mk-ppa-source <version> [<series> ...] [--upload] #
# #
# Donato Meoli #
# Dipartimento di Informatica #
# Universita' di Pisa #
# --------------------------------------------------------------------------- #
set -euo pipefail
# SMS++ fetches FastFlow at configure time: the source package carries it as a
# second component, at the commit the other packages of the project pin too
FASTFLOW_COMMIT=d476f66ab924d8d122f54b4b90aee00ef979aea8
# the date of the FastFlow commit, so that the repacked component is
# byte for byte the same wherever it is built
FASTFLOW_EPOCH=${SMSPP_FASTFLOW_EPOCH:-1700000000}
REGISTRY=https://gitlab.com/api/v4/projects/smspp%2Fsmspp-project/packages/generic/smspp-project
PPA=${SMSPP_PPA:-ppa:smspp-project/smspp}
REVISION=${SMSPP_REVISION:-1}
# a second upload of the same revision to the PPA only bumps this, and then
# the orig tarballs stay out of the upload, the archive has them already
PPA_BUILD=${SMSPP_PPA_BUILD:-1}
here=$(cd "$(dirname "$0")" && pwd)
version=""
series=()
upload=no
for arg in "$@"; do
case $arg in
--upload) upload=yes ;;
-*) echo "$(basename "$0"): unknown option $arg" >&2; exit 2 ;;
*) if [ -z "$version" ]; then version=$arg; else series+=("$arg"); fi ;;
esac
done
if [ -z "$version" ]; then
echo "usage: $(basename "$0") <version> [<series> ...] [--upload]" >&2
exit 2
fi
[ ${#series[@]} -gt 0 ] || series=($(lsb_release -cs))
# Launchpad takes the identity of the uploader from the signature of the
# source package: without a key the package is still built, unsigned, and
# only an upload by hand of a signed one will do
# dpkg-buildpackage would look for the key of the Changed-By of the changelog:
# SMSPP_SIGN_KEY names the one to sign with, which is what the CI has
sign=()
[ -n "${SMSPP_SIGN_KEY:-}" ] && sign=(-k"$SMSPP_SIGN_KEY")
if ! gpg --list-secret-keys >/dev/null 2>&1 ||
[ -z "$(gpg --list-secret-keys --with-colons 2>/dev/null | grep '^sec')" ]; then
sign=(-us -uc)
if [ "$upload" = yes ]; then
echo "$(basename "$0"): no secret GPG key, nothing to upload" >&2
exit 1
fi
echo "$(basename "$0"): no secret GPG key, the package will be unsigned" >&2
fi
work=${SMSPP_WORKDIR:-$PWD/ppa-$version}
mkdir -p "$work"
cd "$work"
tarball=smspp-project_${version}.orig.tar.gz
if [ ! -f "$tarball" ]; then
curl -fsSL -o "$tarball" \
"$REGISTRY/$version/smspp-project-$version.tar.gz"
fi
ff=smspp-project_${version}.orig-fastflow.tar.gz
if [ ! -f "$ff" ]; then
curl -fsSL -o fastflow.tar.gz \
"https://github.com/fastflow/fastflow/archive/$FASTFLOW_COMMIT.tar.gz"
rm -rf fastflow && mkdir fastflow-unpack
tar xzf fastflow.tar.gz -C fastflow-unpack
mv fastflow-unpack/fastflow-* fastflow
# the component has to come out the same on every machine, or a second
# series uploaded later is refused: same contents, different bytes
tar --sort=name --format=gnu --owner=0 --group=0 --numeric-owner \
--mtime="@$FASTFLOW_EPOCH" -cf - fastflow | gzip -n > "$ff"
rm -rf fastflow fastflow-unpack fastflow.tar.gz
fi
for s in "${series[@]}"; do
tree=smspp-project-$version
rm -rf "$tree"
mkdir "$tree"
tar xzf "$tarball" -C "$tree"
cp -r "$here/debian" "$tree/debian"
python3 "$here/gen_debian.py" "$tree"
rm -f "$tree/debian/changelog"
# a PPA needs a version of its own for every series, ordered as the series
DEBEMAIL=${DEBEMAIL:-donato.meoli.95@gmail.com} \
DEBFULLNAME=${DEBFULLNAME:-Donato Meoli} \
dch --create --package smspp-project --newversion \
"$version-$REVISION~$s$PPA_BUILD" --distribution "$s" \
--changelog "$tree/debian/changelog" \
"Packages of the $version release of the project." 2>/dev/null ||
{ echo "$(basename "$0"): dch failed, is devscripts installed?" >&2;
exit 1; }
if [ "$PPA_BUILD" -gt 1 ]; then origs=-sd; else origs=-sa; fi
(cd "$tree" && dpkg-buildpackage -S "$origs" -d "${sign[@]}")
if [ "$upload" = yes ]; then
dput "$PPA" "smspp-project_$version-$REVISION~$s${PPA_BUILD}_source.changes"
fi
done
echo "source packages in $work"