2 # usage: ./mkdeb-xbmc-atv2.sh release/debug (case insensitive)
3 # Allows us to run mkdeb-xbmc-atv2.sh from anywhere in the three, rather than the tools/darwin/packaging/xbmc-atv2 folder only
4 SWITCH=`echo $1 | tr [A-Z] [a-z]`
6 DSYM_TARGET_DIR=/Users/Shared/xbmc-depends/dSyms
7 DSYM_FILENAME=XBMC.frappliance.dSYM
9 if [ ${SWITCH:-""} = "debug" ]; then
10 echo "Packaging Debug target for ATV2"
11 XBMC="$DIRNAME/../../../../build/Debug-iphoneos/XBMC.frappliance"
12 DSYM="$DIRNAME/../../../../build/Debug-iphoneos/$DSYM_FILENAME"
13 elif [ ${SWITCH:-""} = "release" ]; then
14 echo "Packaging Release target for ATV2"
15 XBMC="$DIRNAME/../../../../build/Release-iphoneos/XBMC.frappliance"
16 DSYM="$DIRNAME/../../../../build/Release-iphoneos/$DSYM_FILENAME"
19 echo "You need to specify the build target"
23 #copy bzip2 of dsym to xbmc-depends install dir
25 if [ -d $DSYM_TARGET_DIR ]; then
26 tar -C $DSYM/.. -c $DSYM_FILENAME/ | bzip2 > $DSYM_TARGET_DIR/`$DIRNAME/../gitrev-posix`-${DSYM_FILENAME}.tar.bz2
30 if [ ! -d $XBMC ]; then
31 echo "XBMC.frappliance not found! are you sure you built $1 target?"
34 if [ -f "/usr/libexec/fauxsu/libfauxsu.dylib" ]; then
35 export DYLD_INSERT_LIBRARIES=/usr/libexec/fauxsu/libfauxsu.dylib
36 elif [ -f "/usr/bin/sudo" ]; then
39 if [ -f "/Users/Shared/xbmc-depends/buildtools-native/bin/dpkg-deb" ]; then
40 # make sure we pickup our tar, gnutar will fail when dpkg -i
41 bin_path=$(cd /Users/Shared/xbmc-depends/buildtools-native/bin; pwd)
42 export PATH=${bin_path}:${PATH}
45 PACKAGE=org.xbmc.xbmc-atv2
49 ARCHIVE=${PACKAGE}_${VERSION}-${REVISION}_iphoneos-arm.deb
51 echo Creating $PACKAGE package version $VERSION revision $REVISION
52 ${SUDO} rm -rf $DIRNAME/$PACKAGE
53 ${SUDO} rm -rf $DIRNAME/$ARCHIVE
55 # create debian control file.
56 mkdir -p $DIRNAME/$PACKAGE/DEBIAN
57 echo "Package: $PACKAGE" > $DIRNAME/$PACKAGE/DEBIAN/control
58 echo "Priority: Extra" >> $DIRNAME/$PACKAGE/DEBIAN/control
59 echo "Name: XBMC-ATV2" >> $DIRNAME/$PACKAGE/DEBIAN/control
60 echo "Depends: curl, org.awkwardtv.whitelist, com.nito.updatebegone, org.xbmc.xbmc-seatbeltunlock" >> $DIRNAME/$PACKAGE/DEBIAN/control
61 echo "Version: $VERSION-$REVISION" >> $DIRNAME/$PACKAGE/DEBIAN/control
62 echo "Architecture: iphoneos-arm" >> $DIRNAME/$PACKAGE/DEBIAN/control
63 echo "Description: XBMC Multimedia Center for AppleTV 2" >> $DIRNAME/$PACKAGE/DEBIAN/control
64 echo "Homepage: http://xbmc.org/" >> $DIRNAME/$PACKAGE/DEBIAN/control
65 echo "Maintainer: Scott Davilla, Edgar Hucek" >> $DIRNAME/$PACKAGE/DEBIAN/control
66 echo "Author: TeamXBMC" >> $DIRNAME/$PACKAGE/DEBIAN/control
67 echo "Section: Multimedia" >> $DIRNAME/$PACKAGE/DEBIAN/control
69 # prerm: called on remove and upgrade - get rid of existing bits.
70 echo "#!/bin/sh" > $DIRNAME/$PACKAGE/DEBIAN/prerm
71 echo "find /Applications/XBMC.frappliance -delete" >> $DIRNAME/$PACKAGE/DEBIAN/prerm
72 echo "if [ \"\`uname -r\`\" = \"10.3.1\" ]; then" >> $DIRNAME/$PACKAGE/DEBIAN/prerm
73 echo " find /Applications/Lowtide.app/Appliances/XBMC.frappliance -delete" >> $DIRNAME/$PACKAGE/DEBIAN/prerm
74 echo "else" >> $DIRNAME/$PACKAGE/DEBIAN/prerm
75 echo " find /Applications/AppleTV.app/Appliances/XBMC.frappliance -delete" >> $DIRNAME/$PACKAGE/DEBIAN/prerm
76 echo "fi" >> $DIRNAME/$PACKAGE/DEBIAN/prerm
77 chmod +x $DIRNAME/$PACKAGE/DEBIAN/prerm
79 # postinst: symlink XBMC.frappliance into correct location and reload Lowtide/AppleTV.
80 echo "#!/bin/sh" > $DIRNAME/$PACKAGE/DEBIAN/postinst
81 echo "chown -R mobile:mobile /Applications/XBMC.frappliance" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
82 echo "cp /Applications/XBMC.frappliance/AppIcon.png /Applications/AppleTV.app/com.apple.frontrow.appliance.xbmc\@720p.png" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
83 echo "cp /Applications/XBMC.frappliance/AppIcon.png /private/var/mobile/Library/Caches/AppleTV/MainMenu/com.apple.frontrow.appliance.xbmc@720.png" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
84 echo "cp /Applications/XBMC.frappliance/AppIcon.png /Applications/XBMC.frappliance/TopRowIcon.png" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
85 echo "if [ \"\`uname -r\`\" = \"10.3.1\" ]; then" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
86 echo " ln -sf /Applications/XBMC.frappliance /Applications/Lowtide.app/Appliances/XBMC.frappliance" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
87 echo " killall Lowtide" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
88 echo "else" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
89 echo " mkdir -p /Applications/AppleTV.app/Appliances" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
90 echo " ln -sf /Applications/XBMC.frappliance /Applications/AppleTV.app/Appliances/XBMC.frappliance" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
91 echo " killall AppleTV" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
92 echo "fi" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
93 echo "FILE=/var/mobile/Media/Photos/seas0nTV.png" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
94 echo "if [ -f \$FILE ]; then" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
95 echo " echo \"File \$FILE exists. removing...\"" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
96 echo " rm \$FILE" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
97 echo "fi" >> $DIRNAME/$PACKAGE/DEBIAN/postinst
98 chmod +x $DIRNAME/$PACKAGE/DEBIAN/postinst
100 # prep XBMC.frappliance
101 mkdir -p $DIRNAME/$PACKAGE/Applications
102 cp -r $XBMC $DIRNAME/$PACKAGE/Applications/
103 find $DIRNAME/$PACKAGE/Applications/ -name '.svn' -exec rm -rf {} \;
104 find $DIRNAME/$PACKAGE/Applications/ -name '.gitignore' -exec rm -rf {} \;
105 find $DIRNAME/$PACKAGE/Applications/ -name '.DS_Store' -exec rm -rf {} \;
107 # set ownership to root:root
108 ${SUDO} chown -R 0:0 $DIRNAME/$PACKAGE
110 echo Packaging $PACKAGE
111 # Tell tar, pax, etc. on Mac OS X 10.4+ not to archive
112 # extended attributes (e.g. resource forks) to ._* archive members.
113 # Also allows archiving and extracting actual ._* files.
114 export COPYFILE_DISABLE=true
115 export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
117 dpkg-deb -b $DIRNAME/$PACKAGE $DIRNAME/$ARCHIVE
118 dpkg-deb --info $DIRNAME/$ARCHIVE
119 dpkg-deb --contents $DIRNAME/$ARCHIVE
121 # clean up by removing package dir
122 ${SUDO} rm -rf $DIRNAME/$PACKAGE