[pacman-dev] [PATCH 9/9] repo-add: allow specifying symlink as repo file

Dave Reisner d at falconindy.com
Wed Jun 22 20:38:53 EDT 2011


If the repo file already exists, we allow specifying the symlink instead
of the tarball itself.

Signed-off-by: Dave Reisner <d at falconindy.com>
---
I'm fairly sure this is a safe use of readlink, since it doesn't involve any of
the flags for canonicalizing paths. I was able to test it on OSX with great
success.

 scripts/repo-add.sh.in |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 8865188..3581765 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -582,7 +582,10 @@ done
 if (( success )); then
 	msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
 
-	case "$REPO_DB_FILE" in
+	# allows for syntax such as: repo-add repo.db /path/to/pkg
+	[[ -L "$REPO_DB_FILE" ]] && resolved=$(readlink "$REPO_DB_FILE")
+
+	case "${resolved:-$REPO_DB_FILE}" in
 		*.@(db|files).tar.gz)  TAR_OPT="z" ;;
 		*.@(db|files).tar.bz2) TAR_OPT="j" ;;
 		*.@(db|files).tar.xz)  TAR_OPT="J" ;;
-- 
1.7.5.4



More information about the pacman-dev mailing list