threads / patch / 1265

patch, 5 partscogito: remove use of cp -a, a non-portable GNU extension

Subject: [PATCH 2/5] cogito: remove use of cp -a, a non-portable GNU extension

## tl;dr

6 messages between Jul 16, 2005 and Jul 16, 2005. Diffs are folded; open one to read it.

replies: 5people: 1as markdown or json

Bryan Larsen· Jul 16, 2005, 23:23 UTC · lore

[PATCH 0/5] cogito: compatibility with OS X

Since Linus and Junio were unhappy with my previous set of patches to make git and cogito compatible with OS X and other BSD unices, I have redone my patches to cogito along a similar line.

There is still one outstanding incompatibility: cogito makes use of cp -u. I have this message from Junio:

> I do not speak for Pasky, but to me "cp -u" sounds just like an
> optimization, so maybe defining CP_U='cp -u' and detect missing
> support at config time and falling back on the simple "cp" would
> be an option?

Pasky, does this seem reasonable? Is there a better way? So far I have been able to avoid adding the "config.sh" contained in my first script.

cheers, Bryan

Bryan Larsen· Jul 16, 2005, 23:23 UTC · re: Bryan Larsen · lore

[PATCH 1/5] cogito: remove use of xargs -r, a non-portable GNU extension

Remove usage of xargs -r, a non-portable gnu extension.  
Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
 cg-add  |    6 +++---
 cg-init |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
Show changes to 2 files +4 −4

cg-add, cg-init

diff --git a/cg-add b/cg-add
--- a/cg-add
+++ b/cg-add
@@ -25,8 +25,6 @@ USAGE="cg-add [-N] FILE..."
 
 . ${COGITO_LIB}cg-Xlib
 
-[ "$1" ] || usage
-
 infoonly=
 while optparse; do
 	if optparse -N; then
@@ -36,6 +34,8 @@ while optparse; do
 	fi
 done
 
+[ "$ARGS" ] || usage
+
 TMPFILE=$(mktemp -t gitadd.XXXXXX) || exit 1
 find "${ARGS[@]}" -type f -print0 > $TMPFILE || {
 	die "not all files exist, nothing added"
@@ -43,6 +43,6 @@ find "${ARGS[@]}" -type f -print0 > $TMP
 }
 
 cat $TMPFILE | tr '\0' '\n' | sed 's/^/Adding file /'
-cat $TMPFILE | xargs -0r git-update-cache --add ${infoonly} --
+cat $TMPFILE | xargs -0 git-update-cache --add ${infoonly} --
 
 rm $TMPFILE
diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -55,7 +55,7 @@ if [ "$uri" ]; then
 	echo "Cloned (origin $uri available as branch \"origin\")"
 else
 	git-read-tree # Seed the dircache
-	find * \( -type f -o -type l \) -print0 | xargs -0r cg-add ${infoonly}
+	[ `ls` ] && find * \( -type f -o -type l \) -print0 | xargs -0 cg-add ${infoonly}
 	cg-commit -C -m"Initial commit" -E ${infoonly}
 fi
 
Bryan Larsen· Jul 16, 2005, 23:23 UTC · re: Bryan Larsen · lore
Remove usage of cp -a, a non-portable gnu extension.
Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
 cg-pull |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to cg-pull +1 −1
diff --git a/cg-pull b/cg-pull
--- a/cg-pull
+++ b/cg-pull
@@ -217,7 +217,7 @@ fetch_local () {
 	[ "$1" = "-i" ] && shift
 	[ "$1" = "-s" ] && shift
 
-	cp_flags_l="-va"
+	cp_flags_l="-vdpR"
 	if [ "$1" = "-u" ]; then
 		cp_flags_l="$cp_flags_l -u$can_hardlink"
 		suggest_hardlink=
Bryan Larsen· Jul 16, 2005, 23:23 UTC · re: Bryan Larsen · lore

[PATCH 3/5] cogito: try harder to find gnu stat

Look harder for gnu stat.

Cogito has code to use awk if gnu stat is missing. Look harder for gnu stat under alternate names such as gstat and gnustat, avoiding the use of awk if possible.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
 cg-Xlib |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Show changes to cg-Xlib +3 −3
diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -229,11 +229,11 @@ fi
 
 
 # Compatibility hacks:
-# Fortunately none as of now.
-
 
 export BROKEN_MKTEMP=1
 del=$($(which mktemp) -t 2>/dev/null) && { rm $del; export BROKEN_MKTEMP=; }
-has_stat=$(which stat 2>/dev/null)
+has_stat=$(which gnustat 2> /dev/null ||
+    which gstat 2> /dev/null ||
+    which stat 2>/dev/null)
 [ "$has_stat" ] && $has_stat -c %s / 2>/dev/null >&2 || has_stat=
 has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)
Bryan Larsen· Jul 16, 2005, 23:24 UTC · re: Bryan Larsen · lore

[PATCH 4/5] cogito: try harder to find gnu date

Look harder for gnu date, use if available.
Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
 cg-Xlib |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Show changes to cg-Xlib +6 −2
diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -70,7 +70,7 @@ showdate () {
 	secs=$(($secs + $tzhours * 3600 + $tzmins * 60))
 	[ "$format" ] || format="+%a, %d %b %Y %H:%M:%S $2"
 	if [ "$has_gnudate" ]; then
-		LANG=C date -ud "1970-01-01 UTC + $secs sec" "$format"
+		LANG=C ${has_gnudate} -ud "1970-01-01 UTC + $secs sec" "$format"
 	else
 		LANG=C date -u -r $secs "$format"
 	fi
@@ -236,4 +236,8 @@ has_stat=$(which gnustat 2> /dev/null ||
     which gstat 2> /dev/null ||
     which stat 2>/dev/null)
 [ "$has_stat" ] && $has_stat -c %s / 2>/dev/null >&2 || has_stat=
-has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)
+has_gnudate=$(which gnudate 2> /dev/null || 
+    which gdate 2> /dev/null || 
+    which stat 2>/dev/null)
+[ "$has_gnudate" ] && 
+    $has_gnudate -Rud  "1970-01-01 UTC" 2> /dev/null >&2 || has_gnudate=
Bryan Larsen· Jul 16, 2005, 23:24 UTC · re: Bryan Larsen · lore

[PATCH 5/5] cogito: remove findutils dependency from Portfile

Gnu findutils (xargs) is no longer required; remove the dependency. Gnu coreutils is still required, but only if awk is not installed.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---
 Portfile.in |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Show changes to Portfile.in +1 −2
diff --git a/Portfile.in b/Portfile.in
--- a/Portfile.in
+++ b/Portfile.in
@@ -14,8 +14,7 @@ long_description  The git core, develope
 homepage          http://kernel.org/pub/software/scm/cogito/
 master_sites      http://kernel.org/pub/software/scm/cogito/
 configure	  {}
-depends_lib       bin:gcp:coreutils
-depends_lib       bin:gnuxargs:findutils
+depends_lib       bin:gstat:coreutils
 build.type        gnu
 destroot.type     gnu
 destroot.destdir  prefix=${prefix} DESTDIR=${destroot}

← back to recent threads