Skip to content

Commit

Permalink
packaging: rename platform to meet standard
Browse files Browse the repository at this point in the history
Theses changes include using underscore instead of dash, to include the
full version name for ubuntu (24 => 24.04) and a refactor of Jenkins to
reduce duplications.

Change-Id: I45eada9d5078e7e973527141c743fe1736e87a1b
  • Loading branch information
loulou123546 committed Oct 11, 2024
1 parent 3a8ec3d commit 683f520
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 90 deletions.
82 changes: 46 additions & 36 deletions extras/packaging/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,47 +84,57 @@ pipeline {
}
}
stage('Build distributions') {
parallel {
stage('Ubuntu 22.04') {
steps {
dir('extras/packaging') {
sh """
target="ubuntu-22"
mkdir -p "\$target"
docker build -t "dhtnet-builder:\$target" -f "gnu-linux/\$target.Dockerfile" --build-arg PKG_NAME="$FOLDER_NAME" .
docker run --rm \
-v "\$(pwd)/\$target/":/build/artifacts \
-e PKG_NAME="$FOLDER_NAME" "dhtnet-builder:\$target"
"""
}
matrix {
axes {
axis {
name 'TARGET'
values 'ubuntu_22.04', 'ubuntu_24.04', 'debian_12'/*, 'fedora_39', 'fedora_40', 'almalinux_9'*/
}
}
stage('Ubuntu 24.04') {
steps {
dir('extras/packaging') {
sh """
target="ubuntu-24"
mkdir -p "\$target"
docker build -t "dhtnet-builder:\$target" -f "gnu-linux/\$target.Dockerfile" --build-arg PKG_NAME="$FOLDER_NAME" .
docker run --rm \
-v "\$(pwd)/\$target/":/build/artifacts \
-e PKG_NAME="$FOLDER_NAME" "dhtnet-builder:\$target"
"""
stages {
stage('Build') {
steps {
dir('extras/packaging') {
sh """
target="${TARGET}"
mkdir -p "\$target"
docker build -t "dhtnet-builder:\$target" -f "gnu-linux/\$target.Dockerfile" --build-arg PKG_NAME="$FOLDER_NAME" .
docker run --rm \
-v "\$(pwd)/\$target/":/build/artifacts \
-e PKG_NAME="$FOLDER_NAME" "dhtnet-builder:\$target"
"""
}
}
}
}
stage('Debian 12') {
steps {
dir('extras/packaging') {
sh """
target="debian-12"
mkdir -p "\$target"
docker build -t "dhtnet-builder:\$target" -f "gnu-linux/\$target.Dockerfile" --build-arg PKG_NAME="$FOLDER_NAME" .
docker run --rm \
-v "\$(pwd)/\$target/":/build/artifacts \
-e PKG_NAME="$FOLDER_NAME" "dhtnet-builder:\$target"
"""
}
}
}
stage('Publish to dhtnet.sfl.io') {
steps {
dir('extras/packaging') {
sshagent(credentials: [JENKINS_SSH_KEY, DL_SSH_KEY]) {
sh """
mkdir -p publish
cp -R --parents ubuntu_*/dhtnet_*.deb publish/
cp -R --parents debian_*/dhtnet_*.deb publish/
# cp -R --parents fedora_*/dhtnet-*.rpm publish/
# cp -R --parents almalinux_*/dhtnet-*.rpm publish/
rm -Rf publish/**/*debug*
rm -Rf publish/**/*.src.*
if [ -f "\${SSH_IDENTITY_FILE}" ]; then
export RSYNC_RSH="ssh -i \${SSH_IDENTITY_FILE}"
fi
echo "##########################"
echo "## deploying repository ##"
echo "##########################"
echo "Using RSYNC_RSH='\${RSYNC_RSH}'"
rsync --archive --recursive --verbose \
--delete publish/ \
"${REMOTE_HOST}:/srv/repository/dhtnet/$PUBLISH_CHANNEL"
"""
}
}
}
Expand Down
109 changes: 55 additions & 54 deletions extras/packaging/build_packages.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash
set -e

# move pwd to the directory of this script (extras/packaging)
cd "$(dirname "$0")" || exit 1

PKG_NAME=dhtnet
PKG_VERSION="$(head -1 extras/packaging/build.version | grep -o '^[0-9\.]\+$' -)"
PKG_VERSION="$(head -1 build.version | grep -o '^[0-9\.]\+$' -)"

FOLDER_NAME="${PKG_NAME}-${PKG_VERSION}"

# move pwd to the directory of this script (extras/packaging)
cd "$(dirname "$0")" || exit 1

rm -Rf "${FOLDER_NAME}"
rm -f -- *${PKG_NAME}-${PKG_VERSION}.tar.gz
Expand All @@ -20,9 +21,9 @@ rm -Rf "../../dependencies/restinio"
(cd ../.. && git submodule update --init --recursive)

build_ubuntu=false
build_ubuntu20=false
build_ubuntu22=false
build_ubuntu24=false
build_ubuntu20_04=false
build_ubuntu22_04=false
build_ubuntu24_04=false
build_debian=false
build_debian10=false
build_debian11=false
Expand All @@ -31,45 +32,45 @@ build_debian12=false
parse_args() {
while [ "$1" != "" ]; do
case $1 in
-u | --ubuntu ) build_ubuntu=true
build_ubuntu20=true
build_ubuntu22=true
build_ubuntu24=true
;;
-u20 | --ubuntu20 ) build_ubuntu20=true
build_ubuntu=true
;;
-u22 | --ubuntu22 ) build_ubuntu22=true
build_ubuntu=true
;;
-u24 | --ubuntu24 ) build_ubuntu24=true
build_ubuntu=true
;;
-d | --debian ) build_debian=true
build_debian10=true
build_debian11=true
build_debian12=true
;;
-d10 | --debian10 ) build_debian10=true
build_debian=true
;;
-d11 | --debian11 ) build_debian11=true
build_debian=true
;;
-d12 | --debian12 ) build_debian12=true
build_debian=true
;;
-a | --all ) build_ubuntu=true
# not working: build_ubuntu20=true
build_ubuntu22=true
build_ubuntu24=true
build_debian=true
# not working: build_debian10=true
# not working: build_debian11=true
build_debian12=true
;;
* ) echo "Argument '$1' is not recognized"
;;
-u | --ubuntu ) build_ubuntu=true
build_ubuntu20_04=true
build_ubuntu22_04=true
build_ubuntu24_04=true
;;
-u20 | -u20.04 | --ubuntu20.04 ) build_ubuntu20_04=true
build_ubuntu=true
;;
-u22 | -u22.04 | --ubuntu22.04 ) build_ubuntu22_04=true
build_ubuntu=true
;;
-u24 | -u24.04 | --ubuntu24.04 ) build_ubuntu24_04=true
build_ubuntu=true
;;
-d | --debian ) build_debian=true
build_debian10=true
build_debian11=true
build_debian12=true
;;
-d10 | --debian10 ) build_debian10=true
build_debian=true
;;
-d11 | --debian11 ) build_debian11=true
build_debian=true
;;
-d12 | --debian12 ) build_debian12=true
build_debian=true
;;
-a | --all ) build_ubuntu=true
# not working: build_ubuntu20=true
build_ubuntu22_04=true
build_ubuntu24_04=true
build_debian=true
# not working: build_debian10=true
# not working: build_debian11=true
build_debian12=true
;;
* ) echo "Argument '$1' is not recognized"
;;
esac
shift
done
Expand Down Expand Up @@ -127,29 +128,29 @@ build_target() {
}

# build Ubuntu package (deb-*)
if [ "$build_ubuntu24" == true ]; then
build_target "ubuntu-24"
if [ "$build_ubuntu24_04" == true ]; then
build_target "ubuntu_24.04"
fi

if [ "$build_ubuntu22" == true ]; then
build_target "ubuntu-22"
if [ "$build_ubuntu22_04" == true ]; then
build_target "ubuntu_22.04"
fi

if [ "$build_ubuntu20" == true ]; then
build_target "ubuntu-20"
if [ "$build_ubuntu20_04" == true ]; then
build_target "ubuntu_20.04"
fi

# build Debian package (deb-*)
if [ "$build_debian12" == true ]; then
build_target "debian-12"
build_target "debian_12"
fi

if [ "$build_debian11" == true ]; then
build_target "debian-11"
build_target "debian_11"
fi

if [ "$build_debian10" == true ]; then
build_target "debian-10"
build_target "debian_10"
fi


Expand Down

0 comments on commit 683f520

Please sign in to comment.