Improve the formatting in the mkdmg script.

master
dak180 2012-11-24 15:21:31 -05:00
parent 014cc2c666
commit 8a96e0a34a
1 changed files with 59 additions and 54 deletions

View File

@ -1,13 +1,13 @@
#!/bin/bash
# Config
simgfl="http://downloads.sourceforge.net/project/warzone2100/build-tools/mac/wztemplate.sparseimage"
simgfl="http://downloads.sf.net/project/warzone2100/build-tools/mac/wztemplate.sparseimage"
simgflnme="wztemplate.sparseimage"
simgflmd5="da10e06f2b9b2b565e70dd8e98deaaad"
sequence="http://downloads.sourceforge.net/project/warzone2100/warzone2100/Videos/high-quality-en/sequences.wz"
sequence="http://downloads.sf.net/project/warzone2100/warzone2100/Videos/high-quality-en/sequences.wz"
sequencenme="sequences.wz"
sequencemd5="9a1ee8e8e054a0ad5ef5efb63e361bcc"
sequencelo="http://downloads.sourceforge.net/project/warzone2100/warzone2100/Videos/standard-quality-en/sequences.wz"
sequencelo="http://downloads.sf.net/project/warzone2100/warzone2100/Videos/standard-quality-en/sequences.wz"
sequencelonme="sequences-lo.wz"
sequencelomd5="ab2bbc28cef2a3f2ea3c186e18158acd"
relbuild="${CONFIGURATION_BUILD_DIR}/"
@ -20,7 +20,7 @@ if [ ! "${CONFIGURATION}" = "Release" ]; then
fi
# codesign setup
signd () {
function signd {
if [ ! -z "${CODE_SIGN_IDENTITY}" ]; then
# Local Config
local idetd="${CODE_SIGN_IDENTITY}"
@ -47,10 +47,10 @@ signd () {
}
# Check our sums
ckmd5 () {
function ckmd5 {
local FileName="${1}"
local MD5Sum="${2}"
local MD5SumLoc=`md5 -q "${FileName}"`
local MD5SumLoc="$(md5 -q "${FileName}")"
if [ -z "${MD5SumLoc}" ]; then
echo "error: Unable to compute md5 for ${FileName}" >&2
exit 1
@ -61,54 +61,54 @@ ckmd5 () {
}
# Make a dir and get the sparseimage
mkdir -p "$dmgout"
cd "$dmgout"
if [ ! -f "$simgflnme" ]; then
echo "Fetching $simgfl"
if ! curl -L -O --connect-timeout "30" "$simgfl"; then
echo "error: Unable to fetch $simgfl" >&2
mkdir -p "${dmgout}"
cd "${dmgout}"
if [ ! -f "${simgflnme}" ]; then
echo "Fetching ${simgfl}"
if ! curl -L -O --connect-timeout "30" "${simgfl}"; then
echo "error: Unable to fetch ${simgfl}" >&2
exit 1
fi
ckmd5 "${simgflnme}" "${simgflmd5}"
else
echo "$simgflnme already exists, skipping"
echo "${simgflnme} already exists, skipping"
fi
# Get the sequences
# Comment out the following to skip the high qual seq
# if [ ! -f "$sequencenme" ]; then
# echo "Fetching $sequencenme"
# if ! curl -L --connect-timeout "30" -o "$sequencenme" "$sequence"; then
# echo "error: Unable to fetch $sequence" >&2
# if [ ! -f "${sequencenme}" ]; then
# echo "Fetching ${sequencenme}"
# if ! curl -L --connect-timeout "30" -o "${sequencenme}" "${sequence}"; then
# echo "error: Unable to fetch ${sequence}" >&2
# exit 1
# fi
# ckmd5 "$sequencenme" "$sequencemd5"
# ckmd5 "${sequencenme}" "${sequencemd5}"
# else
# echo "$sequencenme already exists, skipping"
# echo "${sequencenme} already exists, skipping"
# fi
#
# Comment out the following to skip the low qual seq
# if [ ! -f "$sequencelonme" ]; then
# echo "Fetching $sequencelonme"
# if [ ! -f "${sequencelonme}" ]; then
# echo "Fetching ${sequencelonme}"
# if [ -f "/Library/Application Support/Warzone 2100/sequences.wz" ]; then
# cp "/Library/Application Support/Warzone 2100/sequences.wz" "$sequencelonme"
# elif ! curl -L --connect-timeout "30" -o "$sequencelonme" "$sequencelo"; then
# echo "error: Unable to fetch $sequencelo" >&2
# cp -a "/Library/Application Support/Warzone 2100/sequences.wz" "${sequencelonme}"
# elif ! curl -L --connect-timeout "30" -o "${sequencelonme}" "$sequencelo"; then
# echo "error: Unable to fetch ${sequencelo}" >&2
# exit 1
# fi
# ckmd5 "$sequencelonme" "$sequencelomd5"
# ckmd5 "${sequencelonme}" "${sequencelomd5}"
# else
# echo "$sequencelonme already exists, skipping"
# echo "${sequencelonme} already exists, skipping"
# fi
#
# Copy over the app
cd ../../
echo "Copying the app cleanly."
rm -r -f $dmgout/Warzone.app
if ! tar -c --exclude '*.svg' --exclude 'Makefile*' --exclude 'makefile*' --exclude '.DS_Store' --exclude '.MD5SumLoc' -C "${CONFIGURATION_BUILD_DIR}" Warzone.app | tar -xC $dmgout; then
rm -r -f ${dmgout}/Warzone.app
if ! tar -c --exclude '*.svg' --exclude 'Makefile*' --exclude 'makefile*' --exclude '.DS_Store' --exclude '.MD5SumLoc' -C "${CONFIGURATION_BUILD_DIR}" Warzone.app | tar -xC ${dmgout}; then
echo "error: Unable to copy the app" >&2
exit 1
fi
@ -126,7 +126,7 @@ cd Warzone.app/Contents/Resources/data/
echo "== Compressing base.wz =="
if [ -d base/ ]; then
cd base/
zip -r ../base.wz *
zip -r -q ../base.wz *
cd ..
rm -rf base/
fi
@ -134,17 +134,17 @@ fi
echo "== Compressing mp.wz =="
if [ -d mp/ ]; then
cd mp/
zip -r ../mp.wz *
zip -r -q ../mp.wz *
cd ..
rm -rf mp/
fi
cd mods/
modlst=`\ls -1`
modlst="$(\ls -1)"
for moddr in ${modlst}; do
if [ -d ${moddr} ]; then
cd ${moddr}
if [ -d "${moddr}" ]; then
cd "${moddr}"
if [ "${moddr}" = "campaign" ]; then
sbtyp=".cam"
elif [ "${moddr}" = "global" ]; then
@ -156,12 +156,12 @@ for moddr in ${modlst}; do
else
sbtyp=""
fi
modlstd=`ls -1`
modlstd="$(\ls -1)"
for modwz in ${modlstd}; do
if [ -d ${modwz} ]; then
if [ -d "${modwz}" ]; then
echo "== Compressing ${modwz}${sbtyp}.wz =="
cd ${modwz}
zip -r ../${modwz}${sbtyp}.wz *
cd "${modwz}"
zip -r -q ../${modwz}${sbtyp}.wz *
cd ..
rm -rf "${modwz}/"
fi
@ -179,40 +179,45 @@ mv warzone2100-dSYM temp/warzone2100-dSYM
mv warzone2100-dSYM.tar.gz out/warzone2100-dSYM.tar.gz
echo "== Creating DMG =="
cp wztemplate.sparseimage temp/wztemplatecopy.sparseimage
cp -a wztemplate.sparseimage temp/wztemplatecopy.sparseimage
hdiutil resize -size 220m temp/wztemplatecopy.sparseimage
mountpt=`hdiutil mount temp/wztemplatecopy.sparseimage | tr -d "\t" | sed -E 's:(/dev/disk[0-9])( +)(/Volumes/Warzone 2100):\1:'`
cp -a Warzone.app/* /Volumes/Warzone\ 2100/Warzone.app
hdiutilOut="$(hdiutil mount temp/wztemplatecopy.sparseimage | tr -d "\t")"
mountpnt="$(echo "${hdiutilOut}" | sed -E 's:(/dev/disk[0-9])( +)(/Volumes/Warzone 2100):\1:')"
mountpth="$(echo "${hdiutilOut}" | sed -E 's:(/dev/disk[0-9])( +)::')"
cp -a Warzone.app/* "${mountpth}/Warzone.app"
signd
# hdiutil detach `expr match "$mountpt" '\(^[^ ]*\)'`
hdiutil detach "$mountpt"
hdiutil detach "${mountpnt}"
hdiutil convert temp/wztemplatecopy.sparseimage -format UDZO -o out/warzone2100-novideo.dmg
if [ -f "$sequencelonme" ]; then
if [ -f "${sequencelonme}" ]; then
echo "== Creating LQ DMG =="
hdiutil resize -size 770m temp/wztemplatecopy.sparseimage
mountpt=`hdiutil mount temp/wztemplatecopy.sparseimage | tr -d "\t" | sed -E 's:(/dev/disk[0-9])( +)(/Volumes/Warzone 2100):\1:'`
cp sequences-lo.wz /Volumes/Warzone\ 2100/Warzone.app/Contents/Resources/data/sequences.wz
hdiutilOut="$(hdiutil mount temp/wztemplatecopy.sparseimage | tr -d "\t")"
mountpnt="$(echo "${hdiutilOut}" | sed -E 's:(/dev/disk[0-9])( +)(/Volumes/Warzone 2100):\1:')"
mountpth="$(echo "${hdiutilOut}" | sed -E 's:(/dev/disk[0-9])( +)::')"
rm "${mountpth}/Warzone.app/Contents/Resources/data/sequences.wz"
cp -a sequences-lo.wz "${mountpth}/Warzone.app/Contents/Resources/data/sequences.wz"
signd
# hdiutil detach `expr match "$mountpt" '\(^[^ ]*\)'`
hdiutil detach "$mountpt"
hdiutil detach "${mountpnt}"
hdiutil convert temp/wztemplatecopy.sparseimage -format UDZO -o out/warzone2100-lqvideo.dmg
else
echo "$sequencelonme does not exist, skipping"
echo "${sequencelonme} does not exist, skipping"
fi
if [ -f "$sequencenme" ]; then
if [ -f "${sequencenme}" ]; then
echo "== Creating HQ DMG =="
hdiutil resize -size 1145m temp/wztemplatecopy.sparseimage
mountpt=`hdiutil mount temp/wztemplatecopy.sparseimage | tr -d "\t" | sed -E 's:(/dev/disk[0-9])( +)(/Volumes/Warzone 2100):\1:'`
rm /Volumes/Warzone\ 2100/Warzone.app/Contents/Resources/data/sequences.wz
cp sequences.wz /Volumes/Warzone\ 2100/Warzone.app/Contents/Resources/data/sequences.wz
hdiutilOut="$(hdiutil mount temp/wztemplatecopy.sparseimage | tr -d "\t")"
mountpnt="$(echo "${hdiutilOut}" | sed -E 's:(/dev/disk[0-9])( +)(/Volumes/Warzone 2100):\1:')"
mountpth="$(echo "${hdiutilOut}" | sed -E 's:(/dev/disk[0-9])( +)::')"
rm "${mountpth}/Warzone.app/Contents/Resources/data/sequences.wz"
cp -a sequences-lo.wz "${mountpth}/Warzone.app/Contents/Resources/data/sequences.wz"
signd
hdiutil detach "$mountpt"
hdiutil detach "${mountpnt}"
hdiutil convert temp/wztemplatecopy.sparseimage -format UDZO -o out/warzone2100-hqvideo.dmg
else
echo "$sequencenme does not exist, skipping"
echo "${sequencenme} does not exist, skipping"
fi
echo "== Cleaning up =="