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

8 messages from 2005-07-18 to 2005-07-20. Participants: Bryan Larsen, Petr Baudis.
Thread: https://gitlist.dev/t/1269

## Bryan Larsen, 2005-07-18 02:50

Subject: [PATCH 0/6] cogito: compatibility with OS X
Message-ID: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718025024.11198.10556.sendpatchset%40bryan-larsens-ibook-g4.local

```
This is a resend of my previous set of patches.

I have updated these patches with Junio's suggestion.

I have also added some documentation, a simple README.osx.

Once you have applied these patches, could you choose one of these 4
options, Junio?

1) send me the result of "make Portfile" on next release
2) attach the result of "make Portfile" to
http://bugzilla.opendarwin.org/show_bug.cgi?id=3949 on next release
3) upload Portfile's along with the .tar.gz's.
4) tell me you're doing none of the above's, and I'll do the process
manually.

2 of these 5 patches are unchanged from the previous post.  I have
attached them anyways to maintain the series.  Please let me know if
this is poor etiquette.

thanks,
Bryan

```

## Bryan Larsen, 2005-07-18 02:50

Subject: [PATCH 1/6] cogito: remove use of xargs -r, a non-portable GNU extension
Message-ID: <20050718025036.11198.93735.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718025036.11198.93735.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>

```
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(-)

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, 2005-07-18 02:50

Subject: [PATCH 2/6] cogito: remove use of cp -a, a non-portable GNU extension
Message-ID: <20050718025046.11198.10078.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718025046.11198.10078.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>

```
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(-)

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, 2005-07-18 02:51

Subject: [PATCH 3/6] cogito: try harder to find gnu stat
Message-ID: <20050718025057.11198.96144.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718025057.11198.96144.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>

```
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 |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -229,11 +229,16 @@ 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" ] && $has_stat -c %s / 2>/dev/null >&2 || has_stat=
+
+has_stat=
+for stat in "$(which gnustat)" "$(which gstat)" "$(which stat)" ; do
+    if ( [ $stat ] && $stat -c %s / 2> /dev/null >&2 ) ; then
+	has_stat=$stat
+	break
+    fi
+done
+
 has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)

```

## Bryan Larsen, 2005-07-18 02:51

Subject: [PATCH 4/6] cogito: try harder to find gnu date
Message-ID: <20050718025107.11198.93279.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718025107.11198.93279.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>

```
Look harder for gnu date, use if available.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 cg-Xlib |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

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
@@ -241,4 +241,12 @@ for stat in "$(which gnustat)" "$(which 
     fi
 done
 
-has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)
+has_gnudate=
+for date in "$(which gnudate)" "$(which gdate)" "$(which date)" ; do
+    if ( [ $date ] && $date -Rud  "1970-01-01 UTC" 2> /dev/null >&2 ) ; then
+	has_gnudate=$date
+	break
+    fi
+done
+
+

```

## Bryan Larsen, 2005-07-18 02:51

Subject: [PATCH 5/6] cogito: remove findutils dependency from Portfile
Message-ID: <20050718025119.11198.75892.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718025119.11198.75892.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>

```
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 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Portfile.in b/Portfile.in
--- a/Portfile.in
+++ b/Portfile.in
@@ -14,8 +14,8 @@ 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
+depends_lib	  lib:libz.dylib:zlib
 build.type        gnu
 destroot.type     gnu
 destroot.destdir  prefix=${prefix} DESTDIR=${destroot}

```

## Bryan Larsen, 2005-07-18 02:51

Subject: [PATCH 6/6] cogito: update documentation
Message-ID: <20050718025130.11198.34570.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050718025130.11198.34570.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>

```
Update the documentation to add a README.osx and update requirements.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 README     |    2 ++
 README.osx |   31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/README b/README
--- a/README
+++ b/README
@@ -45,6 +45,8 @@ The following tools are optional but str
 
 	libcrypto (OpenSSL)
 	rsync
+	gnu coreutils (the gnu versions of stat, date and cp are
+	           preferred over the BSD variants)
 
 
         Starting a Fresh GIT Repository
diff --git a/README.osx b/README.osx
new file mode 100644
--- /dev/null
+++ b/README.osx
@@ -0,0 +1,31 @@
+This version of Cogito should work on OS X and other BSD variants.
+
+To install on OS X:
+
+1) Install darwinports (http://darwinports.opendarwin.org/) 2) type
+"make Portfile" 3) type "sudo port install"
+
+You may have to deal with md5 mismatches.  Either adjust the md5sum in
+your new Portfile or place the new tarball in
+/opt/local/var/db/dports/distfiles/cogito.
+
+Caveats:
+
+cg-pull on a local repository requires cp -u, a non-portable gnu
+extension.  This means that cg-pull, cg-clone and cg-update from a
+local repository are broken.
+
+Workaround #1: Use rsync for local clones.  I.e.  "cg-clone
+rsync://localhost/dir" instead of "cg-clone dir".  This loses the disk
+space savings of normally gained by cg-clone.
+
+Workaround #2: Use gnu cp.  "cd /opt/local/bin; sudo ln -s gcp cp".
+
+Recommendations:
+
+The gnu versions of "stat" and "date" are preferred over their BSD
+variants.
+
+"patch", "diff", "merge", "curl" and "rysnc" are required.  OS X.4
+includes recent versions of these tools.  If you are not running X.4,
+you may wish to check this.

```

## Petr Baudis, 2005-07-20 09:19

Subject: Re: [PATCH 0/6] cogito: compatibility with OS X
Message-ID: <20050720091933.GG27102@pasky.ji.cz>
URL: https://gitlist.dev/e/20050720091933.GG27102%40pasky.ji.cz
In-Reply-To: <20050718025024.11198.10556.sendpatchset@bryan-larsens-ibook-g4.local>

```
Dear diary, on Mon, Jul 18, 2005 at 04:50:31AM CEST, I got a letter
where Bryan Larsen <bryanlarsen@yahoo.com> told me that...
> 3) upload Portfile's along with the .tar.gz's.

That's what we do with cogito.spec as well and it's fine. Just send me
an appropriate patch for the dist target.

> 2 of these 5 patches are unchanged from the previous post.  I have
> attached them anyways to maintain the series.  Please let me know if
> this is poor etiquette.

I think it's fine. :-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
If you want the holes in your knowledge showing up try teaching
someone.  -- Alan Cox

```
