From 3dcb8151f9858ed53b809f88098ffc06f027640b Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Mon, 29 Dec 2008 21:49:01 +0000
Subject: [PATCH] Add -I and -M options: -I) Install CMUCL directly to the
 given directory, instead of creating     a tarball -M) Specify which
 subdirectory the manpages should go.  Default is     man/man1.

make-dist.sh:
make-main-dist.sh:
o Recognize and handle -I and -M.

make-extra-dist.sh:
o Recognize and handle -I.
---
 tools/make-dist.sh       | 113 +++++++++++++++++++++++----------------
 tools/make-extra-dist.sh |  43 ++++++++-------
 tools/make-main-dist.sh  |  52 ++++++++++--------
 3 files changed, 121 insertions(+), 87 deletions(-)

diff --git a/tools/make-dist.sh b/tools/make-dist.sh
index d76f65571..258d75145 100755
--- a/tools/make-dist.sh
+++ b/tools/make-dist.sh
@@ -1,12 +1,14 @@
 #!/bin/sh
 
 usage() {
-    echo "make-dist.sh: [-hbg] [-G group] [-O owner] dir version arch os"
+    echo "make-dist.sh: [-hbg] [-G group] [-O owner] [-I destdir] [-M mandir] dir version [arch os]"
     echo "  -h           This help"
     echo "  -b           Use bzip2 compression"
     echo "  -g           Use gzip compression"
     echo "  -G group     Group to use"
     echo "  -O owner     Owner to use"
+    echo "  -I destdir   Install directly to given directory instead of creating a tarball"
+    echo "  -M mandir    Install manpages in this subdirectory.  Default is man/man1"
     echo "  -S           Create a source distribution (requires GNU tar)"
     echo "                 The compressed tar file is named cmucl-src-<VERSION>.tar.<ext>"
     echo "   dir         Directory where the build is located"
@@ -14,10 +16,11 @@ usage() {
     echo "   arch        Architecture (x86, sparc, etc.)"
     echo "   os          OS (linux, solaris8, etc.)"
     echo ""
-    echo "Make a CMUCL distribution consisting of two tar files.  One holds"
-    echo "the main files including the C runtime, the lisp core, and PCL library."
-    echo "The second tar file contains extra libraries such as CLX, CLM, and"
-    echo "Hemlock."
+    echo "If the -I option is given, directly install all of the files to the"
+    echo "specified directory.  Otherwise, Make a CMUCL distribution consisting"
+    echo "of two tar files.  One holds the main files including the C runtime,"
+    echo "the lisp core, and PCL library. The second tar file contains extra"
+    echo "libraries such as CLX, CLM, and Hemlock."
     echo ""
     echo "The tar files have the form cmucl-<version>-<arch>-<os>.tar.<c>"
     echo "and cmucl-<version>-<arch>-<os>.extra.tar.<c> where <version>,"
@@ -26,28 +29,7 @@ usage() {
     exit 1
 }
 
-while getopts "G:O:bghS?" arg
-do
-    case $arg in
-	G) GROUP=$OPTARG ;;
-	O) OWNER=$OPTARG ;;
-	b) ENABLE_BZIP=-b ;;
-	g) ENABLE_GZIP=-g  ;;
-        S) MAKE_SRC_DIST=yes ;;
-	h | \?) usage; exit 1 ;;
-    esac
-done
-	
-shift `expr $OPTIND - 1`
-
-# Figure out the architecture and OS
-
-if [ $# -lt 2 ]; then
-    usage
-else
-    # Figure out the architecture and OS
-    ARCH=
-    OS=
+def_arch_os () {
     case `uname -s` in
       SunOS)
 	  ARCH=sparcv9
@@ -65,13 +47,46 @@ else
 	      *) ARCH=ppc ;;
 	  esac
       esac
+}
 
