Portable @INC

  • Thread starter Tielman de Villiers
  • Start date
T

Tielman de Villiers

I want to compile a "portable perl" which will live in users' ~/usr
directory.
I tried to achieve this by:
../Configure -Dprefix=\$HOME/usr -des
and then
make install DESTDIR=/home/auser
By typing
/home/auser/usr/bin/perl -V
@INC displays what I want:
====
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Oct 25 2003 14:10:07
@INC:
/home/auser/usr/lib/perl5/5.8.1/i686-linux
/home/auser/usr/lib/perl5/5.8.1
$HOME/usr/lib/perl5/site_perl/5.8.1/i686-linux
$HOME/usr/lib/perl5/site_perl/5.8.1
$HOME/usr/lib/perl5/site_perl
====
BUT these "compiled in" @INC links do not work.
Is there a way around it?
(Without using "use lib" or /home/auser/usr/bin/perl
-I$HOME/usr/lib/perl5/site_perl)
 
B

Bob Walton

Tielman said:
I want to compile a "portable perl" which will live in users' ~/usr
directory.
I tried to achieve this by:
./Configure -Dprefix=\$HOME/usr -des
and then
make install DESTDIR=/home/auser
By typing
/home/auser/usr/bin/perl -V
@INC displays what I want:
====
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Oct 25 2003 14:10:07
@INC:
/home/auser/usr/lib/perl5/5.8.1/i686-linux
/home/auser/usr/lib/perl5/5.8.1
$HOME/usr/lib/perl5/site_perl/5.8.1/i686-linux
$HOME/usr/lib/perl5/site_perl/5.8.1
$HOME/usr/lib/perl5/site_perl
====
BUT these "compiled in" @INC links do not work.
Is there a way around it?
(Without using "use lib" or /home/auser/usr/bin/perl
-I$HOME/usr/lib/perl5/site_perl)

Hmmmmm...It isn't very clear to me what you are trying to accomplish.
You are compiling a copy of Perl for each luser's home directory. OK --
no problem -- not sure why or anything -- but just go ahead and do it,
and don't escape the $ in $HOME from the shell in the ./Configure, and
everything should go smoothly. The reason things "do not work" above is
that the literal $HOME (which is supposed to be a shell variable
reference) is getting into Perl's internal stuff, like @INC, and it
never sees a shell from there. Perl then looks for the literal
directory '$HOME/usr/...' and doesn't find a directory by that name. If
you wouldn't have escaped the $ from the shell, the expansion
/home/asuer would be there instead, and everything would be fine.

Or am I totally misunderstanding what you are trying to do?
 
T

Tielman de Villiers

Bob Walton said:
Hmmmmm...It isn't very clear to me what you are trying to accomplish.
You are compiling a copy of Perl for each luser's home directory. OK --
no problem -- not sure why or anything -- but just go ahead and do it,
and don't escape the $ in $HOME from the shell in the ./Configure, and
everything should go smoothly. The reason things "do not work" above is
that the literal $HOME (which is supposed to be a shell variable
reference) is getting into Perl's internal stuff, like @INC, and it
never sees a shell from there. Perl then looks for the literal
directory '$HOME/usr/...' and doesn't find a directory by that name. If
you wouldn't have escaped the $ from the shell, the expansion
/home/asuer would be there instead, and everything would be fine.

Or am I totally misunderstanding what you are trying to do?

The idea is to compile the "portable perl" only once, tarball it, and
then expand the tarball in all the users' home dirs -- the "portable
perl" should then "automatically" / "dynamically" know that it is in,
say, "/home/usera" or "/home/userb" and have a corresponding @INC.
This is very do-able by prepending to @INC through "use lib" or
running /path/to/perl -I/path/to/auser, but I want to know if it can
be "hard-coded" into the compiled perl.
 
W

William Herrera

The idea is to compile the "portable perl" only once, tarball it, and
then expand the tarball in all the users' home dirs -- the "portable
perl" should then "automatically" / "dynamically" know that it is in,
say, "/home/usera" or "/home/userb" and have a corresponding @INC.
This is very do-able by prepending to @INC through "use lib" or
running /path/to/perl -I/path/to/auser, but I want to know if it can
be "hard-coded" into the compiled perl.

Don't make your work harder than needed :).

You should just work out a way to redefine the environment variable PERL5LIB
for each user, prior to the time the user runs perl.

See perlrun:

PERL5LIB

A colon-separated list of directories in which to look for Perl library files
before looking in the standard library and the current directory. Any
architecture-specific directories under the specified locations are
automatically included if they exist. If PERL5LIB is not defined, PERLLIB is
used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top