Opened 12 years ago
Closed 10 years ago
#1424 closed defect (fixed)
[PATCH] Remove hardcoded paths for better Linux Packaging support
Reported by: | Vincent Cheng | Owned by: | leper |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 14 |
Component: | Build & Packages | Keywords: | patch |
Cc: | Philip Taylor | Patch: |
Description (last modified by )
Currently, the script that calls pyrogenesis (build/resources/0ad.sh) hardcodes the path to the pyrogenesis binary (/usr/bin/pyrogenesis), which means that Linux distros which install game binaries to /usr/games (i.e. Debian & Ubuntu) end up having to patch the file. Instead of hardcoding the path, I propose the following patch, which looks for the first instance of pyrogenesis in the user's PATH and runs that. The patch below also modifies build/resources/0ad.desktop to use a relative path for the Exec= field rather than a hardcoded path.
--- a/build/resources/0ad.sh +++ b/build/resources/0ad.sh @@ -1,3 +1,9 @@ #!/bin/sh -/usr/bin/pyrogenesis "$@" +path_to_pyrogenesis=$(which pyrogenesis) +if [ -x "$path_to_pyrogenesis" ] ; then + "$path_to_pyrogenesis" "$@" +else + echo "Error: pyrogenesis cannot be found in $PATH" + exit 1 +fi --- a/build/resources/0ad.desktop +++ b/build/resources/0ad.desktop @@ -3,7 +3,7 @@ Name=0 A.D. Comment=A real-time strategy game of ancient warfare Comment[it]=Videogioco strategico in tempo reale di guerre antiche -Exec=/usr/bin/0ad +Exec=0ad Icon=0ad Terminal=false Type=Application
Change History (8)
comment:1 by , 12 years ago
Keywords: | patch review added |
---|
comment:2 by , 12 years ago
Summary: | Remove hardcoded paths for better Linux Packaging support → [PATCH] Remove hardcoded paths for better Linux Packaging support |
---|
comment:4 by , 12 years ago
I can't think of any distro where /usr/bin isn't in the user's path, so if 0ad isn't in $PATH, hardcoding 0ad.sh to look for "/usr/bin/pyrogenesis" would fail as well. Having multiple versions of the game installed in different locations is a valid concern, but it's not 'left to chance' which version of the game will be run; whichever path has the highest precedence on the user's system (often /usr/local/bin) will be used. IMO this is actually preferable to hardcoding the path, e.g. a user who chose to build 0ad from source for whatever reason and installed it to /usr/local probably wants to run his binary rather than the version distributed by his distro, installed into /usr/bin or /usr/games (assuming the user chooses to abide by the FHS and installs site-specific programs and data into /usr/local rather than replacing files in /usr). Incidentally, on Debian/Ubuntu systems, /usr/games has the lowest precedence in $PATH, so users who just want to play 0ad can install it from the repositories and run it; users who prefer building from svn can stick their binary anywhere else in $PATH and run that, without having to modify 0ad.sh.
comment:6 by , 11 years ago
Component: | Core engine → Build & Packages |
---|---|
Keywords: | review removed |
Milestone: | Backlog → Alpha 14 |
Thanks for the patch.
Applying this at least removes the need for patching this file for Debian/Ubunutu, FreeBSD, Slackware (the slackbuild one) and possibly others.
comment:7 by , 10 years ago
Description: | modified (diff) |
---|---|
Milestone: | Alpha 14 → Alpha 18 |
Resolution: | fixed |
Status: | closed → reopened |
There's recently been another bug report from an Ubuntu user about the 0ad.sh wrapper script not being able to find pyrogenesis if /usr/games isn't in the user's path, i.e. https://bugs.launchpad.net/bugs/1380737. It's not ideal, but I've gone ahead and hardcoded the path in the 0ad packages in Debian/Ubuntu:
--- a/build/resources/0ad.sh +++ b/build/resources/0ad.sh @@ -3,6 +3,9 @@ pyrogenesis=$(which pyrogenesis 2> /dev/null) if [ -x "$pyrogenesis" ] ; then "$pyrogenesis" "$@" +elif [ -x /usr/games/pyrogenesis ] ; then + # Fallback in case /usr/games is not in $PATH; see #679033 and LP: #1380737 + /usr/games/pyrogenesis "$@" else echo "Error: pyrogenesis not found in ($PATH)" exit 1
comment:8 by , 10 years ago
Milestone: | Alpha 18 → Alpha 14 |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
To quote you from the linked ticket
/usr/games is by default included in non-root users' $PATH.
So we should include a hardcoding of that path in there, because some users change their system in strange ways?
Might be possible to change the 0ad.sh (or generate it) during build if you pass some flag and set it to the value of bindir, but can we please create a new ticket for that and not reopen old ones?
Hmm, what if 0ad is not in the path though? I don't feel strongly one way or another, but it seems a possibility which hardcoding the path would eliminate. Also there may be confusion if multiple versions of the game are installed in different locations, then it's left to chance as to which will be found on the path.
Probably best to get opinions of those that actually work on packaging though :)