Microperl basic questions

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I wrote some cgi scripts on the NGW100 web server with microperl. It is a nice tool, and it works quite like standard perl. I found some problems however:

1. I found, microperl ignores shell environment variables. I modified it in perl.c, and it works fine now. To keep the original source unchanged I made a patch, put it in package/microperl directory, but it is ignored by the build process. Are there any means to have it "registered" by make?

2. I understand it is the @INC variable that should contain the module paths. It should be defined in PERL5LIB env var. Could anybody help me in where to define such environment variable at boot time please? I thought it would be /etc/.bashrc, if I put "export PERL5LIB=...." there, it will not get a value after bootup. I of course could define @INC in my perl program, but then the program will not be transferable. Not a major problem, but it would be nicer like that.

Any help would be apprechiated!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1) Buildroot doesn't patch things without you asking it to :-). You'll have to fiddle with the .mk script in the package's directory. Add a '.patched' target depended on unpacked and before configured in which you invoke the 'patch-kernel.sh' script to do the actual patching. You should be able to find many examples through the buildroot packages directory :-)

2) Hehe, .bashrc will not be invoked because you aren't running bash! Common mistake. You're actually running (I'm guessing) the default Busybox shell. There are a few options, the most powerful of which is to simply use buildroot to build bash for you and tweak the /bin/sh symlink to point to the newly built bash rather than /bin/busybox. Then .bashrc should be run as you're expecting.

-S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks.
1: I'll give it a go.
2: How is the default PATH defined then with busybox? I just cannot figure it out.
(Hm, I am actually off-topic in my own thread. :? )

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I donno whether the default "/sbin:/usr/sbin:/bin:/usr/bin" is compiled in to busybox init or is a kernel thing (prolly the former) but either way, it isn't scripted.

If you want to change it at compile time you can define BB_ADDITIONAL_PATH.

-S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, you are right. (Kind of used to it :) ) I managed to find PATH wired in busybox source code, and it can be expanded with BB_ADDITIONAL_PATH.

Taking a U-turn to perl, my initial problem was that the location of the perl modules should be defined in PERL5LIB env var, but this I cannot do during bootup. I thought it could be defined just where PATH would be, but obviously, I was wrong.
I checked microperl for a "wired" value, and PERL5LIB seems to get the value /usr/lib/perl/5.8.8. without external definition. I created this directory for my modules, and it works.

By the way - I don't think reading a profile would be a major problem for busybox. I wonder why is it not so.