. "$(dirname "${0}")"/shared.sh
make_output_dir
+standard_args
BUILD_DIR=doc-build
}
notify "Building documentation"
-unpack_dist_to "${BUILD_DIR}"
+unpack_dist_file_to "${DIST_DIR}" "${BUILD_DIR}"
run_command "${DOC_OUT}"-build "${BUILD_DIR}"/doc build_docs
notify "Making doc image for distributions"
my_rm_rf "${DIST_DIR}"
done
-notify "Success!"
+notify_finished
. "$(dirname "${0}")"/shared.sh
make_output_dir
+standard_args
LIARC_DIR=${PROJECT_NAME}-c-${RELEASE}
}
notify "Creating the liarc distribution directory"
-unpack_dist_to "${LIARC_DIR}"
+unpack_dist_file_to "${DIST_DIR}" "${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!"
+notify_finished
. "$(dirname "${0}")"/shared.sh
make_output_dir
+standard_args
build ()
{
for ARCH in i386 x86-64; do
IMAGE_DIR=${DIST_DIR}-${ARCH}
- OUT_ROOT=${BUILD_OUT}-${ARCH}
+ OUT_ROOT=${NATIVE_OUT}-${ARCH}
notify "Building binaries for arch ${ARCH}"
- unpack_dist
+ unpack_dist_file_to "${DIST_DIR}" "${DIST_DIR}"
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}"
+ unpack_into_existing_dir "${DOC_IMAGE_DIR}" \
+ "${IMAGE_DIR}"/lib/mit-scheme-"${ARCH}"
fixup_perms "${IMAGE_DIR}"
make_tar_file "${OUT_ROOT}" "${IMAGE_DIR}"
cleanup_temp_files
done
-notify "Success!"
+notify_finished
. "$(dirname "${0}")"/shared.sh
reset_output_dir
+standard_args
notify "Creating the changelog"
my_rm_f "${CHANGELOG}"
notify "Creating the distribution directory"
new_temp_dir "${DIST_DIR}"
-my_mkdir "${DIST_DIR}"/etc
-for FILE in src doc "${CHANGELOG}" dist/Makefile; do
+my_cp "${CHANGELOG}" "${DIST_DIR}"/.
+for FILE in src doc dist/Makefile; do
my_cp "${SOURCE_TREE}"/"${FILE}" "${DIST_DIR}"/.
done
+my_mkdir "${DIST_DIR}"/etc
my_cp "${SOURCE_TREE}"/etc/xscheme.el "${DIST_DIR}"/etc/.
# Clean up dot files from source tree
run_command "${DOC_OUT}"-config "${DIST_DIR}"/doc reconf
# Clean up after autoconf
-my_find "${DIST_DIR}" -type d -name autom4te.cache -exec rm -rf '{}' \;
+find "${DIST_DIR}" -type d -name autom4te.cache | xargs rm -rf
fixup_perms "${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
+make_tar_file "${SRC_OUT}"-ucode "${UCODE_BASE}" \
+ "${DIST_DIR}"/src/COPYING "${DIST_DIR}"/src/etc "${DIST_DIR}"/src/microcode
-notify "Success!"
+notify_finished
--- /dev/null
+#!/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., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# inputs: ucode tar, scheme binary tars
+# outputs: system-specific tar
+
+system_args ()
+{
+ (( ${#} >= 3 )) || usage
+ DIST_TYPE=${1}
+ ARCH=${2}
+ SYSTEM=${3}
+}
+ARGS_FUNCTION=system_args
+
+system_usage ()
+{
+ echo "usage: ${PROGRAM} TYPE ARCH SYSTEM [OPTIONS]"
+ usage_arg_type
+ echo " ARCH must be 'i386' or 'x86-64'"
+ echo " SYSTEM is the operating system identifier"
+ echo " OPTIONS are passed to the configure script"
+}
+USAGE_FUNCTION=system_usage
+
+. "$(dirname "${0}")"/shared.sh
+make_output_dir
+
+shift 3
+
+OUT=${SYSTEM_OUT}-${ARCH}-${SYSTEM}
+ARCH_BASE=${DIST_DIR}-${ARCH}
+SYSTEM_BASE=${ARCH_BASE}-${SYSTEM}
+UCODE_DIR=${DIST_DIR}/src/microcode
+IMAGE_DIR=temp_image_dir
+LIB_DIR=lib/mit-scheme-"${ARCH}"
+
+compile ()
+{
+ my_configure --enable-native-code="${ARCH}" "${@}"
+ my_make
+}
+
+make_image ()
+{
+ make install DESTDIR="${TL_DIR}"/"${IMAGE_DIR}"
+}
+
+notify "Compiling executable"
+unpack_dist_file_to "${UCODE_BASE}" "${DIST_DIR}"
+run_command "${OUT}"-compile "${UCODE_DIR}" compile "${@}"
+
+notify "Making image directory"
+new_temp_dir "${IMAGE_DIR}"
+run_command "${OUT}"-image "${UCODE_DIR}" make_image
+unpack_dist_file_to "${ARCH_BASE}" "${SYSTEM_BASE}"
+my_mv "${IMAGE_DIR}"/usr/local/bin "${SYSTEM_BASE}"/.
+my_mv "${IMAGE_DIR}"/usr/local/"${LIB_DIR}"/lib "${SYSTEM_BASE}"/"${LIB_DIR}"/.
+
+notify "Making archive file"
+make_tar_file "${OUT}" "${SYSTEM_BASE}"
+
+notify_finished
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301, USA.
-set -e
+set -ae
umask 022
+# Capture standard out so we can send messages there even when it's
+# redirected.
+exec 3>&1
+
TL_DIR=$(pwd)
PROGRAM=${0}
PROJECT_NAME=mit-scheme
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
+ ${USAGE_FUNCTION:-standard_usage} >&2
exit 1
}
-(( ${#} <= 1 )) || usage
-DIST_TYPE=${1:-standard}
+standard_usage ()
+{
+ echo "usage: ${PROGRAM} TYPE"
+ usage_arg_type
+}
+
+usage_arg_type ()
+{
+ echo " TYPE must be 'snapshot' to specify today's date"
+ echo " or 'standard' to specify standard release"
+}
+
+standard_args ()
+{
+ (( ${#} <= 1 )) || usage
+ DIST_TYPE=${1:-standard}
+}
[[ -d ${SOURCE_TREE} ]] || usage
+${ARGS_FUNCTION:-standard_args} "${@}"
+
get_release ()
{
fgrep Release "${SOURCE_TREE}"/src/runtime/version.scm \
}
case ${DIST_TYPE} in
- (snapshot)
- RELEASE=$(date +%Y%m%d)
-
+ snapshot)
+ RELEASE=$(date +%Y%m%d)
;;
- (standard)
- RELEASE=$(get_release)
-
+ standard)
+ RELEASE=$(get_release)
;;
- (*)
+ *)
usage
;;
esac
TAR_SUFFIX=.tar.gz
DIST_DIR=${PROJECT_NAME}-${RELEASE}
+UCODE_BASE=${DIST_DIR}-ucode
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
+NATIVE_OUT=${OUTPUT_DIR}/native
+SYSTEM_OUT=${OUTPUT_DIR}/system
+
+notify ()
+{
+ echo "${@}" >&3
+}
+
+notify_finished ()
+{
+ notify "Success!"
+}
-CMD_TRACE=
cmd ()
{
- [[ -n ${CMD_TRACE} ]] && echo ">>>>" "${@}"
- "${@}"
+ if [[ -z ${CMD_TRACE} ]]; then
+ "${@}"
+ else
+ notify ">>>>" "${@}"
+ if [[ ${CMD_TRACE} != norun ]]; then
+ "${@}"
+ fi
+ fi
}
reset_output_dir ()
cmd chmod 444 "${@}"
}
-notify ()
+run_command ()
{
- echo "${@}"
+ local OUT_FILE=${1}
+ shift
+ run_command_helper "${@}" &> "${OUT_FILE}"
}
-run_command ()
+run_command_helper ()
{
- local OUT_FILE=${1}
- local DIR=${2}
- shift 2
- (cd "${DIR}"; cmd "${@}") > "${OUT_FILE}" 2>&1
+ local DIR=${1}
+ shift
+ pushd "${DIR}" &> /dev/null
+ cmd "${@}"
+ popd &> /dev/null
}
make_tar_file ()
set "${DIR}"
fi
my_rm_f "${TAR_FILE}"
- my_tar "${DIR}" "${@}" > "${OUT_FILE}" 2>&1
+ my_tar "${DIR}" "${@}" &> "${OUT_FILE}"
make_read_only "${TAR_FILE}"
}
-unpack_dist_to ()
+unpack_dist_file_to ()
{
- local DEST=${1}
- guarantee_tar "${DIST_DIR}"
+ local SOURCE=${1}
+ local DEST=${2}
+ guarantee_tar "${SOURCE}"
new_temp_dir "${DEST}"
- unpack_into "${DIST_DIR}" "${DEST}"
+ unpack_into_existing_dir "${SOURCE}" "${DEST}"
}
-unpack_dist ()
+unpack_into_existing_dir ()
{
- guarantee_tar "${DIST_DIR}"
- new_temp_file "${DIST_DIR}"
- my_untar "${DIST_DIR}"
+ my_untar "${1}" -C "${2}" --strip-components 1
}
guarantee_tar ()
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 ()
cleanup_temp_files ()
{
- cd "${TL_DIR}"
- my_rm_rf "${TEMP_FILES[@]}"
- TEMP_FILES=()
+ if [[ -z ${PRESERVE_TEMP_FILES} ]]; then
+ cd "${TL_DIR}"
+ my_rm_rf "${TEMP_FILES[@]}"
+ TEMP_FILES=()
+ fi
}
TEMP_FILES=()