Raymond Toy pushed to branch master at cmucl / cmucl
Commits: 4fce8c07 by Raymond Toy at 2024-09-01T15:13:49+00:00 Fix #352: New compression methods for distribution tarballs
- - - - - 40e553b6 by Raymond Toy at 2024-09-01T15:13:50+00:00 Merge branch 'issue-352-new-compression-for-dist' into 'master'
Fix #352: New compression methods for distribution tarballs
Closes #352
See merge request cmucl/cmucl!252 - - - - -
4 changed files:
- bin/make-dist.sh - bin/make-extra-dist.sh - bin/make-main-dist.sh - bin/make-src-dist.sh
Changes:
===================================== bin/make-dist.sh ===================================== @@ -12,10 +12,10 @@ # $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/tools/make-dist.sh,v 1.20 2011/04/11 16:34:49 rtoy Exp $
usage() { - echo "make-dist.sh: [-hbg] [-G group] [-O owner] [-I destdir] [-M mandir] [-A arch] [-V version] [-o OS] dir" + echo "make-dist.sh: [-h] [-C compress] [-G group] [-O owner] [-I destdir] [-M mandir] [-A arch] [-V version] [-o OS] dir" echo " -h This help" - echo " -b Use bzip2 compression" - echo " -g Use gzip compression" + echo " -C compress Compression method to use for the tar archives. Must be one of" + echo " bzip2, xz, or gzip. The default depends on the OS" 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" @@ -109,15 +109,20 @@ if expr "X${GIT_HASH}" : 'X[0-9][0-9][a-f]' > /dev/null; then DEFAULT_VERSION="${GIT_HASH}" fi
-while getopts "G:O:I:M:bghSA:o:V:?" arg +# Default compression is -J (xz). These variables are passed to the +# other scripts via the environmen, so export them. +COMPRESS=-J +COMPRESS_EXT=xz +COMPRESS_NAME=xz + +while getopts "C:G:O:I:M:hSA:o:V:?" arg do case $arg in + C) COMPRESS_ARG=$OPTARG ;; 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 ;; A) ARCH=$OPTARG ;; o) OS=$OPTARG ;; @@ -133,6 +138,27 @@ if [ $# -lt 1 ]; then usage fi
+# Verify that the -C option is valid +if [ -n "$COMPRESS_ARG" ]; then + case $COMPRESS_ARG in + bzip2) + COMPRESS=-j + COMPRESS_EXT=bz2 + COMPRESS_NAME=bzip2 + ;; + xz) # Defaults work + ;; + gzip) + COMPRESS=-z + COMPRESS_EXT=gz + COMPRESS_NAME=gzip + ;; + *) echo '-C option "'$COMPRESS_ARG'" must be one of bzip2, xz or gzip' + exit 1 + ;; + esac +fi + if [ -z "$VERSION" ]; then # If a default version exists, use it. Otherwise this is an # error---at least one of these must not be empty. @@ -171,21 +197,17 @@ fi echo cmucl-$VERSION-$ARCH-$OS ROOT=`dirname $0`
-# If no compression options given, default to bzip -if [ -z "$ENABLE_GZIP" -a -z "$ENABLE_BZIP" ]; then - ENABLE_BZIP="-b" -fi - -OPTIONS="${GROUP:+ -G ${GROUP}} ${OWNER:+ -O ${OWNER}} ${INSTALL_DIR:+ -I ${INSTALL_DIR}} $ENABLE_GZIP $ENABLE_BZIP" +GTAR_OPTS="-t ${GTAR:-tar}" +EXTRA_OPTS="${GROUP:+ -G ${GROUP}} ${OWNER:+ -O ${OWNER}}" +INSTALL_OPTS="${INSTALL_DIR:+ -I ${INSTALL_DIR}}" MANDIR="${MANDIR:+ -M ${MANDIR}}" +OPTIONS="${GTAR_OPTS} ${EXTRA_OPTS} ${INSTALL_OPTS} ${MANDIR}"
+set -x echo Creating distribution for $ARCH $OS -$ROOT/make-main-dist.sh $OPTIONS ${MANDIR} $TARGET $VERSION $ARCH $OS || exit 1 -$ROOT/make-extra-dist.sh $OPTIONS $TARGET $VERSION $ARCH $OS || exit 2 +$ROOT/make-main-dist.sh -C $COMPRESS -E $COMPRESS_EXT $OPTIONS ${MANDIR} $TARGET $VERSION $ARCH $OS || exit 1 +$ROOT/make-extra-dist.sh -C $COMPRESS -E $COMPRESS_EXT $OPTIONS $TARGET $VERSION $ARCH $OS || exit 2
if [ X"$MAKE_SRC_DIST" = "Xyes" ]; then - # If tar is not GNU tar, set the environment variable GTAR to - # point to GNU tar. - OPTIONS="${INSTALL_DIR:+ -I ${INSTALL_DIR}} $ENABLE_GZIP $ENABLE_BZIP" - $ROOT/make-src-dist.sh $OPTIONS -t ${GTAR:-tar} $VERSION + $ROOT/make-src-dist.sh -C $COMPRESS -E $COMPRESS_EXT ${GTAR_OPTS} ${INSTALL_OPTS} $VERSION fi
===================================== bin/make-extra-dist.sh ===================================== @@ -1,23 +1,57 @@ #!/bin/sh
-while getopts "G:O:I:bgh?" arg +usage() { + cat <<EOF +`basename $0` -C option -E ext [-t tar] [-I destdir] [-G group] [-O owner] + -h This help + -? This help + -t tar Tar program to use + -C option Tar option for compressing the tarball; required. + -E ext Extension to use for the tarball. Must be consistent with + -C option. Required. + -I destdir Install directly to given directory instead of creating a tarball + -G group Group to use + -O owner Owner to use + +This is generally called by make-dist.sh and not normally invoked by the user + +Create a tarball of the extra components for cmucl. This includes things like +CLX; Hemlock; CLM; contrib library not already included in the main +distribution; locale messages. +EOF + exit 1 +} + +GTAR=tar +while getopts "C:E:G:O:I:t:h?" arg do case $arg in + C) COMPRESS=$OPTARG ;; + E) COMPRESS_EXT=$OPTARG ;; G) GROUP="-g $OPTARG" ;; O) OWNER="-o $OPTARG" ;; I) INSTALL_DIR=$OPTARG ;; - b) ENABLE_BZIP=-b ;; - g) ENABLE_GZIP=-g ;; + t) GTAR=$OPTARG ;; h | ?) usage; exit 1 ;; esac done
shift `expr $OPTIND - 1`
+# -C and -E options are required +if [ -z "$COMPRESS" ]; then + echo "-C option is required" + exit 2 +fi + +if [ -z "$COMPRESS_EXT" ]; then + echo "-E option is required" + exit 2 +fi + if [ "$1" = "" -o "$2" = "" -o "$3" = "" -o "$4" = "" ] then - echo "Usage: $0 target-directory version arch os" - exit 1 + usage fi
if [ ! -d "$1" ] @@ -134,16 +168,7 @@ done 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 + $GTAR -C $DESTDIR $COMPRESS -cf cmucl-$VERSION-$ARCH-$OS.extra.tar.$COMPRESS_EXT lib
echo Cleaning $DESTDIR [ -d $DESTDIR ] && rm -rf $DESTDIR
===================================== bin/make-main-dist.sh ===================================== @@ -1,25 +1,61 @@ #!/bin/sh
-# set -x -while getopts "G:O:I:M:bgh?" arg +usage() { + cat <<EOF +`basename $0` -C option -E ext [-h?] [-t tar][-I destdir] [-G group] [-O owner] [-M mandir] + target-directory version arch os + -h This help + -? This help + -t tar Tar program to use + -C option Tar option for compressing the tarball; required. + -E ext Extension to use for the tarball. Must be consistent with + -C option. Required. + -I destdir Install directly to given directory instead of creating a tarball + -G group Group to use + -O owner Owner to use + -M mandir Install manpages in this subdirectory. Default is man/man1 + +This is generally called by make-dist.sh and not normally invoked by the user + +Create a tarball consisting of the main components needed to distribute +a binary installation of cmucl. This includes the C executable and support +libraries; the subsystems like Gray streams, and simple streams; external +formats; contribs like asdf and defsystem; manpages and READMEs." +EOF + exit 1 +} + +GTAR=tar +while getopts "C:E:G:O:I:M:t:h?" arg do case $arg in + C) COMPRESS=$OPTARG ;; + E) COMPRESS_EXT=$OPTARG ;; G) GROUP="-g $OPTARG" ;; O) OWNER="-o $OPTARG" ;; I) INSTALL_DIR=$OPTARG ;; M) MANDIR=$OPTARG ;; - b) ENABLE_BZIP=-b ;; - g) ENABLE_GZIP=-g ;; + t) GTAR=$OPTARG ;; h | ?) usage; exit 1 ;; esac done
shift `expr $OPTIND - 1`
+# -C and -E options are required +if [ -z "$COMPRESS" ]; then + echo "-C option is required" + exit 2 +fi + +if [ -z "$COMPRESS_EXT" ]; then + echo "-E option is required" + exit 2 +fi + if [ "$1" = "" -o "$2" = "" -o "$3" = "" -o "$4" = "" ] then - echo "Usage: $0 target-directory version arch os" - exit 1 + usage fi
if [ ! -d "$1" ] @@ -178,16 +214,7 @@ 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 - . ) | \ - gzip -c > cmucl-$VERSION-$ARCH-$OS.tar.gz - fi - if [ -n "$ENABLE_BZIP" ]; then - echo " Compressing with bzip" - ( cd $DESTDIR >/dev/null ; tar cf - . ) | \ - bzip2 > cmucl-$VERSION-$ARCH-$OS.tar.bz2 - fi + $GTAR -C $DESTDIR $COMPRESS -cf cmucl-$VERSION-$ARCH-$OS.tar.$COMPRESS_EXT .
echo Cleaning $DESTDIR [ -d $DESTDIR ] && rm -rf $DESTDIR
===================================== bin/make-src-dist.sh ===================================== @@ -1,22 +1,31 @@ #!/bin/sh
usage() { - echo "make-src-dist.sh: [-bgh] [-t gnutar] [-I destdir] version" - echo " -h This help" - echo " -b Use bzip2 compression" - echo " -g Use gzip compression" - echo " -t tar Name/path to GNU tar" - echo " -I destdir Install directly to given directory instead of creating a tarball" - echo "" - echo 'Create a tar ball of the cmucl sources. The tarball is named ' - echo 'cmucl-src-$version.tar.bz2 (or gz if using gzip compression)' + cat <<EOF +`basename $0` -C option -E ext [-h?] [-t gnutar] [-I destdir] [version] + -h This help + -? This help + -t tar Name/path to GNU tar + -C option Tar option for compressing the tarball; required. + -E ext Extension to use for the tarball. Must be consistent with + -C option. Required. + -I destdir Install directly to given directory instead of creating a tarball + version The version. Defaults to the current date + +This is generally called by make-dist.sh and not normally invoked by the user + +Create a tar ball of the cmucl sources." +EOF + exit 1 }
-while getopts "bgh?t:I:" arg +GTAR=tar + +while getopts "C:E:h?t:I:" arg do case $arg in - b) ENABLE_BZIP=-b ;; - g) ENABLE_GZIP=-g ;; + C) COMPRESS=$OPTARG ;; + E) COMPRESS_EXT=$OPTARG ;; t) GTAR=$OPTARG ;; I) INSTALL_DIR=$OPTARG ;; h | ?) usage; exit 1 ;; @@ -25,10 +34,15 @@ done
shift `expr $OPTIND - 1`
-# If no compression given, default to gzip (on the assumption that -# that is available everywhere.) -if [ -z "$ENABLE_BZIP" -a -z "$ENABLE_GZIP" ]; then - ENABLE_GZIP=-b +# -C and -E options are required +if [ -z "$COMPRESS" ]; then + echo "-C option is required" + exit 2 +fi + +if [ -z "$COMPRESS_EXT" ]; then + echo "-E option is required" + exit 2 fi
# If no version is given, default to today's date @@ -39,20 +53,11 @@ else fi
echo Creating source distribution -if [ -n "$ENABLE_GZIP" ]; then - ZIP="gzip -c" - ZIPEXT="gz" -fi -if [ -n "$ENABLE_BZIP" ]; then - ZIP="bzip2" - ZIPEXT="bz2" -fi - GTAR_OPTIONS="--exclude=.git --exclude='*.pot.~*~'" if [ -z "$INSTALL_DIR" ]; then - echo " Compressing with $ZIP" - ${GTAR:-tar} ${GTAR_OPTIONS} -cf - bin src tests | ${ZIP} > cmucl-src-$VERSION.tar.$ZIPEXT + # echo " Compressing with $ZIP" + ${GTAR} ${GTAR_OPTIONS} ${COMPRESS} -cf cmucl-src-$VERSION.tar.$COMPRESS_EXT bin src tests else # Install in the specified directory - ${GTAR:-tar} ${GTAR_OPTIONS} -cf - bin src tests | (cd $INSTALL_DIR; ${GTAR:-tar} xf -) + ${GTAR} ${GTAR_OPTIONS} -cf - bin src tests | (cd $INSTALL_DIR; ${GTAR:-tar} xf -) fi
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/c1514a66cfc9cd04a2da582...