You are not logged in.

#1 2010-06-28 08:22:21

synthead
Member
Registered: 2006-05-09
Posts: 1,337

[solved] Exporting PKGBUILD variables

I'm writing a neat script that's helping me compile packages with different compile flags on the fly.  I'm running into a wall though: the package versions and releases sometimes contain variables.  So it's not as easy as just running sed against the PKGBUILD ... I can end up with a variable name as a version!  Is there some way I can export all the variables from a PKGBUILD during a script so I can simply call $pkgver and get the version, for example?

When I'm done with this thing and it is polished, I'll share it with you guys.  It should make cross compiling very, very easy, and will keep a mirror updated with a simple cron job!  But of course, this is just theoretical wink

Last edited by synthead (2010-06-28 14:04:54)

Offline

#2 2010-06-28 08:42:46

Pierre
Developer
From: Bonn
Registered: 2004-07-05
Posts: 1,964
Website

Re: [solved] Exporting PKGBUILD variables

Just source the PKGBUILD to access the evaluated vars:

. PKGBUILD
echo $pkgname-$pkgver

Note: this does not work if those are overridden by split packages. (and there is no sane solution to this problem)

Offline

#3 2010-06-28 14:04:38

synthead
Member
Registered: 2006-05-09
Posts: 1,337

Re: [solved] Exporting PKGBUILD variables

This worked great!  I completely forgot about the . command.  I mean, it's so small!  Anyone could lose it.

My script is working great and is now stripped of sloppy sed commands.  Thanks for your help! big_smile

Offline

Board footer

Powered by FluxBB