#!/bin/bash # # Automatically check for new Wine releases and build rpms # for Red Hat (derived) distributions # # This script has been tested on: # Redhat 9, Centos 4.3, White Box Enterprise Linux 3 # # Copyright 2007 Google (Lei Zhang, thestig@google.com) # Wine RPM spec file previously maintained by: # Vincent Béron, Bill Nottingham, Karsten Hopp, Tim Powers, # Bernhard Rosenkraenzer, Preston Brown, Michael Maher, Cristian Gafton # Set these variables AUTHOR=alice # $EXTRA is a unique identifier consisting of a build version number # and the abbreviation for the distro. ex. 1rh9, 1centos4, 2wbel3. # This script uses $EXTRA to customize the RPM spec file,so it must contain # a string for one of the tested distro: "rh9", "centos4", or "wbel3" EXTRA=1rh9 # $BUILDROOT is the top directory for the RPM build area. As root, the default # $BUILDROOT is /usr/src/redhat, but non-root users do not have the permissions # to build there. Therefore they must create their own build area and set # $BUILDROOT to point to it. Additionally, they need to change ~/.rpmmacros # so the rpmbuild tool knows to use $BUILDROOT. To do this, add the following # line to ~/.rpmmacros: # %_topdir /home/test/mybuildroot # # For more information, see: # http://genetikayos.com/code/repos/rpm-tutorial/trunk/rpm-tutorial.html BUILDROOT=/home/test/mybuildroot # $ARCH can be i386, i686, athlon, etc... ARCH=i686 # The wine version of the last successful build is saved in $VERSIONFILE VERSIONFILE=$HOME/wine_buildrpm_version # No need to change these variables BUILDDIR=$BUILDROOT/BUILD RPMSDIR=$BUILDROOT/RPMS SOURCEDIR=$BUILDROOT/SOURCES SPECDIR=$BUILDROOT/SPECS SRPMSDIR=$BUILDROOT/SRPMS WINEINIT=$SOURCEDIR/wine.init GITURL="http://source.winehq.org/git/wine.git/?a=blob_plain;f=VERSION;hb=HEAD" WINEURL="http://www.ibiblio.org/pub/linux/system/emulators/wine" create_spec_file() { # Set some local variables local VERSION=$1 local AUTHOR=$2 local EXTRA=$3 local DATE=`date +"%a %b %d %Y"` local DISTRO=unknown local SPECFILE=wine-$VERSION-${EXTRA}${AUTHOR}.spec # Do some checks [ -z "$VERSION" ] || [ -z "$AUTHOR" ] || [ -z "$EXTRA" ] && \ (echo Required variable to create spec file not set; return 1) for f in rh9 centos4 wbel3 do echo $EXTRA | grep -q $f if [ "$?" = "0" ] then if [ "$DISTRO" != "unknown" ] then echo Not sure how to create spec file for $EXTRA return 1 fi DISTRO=$f fi done if [ "$DISTRO" = "unknown" ] then echo Not sure how to create spec file for $EXTRA return 1 fi cat > $SPECFILE <> $SPECFILE <> $SPECFILE else echo "BuildRequires: autoconf gcc binutils bison flex fontforge XFree86-devel arts-devel audiofile-devel cups-devel cyrus-sasl-devel e2fsprogs-devel esound-devel expat-devel fontconfig-devel freetype-devel glib2-devel gphoto2-devel isdn4k-utils-devel krb5-devel libao-devel libjpeg-devel libmng-devel libogg-devel libpng-devel libusb-devel libvorbis-devel libxml-devel libxml2-devel libxslt-devel ncurses-devel openldap-devel openssl-devel pkgconfig qt-devel sane-backends-devel zlib-devel" >> $SPECFILE fi if [ "$DISTRO" = "rh9" ] then echo "Requires: glibc >= 2.3.2-27.9.7" >> $SPECFILE fi cat >> $SPECFILE <<"WINERPMEOF" %description While Wine is usually thought of as a Windows(TM) emulator, the Wine developers would prefer that users thought of Wine as a Windows compatibility layer for UNIX. This package includes a program loader, which allows unmodified Windows 3.1/95/NT binaries to run under Intel Unixes. Wine does not require MS Windows, but it can use native system .dll files if they are available. %package devel ExclusiveArch: i386 Summary: Wine development environment. Group: System Environment/Libraries Requires: wine = %{version} %description devel Header, include files and library definition files for developing applications with the Wine Windows(TM) emulation libraries. %prep %setup -q -n wine-%{version} %build export CFLAGS="$RPM_OPT_FLAGS" WINERPMEOF if [[ "$DISTRO" = "rh9" || "$DISTRO" = "wbel3" ]] then echo "export CPPFLAGS=\"-I/usr/kerberos/include\"" >> $SPECFILE fi cat >> $SPECFILE <<"WINERPMEOF" autoconf %configure %{__make} depend %{__make} %install rm -rf $RPM_BUILD_ROOT %makeinstall \ includedir=%{?buildroot:%{buildroot}}%{_includedir}/wine \ dlldir=%{?buildroot:%{buildroot}}%{_libdir}/wine \ LDCONFIG=/bin/true \ UPDATE_DESKTOP_DATABASE=/bin/true # Allow users to launch Windows programs by just clicking on the .exe file... mkdir -p $RPM_BUILD_ROOT%{_initrddir} install -c -m 755 %SOURCE1 $RPM_BUILD_ROOT%{_initrddir}/wine %clean rm -rf $RPM_BUILD_ROOT %post if ! grep -q "^/usr/lib/wine$" /etc/ld.so.conf; then echo "/usr/lib/wine" >>/etc/ld.so.conf fi /sbin/ldconfig /sbin/chkconfig --add wine /sbin/chkconfig --level 2345 wine on /sbin/service wine start &>/dev/null || : if [ "x`which update-desktop-database 2>/dev/null`" != "x" ]; then update-desktop-database fi %preun if test "$1" = "0"; then /sbin/chkconfig --del wine fi %postun if test "$1" = "0"; then perl -pi -e "s,^/usr/lib/wine$,,g" /etc/ld.so.conf fi /sbin/ldconfig if [ "x`which update-desktop-database 2>/dev/null`" != "x" ]; then update-desktop-database fi %files %defattr(-,root,root) %{_bindir}/msiexec %{_bindir}/notepad %{_bindir}/progman %{_bindir}/regedit %{_bindir}/regsvr32 %{_bindir}/uninstaller %{_bindir}/wine %{_bindir}/wine-kthread %{_bindir}/wine-preloader %{_bindir}/wine-pthread %{_bindir}/wineboot %{_bindir}/winebrowser %{_bindir}/winecfg %{_bindir}/wineconsole %{_bindir}/winedbg %{_bindir}/winefile %{_bindir}/winelauncher %{_bindir}/winemine %{_bindir}/winepath %{_bindir}/wineprefixcreate %{_bindir}/wineserver %{_bindir}/wineshelllink %{_bindir}/winhelp %{_libdir}/*.so.1 %{_libdir}/*.so.1.0 %{_libdir}/wine/*dll16 %{_libdir}/wine/*drv16 %{_libdir}/wine/*exe16 %attr(0755, root, root) %dir %{_libdir}/wine %{_libdir}/wine/*.so %{_mandir}/man1/wine.1* %{_mandir}/man1/winedbg.1* %{_mandir}/man1/wineserver.1* %{_mandir}/man1/wineprefixcreate.1* %{_datadir}/aclocal/wine.m4 %{_datadir}/applications/wine.desktop %attr(0755, root, root) %dir %{_datadir}/wine %{_datadir}/wine/generic.ppd %{_datadir}/wine/wine.inf %attr(0755, root, root) %dir %{_datadir}/wine/fonts %{_datadir}/wine/fonts/*.fon %{_datadir}/wine/fonts/*.ttf %config %{_initrddir}/wine %doc ANNOUNCE COPYING.LIB ChangeLog LICENSE LICENSE.OLD README VERSION %doc AUTHORS %doc documentation/ChangeLog.ALPHA documentation/ChangeLog.OLD documentation/README.de documentation/README.es documentation/README.fr documentation/README.it documentation/README.no documentation/README.pt documentation/README.pt_br %files devel %defattr(-,root,root) %{_bindir}/function_grep.pl %{_bindir}/widl %{_bindir}/winebuild %{_bindir}/winecpp %{_bindir}/winedump %{_bindir}/wineg++ %{_bindir}/winegcc %{_bindir}/winemaker %{_bindir}/wmc %{_bindir}/wrc %{_libdir}/*.so %{_mandir}/man1/widl.1* %{_mandir}/man1/winebuild.1* %{_mandir}/man1/winedump.1* %{_mandir}/man1/wineg++.1* %{_mandir}/man1/winegcc.1* %{_mandir}/man1/winemaker.1* %{_mandir}/man1/wmc.1* %{_mandir}/man1/wrc.1* %attr(0755, root, root) %dir %{_includedir}/wine %{_includedir}/wine/* %{_libdir}/wine/*.a %{_libdir}/wine/*.def WINERPMEOF cat >> $SPECFILE << WINERPMEOF %changelog * $DATE $AUTHOR Build RPM for wine-$VERSION. WINERPMEOF } create_wine_init() { local WINEINIT=$1 [ -z "$WINEINIT" ] && return 1 cat > $WINEINIT <<"WINEINITEOF" #!/bin/sh # # wine Allow users to run Windows(tm) applications by just clicking on them # (or typing ./file.exe) # # chkconfig: 35 98 10 # description: Allow users to run Windows(tm) applications by just clicking \ # on them (or typing ./file.exe) . /etc/rc.d/init.d/functions RETVAL=0 start() { echo -n $"Registering binary handler for Windows applications" /sbin/modprobe binfmt_misc &>/dev/null echo ':windows:M::MZ::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || : echo ':windowsPE:M::PE::/usr/bin/wine:' >/proc/sys/fs/binfmt_misc/register || : } stop() { echo -n $"Unregistering binary handler for Windows applications" echo "-1" >/proc/sys/fs/binfmt_misc/windows || : echo "-1" >/proc/sys/fs/binfmt_misc/windowsPE || : } reload() { stop start } wine_status() { if [ -e /proc/sys/fs/binfmt_misc/windows ]; then echo $"Wine binary format handlers are registered." return 0 else echo $"Wine binary format handlers are not registered." return 3 fi } case "$1" in start) start ;; stop) stop ;; status) wine_status RETVAL=$? ;; restart) stop start ;; condrestart) if [ -e /proc/sys/fs/binfmt_misc/windows ]; then stop start fi ;; *) echo $"Usage: $prog {start|stop|status|restart|condrestart}" exit 1 esac exit $RETVAL WINEINITEOF } # main function starts here # sanity checks if [[ -z "$VERSIONFILE" || -z "$AUTHOR" || -z "$EXTRA" || -z "$BUILDROOT" ]] then echo "required variable(s) not set" exit 1 fi for d in $BUILDDIR $RPMSDIR $SOURCEDIR $SPECDIR $SRPMSDIR do if [[ ! -d "$d" || ! -w "$d" ]] then echo Cannot access $d exit 1 fi done for f in $VERSIONFILE $WINEINIT do if [ -e "$f" ] then if [ ! -w "$f" ] then echo Cannot write to $f exit 1 fi fi done # check Wine website for latest version tempfile=`mktemp /tmp/$0.XXXXXX` || exit 1 wget $GITURL -O $tempfile || exit 1 VERSION=`cat $tempfile|cut -d" " -f 3` rm $tempfile if [ -z "$VERSION" ] then echo "cannot get wine version number" exit 1 fi # check to see if latest version changed since the last successful build if [ -e "$VERSIONFILE" ] then oldversion=`cat $VERSIONFILE` if [ "$oldversion" = "$VERSION" ] then echo "no new version" exit 0; fi fi # Done checking pushd $SOURCEDIR rm wine-$VERSION.tar.bz2 wget $WINEURL/wine-$VERSION.tar.bz2 || exit 1 create_wine_init $WINEINIT || exit 1 cd $SPECDIR create_spec_file $VERSION $AUTHOR $EXTRA || exit 1 SPECFILE=wine-$VERSION-${EXTRA}${AUTHOR}.spec # build RPMs rpmbuild -bb --clean --target $ARCH $SPECFILE && \ rpmbuild -bs --clean $SPECFILE # save version number on success if [ "$?" = "0" ] then echo $VERSION > $VERSIONFILE fi popd