Package: openttd Version: 0.6.3-1 Severity: important Tags: patch Preconditions: package is installed, but additional required data files are not Expected behavior: a dialog should pop up explaining that the data files are not installed. Optimally, a gksudo or policykit-enabled dialog would prompt the user for its location and install them. Actual behavior: if the data files are not installed, OpenTTD dies silently (i.e. there is absolutely no feedback to the user after clicking on the menu item). In order to copy the data files, one has to do so manually, with the additional hurdle of having to copy them into /usr/share/games, i.e. a non-user-writable zone.
I propose the attached patch, a shell script that would replace "openttd" as the command to be executed by the OpenTTD menu item. It checks that the data and music files have been installed. If they haven't, it offers to install them, using gksudo for the copy and Zenity for the GUI prompts. It has been checked to work with both bash and dash. The script uses gettext, and if there is interest I'm willing to submit a Spanish translation. -- System Information: Debian Release: 5.0 APT prefers jaunty-updates APT policy: (500, 'jaunty-updates'), (500, 'jaunty-security'), (500, 'jaunty') Architecture: amd64 (x86_64) Kernel: Linux 2.6.28-11-generic (SMP w/4 CPU cores) Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages openttd depends on: ii debconf [debcon 1.5.26ubuntu3 Debian configuration management sy ii libc6 2.9-4ubuntu6 GNU C Library: Shared libraries ii libfontconfig1 2.6.0-1ubuntu12 generic font configuration library ii libfreetype6 2.3.9-4ubuntu0.1 FreeType 2 font engine, shared lib ii libgcc1 1:4.3.3-5ubuntu4 GCC support library ii libpng12-0 1.2.27-2ubuntu2 PNG library - runtime ii libsdl1.2debian 1.2.13-4ubuntu3 Simple DirectMedia Layer ii libstdc++6 4.3.3-5ubuntu4 The GNU Standard C++ Library v3 ii zlib1g 1:1.2.3.3.dfsg-12ubuntu2 compression library - runtime openttd recommends no packages. Versions of packages openttd suggests: ii freepats 20060219-1 Free patch set for MIDI audio synt ii timidity 2.13.2-20ubuntu3 Software sound renderer (MIDI sequ -- debconf information: * openttd/datafiles:
#!/bin/sh . gettext.sh TEXTDOMAIN=openttd-start export TEXTDOMAIN TARGET_LOCATION="/usr/share/games/openttd/" DATA_FILES="data/sample.cat data/trg1r.grf data/trgcr.grf data/trghr.grf data/trgir.grf data/trgtr.grf" MUSIC_FILES="gm/gm_tt00.gm gm/gm_tt01.gm gm/gm_tt02.gm gm/gm_tt03.gm gm/gm_tt04.gm \ gm/gm_tt05.gm gm/gm_tt06.gm gm/gm_tt07.gm gm/gm_tt08.gm gm/gm_tt09.gm \ gm/gm_tt10.gm gm/gm_tt11.gm gm/gm_tt12.gm gm/gm_tt13.gm gm/gm_tt14.gm \ gm/gm_tt15.gm gm/gm_tt16.gm gm/gm_tt17.gm gm/gm_tt18.gm gm/gm_tt19.gm \ gm/gm_tt20.gm gm/gm_tt21.gm" IGNORE_MUSIC_FILE=~/.openttd/skip_music_install MISSING_DATA="" MISSING_MUSIC="" # Arguments: # $1: folder to look at # $2: list of files to find at $1 # $3: name of the variable to append the list of missing files to find_missing_files() { for file in $2 ; do if [ ! -f "$1/$file" ] ; then eval $3="\"\${$3} $file\"" fi done } # Arguments: # $1: files to find find_ttdx_folder() { until [ -n "${TTDX_FOLDER}" ]; do # Prompt for the location of the data files TTDX_FOLDER=$(zenity --file-selection --directory --title "$(gettext 'Choose the folder containing your Transport Tycoon installation')") if [ -z "${TTDX_FOLDER}" ] ; then # User cancelled - abort exit 1 fi FILES_NOT_FOUND="" find_missing_files "${TTDX_FOLDER}" "$1" FILES_NOT_FOUND if [ -n "${FILES_NOT_FOUND}" ] ; then # Invalid folder - does not have all files TTDX_FOLDER="" zenity --error --title "$(gettext 'Invalid folder selected')" --text "$(gettext 'The folder you selected does not contain all the required files.')\n\n$(gettext 'Please choose a folder containing an original Transport Tycoon Deluxe installation.')" continue fi done } # Arguments: # $1: files to install install_files() { if ! gksu --description "$(gettext 'OpenTTD data files installer')" true ; then # User cancelled or authentication failed - abort exit 1 fi for file in $1; do gksu --description "$(gettext 'OpenTTD data files installer')" -- install -m644 -D "$TTDX_FOLDER/$file" "${TARGET_LOCATION}/$file" done } find_missing_files "${TARGET_LOCATION}" "${DATA_FILES}" MISSING_DATA find_missing_files "${TARGET_LOCATION}" "${MUSIC_FILES}" MISSING_MUSIC if [ -n "${MISSING_DATA}" ] ; then if zenity --question --title "$(gettext 'Missing data files')" --text "$(gettext 'In order to start, OpenTTD requires some data files from an original Transport Tycoon Deluxe installation.') $(gettext 'Do you want to install these files now? (you will need administrative rights)')" then find_ttdx_folder "${DATA_FILES}" # Valid folder containing all the files - copy to target install_files "${DATA_FILES}" else # User cancelled - don't even try starting up exit 1 fi fi if [ -n "${MISSING_MUSIC}" -a ! -f "${IGNORE_MUSIC_FILE}" ] ; then if zenity --question --title "$(gettext 'Missing music files')" --text "$(gettext 'You can also install the music files from your original Transport Tycoon Deluxe installation. However, these files are not required to play OpenTTD. If you choose not to install the music files, you will not be asked again.')\n\n$(gettext 'Do you want to install these files now? (you will need administrative rights)')" then find_ttdx_folder "${MUSIC_FILES}" # Valid folder containing all the files - copy to target install_files "${MUSIC_FILES}" else mkdir -p $(dirname "${IGNORE_MUSIC_FILE}") touch "${IGNORE_MUSIC_FILE}" zenity --info --title "$(gettext 'Skipping music files')" --text "$(gettext 'You have selected not to install the music files. If you ever want to install them, delete the following file and restart OpenTTD:')\n\n${IGNORE_MUSIC_FILE}" fi fi openttd