Would it be reasonable to default to gzip/gunzip instead of
compress/uncompress for the bootstap procedures?  Ten years ago
compress was ubiquitous and gzip rare, but today I think that's
changing, probably because of patent issues on compress.

I've run into several Linux distributions which either have no
compress and uncompress (recent Mandrake) or have a kludge from
the sharutils package (SCO Group Linux 4.0 from UnitedLinux)
which uncompresses, but won't compress.  This was easy enough to
deal with where it was entirely missing, but it took a fair
amount of time to figure out that /usr/bin/compress wasn't
working what with its error output buried in a uuencoded script.

I've done a minor hack on the openpkg.boot script from the
current openpkg-20030103.src.rpm which looks for a working
compress or gzip immediately, and quits with an appropriate
message if it can't find one.

Now if I can figure out how to build the bootstrap src.sh file, I
can test this thing :-).

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``It is better to die on your feet than to live on your knees!''
    -- Emiliano Zapata.
--- openpkg.boot.orig	2003-01-03 10:00:46.000000000 -0800
+++ openpkg.boot	2003-01-09 13:14:02.000000000 -0800
@@ -21,6 +21,41 @@
 
 me="openpkg.boot"
 
+#
+# Bill Campbell <[EMAIL PROTECTED]> fixes for compress/uncompress
+#
+# Do this very early so that we know whether it's worthwhile to attempt
+# a build.  There's no point in wasting time if we can't compress.
+#
+# Some recent Linux distributions have no compress or uncompress, or
+# if they do, the uncompress is from sharutils, and compress doesn't
+# work at all.
+#
+# T This is a test file since we need something to compress
+progname=`dirname $0`/`basename $0`
+suffix=$$
+tmpfile=/tmp/testcompress.$suffix.Z
+#   determine compression tool
+compress=""
+for t in compress gzip; do #{
+	for p in `IFS=":"; echo . $PATH /bin /sbin /usr/bin /usr/sbin`; do #{
+		if [ -f "$p/$t" ]; then #{
+			compress="$p/$t"
+			if [ ".$t" = .gzip ]; then #{
+				compress="$compress -S.Z"
+			fi #}
+			$compress < $progname > $tmpfile && {
+				break
+			}
+			compress=''
+		fi #}
+	done #}
+done #}
+rm -f $tmpfile 2>/dev/null
+if [ ".$compress" = . ]; then
+    echo "$0:FAILED: required gzip or compress tool not found"
+    exit 1
+fi
 ##
 ##  command line handling
 ##
@@ -95,7 +130,6 @@
 sh ./shtool echo -e "%BOpenPKG Bootstrap Procedure%b"
 echo "++ bootstrap version: $version-$release"
 echo "++ user/group pairs: $susr/$sgrp $musr/$mgrp $rusr/$rgrp $nusr/$ngrp"
-
 ##
 ##   optionally roll just a bootstrap source package
 ##
@@ -142,7 +176,7 @@
     rm -f $tmpdir/.sh
     sed <$srcdir/aux.wrapsrc.sh >$pkgdir/$name-$version-$release.src.sh \
         -e "s;@DIR@;$name-$version-$release.src;" -e "s;@TGZ@;$name-$version-$release.src.tar.Z;"
-    (cd $tmpdir && tar cf - *) | compress |\
+    (cd $tmpdir && tar cf - *) | $compress |\
     uuencode $name-$version-$release.src.tar.Z |\
         dd bs=64000 2>/dev/null >>$pkgdir/$name-$version-$release.src.sh
     exit 0
@@ -476,7 +510,7 @@
 done
 ( cd $RPM_BUILD_ROOT$prefix;
   $RPM_BUILD_ROOT$prefix/lib/openpkg/tar --no-recursion -cf - $files) |\
-compress | uuencode openpkg-$v.$t.tar.Z >>$dstdir/openpkg-$v.$t.sh
+$compress | uuencode openpkg-$v.$t.tar.Z >>$dstdir/openpkg-$v.$t.sh
 
 #   cleanup
 echo "++ cleaning up"

Reply via email to