Thomas Klausner wrote:
> Hi!
> 
> I'm currently fuzzing around with a Build.PL that should do the 
> following:
> 
> - ask for a location where the application shall be installed to
> - make sure the location exists
> - install various files there
> - install the libs into the default location
> 
> Everything works fine, but:
> 
> If I want to install the libs, I have to be root (or do sudo ./Build 
> istall). But if I do this, all the extra stuff installed into the app 
> dir also belongs to root. Which sucks. If I install without sudo, the 
> installation doesn't work, because of missing permissions...
>
> Is there an easy way around this? I would like to avoid to have to set 
> all files to a different owner after installation (from within 
> Build.PL). 
>
> Can I somehow add Build actions? If yes, I could define a new action 
> 'app_install', and call that with correct user. i.e
> perl Build.PL
> ./Build
> ./Build test
> ./Build app_install
> sudo ./Build install
> 
> Is this possible? If yes, how? Or are there other, better ways to solve 
> my problem?

I would say to define ACTION_app_install() and call that from
ACTION_install(), that way it's one command.  Inside that method simply
downgrade your permissions, like any other root program can do, using

  local $> = $uid;

$ sudo perl -wle 'open FILE, ">root_file";  $> = 501;  open FILE, ">user_file";'
$ ls -l root_file user_file
-rw-r--r-- 1 root    schwern 0 Oct 17 18:47 root_file
-rw-r--r-- 1 schwern schwern 0 Oct 17 18:47 user_file

The trick is knowing what user to downgrade to... and, of course, the app dir
might require root permissions, too.

Alternatively, do it in two steps and customize ACTION_install() to print out
instructions to run app_install.

        sub ACTION_install {
                my $self = shift;

                # I think actions return success/failure.  I could be wrong
                if( $self->SUPER::ACTION_install(@_) ) {
                        print "Now run app_install to blah blah blah\n";
                }
        }


-- 
You know what the chain of command is? It's the chain I go get and beat you
with 'til you understand who's in ruttin' command here.
        -- Jayne Cobb, "Firefly"

Reply via email to