summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2018-08-28 17:48:08 -0400
committerLuke Shumaker <lukeshu@parabola.nu>2018-09-02 18:55:31 -0400
commit8f6e0851ec13e8509639a7ed93fd0ff06fe41b6a (patch)
treef16b1ddb41471c9525f944e7d4304077ce5d446f
parent428eb1dda4bebf6fe7fcbd9dab127dd1579a7240 (diff)
db-update: Allow packages to be symlinks for db-import
-rw-r--r--db-functions12
-rwxr-xr-xdb-update15
2 files changed, 24 insertions, 3 deletions
diff --git a/db-functions b/db-functions
index 6356792..356777a 100644
--- a/db-functions
+++ b/db-functions
@@ -34,6 +34,18 @@ mv_acl() {
rm -f "$1"
}
+# just like mv -f, but won't break relative symlinks
+mv_ln() {
+ if [[ -L $1 ]]; then
+ local target
+ target=$(readlink -f -- "$1") || return 1
+ ln -srf -- "$target" "$2" || return 1
+ rm -f -- "$1";
+ else
+ mv -f -- "$1" "$2"
+ fi
+}
+
# set up general environment
WORKDIR=$(mktemp -dt "${0##*/}.XXXXXXXXXX")
LOCKS=()
diff --git a/db-update b/db-update
index e70b94b..a36199e 100755
--- a/db-update
+++ b/db-update
@@ -51,7 +51,16 @@ for repo in "${repos[@]}"; do
if (( $? == 0 )); then
for pkg in "${pkgs[@]}"; do
if [[ -h ${pkg} ]]; then
- die "Package %s is a symbolic link" "$repo/${pkg##*/}"
+ # As a special hack for inheriting packages between db-import
+ # upstreams, allow symlinks that point to arch=(any) packages in a
+ # different PKGPOOL.
+ if ! [[
+ -f ${pkg} &&
+ "$(readlink -f -- "$pkg")" = "${FTP_BASE}"/pool/*-any${PKGEXTS} &&
+ "$(readlink -f -- "$pkg")" != "${FTP_BASE}/${PKGPOOL}"/*
+ ]]; then
+ die "Package %s is a symbolic link" "$repo/${pkg##*/}"
+ fi
fi
if ! check_pkgfile "${pkg}"; then
die "Package %s is not consistent with its meta data" "$repo/${pkg##*/}"
@@ -94,12 +103,12 @@ for repo in "${repos[@]}"; do
msg2 '%s (%s)' "$pkgfile" "$pkgarch"
# any packages might have been moved by the previous run
if [[ -f ${pkg} ]]; then
- mv "${pkg}" "$FTP_BASE/${PKGPOOL}"
+ mv_ln "${pkg}" "$FTP_BASE/${PKGPOOL}"
fi
ln -s "../../../${PKGPOOL}/${pkgfile}" "$FTP_BASE/$repo/os/${pkgarch}"
# also move signatures
if [[ -f ${pkg}.sig ]]; then
- mv "${pkg}.sig" "$FTP_BASE/${PKGPOOL}"
+ mv_ln "${pkg}.sig" "$FTP_BASE/${PKGPOOL}"
fi
if [[ -f $FTP_BASE/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "$FTP_BASE/$repo/os/${pkgarch}"