From 3111f2e690d3045957940130b92101e79b2d65d3 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 21 Feb 2010 03:30:53 -0800 Subject: [PATCH] Rewrite dist scripts for so many reasons. --- dist/make-c-files | 97 -------- dist/make-dist-files | 214 ++++------------- dist/make-doc-files | 70 ++++++ dist/{release-prefix => make-liarc-files} | 47 ++-- dist/make-src-files | 133 +++-------- dist/shared.sh | 266 ++++++++++++++++++++++ 6 files changed, 433 insertions(+), 394 deletions(-) delete mode 100644 dist/make-c-files create mode 100755 dist/make-doc-files rename dist/{release-prefix => make-liarc-files} (58%) create mode 100644 dist/shared.sh diff --git a/dist/make-c-files b/dist/make-c-files deleted file mode 100644 index c4a6846a8..000000000 --- a/dist/make-c-files +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -# -# Copyright 2007 Massachusetts Institute of Technology -# -# This file is part of MIT/GNU Scheme. -# -# MIT/GNU Scheme is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# MIT/GNU Scheme is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with MIT/GNU Scheme; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. - -set -e - -if [ $# -gt 3 ]; then - echo "usage: ${0} [TYPE [VERSION [DESTINATION]]]" - exit 1 -fi - -TYPE="${1:-std}" -VERSION="${2}" -DESTINATION="${3}" - -case "${TYPE}" in -(6001 | all | std) - ;; -(snapshot) - [ "${VERSION}" ] || VERSION="snapshot" - ;; -(*) - echo "Unknown distribution type: ${TYPE}" - echo "Valid types: std all 6001 snapshot" - exit 1 - ;; -esac - -if [ "${VERSION}" = "snapshot" ]; then - VERSION=$(date +%Y%m%d) -fi - -DIST_DIR="/scheme/v7/dist" - -. "${DIST_DIR}/release-prefix" - -TL_DIR="$(pwd)" - -C_DIR_REL="$(get_release_prefix "${VERSION}")" -C_DIR="${TL_DIR}/${C_DIR_REL}" -SRC_FILE="${C_DIR}.tar.gz" -STAMP_C="${TL_DIR}/stamp-c" - -if [ ! -f "${SRC_FILE}" ]; then - echo "No source file: ${SRC_FILE}" - exit 1 -fi - -if [ ! -f "${STAMP_C}" ]; then - rm -rf "${C_DIR}" - - tar xzf "${SRC_FILE}" - - cd "${C_DIR}/src" - ./configure --enable-native-code=c - make c - make c-clean - - touch "${STAMP_C}" -fi - -cd "${TL_DIR}" - -tarfile="${C_DIR}-c.tar.gz" -zipfile="${C_DIR}-c.zip" - -rm -f "${tarfile}" -rm -f "${zipfile}" - -tar cvzf "${tarfile}" "${C_DIR_REL}" - -rm -rf "${C_DIR}/src/lib" -for S in $(find ${C_DIR} -type l); do - [ ! -r "${S}" ] && rm -f "${S}" -done - -zip -rl "${zipfile}" "${C_DIR_REL}" -chmod -w "${zipfile}" - -rm -rf "${STAMP_C}" "${C_DIR}" diff --git a/dist/make-dist-files b/dist/make-dist-files index afb43bf8b..f01912ce5 100755 --- a/dist/make-dist-files +++ b/dist/make-dist-files @@ -20,185 +20,53 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -set -e +# inputs: source tar, doc image tar +# outputs: scheme binary tars -if [[ ${#} -gt 1 ]]; then - echo "usage: ${0} [TYPE]" >&2 - exit 1 -fi +. "$(dirname "${0}")"/shared.sh +make_output_dir -TYPE=${1:-standard} - -case ${TYPE} in -(standard) - FOO=$(ls mit-scheme-*.zip) - if [[ ${FOO} =~ mit-scheme-([0-9.]+)\.zip ]]; then - VERSION=${BASH_REMATCH[1]} - else - echo "Unable to determine version number; maybe in wrong directory?" >&2 - exit 1 - fi - ;; -(snapshot) - VERSION=$(date +%Y%m%d) - ;; -(*) - echo "Unknown distribution type: ${TYPE}" >&2 - echo "Valid types: standard snapshot" >&2 - exit 1 - ;; -esac - -TL_DIR=$(pwd) -BUILD_ROOT=mit-scheme-${VERSION} -SRC_FILE=${BUILD_ROOT}.tar.gz -LOCAL_DIR=/usr/local -OUTPUT_DIR=.out - -if [[ ! -f ${SRC_FILE} ]]; then - echo "No source file: ${SRC_FILE}." >&2 - exit 1 -fi - -MKDIR=(install -d -m 755) -INSTALL=(install -p) -INSTALL_DATA=("${INSTALL[@]}" -m 644) - -"${MKDIR[@]}" "${OUTPUT_DIR}" - -fixup_perms () +build () { - chmod -R og-w "${1}" + local ARCH=${1} + my_configure --enable-native-code="${ARCH}" \ + --with-mcrypt=no --with-libpq=no --with-db-4=no + my_make } -DOC_BUILD_DIR=${BUILD_ROOT}-doc -DOC_IMAGE_DIR=${DOC_BUILD_DIR}-image -DOC_BUILD_OUT=${OUTPUT_DIR}/doc-build -DOC_IMAGE_OUT=${OUTPUT_DIR}/doc-image -STAMP_DOC_BUILD=${DOC_BUILD_DIR}.stamp -STAMP_DOC_IMAGE=${DOC_IMAGE_DIR}.stamp -if [[ ! -f ${STAMP_DOC_BUILD} ]]; then - echo "Building documentation" >&2 - - rm -rf "${BUILD_ROOT}" "${DOC_BUILD_DIR}" - tar xzf "${SRC_FILE}" - mv "${BUILD_ROOT}" "${DOC_BUILD_DIR}" - ( - set -e - cd "${DOC_BUILD_DIR}"/doc - ./configure - make - ) &> "${DOC_BUILD_OUT}" - touch "${STAMP_DOC_BUILD}" -fi - -if [[ ! -f ${STAMP_DOC_IMAGE} ]]; then - echo "Make images for documentation" >&2 -( - set -e - - # First build the image for binary distributions. - rm -rf "${DOC_IMAGE_DIR}" - ( - set -e - cd "${DOC_BUILD_DIR}"/doc - make install-info-gz \ - infodir="${TL_DIR}"/"${DOC_IMAGE_DIR}"/edwin/info - make install-html htmldir="${TL_DIR}"/"${DOC_IMAGE_DIR}"/doc - ) - "${INSTALL_DATA[@]}" "${DOC_BUILD_DIR}"/src/COPYING \ - "${DOC_IMAGE_DIR}"/doc/. - fixup_perms "${DOC_IMAGE_DIR}" - - # Then build the images for documentation tarballs. - DOC_FORMATS=(html info pdf ps) - IMAGE_DIR=${BUILD_ROOT}/doc - for FORMAT in "${DOC_FORMATS[@]}"; do - DOCFILE_BASE=${BUILD_ROOT}-doc-${FORMAT} - rm -rf "${BUILD_ROOT}" - "${MKDIR[@]}" "${IMAGE_DIR}" - ( - set -e - cd "${DOC_BUILD_DIR}"/doc - make install-"${FORMAT}" \ - "${FORMAT}"dir="${TL_DIR}"/"${IMAGE_DIR}" - ) - rm -f "${DOCFILE_BASE}".tar.gz - tar cvzf "${DOCFILE_BASE}".tar.gz "${IMAGE_DIR}" - rm -f "${DOCFILE_BASE}".zip - zip -r "${DOCFILE_BASE}".zip "${IMAGE_DIR}" - rm -rf "${BUILD_ROOT}" - chmod 444 "${DOCFILE_BASE}".* - done +make_image () +{ + local IMAGE_DIR=${TL_DIR}/${1} + my_make install DESTDIR="${IMAGE_DIR}" + my_mv "${IMAGE_DIR}"/usr/local/* "${IMAGE_DIR}"/. + my_rmdir "${IMAGE_DIR}"/usr/local + my_rmdir "${IMAGE_DIR}"/usr +} - touch "${STAMP_DOC_IMAGE}" - rm -rf "${DOC_BUILD_DIR}" -) &> "${DOC_IMAGE_OUT}" -fi +remove_unshipped_files () +{ + local IMAGE_DIR=${1} + local LIB_DIR=${IMAGE_DIR}/lib/mit-scheme-${2} + my_rm_rf "${IMAGE_DIR}"/bin "${LIB_DIR}"/lib + my_rm_f "${LIB_DIR}"/runtime.com "${LIB_DIR}"/macosx-starter +} for ARCH in i386 x86-64; do - BUILD_DIR=${BUILD_ROOT}-${ARCH} - SRC_DIR=${BUILD_DIR}/src - IMAGE_DIR=${BUILD_DIR}-image - TARFILE=${BUILD_DIR}.tar.gz - IMAGE_LOCAL=${IMAGE_DIR}${LOCAL_DIR} - IMAGE_BIN=${IMAGE_LOCAL}/bin - IMAGE_LIB=${IMAGE_LOCAL}/lib/mit-scheme-${ARCH} - STAMP_BUILD=${BUILD_DIR}.stamp - STAMP_IMAGE=${IMAGE_DIR}.stamp - STAMP_TAR=${BUILD_DIR}-tar.stamp - - if [[ ! -f ${STAMP_BUILD} ]];then - echo "Building binaries for arch ${ARCH}" >&2 - ( - set -e - rm -rf "${BUILD_DIR}" - tar xzf "${SRC_FILE}" - mv "${BUILD_ROOT}" "${BUILD_DIR}" - ( - set -e - cd "${SRC_DIR}" - ./configure --enable-native-code="${ARCH}" \ - --with-mcrypt=no --with-libpq=no --with-db-4=no - make - ) - rm -f "${SRC_DIR}"/lib/runtime.com - touch "${STAMP_BUILD}" - ) &> "${OUTPUT_DIR}"/"${ARCH}"-compile - fi - if [[ ! -f ${STAMP_IMAGE} ]]; then - echo "Making image for arch ${ARCH}" >&2 - ( - set -e - rm -rf "${IMAGE_DIR}" - ( - set -e - cd "${SRC_DIR}" - make install DESTDIR="${TL_DIR}"/"${IMAGE_DIR}" - ) - # Don't save system-specific files. - rm -rf "${IMAGE_BIN}" - rm -rf "${IMAGE_LIB}"/lib - rm -f "${IMAGE_LIB}"/macosx-starter - # Merge in doc files. - cp -pR "${DOC_IMAGE_DIR}"/* "${IMAGE_LIB}"/. - - fixup_perms "${IMAGE_DIR}" - touch "${STAMP_IMAGE}" - rm -rf "${BUILD_DIR}" - ) &> "${OUTPUT_DIR}"/"${ARCH}"-image - fi - if [[ ! -f ${STAMP_TAR} ]]; then - ( - set -e - rm -f "${TARFILE}" - cd "${IMAGE_LOCAL}" - tar cvzf "${TL_DIR}"/"${TARFILE}" * - chmod 444 "${TL_DIR}"/"${TARFILE}" - ) &> "${OUTPUT_DIR}"/"${ARCH}"-tar - touch "${STAMP_TAR}" - rm -rf "${IMAGE_DIR}" - fi + IMAGE_DIR=${DIST_DIR}-${ARCH} + OUT_ROOT=${BUILD_OUT}-${ARCH} + + notify "Building binaries for arch ${ARCH}" + unpack_dist + run_command "${OUT_ROOT}"-compile "${DIST_DIR}"/src build "${ARCH}" + + notify "Making image for arch ${ARCH}" + new_temp_dir "${IMAGE_DIR}" + run_command "${OUT_ROOT}"-image "${DIST_DIR}"/src make_image "${IMAGE_DIR}" + remove_unshipped_files "${IMAGE_DIR}" "${ARCH}" + unpack_doc_image_into "${IMAGE_DIR}"/lib/mit-scheme-"${ARCH}" + fixup_perms "${IMAGE_DIR}" + make_tar_file "${OUT_ROOT}" "${IMAGE_DIR}" + cleanup_temp_files done -rm -rf "${DOC_IMAGE_DIR}" -rm -f *.stamp + +notify "Success!" diff --git a/dist/make-doc-files b/dist/make-doc-files new file mode 100755 index 000000000..b12095dc6 --- /dev/null +++ b/dist/make-doc-files @@ -0,0 +1,70 @@ +#!/bin/bash +# +# Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, +# 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010 Massachusetts Institute of +# Technology +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. + +# inputs: source tar +# outputs: doc image tar, formatted doc tars + +. "$(dirname "${0}")"/shared.sh +make_output_dir + +BUILD_DIR=doc-build + +build_docs () +{ + my_configure + my_make +} + +make_image_dir () +{ + local DEST=${TL_DIR}/${DOC_IMAGE_DIR} + my_make install-info-gz infodir="${DEST}"/edwin/info + my_make install-html htmldir="${DEST}"/doc + my_install_data "${TL_DIR}"/"${BUILD_DIR}"/src/COPYING "${DEST}"/doc/. + fixup_perms "${DEST}" +} + +make_archive_dir () +{ + local FORMAT=${1} + my_make install-"${FORMAT}" "${FORMAT}"dir="${TL_DIR}"/"${DIST_DIR}"/doc +} + +notify "Building documentation" +unpack_dist_to "${BUILD_DIR}" +run_command "${DOC_OUT}"-build "${BUILD_DIR}"/doc build_docs + +notify "Making doc image for distributions" +new_temp_dir "${DOC_IMAGE_DIR}" +run_command "${DOC_OUT}"-image "${BUILD_DIR}"/doc make_image_dir +make_tar_file "${DOC_OUT}"-image "${DOC_IMAGE_DIR}" + +new_temp_dir "${DIST_DIR}" +for FORMAT in html info pdf; do + OUT=${DOC_OUT}-${FORMAT} + notify "Making archive for ${FORMAT}" + run_command "${OUT}" "${BUILD_DIR}"/doc make_archive_dir "${FORMAT}" + make_tar_file "${OUT}" "${DIST_DIR}"-doc-"${FORMAT}" "${DIST_DIR}"/doc + my_rm_rf "${DIST_DIR}" +done + +notify "Success!" diff --git a/dist/release-prefix b/dist/make-liarc-files similarity index 58% rename from dist/release-prefix rename to dist/make-liarc-files index d00039026..03f2098d4 100755 --- a/dist/release-prefix +++ b/dist/make-liarc-files @@ -1,8 +1,8 @@ -# -*- shell-script -*- +#!/bin/bash # # Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Massachusetts Institute of +# 2005, 2006, 2007, 2008, 2009, 2010 Massachusetts Institute of # Technology # # This program is free software; you can redistribute it and/or modify @@ -20,31 +20,26 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -get_release () -{ - local prefix - if [[ -n ${1} ]]; then - prefix=${1}/ - else - prefix= - fi - fgrep Release "${prefix}"src/runtime/version.scm \ - | awk 'BEGIN { OFS = "." } - NF == 4 { print $3, $4 } - NF == 5 { print $3, $4, $5 } - NF == 6 { print $3, $4, $5, $6 } - NF == 7 { print $3, $4, $5, $6, $7 }' \ - | tr -d \(\)\'\" -} +# inputs: source tar +# outputs: liarc tar -get_release_prefix () -{ - v="${1:-$(get_release)}" - echo "mit-scheme-${v}" -} +. "$(dirname "${0}")"/shared.sh +make_output_dir + +LIARC_DIR=${PROJECT_NAME}-c-${RELEASE} -get_release_tag () +compile_liarc_dist () { - v="${1:-$(get_release)}" - echo "release-$(echo "${v}" | tr . -)" + MIT_SCHEME_EXE=mit-scheme-native cmd etc/make-liarc-dist.sh } + +notify "Creating the liarc distribution directory" +unpack_dist_to "${LIARC_DIR}" + +notify "Compiling the liarc bootstrap files" +run_command "${LIARC_OUT}"-compile "${LIARC_DIR}"/src compile_liarc_dist + +notify "Creating liarc archive file" +make_tar_file "${LIARC_OUT}" "${LIARC_DIR}" + +notify "Success!" diff --git a/dist/make-src-files b/dist/make-src-files index 36cb54b59..534ff01c5 100755 --- a/dist/make-src-files +++ b/dist/make-src-files @@ -20,112 +20,49 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA. -set -e -umask 022 +# inputs: git source tree +# outputs: changelog, source tar, ucode tar -PROJECT_NAME=mit-scheme -PROGRAM=${0} +. "$(dirname "${0}")"/shared.sh +reset_output_dir -usage () -{ - echo "usage: ${PROGRAM} TYPE" >&2 - echo " TYPE must be 'snapshot' to specify today's date" >&2 - echo " or 'standard' to specify standard release" >&2 - exit 1 -} - -(( ${#} <= 1 )) || usage -TYPE=${1:-standard} - -# We assume that there's a git working tree here that's in the right state. -[[ -d ${PROJECT_NAME} ]] || usage - -# Make sure there's a change log for us to publish. -(cd "${PROJECT_NAME}"; etc/make-git-log) - -# Determine the appropriate release and tag info. -source "$(dirname "${PROGRAM}")"/release-prefix -case ${TYPE} in - snapshot) - RELEASE=$(date +%Y%m%d) - TAG=snapshot-${RELEASE} - ;; - standard) - RELEASE=$(get_release "${PROJECT_NAME}") - TAG=$(get_release_tag "${RELEASE}") - ;; - *) - usage - ;; -esac - -DIST_DIR=mit-scheme-${RELEASE} -LIARC_DIST_DIR=mit-scheme-c-${RELEASE} -CHANGELOG=changelog.txt -OUTPUT_DIR=.out - -# Set up trap to clean up any temporary files. -CLEANUP_BASE=$(pwd) -cleanup () -{ - cd "${CLEANUP_BASE}" - rm -rf "${DIST_DIR}" "${LIARC_DIST_DIR}" -} -trap cleanup EXIT SIGINT SIGQUIT SIGTERM -cleanup - -rm -rf "${OUTPUT_DIR}" -mkdir "${OUTPUT_DIR}" +notify "Creating the changelog" +my_rm_f "${CHANGELOG}" +run_command "${CHANGELOG}" "${SOURCE_TREE}" git log --name-status +make_read_only "${CHANGELOG}" -# Create the dist directory, a subset of the repo. -echo "Creating the distribution directory" -mkdir "${DIST_DIR}" "${DIST_DIR}"/etc +notify "Creating the distribution directory" +new_temp_dir "${DIST_DIR}" +my_mkdir "${DIST_DIR}"/etc for FILE in src doc "${CHANGELOG}" dist/Makefile; do - cp -pR "${PROJECT_NAME}"/"${FILE}" "${DIST_DIR}"/. + my_cp "${SOURCE_TREE}"/"${FILE}" "${DIST_DIR}"/. done -cp -pR "${PROJECT_NAME}"/etc/xscheme.el "${DIST_DIR}"/etc/. - -# Configure the dist directory. -echo "Configuring the distribution directory" -(cd "${DIST_DIR}"/src; ./Setup.sh) > "${OUTPUT_DIR}"/src-config 2>&1 -(cd "${DIST_DIR}"/doc; autoconf) > "${OUTPUT_DIR}"/doc-config 2>&1 - -# Clean up after autoconf. -find "${DIST_DIR}" -type d -name autom4te.cache | xargs rm -rf - -# Make sure permissions are reasonable. -find "${DIST_DIR}" -exec chmod go-w '{}' \; +my_cp "${SOURCE_TREE}"/etc/xscheme.el "${DIST_DIR}"/etc/. -# Now make the liarc dist directories. -echo "Creating the liarc distribution directories" -cp -pR "${DIST_DIR}" "${LIARC_DIST_DIR}" +# Clean up dot files from source tree +my_find "${DIST_DIR}" -name '.*' -exec rm -f '{}' \; -# The liarc dist requires additional setup. -echo "Compiling the liarc bootstrap files" -(cd "${LIARC_DIST_DIR}"/src; MIT_SCHEME_EXE=mit-scheme-native etc/make-liarc-dist.sh) \ - > "${OUTPUT_DIR}"/liarc-compile 2>&1 - -# OK, we've built the directories, time to build the output files. -echo "Building distribution archive files" -TAR_FILE=${DIST_DIR}.tar.gz -LIARC_FILE=${LIARC_DIST_DIR}.tar.gz -ZIP_FILE=${DIST_DIR}.zip -UCODE_FILE=${DIST_DIR}-ucode.tar.gz -OUTPUTS=("${TAR_FILE}" "${LIARC_FILE}" "${ZIP_FILE}" "${UCODE_FILE}" "${CHANGELOG}") +reconf () +{ + if [[ -f configure ]]; then + my_configure + my_make distclean + else + cmd autoconf + fi +} -rm -f "${OUTPUTS[@]}" +notify "Configuring the distribution directory" +run_command "${SRC_OUT}"-config "${DIST_DIR}"/src ./Setup.sh +run_command "${DOC_OUT}"-config "${DIST_DIR}"/doc reconf -tar czf "${TAR_FILE}" "${DIST_DIR}" -tar czf "${LIARC_FILE}" "${LIARC_DIST_DIR}" -tar czf "${UCODE_FILE}" "${DIST_DIR}"/src/COPYING "${DIST_DIR}"/src/microcode -cp -p "${DIST_DIR}"/"${CHANGELOG}" . +# Clean up after autoconf +my_find "${DIST_DIR}" -type d -name autom4te.cache -exec rm -rf '{}' \; +fixup_perms "${DIST_DIR}" -rm -rf "${DIST_DIR}"/src/lib -# zip will complain if we have any dangling symlinks. -for S in $(find "${DIST_DIR}" -type l); do - [[ ! -r ${S} ]] && rm -f "${S}" -done -zip -rlq "${ZIP_FILE}" "${DIST_DIR}" +notify "Creating archive files" +make_tar_file "${SRC_OUT}" "${DIST_DIR}" +make_tar_file "${SRC_OUT}"-ucode "${DIST_UCODE}" \ + "${DIST_DIR}"/src/COPYING "${DIST_DIR}"/src/microcode -chmod -w "${OUTPUTS[@]}" -echo "Success!" +notify "Success!" diff --git a/dist/shared.sh b/dist/shared.sh new file mode 100644 index 000000000..a04aaaf1d --- /dev/null +++ b/dist/shared.sh @@ -0,0 +1,266 @@ +# +# Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, +# 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009, 2010 Massachusetts Institute of +# Technology +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. + +set -e +umask 022 + +TL_DIR=$(pwd) +PROGRAM=${0} +PROJECT_NAME=mit-scheme +SOURCE_TREE=${PROJECT_NAME} + +usage () +{ + echo "usage: ${PROGRAM} TYPE" >&2 + echo " TYPE must be 'snapshot' to specify today's date" >&2 + echo " or 'standard' to specify standard release" >&2 + exit 1 +} + +(( ${#} <= 1 )) || usage +DIST_TYPE=${1:-standard} + +[[ -d ${SOURCE_TREE} ]] || usage + +get_release () +{ + fgrep Release "${SOURCE_TREE}"/src/runtime/version.scm \ + | awk 'BEGIN { OFS = "." } + NF == 4 { print $3, $4 } + NF == 5 { print $3, $4, $5 } + NF == 6 { print $3, $4, $5, $6 } + NF == 7 { print $3, $4, $5, $6, $7 }' \ + | tr -d \(\)\'\" +} + +case ${DIST_TYPE} in + (snapshot) + RELEASE=$(date +%Y%m%d) + + ;; + (standard) + RELEASE=$(get_release) + + ;; + (*) + usage + ;; +esac + +CHANGELOG=changelog.txt +TAR_SUFFIX=.tar.gz + +DIST_DIR=${PROJECT_NAME}-${RELEASE} +DOC_IMAGE_DIR=${DIST_DIR}-doc-image + +DIST_UCODE=${DIST_DIR}-ucode + +OUTPUT_DIR=${TL_DIR}/.out +SRC_OUT=${OUTPUT_DIR}/src +DOC_OUT=${OUTPUT_DIR}/doc +LIARC_OUT=${OUTPUT_DIR}/liarc +BUILD_OUT=${OUTPUT_DIR}/build + +CMD_TRACE= +cmd () +{ + [[ -n ${CMD_TRACE} ]] && echo ">>>>" "${@}" + "${@}" +} + +reset_output_dir () +{ + my_rm_rf "${OUTPUT_DIR}" + cmd mkdir "${OUTPUT_DIR}" +} + +make_output_dir () +{ + my_mkdir "${OUTPUT_DIR}" +} + +my_cp () +{ + cmd cp -pR "${@}" +} + +my_mv () +{ + cmd mv "${@}" +} + +my_rm_f () +{ + cmd rm -f "${@}" +} + +my_rm_rf () +{ + cmd rm -rf "${@}" +} + +my_rmdir () +{ + cmd rmdir "${@}" +} + +my_mkdir () +{ + cmd install -d -m 755 "${@}" +} + +my_install () +{ + cmd install -p "${@}" +} + +my_install_data () +{ + cmd my_install -m 644 "${@}" +} + +my_tar () +{ + local TAR_FILE=${1}${TAR_SUFFIX} + shift + cmd tar cvzf "${TAR_FILE}" "${@}" +} + +my_untar () +{ + local TAR_FILE=${1}${TAR_SUFFIX} + shift + cmd tar xzf "${TAR_FILE}" "${@}" +} + +my_configure () +{ + cmd ./configure "${@}" +} + +my_make () +{ + cmd make "${@}" +} + +my_find () +{ + cmd find "${@}" +} + +fixup_perms () +{ + cmd chmod -R og-w "${1}" +} + +make_read_only () +{ + cmd chmod 444 "${@}" +} + +notify () +{ + echo "${@}" +} + +run_command () +{ + local OUT_FILE=${1} + local DIR=${2} + shift 2 + (cd "${DIR}"; cmd "${@}") > "${OUT_FILE}" 2>&1 +} + +make_tar_file () +{ + local OUT_FILE=${1}-tar + local DIR=${2} + local TAR_FILE=${DIR}${TAR_SUFFIX} + shift 2 + if (( ${#} < 1 )); then + set "${DIR}" + fi + my_rm_f "${TAR_FILE}" + my_tar "${DIR}" "${@}" > "${OUT_FILE}" 2>&1 + make_read_only "${TAR_FILE}" +} + +unpack_dist_to () +{ + local DEST=${1} + guarantee_tar "${DIST_DIR}" + new_temp_dir "${DEST}" + unpack_into "${DIST_DIR}" "${DEST}" +} + +unpack_dist () +{ + guarantee_tar "${DIST_DIR}" + new_temp_file "${DIST_DIR}" + my_untar "${DIST_DIR}" +} + +guarantee_tar () +{ + guarantee_file "${1}""${TAR_SUFFIX}" +} + +guarantee_file () +{ + if [[ ! -f ${1} ]]; then + echo "No source file: ${1}" + exit 1 + fi +} + +unpack_doc_image_into () +{ + unpack_into "${DOC_IMAGE_DIR}" "${1}" +} + +unpack_into () +{ + my_untar "${1}" -C "${2}" --strip-components 1 +} + +# Keep track of temp files and clean them up. + +new_temp_file () +{ + TEMP_FILES+=("${@}") + my_rm_rf "${@}" +} + +new_temp_dir () +{ + new_temp_file "${1}" + my_mkdir "${1}" +} + +cleanup_temp_files () +{ + cd "${TL_DIR}" + my_rm_rf "${TEMP_FILES[@]}" + TEMP_FILES=() +} + +TEMP_FILES=() +trap cleanup_temp_files EXIT SIGINT SIGQUIT SIGTERM -- 2.25.1