Skip to content

Instantly share code, notes, and snippets.

@lhw
Created June 21, 2012 01:05
Show Gist options
  • Save lhw/2963266 to your computer and use it in GitHub Desktop.
Save lhw/2963266 to your computer and use it in GitHub Desktop.
GoG.com ScummVM Windows to Linux (debian)
#!/bin/sh
#
## This script extracts the game data and builds a debian archive which can be easily installed
## The following debian/ubuntu packages are required fakeroot, dpkg, imagemagick, innoextract
#
FILE=`zenity --file-selection --file-filter='*.exe'`
INFO=`zenity --forms --text "the scummvm short (e.g. sky) can be found here\n http://www.scummvm.org/compatibility/" --add-entry=scummvm-short`
GAME=`basename $FILE .exe | sed "s;setup_;;g"`
SHORT=`echo $INFO | cut -d"|" -f1`
TITLE="`wget www.gog.com/en/gamecard/$GAME/ -O - 2>/dev/null | sed -n -e 's;.*<title>\(.*\) -.*</title>.*;\1;p'`"
GAME=`echo $GAME | sed "s;_;-;g"`
FULLNAME="`getent passwd $(whoami) | cut -d ':' -f 5 | cut -d ',' -f1`"
MAINTAINER="$FULLNAME <$USER@`cat /etc/hostname`>"
WORKSPACE=/tmp/$GAME
mkdir $WORKSPACE
cd $WORKSPACE
innoextract $FILE
rm -rf app/ScummVM app/innosetup_license.txt
mkdir -p $GAME/usr/share/applications $GAME/DEBIAN
mv app $GAME/usr/share/$GAME
cat > $GAME/usr/share/applications/$GAME.desktop <<EOF
[Desktop Entry]
Name=$TITLE
Exec=scummvm -c /usr/share/$GAME/SKY.CFG -p /usr/share/$GAME $SHORT
Type=Application
Icon=/usr/share/$GAME/gfw_high.png
Categories=Games
EOF
cat > $GAME/DEBIAN/control <<EOF
Package: $GAME
Section: games
Version: 0.0-1
Priority: optional
Maintainer: $MAINTAINER
Architecture: all
Depends: scummvm
Homepage: http://www.gog.com/en/gamecard/$GAME/
Description: Downloaded from GOG.com
EOF
convert $GAME/usr/share/$GAME/gfw_high.ico gfw_high.png
mv "`ls -S | head -n1`" "$GAME/usr/share/$GAME/gfw_high.png"
cd $GAME
find usr -type f -exec md5sum {} \; > DEBIAN/md5sums
cd ..
find $GAME/ -type f -exec chmod 644 {} \;
find $GAME/ -type d -exec chmod 755 {} \;
fakeroot dpkg-deb --build $GAME
mv $GAME.deb $HOME
rm -rf $WORKSPACE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment