#! /bin/sh # ####################################################################### # makeDistribution - Make TclTkAqua distribution # # FILE: "makeDistribution" # created: 15/3/03 1:32:28 EST # # Author: Daniel A. Steffen # E-mail: # mail: Mathematics Departement # Macquarie University NSW 2109 Australia # www: # # RCS: @(#) $Id: makeDistribution,v 1.9 2005/06/04 13:22:52 das Exp $ # # BSD License: c.f. # # Copyright (c) 2002-2005, Daniel A. Steffen # All rights reserved. # # Redistribution and use in source and binary forms, with or # without modification, are permitted provided that the following # conditions are met: # # * Redistributions of source code must retain the above # copyright notice, this list of conditions and the # following disclaimer. # # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials # provided with the distribution. # # * Neither the name of Macquarie University nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # ####################################################################### if [ ${USER} != "root" ]; then echo "$0 needs to be run as root!" exit 1 fi TMP="${TMP_DIR:-$(pwd)}" SRC="${SRC_DIR:-${TMP}}" DMG="${DMG:-dmg}" USAGE="usage: $(basename "$0") [-n] [-b|-s] []" while getopts nbs o; do case $o in n) nodmg=1;; b) BI=1; package=TclTkAquaBI; size=50; targets=defaultdate;; s) SA=1; package=TclTkAquaStandalone; size=5;; \?) echo $USAGE; exit 2;; esac done shift $(($OPTIND - 1)) # Requires or two version arguments and at most one of -b or -s if [ $# -lt 1 -o $# -gt 2 -o \( -n "${BI}" -a -n "${SA}" \) ] ; then echo $USAGE; exit 2 fi : ${package:=TclTkAqua} version="$1" shortvers="$2" : ${shortvers:=${version}} name="${package}-${version}" : ${size:=10} : ${targets:=tcl} D="$(cd $(dirname $0); pwd)" C="${D}/.." I="${D}/../Installer" cd "${TMP}" mkdir -p "${DMG}" if [ -z "${nodmg}" ] ; then volume="/Volumes/${name}" rm -f "${TMP}/${name}".dmg ${D}/diskImageHelper create "${name}" "${size}" else volume="${DMG}/${name}" rm -rf "${volume}" mkdir -p "${volume}" fi substATSeqs ( ) { if (echo "$1" | egrep -q '\.rtfd$') ; then f="$1/TXT.rtf" rm -rf "$1/CVS" else f="$1" fi cvsdate=$(awk "/^(${targets}|defaultdate)( |\\t)/ {gsub(\"\\\"|\\\\\(|\\\\)\",\"\"); if(sub(/^[0-9A-Za-z]+( |\\t)+.*-D( |\\t)+/,\"\")) print}" \ ${D}/../cvsTag.conf | head -1) date=$(date -u '+%e/%b/%Y') os=$(awk '/ProductVersion/ {getline; split($0,a,"<[^>]*>"); split(a[2],b,"\."); print b[1]"."b[2]}' \ /System/Library/CoreServices/SystemVersion.plist) if [ -z "${cvsdate}" ]; then cvsdate="${date}"; fi sed -e "s|@DATE@|${date}|g" -e "s|@CVSDATE@|${cvsdate}|g" \ -e "s|@VERS@|${version}|g" -e "s|@SHORTVERS@|${shortvers}|g" \ -e "s|@PROJ@|${package}|g" -e "s|@OS@|${os}|g" "${f}" > "${f}.1" mv -f "${f}.1" "${f}" } transferTextFile ( ) { if [ -n "$1" ]; then if (echo "$1" | egrep -q '\.(html|rtf|rtfd)$') ; then ext=$(echo "$1" | awk -F\. '{print $NF}') echo " copying \"$(basename "$1")\" to \"$2.${ext}\"" pkgtxtf="${volume}/$2.${ext}" cp -RH "$1" "${pkgtxtf}" substATSeqs "${pkgtxtf}" else echo " converting \"$(basename "$1")\" to \"$2.rtf\"" pkgtxtf="${volume}/$2.rtf" toRtf "$1" "${pkgtxtf}" fi fi } transferInstallerFile ( ) { instf="$2" if [ -n "${instf}" -a -r "${instf}" ]; then echo " copying \"$1\"" pkginstf="${volume}/$1" cp -RH "${instf}" "${pkginstf}" if $(echo "$1" | egrep -q -v '\.(tiff|jpg|png|gif)$'); then substATSeqs "${pkginstf}" chmod -R a+x "${pkginstf}" fi fi } buildPackage ( ) { ${D}/buildPackage -m -v "${version}" -d "${volume}" -n "${package}" \ -w "${I}/$1/Welcome.rtfd" -r "${I}/$1/ReadMe.rtfd" -l "${I}/$1/License.rtf" \ -o "${I}/stats/postflight" -f "${I}/tcltkaqua-uninstall.pl" ${targets} cp -p -R "${volume}/${package}.mpkg/Contents/Resources/ReadMe.rtfd" "${volume}" cp -p -R "${volume}/${package}.mpkg/Contents/Resources/License.rtf" "${volume}" } DS_Stores ( ) { if [ -e "${I}/$1/DS_Store_Dmg" ] ; then cp "${I}/$1/DS_Store_Dmg" "${volume}/.DS_Store" fi if [ -e "${I}/$1/DS_Store_Pkgs" ] ; then cp "${I}/$1/DS_Store_Pkgs" "${volume}/Packages/.DS_Store" fi } chmod 1775 "${volume}" chown root:wheel "${volume}" case "${package}" in TclTkAqua) make ${EXTRA_MAKE_FLAGS} -C "${C}" package/core INSTALL_ROOT="${volume}/" PKG_ARCHIVE_DIR= RELOCATABLE= buildPackage "${package}" transferInstallerFile "${package} Uninstall.command" "${I}/TclTkAquaUninstall.command" DS_Stores "${package}" ;; TclTkAquaBI) r="Batteries-Included README"; l="${volume}/pkg_list"; rm -f "${l}" awk '/@PKG_LIST_START@/ {s=1; next}; /@PKG_LIST_END@/ {nextfile}; s==1 {print}' \ "${I}/${package}/${r}.html" > "${l}.in" make ${EXTRA_MAKE_FLAGS} -C "${C}" package INSTALL_ROOT="${volume}/" PKG_ARCHIVE_DIR= RELOCATABLE= PKG_LIST="${l}" buildPackage "${package}" transferTextFile "${I}/${package}/${r}.html" "${r}" awk '/@PKG_LIST_START@/ {nextfile}; {print}' "${volume}/${r}.html" > "${volume}/${r}.html.1" cat "${l}" >> "${volume}/${r}.html.1" awk '/@PKG_LIST_END@/ {s=1; next}; s==1 {print}' "${volume}/${r}.html" >> "${volume}/${r}.html.1" mv -f "${volume}/${r}.html.1" "${volume}/${r}.html"; rm -f "${l}"{,.in} transferInstallerFile "${package} Uninstall.command" "${I}/TclTkAquaUninstall.command" DS_Stores "${package}" ;; TclTkAquaStandalone) make ${EXTRA_MAKE_FLAGS} -C "${C}" destroot/standalone INSTALL_ROOT="${volume}/" transferTextFile "${I}/${package}/ReadMe.rtfd" ReadMe transferTextFile "${I}/${package}/License.rtf" License DS_Stores "${package}" ;; esac cp ${SRC}/tk/macosx/README "${volume}/TclTk Aqua README.txt" webloc="TclTkAqua Binary Distributions.webloc" touch "${volume}/${webloc}" cp "${I}/TclTkAquaBIHomepage.webloc.rsrc" "${volume}/${webloc}/rsrc" /Developer/Tools/SetFile -t ilht -c MACS "${volume}/${webloc}" if [ -z "${nodmg}" ] ; then ${D}/openUp "${volume}" ${D}/diskImageHelper freeze "${name}" chown `ls -ld . | awk '{print $3}'` "${name}".dmg mv -f "${name}".dmg ${DMG} fi echo "Done." echo