[pacman-dev] [PATCH 5/9] repo-add: enforce file extensions

Dan McGee dpmcgee at gmail.com
Fri Jun 24 00:13:07 EDT 2011


On Wed, Jun 22, 2011 at 7:38 PM, Dave Reisner <d at falconindy.com> wrote:
> Allow one of 4 archive extensions: .tar{,.gz,.xz,.bz2} for each of the 2
> valid repo extensions: .db and .files

Good here, but- we should validate up front. What about moving this
bit into a function that takes one argument (the db filename), and
then calling that both when we first read the DB name, and then later
when we need a tar flag? The function would return a tar compression
flag, or "" for no compression, along with some designated invalid
value that the initial call would check for and thus reject the
database name. That way we don't need extension lists and expansion
crazyness in more than one place.

>
> Signed-off-by: Dave Reisner <d at falconindy.com>
> ---
>  scripts/repo-add.sh.in |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
> index ab97952..17639ed 100644
> --- a/scripts/repo-add.sh.in
> +++ b/scripts/repo-add.sh.in
> @@ -573,10 +573,10 @@ if (( success )); then
>        msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
>
>        case "$REPO_DB_FILE" in
> -               *.tar.gz)  TAR_OPT="z" ;;
> -               *.tar.bz2) TAR_OPT="j" ;;
> -               *.tar.xz)  TAR_OPT="J" ;;
> -               *.tar)     TAR_OPT="" ;;
> +               *.@(db|files).tar.gz)  TAR_OPT="z" ;;
> +               *.@(db|files).tar.bz2) TAR_OPT="j" ;;
> +               *.@(db|files).tar.xz)  TAR_OPT="J" ;;
> +               *.@(db|files).tar)     TAR_OPT="" ;;
>                *) warning "$(gettext "'%s' does not have a valid archive extension.")" \
>                "$REPO_DB_FILE" ;;
>        esac
> --
> 1.7.5.4
>
>
>


More information about the pacman-dev mailing list