From 8f6e0851ec13e8509639a7ed93fd0ff06fe41b6a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 28 Aug 2018 17:48:08 -0400 Subject: db-update: Allow packages to be symlinks for db-import --- db-functions | 12 ++++++++++++ db-update | 15 ++++++++++++--- 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}" -- cgit v1.2.2