FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 08-11-2012, 12:20 AM
Dave Reisner
 
Default makepkg: implement dir_is_empty for dir content checks

Rather than calling upon ls for this, use a proper shell function which
uses globbing to determine the existance of files in a directory.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
scripts/makepkg.sh.in | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index dd4066b..262bcf8 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -2212,6 +2212,14 @@ canonicalize_path() {
fi
}

+dir_is_empty() {
+ (
+ shopt -s dotglob nullglob
+ files=("$1"/*)
+ (( ${#files} == 0 ))
+ )
+}
+
m4_include(library/parseopts.sh)

usage() {
@@ -2695,14 +2703,14 @@ if (( NOEXTRACT )); then
warning "$(gettext "Skipping source integrity checks -- using existing %s tree")" "src/"
warning "$(gettext "Skipping source extraction -- using existing %s tree")" "src/"

- if (( NOEXTRACT )) && [[ -z $(ls "$srcdir" 2>/dev/null) ]]; then
+ if (( NOEXTRACT )) && dir_is_empty "$srcdir"; then
error "$(gettext "The source directory is empty, there is nothing to build!")"
plain "$(gettext "Aborting...")"
exit 1
fi
elif (( REPKG )); then
if (( ! PKGFUNC && ! SPLITPKG ))
- && [[ ! -d $pkgdir || -z $(ls "$pkgdir" 2>/dev/null) ]]; then
+ && { [[ ! -d $pkgdir ]] || dir_is_empty "$pkgdir"; }; then
error "$(gettext "The package directory is empty, there is nothing to repackage!")"
plain "$(gettext "Aborting...")"
exit 1
--
1.7.11.4
 

Thread Tools




All times are GMT. The time now is 03:19 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org