-      if [ $# -eq 3 ]; then
-	  ARCH=$3
-      elif [ $# -eq 4 ]; then
-	  ARCH=$3
-	  OS=$4
-      fi
+while getopts "G:O:I:M:bghS?" arg
+do
+    case $arg in
+	G) GROUP=$OPTARG ;;
+	O) OWNER=$OPTARG ;;
+        I) INSTALL_DIR=$OPTARG ;;
+        M) MANDIR=$OPTARG ;;
+	b) ENABLE_BZIP=-b ;;
+	g) ENABLE_GZIP=-g  ;;
+        S) MAKE_SRC_DIST=yes ;;
+	h | \?) usage; exit 1 ;;
+    esac
+done
+	
+shift `expr $OPTIND - 1`
+
+# Figure out the architecture and OS
+ARCH=
+OS=
+
+if [ -n ${INSTALL_DIR} ]; then
+    # Doing direct installation
+    if [ $# -lt 1 ]; then
+	usage
+    else
+	def_arch_os
+    fi
+elif [ $# -lt 2 ]; then
+    usage
+else
+    # Figure out the architecture and OS
+    def_arch_os
+    if [ $# -eq 3 ]; then
+	ARCH=$3
+    elif [ $# -eq 4 ]; then
+	ARCH=$3
+	OS=$4
+    fi
 fi
 
 if [ ! -d "$1" ]
@@ -80,19 +95,25 @@ then
 	exit 2
 fi
 
-if [ -z "$ARCH" ]; then
-    echo "Unknown architecture.  Please specify one"
-    usage
-fi
+if [ -z "$INSTALL_DIR" ]; then
+    if [ -z "$ARCH" ]; then
+	echo "Unknown architecture.  Please specify one"
+	usage
+    fi
+
+    if [ -z "$OS" ]; then
+	echo "Unknown OS.  Please specify one"
+	usage
+    fi
+fi   
 
-if [ -z "$OS" ]; then
-    echo "Unknown OS.  Please specify one"
-    usage
-fi
-    
-  
 TARGET="`echo $1 | sed 's:/*$::'`"
-VERSION=$2
+
+if [ -z "$INSTALL_DIR" ]; then
+    VERSION=$2
+else
+    VERSION="today"
+fi
 
 ROOT=`dirname $0`
 
@@ -101,10 +122,10 @@ if [ -z "$ENABLE_GZIP" -a -z "$ENABLE_BZIP" ]; then
     ENABLE_BZIP="-b"
 fi
 
-OPTIONS="${GROUP:+ -G ${GROUP}} ${OWNER:+ -O ${OWNER}} $ENABLE_GZIP $ENABLE_BZIP"
+OPTIONS="${GROUP:+ -G ${GROUP}} ${OWNER:+ -O ${OWNER}} ${INSTALL_DIR:+ -I ${INSTALL_DIR}} $ENABLE_GZIP $ENABLE_BZIP"
 
 echo Creating distribution for $ARCH $OS
-$ROOT/make-main-dist.sh $OPTIONS $TARGET $VERSION $ARCH $OS || exit 1
+$ROOT/make-main-dist.sh $OPTIONS ${MANDIR:+ -M ${MANDIR}} $TARGET $VERSION $ARCH $OS || exit 1
 $ROOT/make-extra-dist.sh $OPTIONS $TARGET $VERSION $ARCH $OS || exit 2
 
 if [ X"$MAKE_SRC_DIST" = "Xyes" ]; then
diff --git a/tools/make-extra-dist.sh b/tools/make-extra-dist.sh
index 7f896f0d1..28db10b9e 100755
--- a/tools/make-extra-dist.sh
+++ b/tools/make-extra-dist.sh
@@ -1,10 +1,11 @@
 #!/bin/sh
 
-while getopts "G:O:bgh?" arg
+while getopts "G:O:I:bgh?" arg
 do
     case $arg in
 	G) GROUP="-g $OPTARG" ;;
 	O) OWNER="-o $OPTARG" ;;
+        I) INSTALL_DIR=$OPTARG ;;
 	b) ENABLE_BZIP=-b ;;
 	g) ENABLE_GZIP=-g  ;;
 	h | \?) usage; exit 1 ;;
@@ -25,7 +26,7 @@ then
 	exit 2
 fi
 
-DESTDIR=release
+DESTDIR=${INSTALL_DIR:-release}
 TARGET="`echo $1 | sed 's:/*$::'`"
 VERSION=$2
 ARCH=$3
@@ -49,8 +50,10 @@ then
 	PATH=/usr/ucb:$PATH
 fi
 
-echo Cleaning $DESTDIR
-[ -d $DESTDIR ] && rm -rf $DESTDIR
+if [ -z "$INSTALL_DIR" ]; then
+    echo Cleaning $DESTDIR
+    [ -d $DESTDIR ] && rm -rf $DESTDIR
+fi
 
 echo Installing extra components
 install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib
@@ -78,19 +81,21 @@ install ${GROUP} ${OWNER} -m 0755 src/hemlock/mh-scan $DESTDIR/lib/cmucl/lib/
 install ${GROUP} ${OWNER} -m 0755 $TARGET/motif/server/motifd \
 	$DESTDIR/lib/cmucl/lib/
 
-sync ; sleep 1 ; sync ; sleep 1 ; sync
-echo Tarring extra components
-if [ -n "$ENABLE_GZIP" ]; then
-    echo "  Compressing with gzip"
-    ( cd $DESTDIR >/dev/null ; tar cf - lib ) | \
-	gzip -c > cmucl-$VERSION-$ARCH-$OS.extra.tar.gz
-fi
-if [ -n "$ENABLE_BZIP" ]; then
-    echo "  Compressing with bzip"
-    ( cd $DESTDIR >/dev/null ; tar cf - lib ) | \
-	bzip2 > cmucl-$VERSION-$ARCH-$OS.extra.tar.bz2
-fi
+if [ -z "$INSTALL_DIR" ]; then
+    sync ; sleep 1 ; sync ; sleep 1 ; sync
+    echo Tarring extra components
+    if [ -n "$ENABLE_GZIP" ]; then
+	echo "  Compressing with gzip"
+	( cd $DESTDIR >/dev/null ; tar cf - lib ) | \
+	 gzip -c > cmucl-$VERSION-$ARCH-$OS.extra.tar.gz
+    fi
+    if [ -n "$ENABLE_BZIP" ]; then
+	echo "  Compressing with bzip"
+	( cd $DESTDIR >/dev/null ; tar cf - lib ) | \
+	 bzip2 > cmucl-$VERSION-$ARCH-$OS.extra.tar.bz2
+    fi
 
