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

Signed-off-by: Dave Reisner <[email protected]>
---
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


Reply via email to