mirror of
https://codeberg.org/privacy1st/arch
synced 2024-12-23 01:16:04 +01:00
fix shell globbing in case of no matching files
This commit is contained in:
parent
2856aee2ad
commit
812fcff8b7
@ -2,8 +2,8 @@
|
|||||||
_pkgname=repo
|
_pkgname=repo
|
||||||
_reponame=arch
|
_reponame=arch
|
||||||
pkgname="de-p1st-$_pkgname"
|
pkgname="de-p1st-$_pkgname"
|
||||||
pkgver=0.1.4
|
pkgver=0.1.5
|
||||||
pkgrel=2
|
pkgrel=1
|
||||||
pkgdesc="Bash script to manage remote Arch Linux repository"
|
pkgdesc="Bash script to manage remote Arch Linux repository"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
url="https://codeberg.org/privacy1st/${_reponame}"
|
url="https://codeberg.org/privacy1st/${_reponame}"
|
||||||
|
@ -6,11 +6,29 @@ source /etc/de-p1st-repo/arch-repo.cfg || exit
|
|||||||
|
|
||||||
cd "${LOCAL_PKG_DIR}" || exit
|
cd "${LOCAL_PKG_DIR}" || exit
|
||||||
|
|
||||||
# get list of new packages, one package per line
|
# check if at least one matching file exists
|
||||||
|
match="0"
|
||||||
|
for PKG in ./*.pkg.tar.{xz,zst}; do
|
||||||
|
[ -f "$PKG" ] || { echo "No match for pattern $PKG"; continue; }
|
||||||
|
|
||||||
|
# if we are here, then there is at least one match!
|
||||||
|
match="1"
|
||||||
|
break
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$match" = "0" ]; then
|
||||||
|
echo "There are no local packages"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# 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 \
|
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, 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;
|
||||||
|
21
pkg/de-p1st-repo/iterate-files-test.sh
Normal file
21
pkg/de-p1st-repo/iterate-files-test.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source /etc/de-p1st-repo/arch-repo.cfg || exit
|
||||||
|
|
||||||
|
|
||||||
|
cd "${LOCAL_PKG_DIR}" || exit
|
||||||
|
|
||||||
|
match="0"
|
||||||
|
for PKG in ./*.pkg.tar.{xz,zst}; do
|
||||||
|
[ -f "$PKG" ] || { echo "No match for pattern $PKG"; continue; }
|
||||||
|
|
||||||
|
# if we are here, there is at least one match!
|
||||||
|
match="1"
|
||||||
|
break
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$match" = "1" ]; then
|
||||||
|
shopt -s nullglob
|
||||||
|
# print all matching
|
||||||
|
echo ./*.pkg.tar.{xz,zst}
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user