tags:

views:

80

answers:

3

Is there an easy/clean way to do this in Linux/ a Linux-like environment?

Purpose

My aim is to run CPAN with admin permissions only during the installation phase, not at the get/make/test phases.

+2  A: 

The CPAN configuration items make_install_make_command and mbuild_install_build_command deal with this. Change them to enable sudo support.

daxim
This isn't what i was after, but it would certainly be helpful. `o conf make_install_make_command` says it is bound to `sudo make`, but installing fails when trying to write to system bin directories, claiming `\usr\bin\make` lacks permission...
Charles Stewart
You're mistaken, this is **exactly** what you want. These configuration items were specifically added for this scenario so that people do not run the full cpan, especially the testing step, with elevated privileges. Make resides at `/usr/bin/make`, note the forward slashes. Correct your configuration and try again.
daxim
Charles Stewart
A: 

For the sake of documenting an approach that seems promising, but doesn't work - the shell command:

find . -type d -mindepth 1 -maxdepth 1 -print | while read -r DIR; do pushd $DIR;  make -q; mk=$?; make -q install; inst=$?; make -q test; tst=$?; echo Directory "$DIR $mk $inst $tst"; popd; done| fgrep -ve /build

when executed in the cpan build dir lists the exit statuses of make -q for "", "test" and "install", which says whether that make goal needs any work to achieve.

But all have nonzero exit statuses, which means they all will do something if you execute them, even if the make has successfully been completed. So you can't tell anything this way.

Charles Stewart
+1  A: 

Assuming you're using CPAN.pm for that, I have a somewhat unorthodox suggestion.

Make a subclass of CPAN.pm, which actually publishes the results/stages of each module it works with to a registry (via a suplied callback API to make the registry implementation flexible).

Then you need to simply check that registry.

(or you can try to put that as a patch into CPAN.pm itself)

DVK
I'm using CPAN.pm, yes. Should I gather that CPAN doesn't record any state outside the results of make, and so the answer to the exact question I asked is: Sorry, you can't do that?
Charles Stewart
Charles Stewart