arch/pkg/de-p1st-repo/arch-repo-push-new.sh
2021-04-26 15:16:40 +02:00

31 lines
807 B
Bash

#!/bin/bash
source /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
# if there are no new packages, exit
if [ ! -s new-pkg.txt ]; then
echo "No new packages.";
exit 0;
fi
# 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}" "/usr/bin/arch-repo-receive-new" || exit