#!/bin/bash
##########################################################################
# Create Darwine distribution
# create a Disk Image Containing WineHelper and Wine for the official
# darwine distrib
#
# Copyright (c) 2005 Pierre d'Herbemont
# Copyright (c) 2006 Emmanuel Maillard
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##########################################################################
usage()
{
echo "$0: illegal argument"
echo "usage: create_darwine_distrib [--no-wine-build] version wine_sources"
echo " --no-wine-build do not build wine, skip configure and make"
echo " (saves time, but will not work if ./configure --prefix= was"
echo " correctly set)"
echo " wine_sources /absolute/path/to/the/wine/sources"
echo " version darwine version to release"
}
check_err()
{
if [ "${1}" -ne "0" ]; then
echo "***** Error: ${2}"
exit ${1}
fi
}
cleanup()
{
rm -Rf "/tmp/$DARWINEPKGNAME"
rm -Rf /tmp/wine_root
rm -Rf /tmp/WineHelper
}
##########################################################################
# Arg check
if [ "$#" -eq 2 ]
then
BUILDWINE="yes"
VERSION=$1
WINE=$2
elif [ "$#" -eq 3 ] && [ "$1" = "--no-wine-build" ]
then
BUILDWINE="no"
VERSION=$2
WINE=$3
else
usage
exit 1
fi
USER_WD=`pwd`
DISTRIB_D=`pwd`
DARWINEPKGNAME="Darwine $VERSION"
##########################################################################
echo "# Packaging Darwine for version $VERSION using Wine sources in $WINE..."
cleanup
mkdir -p "/tmp/$DARWINEPKGNAME/Darwine"
mkdir -p "/tmp/$DARWINESDKPKGNAME"
##########################################################################
# Wine
echo "# Building Wine in $WINE (warning: takes a long time)..."
rm -Rf /tmp/wine_root
mkdir -p /tmp/wine_root
check_err $? "Can't create /tmp/wine_root"
cd $WINE
if [ "$BUILDWINE" = "yes" ]
then
./configure --prefix=/tmp/wine_root --silent && make -s && make -s install
else
make -s install
fi
check_err $? "Can't build wine"
##########################################################################
# Build WineHelper from CVS
echo "# Building WineHelper from CVS..."
cd /tmp
cp -R ~/Desktop/WineHelper /tmp
check_err $? "Can't checkout WineHelper from CVS $?"
cd WineHelper
xcodebuild -project WineHelper.xcodeproj
check_err $? "Can't build WineHelper"
mv build/Default/WineHelper.app "/tmp/$DARWINEPKGNAME/Darwine"
check_err $? "Can't build WineHelper"
##########################################################################
# Create Wine.bundle
echo "# Creating Wine.bundle..."
mkdir -p "/tmp/$DARWINEPKGNAME/Darwine/Wine.bundle/Contents"
check_err $? "Can't create Wine.bundle"
cd "/tmp/$DARWINEPKGNAME/Darwine/Wine.bundle/Contents/"
cp -r /tmp/wine_root/ .
rm -rf ./include
check_err $? "Can't create Wine.bundle"
##########################################################################
# sexy WineLib apps in "Sample WineLib Applications"
echo "# Putting sexy WineLib apps in \"Sample WineLib Applications\"..."
cd "/tmp/$DARWINEPKGNAME/Darwine"
mkdir Sample\ WineLib\ Applications
cd Sample\ WineLib\ Applications
cp "/tmp/wine_root/lib/wine/winefile.exe.so" winefile.exe
cp "/tmp/wine_root/lib/wine/clock.exe.so" clock.exe
cp "/tmp/wine_root/lib/wine/winemine.exe.so" winemine.exe
cp "/tmp/wine_root/lib/wine/notepad.exe.so" notepad.exe
cp "/tmp/wine_root/lib/wine/regedit.exe.so" regedit.exe
cp "/tmp/wine_root/lib/wine/winecfg.exe.so" winecfg.exe
check_err $? "Error"
################################################
# ReadMe
echo "# Create the Readme..."
touch ~/Desktop/readme.html
cd "/tmp/$DARWINEPKGNAME/Darwine"
sed "s/@VERSION@/$VERSION/" "$DISTRIB_D/readme.html" > "Read Me.html"
check_err $? "Error"
################################################
# Make a Disk Image
echo "# Create the Disk Image for Darwine $VERSION..."
cd /tmp
hdiutil create -srcfolder "/tmp/$DARWINEPKGNAME" "$USER_WD/$DARWINEPKGNAME.dmg"
check_err $? "Can't create the Disk Image."
################################################
# Prepare for Universal SDK
echo "# Prepare the SDK for Darwine $VERSION..."
echo "# Building SDK tree : $WINE/SDKRoot"
cd $WINE
if test ! -d "$WINE/SDKRoot"; then
mkdir -p SDKRoot/ppc
mkdir -p SDKRoot/x86
mkdir -p SDKRoot/Library
mkdir -p SDKRoot/Developer/Headers/Wine
mkdir -p SDKRoot/Developer/Tools
mkdir -p SDKRoot/Developer/Examples/Darwine
fi
# copy tools
cd /tmp/wine_root/bin
case `uname -p` in
powerpc)
cp winebuild winecpp wineg++ winegcc wrc widl $WINE/SDKRoot/ppc
;;
*)
cp winebuild winecpp wineg++ winegcc wrc widl $WINE/SDKRoot/x86
;;
esac
cp winemaker $WINE/SDKRoot/Developer/Tools
# copy headers
cd /tmp
cp -r wine_root/include $WINE/SDKRoot/Developer/Headers/Wine
################################################
# Clean up
echo "# Clean up..."
cleanup
check_err $? "Error"
echo "# Done (image: $USER_WD/$DARWINEPKGNAME.dmg )..."