2021-04-22 11:06:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-04-22 11:11:46 +02:00
|
|
|
source /etc/de-p1st-repo/arch-repo.cfg || exit
|
2021-04-22 11:06:27 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
function main() {
|
|
|
|
cd "${LOCAL_PKG_DIR}" || exit
|
2021-04-22 11:06:27 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
# 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; }
|
2021-04-22 11:24:04 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
# if we are here, then there is at least one match!
|
|
|
|
match="1"
|
|
|
|
break
|
|
|
|
done
|
2021-04-22 11:06:27 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
if [ "$match" = "0" ]; then
|
|
|
|
echo "There are no local packages"
|
|
|
|
exit 0
|
|
|
|
fi
|
2021-04-27 11:41:35 +02:00
|
|
|
|
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
# Get list of new packages, one package per line.
|
|
|
|
# Enable nullglob for the case that e.g. just *.zst but not *.xz packages exist.
|
|
|
|
shopt -s nullglob
|
|
|
|
rsync --ignore-existing --out-format="%n" --dry-run \
|
|
|
|
./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" > new-pkg.txt || exit
|
2021-04-27 11:41:35 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
# if there are no new packages to push/synchronize, then exit
|
|
|
|
if [ ! -s new-pkg.txt ]; then
|
|
|
|
echo "No new packages.";
|
|
|
|
exit 0;
|
|
|
|
fi
|
2021-04-27 11:41:35 +02:00
|
|
|
|
2021-04-26 14:45:18 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
# transfer new packages using rsync
|
|
|
|
rsync --ignore-existing --progress --human-readable \
|
|
|
|
./*.pkg.tar.{xz,zst} "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit
|
2021-04-26 15:16:40 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
# transfer new-pkg.txt
|
|
|
|
rsync --ignore-times --checksum --progress --human-readable \
|
|
|
|
new-pkg.txt "${REMOTE_SSH_HOST}":"${REMOTE_PKG_DIR}" || exit
|
2021-04-26 14:45:18 +02:00
|
|
|
|
2021-04-22 11:06:27 +02:00
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
# add each new package to database
|
|
|
|
ssh "${REMOTE_SSH_HOST}" "/usr/bin/arch-repo-receive-new" || exit
|
|
|
|
}
|
2021-04-26 14:45:18 +02:00
|
|
|
|
|
|
|
|
2021-05-13 15:57:01 +02:00
|
|
|
for LOCAL_PKG_DIR in "${LOCAL_PKG_DIRS[@]}"; do
|
|
|
|
main
|
|
|
|
done
|