From a97803454ff30cd1c48bf090eb13e8f1f26f334d Mon Sep 17 00:00:00 2001 From: langfingaz Date: Thu, 22 Apr 2021 11:06:27 +0200 Subject: [PATCH] add remote repository manager --- pkg/de-p1st-repo/PKGBUILD | 32 +++++++++++++++++ pkg/de-p1st-repo/arch-repo-push-new.sh | 21 ++++++++++++ pkg/de-p1st-repo/arch-repo-receive-new.sh | 42 +++++++++++++++++++++++ pkg/de-p1st-repo/arch-repo.cfg | 4 +++ 4 files changed, 99 insertions(+) create mode 100644 pkg/de-p1st-repo/PKGBUILD create mode 100644 pkg/de-p1st-repo/arch-repo-push-new.sh create mode 100644 pkg/de-p1st-repo/arch-repo-receive-new.sh create mode 100644 pkg/de-p1st-repo/arch-repo.cfg diff --git a/pkg/de-p1st-repo/PKGBUILD b/pkg/de-p1st-repo/PKGBUILD new file mode 100644 index 0000000..f7bca11 --- /dev/null +++ b/pkg/de-p1st-repo/PKGBUILD @@ -0,0 +1,32 @@ +# Maintainer: Daniel Langbein +_pkgname=repo +_reponame=arch-pkg +pkgname="de-p1st-$_pkgname" +pkgver=0.0.1 +pkgrel=1 +pkgdesc="Bash script to manage remote Arch Linux repository" +arch=('any') +url="https://git.privacy1st.de/langfingaz/${_reponame}" +license=('MIT') +groups=() +depends=('openssh' 'bash') +makedepends=() +optdepends=() +provides=() +conflicts=() +replaces=() +backup=() +options=() +install= +changelog= +source=("git+${url}.git") +noextract=() +sha256sums=('SKIP') + +package() { + cd "${_reponame}/pkg/${pkgname}" + + install -Dm0544 arch-repo-push-new.sh "$pkgdir"/usr/bin/arch-repo-push-new + install -Dm0544 arch-repo-receive-new.sh "$pkgdir"/usr/bin/arch-repo-receive-new + install -Dm0644 arch-repo.cfg "$pkgdir"/etc/de-p1st-repo/arch-repo.cfg +} diff --git a/pkg/de-p1st-repo/arch-repo-push-new.sh b/pkg/de-p1st-repo/arch-repo-push-new.sh new file mode 100644 index 0000000..3c5673a --- /dev/null +++ b/pkg/de-p1st-repo/arch-repo-push-new.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +souce /etc/de-p1st-repo/arch-repo.cfg || exit + + +cd "${LOCAL_PKG_DIR}" || exit + +# get list of new packages, one package per line +rsync --ignore-existing --out-format="%n" --dry-run \ + ./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" > new-pkg.txt || exit + +# transfer new packages using rsync +rsync --ignore-existing --progress --human-readable \ + ./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit + +# transfer new-pkg.txt +rsync --ignore-times --checksum --progress --human-readable \ + new-pkg.txt "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit + +# add each new package to database +ssh "${REMOTE_SSH_HOST}" "/home/yoda/arch-repo-receive-new.sh" diff --git a/pkg/de-p1st-repo/arch-repo-receive-new.sh b/pkg/de-p1st-repo/arch-repo-receive-new.sh new file mode 100644 index 0000000..0c1dba9 --- /dev/null +++ b/pkg/de-p1st-repo/arch-repo-receive-new.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +souce /etc/de-p1st-repo/arch-repo.cfg || exit + + +# +# add new packages to database +# +function add_to_db(){ + mapfile -t PKGS < <(cat new-pkg.txt) + for PKG in "${PKGS[@]}"; do + repo-add -n "${REMOTE_DB_NAME}.db.tar.gz" "${PKG}" || exit + done +} + + +# +# generate index.html +# +function generate_index(){ + echo ' + + +privacy1st.de Arch Packages + + +

privacy1st.de Arch Packages

+' > index.html + + for PKG in ./*.pkg.tar.{xz,zst}; do + echo "

$PKG

" >> index.html; + done + + echo ' + +' >> index.html +} + + +cd "${REMOTE_PKG_DIR}" || exit +add_to_db +generate_index diff --git a/pkg/de-p1st-repo/arch-repo.cfg b/pkg/de-p1st-repo/arch-repo.cfg new file mode 100644 index 0000000..1518da8 --- /dev/null +++ b/pkg/de-p1st-repo/arch-repo.cfg @@ -0,0 +1,4 @@ +REMOTE_SSH_HOST=rootnas +LOCAL_PKG_DIR=/home/custompkgs +REMOTE_PKG_DIR=/mnt/data/live/arch-repo +REMOTE_DB_NAME=de-p1st \ No newline at end of file