From 10d1df039a32a3b8c96ec1477cb8d360147fb678 Mon Sep 17 00:00:00 2001 From: delta Date: Tue, 31 Aug 2021 22:21:02 +0800 Subject: [PATCH] added templating for distributions --- configs/reprepro-distributions.temp | 8 ++++++++ scripts/create-distros.sh | 32 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 configs/reprepro-distributions.temp create mode 100644 scripts/create-distros.sh diff --git a/configs/reprepro-distributions.temp b/configs/reprepro-distributions.temp new file mode 100644 index 0000000..dc31a5a --- /dev/null +++ b/configs/reprepro-distributions.temp @@ -0,0 +1,8 @@ +Origin: {{EASYREPO_ORIGIN}} +Label: {{EASYREPO_LABEL}} +Suite: {{EASYREPO_SUITE}} +Codename: {{EASYREPO_CODENAME}} +Version: 3.1 +Architectures: {{EASYREPO_ARCHITECTURES}} +Components: main non-free contrib +Description: {{EASYREPO_DESCRIPTION}} diff --git a/scripts/create-distros.sh b/scripts/create-distros.sh new file mode 100644 index 0000000..ce233c4 --- /dev/null +++ b/scripts/create-distros.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +REPREPRO_DIST="${REPREPRO_OVERRIDE:-/var/lib/reprepro/conf/distributions}" + +# path to template file +REPREPRO_DIST_TEMP="/etc/reprepro-distributions.temp" + +# Default results to configs/reprepro-distributions +EASYREPO_SUITES="${EASYREPO_SUITES:-unstable,sid/stable,buster/testing,bullseye}" +EASYREPO_ORIGIN="${EASYREPO_ORIGIN:-Test Origin}" +EASYREPO_LABEL="${EASYREPO_LABEL:-Easy Debian Repository}" +EASYREPO_ARCHITECTURES="${EASYREPO_ARCHITECTURES:-i386 amd64 powerpc source}" +EASYREPO_DESCRIPTION="${EASYREPO_LABEL:-Easy Debian Repository}" + +# Empty the file +echo -n > $REPREPRO_DIST + +# Slash delimited +for i in $(echo ${EASYREPO_SUITES} | sed "s/\// /g") +do + g=($(echo $i | sed "s/\,/ /g")) + sed -e "s/{{EASYREPO_ORIGIN}}/${EASYREPO_ORIGIN}/" \ + -e "s/{{EASYREPO_LABEL}}/${EASYREPO_LABEL}/" \ + -e "s/{{EASYREPO_SUITE}}/${g[0]}/" \ + -e "s/{{EASYREPO_CODENAME}}/${g[1]}/" \ + -e "s/{{EASYREPO_ARCHITECTURES}}/${EASYREPO_ARCHITECTURES}/" \ + -e "s/{{EASYREPO_DESCRIPTION}}/${EASYREPO_DESCRIPTION}/" $REPREPRO_DIST_TEMP >> $REPREPRO_DIST + echo "" >> $REPREPRO_DIST +done + +# Remove last line +sed -i '$ d' $REPREPRO_DIST