update arch-repo

This commit is contained in:
Daniel Langbein 2021-05-13 13:57:01 +00:00
parent 168ae92f8d
commit 43f0e2a461
2 changed files with 45 additions and 40 deletions

View File

@ -2,47 +2,52 @@
source /etc/de-p1st-repo/arch-repo.cfg || exit source /etc/de-p1st-repo/arch-repo.cfg || exit
function main() {
cd "${LOCAL_PKG_DIR}" || exit
# check if at least one matching file exists
cd "${LOCAL_PKG_DIR}" || exit match="0"
for PKG in ./*.pkg.tar.{xz,zst}; do
# check if at least one matching file exists
match="0"
for PKG in ./*.pkg.tar.{xz,zst}; do
[ -f "$PKG" ] || { echo "There are no local packages for the pattern $PKG"; continue; } [ -f "$PKG" ] || { echo "There are no local packages for the pattern $PKG"; continue; }
# if we are here, then there is at least one match! # if we are here, then there is at least one match!
match="1" match="1"
break break
done done
if [ "$match" = "0" ]; then if [ "$match" = "0" ]; then
echo "There are no local packages" echo "There are no local packages"
exit 0 exit 0
fi fi
# Get list of new packages, one package per line. # Get list of new packages, one package per line.
# Enable nullglob for the case that e.g. just *.zst but not *.xz packages exist. # Enable nullglob for the case that e.g. just *.zst but not *.xz packages exist.
shopt -s nullglob shopt -s nullglob
rsync --ignore-existing --out-format="%n" --dry-run \ rsync --ignore-existing --out-format="%n" --dry-run \
./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" > new-pkg.txt || exit ./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" > new-pkg.txt || exit
# if there are no new packages to push/synchronize, then exit # if there are no new packages to push/synchronize, then exit
if [ ! -s new-pkg.txt ]; then if [ ! -s new-pkg.txt ]; then
echo "No new packages."; echo "No new packages.";
exit 0; exit 0;
fi fi
# transfer new packages using rsync # transfer new packages using rsync
rsync --ignore-existing --progress --human-readable \ rsync --ignore-existing --progress --human-readable \
./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit ./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit
# transfer new-pkg.txt # transfer new-pkg.txt
rsync --ignore-times --checksum --progress --human-readable \ rsync --ignore-times --checksum --progress --human-readable \
new-pkg.txt "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit new-pkg.txt "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit
# add each new package to database # add each new package to database
ssh "${REMOTE_SSH_HOST}" "/usr/bin/arch-repo-receive-new" || exit ssh "${REMOTE_SSH_HOST}" "/usr/bin/arch-repo-receive-new" || exit
}
for LOCAL_PKG_DIR in "${LOCAL_PKG_DIRS[@]}"; do
main
done

View File

@ -3,7 +3,7 @@
# REMOTE_PKG_DIR # REMOTE_PKG_DIR
REMOTE_SSH_HOST=rootnas REMOTE_SSH_HOST=rootnas
LOCAL_PKG_DIR=/home/custompkgs LOCAL_PKG_DIRS=('/home/custompkgs' '/home/yoda/Downloads/git/arch/out')
REMOTE_PKG_DIR=/mnt/data/live/arch-repo REMOTE_PKG_DIR=/mnt/data/live/arch-repo
REMOTE_DB_NAME=de-p1st REMOTE_DB_NAME=de-p1st