Tags
I just bought the Humble Bundle V and, all happily, i tried to install some games from it. First i downloaded Swords&Sworcery and the installed without any problems. Next i wanted to install Bastion.
I’ve downloaded the installer script, ran it as user. First thing, i seem not to have enough space in /tmp (found out that debian uses RAM for tmp, and only 1G), changed that to some folder in home. Choose /usr/shared/games as install folder, /usr/bin as binaries folder, enter root password, and there it stopped.
So, no problem i thought, run the script as root. I did. It installed the game in /usr/shared/games, but no uninstall script in /usr/bin, and only root has permission to run it. Now, that’s not acceptable.
Third try, found that i’m not the only one that has some problems with this, Urfoex explains how he installed it. Tried that as user, with same result as first run. So i decided i’ll do it manually. (Anything you see here and decide to run on your computer, you do so at your own risk, double check everything for typos and don’t blame me if something dies in the process)
$ ./Bastion-HIB-2012-06-01-1.sh --target ~/BastionExtract --noexec --keep $ cd ~/BastionExtract/ $ ./startupinstaller.sh
Choose ~/Binaries as install folder, choose ~/bin as binaries folder, and install. That went well, and worked, and had uninstall script in ~/bin. But i still wanted it in /usr/bin and /usr/share/games where it belongs.
So, a few steps for that (this is done as root, every instance of “user” should be replaced with your username, now and everywhere in this post):
# chown -R root:root /home/user/Binaries/Bastion # chmod -R a+r /home/user/Binaries/Bastion # mv /home/user/Binaries/Bastion /usr/share/games/
Next, open ~/.local/share/applications/Bastion.desktop and edit the folowing lines to:
Exec=/usr/share/games/Bastion/Bastion.bin.x86_64 Icon=/usr/share/games/Bastion/Bastion.png
Now that’s great, but when you try to run it, permission denied. Only the root can run it now. So change the permission of binary to allow anyone to run it.
# chmod a+x /usr/share/games/Bastion/Bastion.bin.x86_64
Try to run it, permission denied again. Right, there is a few more files that need execute permission in order to run the game. At this point i could either manually try to change permission of unknown number of files in Bastions install folder, or do it somehow automagicaly. Since i’m not nearly good enough with bash to search and change permissions only using grep and pipes, i decided to write a python script to do it for me. Basically what this does is checks if file (or folder) has execute permission, and if it does grants execute for everyone (script checks whether there is Bastion executable in chosen folder before it does anything, but since you have to run it as root, standard care is advised):
#! /usr/bin/python
# -*- coding: utf-8 -*-
from subprocess import call
import os, sys
from stat import *
def walktree(top, callback):
'''recursively descend the directory tree rooted at top,
calling the callback function for file and directory
that has execute permission by owner'''
for f in os.listdir(top):
pathname = os.path.join(top, f)
mode = os.stat(pathname).st_mode
if S_ISDIR(mode):
if S_IXUSR & os.stat(pathname)[ST_MODE]:
callback(pathname)
walktree(pathname, callback)
elif S_ISREG(mode):
if S_IXUSR & os.stat(pathname)[ST_MODE]:
callback(pathname)
else:
# Unknown file type, print a message
print 'Skipping %s' % pathname
def visitfile(path):
print 'Executable by owner:', path
def grant_permission(path):
call(["chmod", "a+x" , path])
if __name__ == '__main__':
path = sys.argv[1]
if os.path.isfile(''.join([path, 'Bastion.bin.x86_64'])):
walktree(path, grant_permission)
else:
print('This doesn\'t seem to be Bastion install folder.')
Save it somewhere as something.py, say grant_perm.py. Grant it execute permission with:
# chmod +x grant_perm.py
And run it with (assuming you have put the install folder where I have):
# ./grant_perm /usr/share/games/Bastion/
Again, this is ran as root, you should be aware of what code does before you run anything from internet, be it as user or root.
If you try to run Bastion now, it should work for any user (you might need to copy/modify Bastion.desktop to other users home folders).
Only thing left to do is to fix uninstall script. Open ~/bin/uninstall-Bastion in gedit (or whichever text editor you prefer). Find and replace “/home/user/Binaries” with “/usr/share/games”. Find and replace “/home/user/bin” with “/usr/bin”. REMOVE SECOND TO LAST LINE IN uninstall-Bastion. This line will try to remove your /usr/bin folder, it should fail since it uses rmdir, but i still don’t like it.
After this is done, change owner to root and move uninstall script to /usr/bin:
# chown root:root /home/user/bin/uninstall-Bastion # mv /home/user/bin/uninstall-Bastion /usr/bin/
You can now remove /home/user/bin/ folder if you don’t use it:
$ rmdir /home/user/bin
That’s it. It should now work for anyone and be removable only by root.



