File: packageMacOSX

package info (click to toggle)
albumshaper 2.1-2.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,748 kB
  • ctags: 2,047
  • sloc: cpp: 20,875; ansic: 714; sh: 180; makefile: 52; xml: 8
file content (123 lines) | stat: -rwxr-xr-x 3,883 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh

#much of this was based on work provided at:
#http://www.kernelthread.com/mac/apme/archive/mkdmg.txt

VERSION=`cat ./src/config.h | awk '/ALBUMSHAPER_VERSION/ {print $3}' | sed s/\"//g`
MAJORVERSION=`cat ./src/config.h | awk '/ALBUMSHAPER_VERSION/ {print $3}' | sed s/\"//g | sed 's/\./ /' | awk '{print $1}'`

BUNDLE_SOURCE="build/AlbumShaper_Clean.app"
BUNDLE_NAME="Album Shaper ${MAJORVERSION}.app"
DISK_IMAGE="albumshaper_${VERSION}_mac.dmg"
MOUNTED_DISK_NAME="Album Shaper ${VERSION}"

#output function
croak()
{
  echo "$1"
}

#return error message
chkerror()
{
  if [ $? -ne 0 ]
  then
    echo "Error!"
    exit 1
  fi
}

#check binary does not depend on xslt, xml2, or qt
echo "Checking dependencies..."
if [ -n "`otool -L build/AlbumShaper.app/Contents/MacOS/AlbumShaper | egrep '(xslt.dylib|xml2.dylib|libqt.dylib)'`" ]; then

XSLT=`otool -L build/AlbumShaper.app/Contents/MacOS/AlbumShaper | grep xslt`
XML2=`otool -L build/AlbumShaper.app/Contents/MacOS/AlbumShaper | grep xml2`
QT=`otool -L build/AlbumShaper.app/Contents/MacOS/AlbumShaper | grep libqt`

echo "Binary is not completely static!"
echo $XSLT
echo $XML2
echo $QT
exit
fi

#make sure all resources and frameworks are placed in bundle
echo "Copying resources and frameworks into bundle"
make install

#make clean bundle, which means removing stuff like CVS directories. 
#unfortunatley we can't do this using cp so instead we'll make a 
#copy of the bundle directory, tar it, remove the copy, then untar 
#it before copying it to the disk image
echo "Cleaning bundle..."
cd build
cp -R AlbumShaper.app AlbumShaper_Clean.app
tar --exclude 'CVS' --exclude '.xvpics' -cf AlbumShaper_Clean.app.tar AlbumShaper_Clean.app
rm -rf AlbumShaper_Clean.app
tar -xf AlbumShaper_Clean.app.tar
rm -f AlbumShaper_Clean.app.tar
cd ../.

#estimate space required for disk image
SIZE=`du -s -k $BUNDLE_SOURCE | awk '{print $1}'`
chkerror
SIZE=`expr 5 + $SIZE / 1000`
chkerror
croak "Using $SIZE MB"

#remove old disk and sparse images if they exist
rm -f ../tmp/${DISK_IMAGE}
rm -rf ${SPARSE_IMAGE}

#create sparse image
hdiutil create "${DISK_IMAGE}.sparseimage" -volname "${MOUNTED_DISK_NAME}" -megabytes $SIZE -type SPARSE -fs HFS+ 2>/dev/null >/dev/null
chkerror
croak "${DISK_IMAGE}.sparseimage created"

#mount sparse image
hdiutil mount ./${DISK_IMAGE}.sparseimage 2>/dev/null >/dev/null
#hdid ./${DISK_IMAGE}.sparseimage 2>/dev/null >/dev/null
chkerror
croak "${DISK_IMAGE}.sparseimage mounted"

#find out allocated device
DEV=`mount | grep "Volumes/${MOUNTED_DISK_NAME}" | awk '{print $1}'`
croak "Device in use is $DEV"

# Use ditto to copy everything to the image, preserving resource forks
ditto -rsrcFork $BUNDLE_SOURCE "/Volumes/${MOUNTED_DISK_NAME}/${BUNDLE_NAME}" 2>/dev/null >/dev/null
chkerror
croak "Bundle coppied over successfully"

# Copy over the disk image background and hide it
#BACKGROUND="resources/icons/as128.png"
#ditto -rsrcFork $BACKGROUND "/Volumes/$MOUNTED_DISK_NAME/diskImageBackground.png" 2>/dev/null >/dev/null
#/Developer/Tools/SetFile -a V "/Volumes/$MOUNTED_DISK_NAME/diskImageBackground.png" 2>/dev/null >/dev/null
#chkerror
#croak "Disk image background copied, hide, and set"

# Detach the disk image
hdiutil detach $DEV 2>/dev/null >/dev/null
chkerror
croak "$DEV detached"

# Compress the image (maximum compression)
hdiutil convert "${DISK_IMAGE}.sparseimage" -format UDZO -o "${DISK_IMAGE}" -imagekey zlib-devel=9 2>/dev/null >/dev/null
chkerror
croak "Disk image successfully compressed"

#remove sparseimage folder
echo "Removing ${DISK_IMAGE}.sparseimage"
rm -rf ${DISK_IMAGE}.sparseimage

#remove clean app bundle
echo "Removing ${BUNDLE_SOURCE}"
rm -rf ${BUNDLE_SOURCE}

#make disk image interent enabled and announce being done
hdiutil internet-enable -yes ${DISK_IMAGE} 2>/dev/null >/dev/null
mv ${DISK_IMAGE} ../tmp/.
chkerror
croak "${DISK_IMAGE} created!"