You are not logged in.

#1 2012-11-03 18:36:40

aardwolf
Member
From: Belgium
Registered: 2005-07-23
Posts: 256

pkgdir for data?

Hello,

I made a package for a program. The program has some image files for skins and such. So it are data files the program requires to run. These should go in some directory. The directory is a compiler argument to the program so that it knows where its data directory is.

Where are such files supposed to go on Archlinux?

In a PKGBUILD file, is the pkgdir varuable supposed to represent the place where such data files are supposed to go, and, should I use pkgdir for the DESTDIR variable given to the make command?

If not, what should I use as data file directory and how do I get its path at build time?

I'm asking because when trying it out, it turns out pkgdir is just a subdirectory of the current directory I'm in to build the package. That is NOT good! I would expect it to become something under /usr.

Thanks!

Last edited by aardwolf (2012-11-03 18:37:17)

Offline

#2 2012-11-03 18:58:09

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,338

Re: pkgdir for data?

You really, really need to do some research/testing/reading about PKGBUILDs. You saying that the pkgdir being a subdir of the pwd is "NOT good!" show a fundamental lack of understanding packages. The pkgdir is just where the pkg file is built, not the install directory itself. Under pkgdir, you'll see the usr directory you mentioned.

Last edited by Scimmia (2012-11-03 19:00:49)

Offline

#3 2012-11-03 19:04:52

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: pkgdir for data?

pkgdir is <build-dir>/pkg, where <build-dir> is the directory with the PKGBUILD in it. It is the package root directory, which will become / when the package is installed. So if you want stuff to end up in /usr, your PKGBUILD should install it in $pkgdir/usr.

As per /usr/share/pacman/PKGBUILD.proto, 'make DESTDIR="$pkgdir/" install' is correct in many cases, but obviously it is necessary to check upstream documentation first.

Offline

#4 2012-11-03 19:21:43

aardwolf
Member
From: Belgium
Registered: 2005-07-23
Posts: 256

Re: pkgdir for data?

In this case, it looks like not only I need to learn more about PKGBUILD, but also about writing software for Linux that uses data files.

My program takes its data directory as a flag at compile time (it's a define given as -D flag to g++), and I give it DESTDIR as that directory in the makefile, I had understood that this was how it's done. Is it not?

If it doesn't find its data directory, it'll quit with an error, because it can't do anything anyway without its UI skin graphics, translation file, and so on. So obviously this directory should not be in /tmp, or in the subdir I made in my homedir to temporarily run this PKGBUILD...

If you say that the directory will suddenly become "/" at install time, then that is too late in fact: the program is already compiled at that point with the $pkgdir it got at compile time...

Does there exist an example or so of a very simple program that needs some data files in a stable location, and in which way this is done and what directory is used? The documentation really does not answer my particular question and everything contradicts, an actual real life example could help me...

Last edited by aardwolf (2012-11-03 19:22:41)

Offline

#5 2012-11-03 19:26:23

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,757
Website

Re: pkgdir for data?

As I have to second (or 3rd/4th) what has been said about how it really sounds like you need to study PKGBUILDS to see how they work, I also see the other part of the question:  Once you learn how to use a PKGBUILD, where should you direct that program to store its data files.

I'd recommend /usr/share/<programname>/<imagefiles> as a good place.

In the PKGBUILD, these files should be installed to ${pkgdir}/usr/share/<programname>/ but the parameter passed to the program so it knows where to look for the files should just be /usr/share/<programname>


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#6 2012-11-03 19:35:03

aardwolf
Member
From: Belgium
Registered: 2005-07-23
Posts: 256

Re: pkgdir for data?

Thanks! I was not sure about /usr/share, because there's also /usr/local/share, and then there's /bin, /usr/bin and /usr/local/bin and the sbin variants of all these, and then some distros use different conventions than others, so it was confusing smile

Offline

#7 2012-11-03 20:16:00

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,757
Website

Re: pkgdir for data?

See the table: https://en.wikipedia.org/wiki/Filesyste … y_Standard

Each directory has specific purposes.  There are certainly some circumstances that can be a bit ambigious, but this doesn't seem to be one of them.  Image files should definitely not go in any of the *bin directories.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#8 2012-11-03 20:32:25

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 5,338

Re: pkgdir for data?

aardwolf wrote:

If you say that the directory will suddenly become "/" at install time, then that is too late in fact: the program is already compiled at that point with the $pkgdir it got at compile time...

Compilation and installation should be two separate steps. You build the program with the path you're talking about, but then install it into the $pkgdir instead of "/". The archive will use $pkgdir as it's root, so when it gets extracted, it gets extracted directly to "/"

Offline

Board footer

Powered by FluxBB