You are not logged in.

#1 2019-06-01 20:50:57

neilsimp1
Member
Registered: 2019-01-20
Posts: 12

Creating my first AUR package - How to set ownership/permissions?

I'm attempting creating my first AUR package. I followed a similar package on the AUR and was able to get about 98% of the way there.
After `makepkg` and `sudo pacman -U my-package.pkg.tar.xz`, everything is installed to the correct locations.

I have a sh script in /usr/bin to `exec /opt/my-package/my-package`. Problem is, when I try to run it, I get permission issues. `my-package` fails, but `sudo my-package` works fine. I dno't want to run this as root.

Everything in /opt/my-package is root:root -rwxr-xr-x.
I think the issue is that my user account needs write access to /opt/my-package, since when running as root it generates a .cfg file when it starts up.


How can my PKGBUILD script set the permissions for /opt/my-package? I am copying files in to this by way of `install -Dm755 srcfile "$pkgdir"/opt/my-package/destfile`.

Offline

#2 2019-06-02 13:30:25

Omar007
Member
Registered: 2015-04-09
Posts: 334

Re: Creating my first AUR package - How to set ownership/permissions?

From what you're explaining, the permissions are actually correct. In this case it seems you're hitting a problem with how the application handles its configuration.

The application you're trying to package is attempting to write to the location it is installed to instead of the user's home directory (be it ${XDG_CONFIG_HOME} or loose dot-files in ${HOME}).
Since the install location is owned by root and writeable only by root (as it should be!!!), this fails. Depending on the program, there are usually a few solutions available you can use:
1) The program has a flag you can provide to point it to where it should write its configuration; in this case, add the flag to your wrapper script. E.g. `... --config-dir=${XDG_CONFIG_HOME:-${HOME}/.config}/TheApplicationName`
2) The program uses the working directory for operations; in your wrapper script, change to a desired file location first. E.g. something like `mkdir ${XDG_CONFIG_HOME:-${HOME}/.config}/TheApplicationName && cd ${XDG_CONFIG_HOME:-${HOME}/.config}/TheApplicationName && ...`. If the program attempts to locate required libraries it includes as relative paths, this might now fail. In that case you might also need to set and export the LD_LIBRARY_PATH env var in your wrapper script to include the aplication's install location.
3) The application hard-codes to always write relative to the executable location and this can't be changed; in this case the 'best' approach would probably be to make the wrapper script copy the application over to a location owned by the user (be it a temporary location or somewhere in his home) and run it from there (akin to what the tor-browser package does).

Last edited by Omar007 (2019-06-02 13:34:10)

Offline

#3 2019-06-02 13:37:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,288
Website

Re: Creating my first AUR package - How to set ownership/permissions?

neilsimp1 wrote:

Problem is, when I try to run it, I get permission issues.

That is not an error message.

The reply above is excellent - and quite generous.  Omar007 is trying to give reasonable answers to every possible problem that could have because you've not given nearly enough information for us to know exactly what problem you're actually having.

What is this package?  What software is packaged?  What PKGBUILD are you using?  Don't make use play 20-questions; present this information at the start of a help request.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2019-06-03 23:54:37

neilsimp1
Member
Registered: 2019-01-20
Posts: 12

Re: Creating my first AUR package - How to set ownership/permissions?

Trilby wrote:

That is not an error message.

Fair, but I didn't include the error message since that was specific to the application itself, and my question was meant to be more of whether or not I was packaging it correctly. Also, I was 99% sure the only issue was with permissions, not the application.

For what it's worth, the application is NetRunner - http://www.mysticbbs.com/downloads.html, and the error is

An unhandled exception occurred at $000000000042CE39:
EInOutError: Access denied
  $000000000042CE39

Omar007's post answered everything quite thoroughly for me though.

Since the application only comes pre-compiled and there seem to be no flags it accepts, option #1 is off the table.
I tried option #2 as well, no dice.

I will take a look at the tor-browser package and see if I can't use that. Thank you!!

Offline

#5 2019-06-04 00:05:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,288
Website

Re: Creating my first AUR package - How to set ownership/permissions?

neilsimp1 wrote:

I didn't include the error message since that was specific to the application itself, and my question was meant to be more of whether or not I was packaging it correctly.

And there's no way for us to address this as you've still told us absolutely nothing about how you are packaging it.

neilsimp1 wrote:

Also, I was 99% sure the only issue was with permissions, not the application.

These are not mutually exclusive, and the issuing being "with permissions" could still mean many different things.  Is the binary properly executable?  Now we know it is given the little bit of output in the last post, but we didn't at first.

neilsimp1 wrote:

For what it's worth, the application is NetRunner - http://www.mysticbbs.com/downloads.html

It's not worth much as that's only the upstream source, not your PKGBUILD or anything about the package you're seeking feedback on.  A search of the AUR for 'netrunner' doesn't return any results, so I still have no idea how this is packaged.

You can, and probably should, change the permissions on the /opt/my-package directory.

But as you are not providing any relevant info, nothing more can really be said.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB