[pacman-dev] [PATCH] Remove existing pkg/ dir only if it's not empty.

Dan McGee dpmcgee at gmail.com
Tue Feb 1 10:54:31 EST 2011


On Tue, Feb 1, 2011 at 6:22 AM, Esa Määttä <esa.maatta at iki.fi> wrote:
> This allows symbolic linking of the pkg directory. Without this patch the
> symbolic link to an another directory would be removed as existing pkg/
> directory.
>
> Signed-off-by: Esa Määttä <esa.maatta at iki.fi>
> ---
>  scripts/makepkg.sh.in |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index b1b1b75..bd2739b 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -2056,8 +2056,8 @@ if (( NOBUILD )); then
>        msg "$(gettext "Sources are ready.")"
>        exit 0 #E_OK
>  else
> -       # check for existing pkg directory; don't remove if we are repackaging
> -       if [[ -d $pkgdir ]] && (( ! REPKG || PKGFUNC || SPLITPKG )); then
> +       # check for existing non empty pkg directory; don't remove if we are repackaging
> +       if [[ -n $(ls -A "$pkgdir" 2>/dev/null) ]] && (( ! REPKG || PKGFUNC || SPLITPKG )); then
Please read `man 1 test` and figure out what you are actually trying
to check for, I'm sure ls invocation is not required. And on that
note:

$ mkdir test
$ ln -s test linktest
$ [[ -d test ]] && echo "true"
true
$ [[ -d linktest ]] && echo "true"
true

Or maybe I'm just not understanding at all the "why" behind your
patch? Whether it is a symlink or not, we shouldn't be treating it any
differently.

>                msg "$(gettext "Removing existing pkg/ directory...")"
>                rm -rf "$pkgdir"
>        fi
> --
> 1.7.4


More information about the pacman-dev mailing list