# # $Id: compressed.in,v 1.14 2003/09/23 16:40:24 jmmv Exp $ # Build compressed type distribution files. # # buildtool # Copyright (c) 2002, 2003 Julio M. Merino Vidal. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. 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. # 3. Neither the name of the author nor the names of contributors may # be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. # is_compressed() { case $1 in tar.gz|tgz|tar.bz2|tbz|zip) return 0 ;; *) return 1 ;; esac } make_compressed() { local fmt=$1 local dirname=${BT_PKG_NAME}-${BT_PKG_VERSION} local moved=no local curdir=$(pwd) local curbase=${curdir##*/} echo "${ProgName}: building compressed dist, type ${fmt}" cd .. if [ ! -d ${dirname} ]; then mv ${curbase} ${dirname} moved=yes fi echo -n "${dirname}.${fmt}: " case ${fmt} in tar.gz|tgz) compress_tar_gz ${dirname} ${fmt} ;; tar.bz2|tbz) compress_tar_bz2 ${dirname} ${fmt} ;; zip) compress_zip ${dirname} ${fmt} ;; esac [ ${moved} = yes ] && mv ${dirname} ${curbase} cd ${curdir} echo done. } compress_tar_gz() { tar cf - $1 | gzip -9 > "$1.$2" } compress_tar_bz2() { tar cf - $1 | bzip2 -9 > "$1.$2" } compress_zip() { zip -r9 "$1.$2" $1 2>&1 > /dev/null } # Local Variables: *** # mode: shell-script *** # End: *** # vim: syntax=sh