You are not logged in.

#1 2015-09-14 17:54:44

STREBLO
Member
Registered: 2015-02-15
Posts: 135

srcdir usage

In the creating packages wiki srcdir is described as

srcdir
This points to the directory where makepkg extracts or symlinks all files in the source array.

I've also seen people cd'ing into it in their PKGBUILD. Where exactly is the srcdir? I can't find much describing how exactly we are suppose to use it.

Offline

#2 2015-09-14 18:50:20

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: srcdir usage

That cd'ing is not necessary (anymore?), but the documentation was [1] unclear (and some examples used it) so you'll see it a lot.

I'm not exactly sure what else you're asking. The directory is somewhere (usually inside the directory makepkg is started in), the variable $srcdir tells you where this somewhere is (it contains the path) and, as the man page says, makepkg puts all the sources for the package in this directory before running the functions in the PKGBUILD (and these functions execute commands that operate on these source files, which is why they start in $srcdir, so you can use relative paths and `make` finds the Makefile in the current directory etc.).

[1] https://projects.archlinux.org/pacman.g … b8ba84c7be

Offline

#3 2015-09-14 21:15:07

STREBLO
Member
Registered: 2015-02-15
Posts: 135

Re: srcdir usage

So basically $srcdir is your current directory?  Do I just forget that it exists and assume i'm working in the $srcdir?

Offline

#4 2015-09-14 21:20:06

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: srcdir usage

If there is any doubt, you can always modify the script as an experiment and echo the value of srcdir  at the point of interest.

Last edited by ewaller (2015-09-14 23:28:38)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2015-09-14 21:26:14

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: srcdir usage

Do I just forget that it exists

No.

and assume i'm working in the $srcdir?

Yes, if you are inside one of the documented functions in a PKGBUILD. The variable is still useful, if you are cd'ing around in your function and want to quickly back out to the top without counting the levels with "cd ../../../"

Edit: Using the variable is not wrong, so if you like a more verbose style, then you can still start your function with "cd $srcdir/foobar"

Last edited by progandy (2015-09-14 21:28:13)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#6 2015-09-14 22:09:22

STREBLO
Member
Registered: 2015-02-15
Posts: 135

Re: srcdir usage

So it's basically the root of the packaging directory?

Offline

#7 2015-09-14 22:22:08

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: srcdir usage

STREBLO wrote:

So it's basically the root of the packaging directory?

Define packaging directory -- that sounds more like $pkgdir.

But as ewaller says, go and experiment. Grab a PKGBUILD, modify it to echo the values of these variables and then also look at the directory structure that makepkg creates.

Offline

Board footer

Powered by FluxBB