You are not logged in.

#1 2010-10-14 10:27:28

jlcordeiro
Member
From: Portugal
Registered: 2009-05-23
Posts: 76

[SOLVED] sudo and XDG_CONFIG_HOME

I'm not really sure in which section my problem fits, but since I realized I had it creating a new package... Here it is.

I submitted a new package (brogue) to the AUR. The way the code was written makes it necessary to have the executable in the same folder as the png and so files. To work around it I thought of moving all the files to one folder and then create a shell script that would cd to that folder, run the game, and return to the previous path. I could move them to /usr/ or somewhere in $HOME. I chose the second one and here is my problem.

When I check for XDG_CONFIG_HOME in PKGBUILD I get one path and when I do it the same way to run the game I get another one.

if [ -z "$XDG_CONFIG_HOME" ]; then
    _config_dir="$pkgdir/$HOME/.config/brogue"
else
    _config_dir="$pkgdir/$XDG_CONFIG_HOME/brogue"
fi

if [ -z "$XDG_CONFIG_HOME" ]; then
  _config_dir="$HOME/.config/brogue"
else
  _config_dir="$XDG_CONFIG_HOME/brogue"
fi

I know this happens because (obviously) I install as root and run it as normal user. One way to solve this is to sudo -u username pacman but it is a crappy way.


What's wrong? Am I looking for XDG_CONFIG_HOME the wrong way in the PKGBUILD? Or should I have sudo using my user as default (don't really think so)?


PS: Since the files are not really config files, sould I dump them on other place? For instance, I realize that I could have solved this moving them to /usr/share/. But the problem would come eventually and I would have to ask you guys just the same....

Last edited by jlcordeiro (2010-10-14 13:36:58)

Offline

#2 2010-10-14 11:42:46

hbekel
Member
Registered: 2008-10-04
Posts: 311

Re: [SOLVED] sudo and XDG_CONFIG_HOME

Packages should never touch the user's home directory in any way. Namcap could have warned you about this. You're also missing some dependencies.

Just install the executable and image files in /usr/share/brogue, the .so files in /usr/lib and add a frontend script to /usr/bin.

Note that this is still ugly. Installing the precompiled binaries and libraries should be avoided. Instead, create a separate package for libtcod and have your brogue package depend on it, then properly build brogue from source in your PKGBUILD.

In your frontend script, just cd to /usr/share/brogue and run it. No need to cd back to '-'.

Also, makepkg runs as a normal user, so using an environment variable in the PKGBUILD should yield the user value.

Offline

#3 2010-10-14 12:35:24

jlcordeiro
Member
From: Portugal
Registered: 2009-05-23
Posts: 76

Re: [SOLVED] sudo and XDG_CONFIG_HOME

Ty. On it.

Offline

#4 2010-10-14 13:36:36

jlcordeiro
Member
From: Portugal
Registered: 2009-05-23
Posts: 76

Re: [SOLVED] sudo and XDG_CONFIG_HOME

Just so that the package installs correctly I fixed the dependency and destiny folder issues.

It seems to work correctly.


I wasn't able to compile both the libs and game yet because libtcod-svn from aur returns errors and I'm trying to solve that. Stable release of libtcod wasn't be enough to start the game...


Anyway, I can  already mark this thread as solved. Tyvm for the quick answer.

Offline

Board footer

Powered by FluxBB