Skip to content

Commit bd31bb0

Browse files
committed
debian: add scripts to publish .deb packages to repo server
Signed-off-by: Mike Sul <mike.sul@foundries.io>
1 parent 811afb9 commit bd31bb0

2 files changed

Lines changed: 104 additions & 0 deletions

File tree

debian/release-prep-archive.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh -e
2+
## Used to download and prepare a composectl release for publishing. It:
3+
## * rsyncs current package archive contents locally
4+
## * copyies latest .debs from github into local archive
5+
## Things will be formatted for the release-publish-archive.sh script to process
6+
7+
if [ $# -ne 2 ] ; then
8+
echo "Usage: $0 <package-repo-dir> <version>"
9+
echo " example: $0 bin/package-repo-dir 1.1.0"
10+
exit 0
11+
fi
12+
13+
releasedir=$1
14+
version=$2
15+
version=${version#v} # make sure its 0.1.0 not v0.1.0
16+
17+
gsutil -m rsync -r gs://fioup.foundries.io/ ${releasedir}/
18+
19+
url="https://github.com/foundriesio/composeapp/releases/download/v${version}/composectl_${version}_amd64.deb"
20+
wget -O ${releasedir}/pkg/deb/pool/composectl_${version}_amd64.deb $url
21+
22+
url="https://github.com/foundriesio/composeapp/releases/download/v${version}/composectl_${version}_arm64.deb"
23+
wget -O ${releasedir}/pkg/deb/pool/composectl_${version}_arm64.deb $url

debian/release-publish-archive.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/sh -e
2+
## Used to create a debian package archive layout to publish new debs. It
3+
## assumes the "release-prep-archive.sh" script has been run before hand to
4+
## prepare the content
5+
## Required keys in <keys dir> are:
6+
## 1. <keys dir>/bot.foundries.pub.gpg
7+
## 2. <keys dir>/bot.foundries.signing.secret.gpg
8+
## 3. "gpgpass" environment variable with the signing key password should be set
9+
10+
if [ $# -ne 2 ] ; then
11+
echo "Usage $0 <keys dir> <package-repo-dir>"
12+
exit 0
13+
fi
14+
15+
if [ -z "$gpgpass" ] ; then
16+
echo "gpgpass environment variable not defined"
17+
exit 0
18+
fi
19+
20+
keysdir=$1
21+
pubdir=$2
22+
23+
do_hash() {
24+
HASH_NAME=$1
25+
HASH_CMD=$2
26+
echo "${HASH_NAME}:"
27+
for f in $(find -type f); do
28+
f=$(echo $f | cut -c3-) # remove ./ prefix
29+
if [ "$f" = "Release" ]; then
30+
continue
31+
fi
32+
echo " $(${HASH_CMD} ${f} | cut -d" " -f1) $(wc -c $f)"
33+
done
34+
}
35+
36+
docker run --rm -i \
37+
-v ${keysdir}:/keys:ro \
38+
-v ${pubdir}/pkg/deb:/layout \
39+
debian:trixie <<EOF
40+
set -ex
41+
42+
apt update && apt install -y dpkg-dev
43+
44+
mkdir -p /layout/dists/stable/main/binary-amd64
45+
mkdir -p /layout/dists/stable/main/binary-arm64
46+
47+
cd /layout
48+
dpkg-scanpackages --multiversion --arch amd64 pool/ > dists/stable/main/binary-amd64/Packages
49+
dpkg-scanpackages --multiversion --arch arm64 pool/ > dists/stable/main/binary-arm64/Packages
50+
51+
chown -R $(id -u):$(id -g) /layout
52+
EOF
53+
54+
cd ${pubdir}/pkg/deb/dists/stable
55+
cat >Release <<EOF
56+
Origin: Fioup Debian Repository
57+
Suite: stable
58+
Architectures: amd64 arm64
59+
Components: main
60+
Date: $(date -Ru)
61+
EOF
62+
do_hash "MD5Sum" "md5sum" >> Release
63+
do_hash "SHA1" "sha1sum" >> Release
64+
do_hash "SHA256" "sha256sum" >> Release
65+
66+
docker run --rm -i \
67+
-v ${keysdir}:/keys:ro \
68+
-v ${pubdir}/pkg/deb:/layout \
69+
debian:trixie <<EOF
70+
set -ex
71+
72+
apt update && apt install -y gnupg2
73+
gpg2 --import /keys/bot.foundries.pub.gpg
74+
echo ${gpgpass} | gpg2 --batch --passphrase-fd 0 --import /keys/bot.foundries.signing.secret.gpg
75+
76+
cd /layout/dists/stable
77+
gpg --armor --export > Release.gpg
78+
echo ${gpgpass} | gpg --batch --pinentry-mode loopback --passphrase-fd 0 --clearsign -o - Release > InRelease
79+
EOF
80+
81+
echo Everything is staged. Now run: gsutil -m rsync -r ${pubdir}/ gs://fioup.foundries.io/

0 commit comments

Comments
 (0)