You are not logged in.

#1 2013-01-21 07:50:31

ciembor
Member
Registered: 2008-03-30
Posts: 57

[Solved] Adding vendor_perl directory to $PATH

Hi. I'm working on a PKGBUILD, which install executable perl script. It is installed after all in /usr/bin/vendor_perl. It's recommended on ArchLinux Wiki. The problem is, this path isn't in $PATH, so I can't simply run it from a command line. What should I do to make this possible after package installation? I can export PATH=$PATH:/usr/bin/vendor_perl, but I don't know how to do this permanently from PKGBUILD.

Last edited by ciembor (2013-01-21 10:40:46)

Offline

#2 2013-01-21 08:03:25

msthev
Member
Registered: 2012-04-05
Posts: 177

Re: [Solved] Adding vendor_perl directory to $PATH

Look at /etc/profile.d/. Example: https://projects.archlinux.org/svntogit … /mercurial

By the way, I think all you need to do in case of your script is relogin / source /etc/profile.d/perlbin.sh:

$ cat /etc/profile.d/perlbin.sh
# Set path to perl scriptdirs if they exist
# https://wiki.archlinux.org/index.php/Perl_Policy#Binaries_and_Scripts
# Added /usr/bin/*_perl dirs for scripts
# Remove /usr/lib/perl5/*_perl/bin in next release

[ -d /usr/bin/site_perl ] && PATH=$PATH:/usr/bin/site_perl
[ -d /usr/lib/perl5/site_perl/bin ] && PATH=$PATH:/usr/lib/perl5/site_perl/bin

[ -d /usr/bin/vendor_perl ] && PATH=$PATH:/usr/bin/vendor_perl
[ -d /usr/lib/perl5/vendor_perl/bin ] && PATH=$PATH:/usr/lib/perl5/vendor_perl/bin

[ -d /usr/bin/core_perl ] && PATH=$PATH:/usr/bin/core_perl

export PATH

# If you have modules in non-standard directories you can add them here.
#export PERLLIB=dir1:dir2
$ pacman -Qo /etc/profile.d/perlbin.sh
/etc/profile.d/perlbin.sh is owned by perl 5.16.2-2

Offline

#3 2013-01-21 08:07:25

digirium
Member
Registered: 2012-11-15
Posts: 51

Re: [Solved] Adding vendor_perl directory to $PATH

Already being done? core/perl installs scripts in /etc/profile.d that add the vendor_perl directory to PATH when a shell starts.

Edit: Didn't see a reply was made already rule#1 never post before waking up properly le sigh.

Last edited by digirium (2013-01-21 08:09:06)

Offline

#4 2013-01-21 08:15:15

ciembor
Member
Registered: 2008-03-30
Posts: 57

Re: [Solved] Adding vendor_perl directory to $PATH

Hmm... but this script doesn't run after installing package. I had to reboot. Is there good way to enforce this?

Offline

#5 2013-01-21 08:18:46

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 4,712

Re: [Solved] Adding vendor_perl directory to $PATH

Call the script from the install file.

Offline

#6 2013-01-21 08:35:24

ciembor
Member
Registered: 2008-03-30
Posts: 57

Re: [Solved] Adding vendor_perl directory to $PATH

That's strange, but it doesn't update PATH when I run it by hand. Both perlbin.sh and perlbin.csh. I really had to reboot:(.

//edit

OK, I'm stupid. Didn't use source, like msthev said;).

//edit

Uhh, but it dosn't work from .install sad.

Last edited by ciembor (2013-01-21 08:52:49)

Offline

#7 2013-01-21 09:09:32

msthev
Member
Registered: 2012-04-05
Posts: 177

Re: [Solved] Adding vendor_perl directory to $PATH

ciembor wrote:

That's strange, but it doesn't update PATH when I run it by hand.

That's normal -- by running it you create a new shell, and when the script returns, everything in regards to the environment disappears (in this case: global variables). If you want the script to run in current shell, you need to run it with the dot (or source in Bash).
A little demo:

$ echo 'export TESTVAR=yup' >test.sh
$ chmod +x test.sh
$ echo $TESTVAR

$ ./test.sh
$ echo $TESTVAR

$ . test.sh
$ echo $TESTVAR
yup
ciembor wrote:

Uhh, but it dosn't work from .install sad.

/etc/profile.d/* gets sourced at every login. You just need to relogin (after installing) to have the variable in your profile environment (i.e. every shell you open).

Offline

#8 2013-01-21 10:40:07

ciembor
Member
Registered: 2008-03-30
Posts: 57

Re: [Solved] Adding vendor_perl directory to $PATH

Solved: http://www.reddit.com/r/archlinux/comme … itar_hero/ smile

Thanks for support!

Last edited by ciembor (2013-01-21 10:43:37)

Offline

Board footer

Powered by FluxBB