-echo Cleaning $DESTDIR
-[ -d $DESTDIR ] && rm -rf $DESTDIR
-echo Done
+    echo Cleaning $DESTDIR
+    [ -d $DESTDIR ] && rm -rf $DESTDIR
+    echo Done
+fi
diff --git a/tools/make-main-dist.sh b/tools/make-main-dist.sh
index 505394442..01ba2be2d 100755
--- a/tools/make-main-dist.sh
+++ b/tools/make-main-dist.sh
@@ -1,11 +1,13 @@
 #!/bin/sh
 
 # set -x
-while getopts "G:O:bgh?" arg
+while getopts "G:O:I:M:bgh?" arg
 do
     case $arg in
 	G) GROUP="-g $OPTARG" ;;
 	O) OWNER="-o $OPTARG" ;;
+        I) INSTALL_DIR=$OPTARG ;;
+        M) MANDIR=$OPTARG ;;
 	b) ENABLE_BZIP=-b ;;
 	g) ENABLE_GZIP=-g  ;;
 	h | \?) usage; exit 1 ;;
@@ -26,7 +28,8 @@ then
 	exit 2
 fi
 
-DESTDIR=release
+DESTDIR=${INSTALL_DIR:-release}
+MANDIR=${MANDIR:-man}
 TARGET="`echo $1 | sed 's:/*$::'`"
 VERSION=$2
 ARCH=$3
@@ -69,8 +72,11 @@ then
 	PATH=/usr/ucb:$PATH
 fi
 
-echo Cleaning $DESTDIR
-[ -d $DESTDIR ] && rm -rf $DESTDIR
+if [ -z "$INSTALL_DIR" ]; then
+    # Clean out DESTDIR, if we're not installing there.
+    echo Cleaning $DESTDIR
+    [ -d $DESTDIR ] && rm -rf $DESTDIR
+fi
 
 # set -x
 echo Installing main components
@@ -80,7 +86,7 @@ install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl
 install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib
 install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/subsystems
 install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/ext-formats
-install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/man/man1
+install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/${MANDIR}
 install ${GROUP} ${OWNER} -m 0755 $TARGET/lisp/lisp $DESTDIR/bin/
 if [ "$EXECUTABLE" = "true" ]
 then
@@ -117,9 +123,9 @@ do
 done
 
 install ${GROUP} ${OWNER} -m 0644 src/general-info/cmucl.1 \
-	$DESTDIR/man/man1/
+	$DESTDIR/${MANDIR}/
 install ${GROUP} ${OWNER} -m 0644 src/general-info/lisp.1 \
-	$DESTDIR/man/man1/
+	$DESTDIR/${MANDIR}/
 install ${GROUP} ${OWNER} -m 0644 src/general-info/README $DESTDIR/doc/cmucl/
 if [ -f src/general-info/release-$VERSION.txt ] 
 then
@@ -127,19 +133,21 @@ then
 		$DESTDIR/doc/cmucl/
 fi
 
-sync ; sleep 1 ; sync ; sleep 1 ; sync
-echo Tarring main components
-if [ -n "$ENABLE_GZIP" ]; then
-    echo "  Compressing with gzip"
-    ( cd $DESTDIR >/dev/null ; tar cf - bin doc lib man ) | \
-	gzip -c > cmucl-$VERSION-$ARCH-$OS.tar.gz
-fi
-if [ -n "$ENABLE_BZIP" ]; then
-    echo "  Compressing with bzip"
-    ( cd $DESTDIR >/dev/null ; tar cf - bin doc lib man ) | \
-	bzip2 > cmucl-$VERSION-$ARCH-$OS.tar.bz2
-fi
+if [ -z "$INSTALL_DIR" ]; then
+    sync ; sleep 1 ; sync ; sleep 1 ; sync
+    echo Tarring main components
+    if [ -n "$ENABLE_GZIP" ]; then
+	echo "  Compressing with gzip"
+	( cd $DESTDIR >/dev/null ; tar cf - bin doc lib `dirname $MANDIR` ) | \
+	  gzip -c > cmucl-$VERSION-$ARCH-$OS.tar.gz
+    fi
+    if [ -n "$ENABLE_BZIP" ]; then
+	echo "  Compressing with bzip"
+	( cd $DESTDIR >/dev/null ; tar cf - bin doc lib `dirname $MANDIR` ) | \
+	  bzip2 > cmucl-$VERSION-$ARCH-$OS.tar.bz2
+    fi
 
-echo Cleaning $DESTDIR
-[ -d $DESTDIR ] && rm -rf $DESTDIR
-echo Done
+    echo Cleaning $DESTDIR
+    [ -d $DESTDIR ] && rm -rf $DESTDIR
+    echo Done
+fi
-- 
GitLab