1#!/bin/sh -e 2# 3# dist-module.sh - make release tarballs for one SVN module 4# 5# Largely based on dist-fink.sh, Copyright (c) 2001 Christoph Pfisterer. 6# Modified to use Subversion instead of CVS by Max Horn in 2007. 7# Modified to use git by Eugene Sandulenko in 2015. 8# 9# ScummVM is the legal property of its developers, whose names 10# are too numerous to list here. Please refer to the COPYRIGHT 11# file distributed with this source distribution. 12# 13# This program is free software; you can redistribute it and/or 14# modify it under the terms of the GNU General Public License 15# as published by the Free Software Foundation; either version 2 16# of the License, or (at your option) any later version. 17# 18# This program is distributed in the hope that it will be useful, 19# but WITHOUT ANY WARRANTY; without even the implied warranty of 20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21# GNU General Public License for more details. 22# 23# You should have received a copy of the GNU General Public License 24# along with this program; if not, write to the Free Software 25# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 26# 27 28### configuration 29 30scummvmrepo='https://github.com/scummvm/scummvm.git' 31toolsrepo='https://github.com/scummvm/scummvm-tools.git' 32 33### init 34 35if [ $# -lt 2 ]; then 36 echo "Usage: $0 <scummvm | scummvm-tools> <version-number> [<temporary-directory> [<tag>]]" 37 exit 1 38fi 39 40echo_n() { 41 printf "$@" 42} 43 44module=$1 45version=$2 46tmpdir=${3:-/tmp} 47tag=$4 48if [ -z "$tag" ]; then 49 tag="v$version" 50fi 51fullname="$module-$version" 52 53# Check modules 54case $module in 55scummvm) 56 gitrepo=$scummvmrepo 57;; 58scummvm-tools) 59 gitrepo=$toolsrepo 60;; 61*) 62 echo "Unknown module $module. Only scummvm or scummvm-tools are supported" 63 exit 1 64esac 65 66 67echo "packaging $module release $version, GIT tag $tag" 68 69### setup temp directory 70 71mkdir -p $tmpdir 72cd $tmpdir 73umask 022 74 75if [ -d $fullname ]; then 76 echo "There is a left-over directory in $tmpdir." 77 echo "Remove $tmpdir/$fullname, then try again." 78 exit 1 79fi 80 81### check code out from GIT 82 83echo "Cloning module $module from GIT:" 84git clone $gitrepo $fullname 85if [ ! -d $fullname ]; then 86 echo "GIT clone failed, directory $fullname doesn't exist!" 87 exit 1 88fi 89 90cd $tmpdir/$fullname 91 92echo_n "Checking out tag $tag..." 93if git checkout $tag --quiet 2>/dev/null; then 94 echo done 95else 96 echo "checking out tag $tag failed." 97 exit 1 98fi 99 100cd $tmpdir 101 102echo "Cleaning up .git directory" 103rm -rf $fullname/.git 104 105### roll the tarball 106 107echo "Creating tarball $fullname.tar..." 108rm -f $fullname.tar $fullname.tar.gz 109tar -cf $fullname.tar $fullname 110 111echo "Compressing (using gzip) tarball $fullname.tar.gz..." 112gzip -c9 $fullname.tar > $fullname.tar.gz 113if [ ! -f $fullname.tar.gz ]; then 114 echo "Packaging failed, $fullname.tar.gz doesn't exist!" 115 exit 1 116fi 117 118echo "Compressing (using bzip2) tarball $fullname.tar.bz2..." 119bzip2 -c9 $fullname.tar > $fullname.tar.bz2 120if [ ! -f $fullname.tar.bz2 ]; then 121 echo "Packaging failed, $fullname.tar.bz2 doesn't exist!" 122 exit 1 123fi 124 125echo "Compressing (using xz) tarball $fullname.tar.xz..." 126xz -c9 $fullname.tar > $fullname.tar.xz 127if [ ! -f $fullname.tar.xz ]; then 128 echo "Packaging to xz failed, $fullname.tar.xz doesn't exist!" 129 # But do not exit 130fi 131 132echo "Compressing (using lzip) tarball $fullname.tar.lz..." 133lzip -c9 $fullname.tar > $fullname.tar.lz 134if [ ! -f $fullname.tar.lz ]; then 135 echo "Packaging to lz failed, $fullname.tar.lz doesn't exist!" 136 # But do not exit 137fi 138 139echo "Zipping $fullname.zip..." 140zip -r9 $fullname.zip $fullname >/dev/null 141if [ ! -f $fullname.zip ]; then 142 echo "Packaging failed, $fullname.zip doesn't exist!" 143 exit 1 144fi 145 146 147### finish up 148 149echo "Done:" 150ls -l $fullname.tar.gz $fullname.tar.bz2 $fullname.tar.xz $fullname.tar.lz $fullname.zip 151md5sum $fullname.tar.gz $fullname.tar.bz2 $fullname.tar.xz $fullname.tar.lz $fullname.zip 152 153exit 0 154