[pacman-dev] [PATCH] repo-add: create relative DB symlinks

Dan McGee dan at archlinux.org
Wed Aug 18 14:23:16 EDT 2010


As noted in FS#20498, if an absolute path is used for specifying the
database when invoking repo-add, the symlink generated will point to the
absolute path instead of being relative to the directory. Fix this for
the two linking cases, but leave the copy untouched so that will still
work.

Signed-off-by: Dan McGee <dan at archlinux.org>
---
 scripts/repo-add.sh.in |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 2838f81..283ad07 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -488,8 +488,9 @@ if (( success )); then
 	[[ -f $REPO_DB_FILE ]] && mv -f "$REPO_DB_FILE" "${REPO_DB_FILE}.old"
 	[[ -f $tmpdir/$filename ]] && mv "$tmpdir/$filename" "$REPO_DB_FILE"
 	dblink="${REPO_DB_FILE%.tar.*}"
-	ln -sf "$REPO_DB_FILE" "$dblink" 2>/dev/null || \
-		ln -f "$REPO_DB_FILE" "$dblink" 2>/dev/null || \
+	target=${REPO_DB_FILE##*/}
+	ln -sf "$target" "$dblink" 2>/dev/null || \
+		ln -f "$target" "$dblink" 2>/dev/null || \
 		cp "$REPO_DB_FILE" "$dblink"
 else
 	msg "$(gettext "No packages modified, nothing to do.")"
-- 
1.7.2.1



More information about the pacman-dev mailing list