From 131be5e113248aea2f2817ca36293cd1ae4b772a Mon Sep 17 00:00:00 2001 From: Albert S Date: Wed, 19 Aug 2020 12:25:14 +0200 Subject: [PATCH] initial commit --- CONFIG.example | 4 +++ README.md | 7 ++++++ build/CHANGELOG_TEMPLATE | 6 +++++ build/adhocify/build | 14 +++++++++++ build/adhocify/debian/adhocify.install | 1 + build/adhocify/debian/changelog | 5 ++++ build/adhocify/debian/control | 16 ++++++++++++ build/adhocify/debian/rules | 8 ++++++ build/adhocify/debian/source/format | 1 + build/functions.bash | 34 ++++++++++++++++++++++++++ repo.conf | 4 +++ update_repo | 14 +++++++++++ 12 files changed, 114 insertions(+) create mode 100644 CONFIG.example create mode 100644 README.md create mode 100644 build/CHANGELOG_TEMPLATE create mode 100755 build/adhocify/build create mode 100644 build/adhocify/debian/adhocify.install create mode 100644 build/adhocify/debian/changelog create mode 100644 build/adhocify/debian/control create mode 100755 build/adhocify/debian/rules create mode 100644 build/adhocify/debian/source/format create mode 100644 build/functions.bash create mode 100644 repo.conf create mode 100755 update_repo diff --git a/CONFIG.example b/CONFIG.example new file mode 100644 index 0000000..81bfe2f --- /dev/null +++ b/CONFIG.example @@ -0,0 +1,4 @@ +TARGET_SERVER="hostname" +TARGET_PATH="/var/www/somewhere" +TARGET_OWNER="nginx" +SIGNING_KEY_EMAIL="mail@example.tld" diff --git a/README.md b/README.md new file mode 100644 index 0000000..207daf8 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +apt repository for quitesimple.org projects +=========================================== +This follows a rather pragmatic approach. + +Some inspiration was taken from https://manuel-io.github.io/blog/2017/07/09/creating-an-apt-repository/, thanks! + +Hosted at https://repo.quitesimple.org/debian/ diff --git a/build/CHANGELOG_TEMPLATE b/build/CHANGELOG_TEMPLATE new file mode 100644 index 0000000..a76a17c --- /dev/null +++ b/build/CHANGELOG_TEMPLATE @@ -0,0 +1,6 @@ +NAME_PLACEHOLDER (VERSION_PLACEHOLDER) unstable; urgency=medium + + * Generated package for VERSION_PLACEHOLDER. + + -- quitesimple.org repo management department ;-) DATE_PLACEHOLDER + diff --git a/build/adhocify/build b/build/adhocify/build new file mode 100755 index 0000000..02fa4b1 --- /dev/null +++ b/build/adhocify/build @@ -0,0 +1,14 @@ +#!/bin/bash +source ../functions.bash +if [ $# -ne 1 ] ; then +echo "Usage: $0 poolpath" 1>&2 +exit 1 +fi +set -e + +TAG="_auto_" +BUILDDIR=$(mktemp -d) +OUTPUT_DIR="$1" + +build_git_repo "$BUILDDIR" "https://gitea.quitesimple.org/crtxcr/adhocify" adhocify "$TAG" "$OUTPUT_DIR" + diff --git a/build/adhocify/debian/adhocify.install b/build/adhocify/debian/adhocify.install new file mode 100644 index 0000000..96270a8 --- /dev/null +++ b/build/adhocify/debian/adhocify.install @@ -0,0 +1 @@ +adhocify /usr/bin/ diff --git a/build/adhocify/debian/changelog b/build/adhocify/debian/changelog new file mode 100644 index 0000000..cb6b185 --- /dev/null +++ b/build/adhocify/debian/changelog @@ -0,0 +1,5 @@ +adhocify (1.0) unstable; urgency=medium + + * Initial Release. + + -- quitesimple.org repo management department ;-) Tue, 18 Aug 2020 18:17:03 +0200 diff --git a/build/adhocify/debian/control b/build/adhocify/debian/control new file mode 100644 index 0000000..3b1c104 --- /dev/null +++ b/build/adhocify/debian/control @@ -0,0 +1,16 @@ +Source: adhocify +Section: unknown +Priority: optional +Maintainer: quitesimple.org repo management department ;-) +Build-Depends: debhelper-compat (= 12) +Standards-Version: 4.4.1 +Homepage: + +Package: adhocify +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Executes commands upon file system events + This tool allows watching filesystem paths for certain events, + such as writes, deletions etc. The user specifies commands which + should be executed when those events occur. It utilizes the + inotify API to do so. diff --git a/build/adhocify/debian/rules b/build/adhocify/debian/rules new file mode 100755 index 0000000..7a0c644 --- /dev/null +++ b/build/adhocify/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f +%: + dh $@ + +override_dh_auto_build: + make release + +override_dh_auto_install: diff --git a/build/adhocify/debian/source/format b/build/adhocify/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/build/adhocify/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/build/functions.bash b/build/functions.bash new file mode 100644 index 0000000..b742bc7 --- /dev/null +++ b/build/functions.bash @@ -0,0 +1,34 @@ +#!/bin/bash + +function newest_git_tag() +{ + git tag --sort="-version:refname" | head -n 1 +} + +function build_git_repo() +{ + BUILDDIR="$1" + REPOURL="$2" + NAME="$3" + VERSION="$4" + TARGET_DIR="$5" + cp -R debian "$BUILDDIR" + cp ../CHANGELOG_TEMPLATE "$BUILDDIR"/debian/changelog + cd "$BUILDDIR" + git clone "$REPOURL" "$NAME" + cd "$NAME" + if [ "$VERSION" = "_auto_" ] ; then + VERSION=$(newest_git_tag) + fi + + git verify-tag "$VERSION" + git checkout "$VERSION" + mv ../debian/ . + VERSION_CHANGELOG=$( echo $VERSION | sed -e 's/v//g') + sed -e "s/NAME_PLACEHOLDER/$NAME/g" -i ./debian/changelog + sed -e "s/VERSION_PLACEHOLDER/$VERSION_CHANGELOG/g" -i ./debian/changelog + DATE_CHANGELOG=$(date -R) + sed -e "s/DATE_PLACEHOLDER/$DATE_CHANGELOG/g" -i ./debian/changelog + dpkg-buildpackage --no-sign + cp -a ../*.deb "$TARGET_DIR"/ +} diff --git a/repo.conf b/repo.conf new file mode 100644 index 0000000..c67dd17 --- /dev/null +++ b/repo.conf @@ -0,0 +1,4 @@ +APT::FTPArchive::Release::Codename "default"; +APT::FTPArchive::Release::Components "main"; +APT::FTPArchive::Release::Label "quitesimple.org apt repository"; +APT::FTPArchive::Release::Architectures "amd64"; diff --git a/update_repo b/update_repo new file mode 100755 index 0000000..beeb1d2 --- /dev/null +++ b/update_repo @@ -0,0 +1,14 @@ +#!/bin/bash +set -u +source ./CONFIG +mkdir -p repo/dists +mkdir -p repo/pool +mkdir -p repo/dists/default/main/binary-amd64/ +cd repo +dpkg-scanpackages -a amd64 pool > ./dists/default/main/binary-amd64/Packages +cd dists/default/ +apt-ftparchive -c ../../../repo.conf release . > Release +gpg -a --yes --clearsign --output InRelease --local-user "$SIGNING_KEY_EMAIL" --detach-sign Release +cd ../../../ +rsync -aAXPv --delete repo/ "$TARGET_SERVER":"$TARGET_PATH" +ssh "$TARGET_SERVER" chown -R "$TARGET_OWNER" "$TARGET_PATH"