From b825738de2f33ffd893f4d1fd2c777d1a7436d32 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Thu, 31 Dec 2020 05:19:23 +0100 Subject: added debian packaging --- build-aux/build-debian.sh | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 build-aux/build-debian.sh (limited to 'build-aux/build-debian.sh') diff --git a/build-aux/build-debian.sh b/build-aux/build-debian.sh new file mode 100755 index 0000000..1f9aa40 --- /dev/null +++ b/build-aux/build-debian.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +set -eo pipefail + +export DEBEMAIL="noreply@rafaelmartins.eng.br" +export DEBFULLNAME="Snapshot github-actions" + +download_pbuilder_chroots() { + local arch="amd64" + local os="$(uname -s | tr '[:upper:]' '[:lower:]')" + + local index="$(curl --silent https://distfiles.rgm.io/pbuilder-chroots/LATEST/)" + local archive="$(echo "${index}" | sed -n "s/.*\(pbuilder-chroots-${os}-${arch}-.*\)\.sha512.*/\1/p")" + local folder="$(echo "${index}" | sed -n "s/.*\(pbuilder-chroots-${os}-${arch}-.*\)\.tar.*\.sha512.*/\1/p")" + local p="$(echo "${folder}" | sed "s/pbuilder-chroots-${os}-${arch}-\(.*\)/pbuilder-chroots-\1/")" + + curl --fail --output "${archive}" "https://distfiles.rgm.io/pbuilder-chroots/${p}/${archive}" + curl --fail --output "${archive}.sha512" "https://distfiles.rgm.io/pbuilder-chroots/${p}/${archive}.sha512" + + sha512sum --check --status "${archive}.sha512" + + sudo rm -rf /tmp/pbuilder + fakeroot tar -xf "${archive}" -C /tmp +} + +create_reprepro_conf() { + for dist in "$@"; do + echo "Origin: blogc-snapshot" + echo "Label: blogc-snapshot" + echo "Codename: ${dist}" + echo "Architectures: amd64" + echo "Components: ${dist}" + echo "Description: Apt repository containing blogc snapshots" + echo + done +} + +download_pbuilder_chroots + +${MAKE_CMD:-make} dist-xz + +MY_PV="$(echo ${PV} | sed -e 's/-dirty//g' -e 's/-/./g')" +MY_P="${PN}_${MY_PV}" + +mv ${P}.tar.xz "../${MY_P}.orig.tar.xz" + +for dir in /tmp/pbuilder/*/base.cow; do + export DIST="$(basename "$(dirname "${dir}")" | cut -d- -f1)" + RES="${BUILDDIR}/deb/${DIST}" + mkdir -p "${RES}" + + rm -rf "../${P}" + tar -xf "../${MY_P}.orig.tar.xz" -C .. + cp -r ../debian "../${P}/" + + pushd "../${P}" > /dev/null + + # do not mess with changelog for releases, it should be done manually during version bump + if [[ ${PV} == *-* ]]; then + dch \ + --distribution "${DIST}" \ + --newversion "${MY_PV}-1" \ + "snapshot" + fi + + pdebuild \ + --pbuilder cowbuilder \ + --buildresult "${RES}" \ + -- --basepath "${dir}" + + popd > /dev/null + +done + +DISTS="$(ls -1 "${BUILDDIR}/deb")" + +mkdir -p "${BUILDDIR}/deb-repo/conf" +create_reprepro_conf ${DISTS} > "${BUILDDIR}/deb-repo/conf/distributions" + +pushd "${BUILDDIR}/deb-repo" > /dev/null + +for dist in ${DISTS}; do + for deb in "../deb/${dist}"/*.deb; do + reprepro includedeb "${dist}" "${deb}" + done +done + +popd > /dev/null + +tar \ + -cJf "blogc-deb-repo-${PV}.tar.xz" \ + --exclude ./deb-repo/conf \ + --exclude ./deb-repo/db \ + ./deb-repo -- cgit v1.2.3-18-g5258