diff options
| author | fukachan <fukachan> | 2004-06-07 16:04:41 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-06-07 16:04:41 +0000 |
| commit | fa7a80e4fc6ed2f60a3a565cb25452ba4c6ca0b0 (patch) | |
| tree | 88c8f4e7b8405e7fe8262f6baf91b76c5d3f00cb | |
| parent | c48969cc321030ef29a4a10e4e5eaec6fc3978be (diff) | |
| download | fml8-fa7a80e4fc6ed2f60a3a565cb25452ba4c6ca0b0.tar.gz fml8-fa7a80e4fc6ed2f60a3a565cb25452ba4c6ca0b0.tar.bz2 fml8-fa7a80e4fc6ed2f60a3a565cb25452ba4c6ca0b0.zip | |
enhanced to enable "make install install_root=/prefix" for package system.
install_root is the prefix that is prepended to the pathnames of
installed files.
[IMPORTANT]
In a lot of systems, "make install prefix=/prefix" is used. But it is
confusing against usage of othre software e.g. "./configure
--prefix=/prefix". So, we avoid this confusion to use other keyword,
which is same as Postfix.
| -rw-r--r-- | fml/lib/FML/Install.pm | 56 | ||||
| -rwxr-xr-x | install.pl.in | 24 |
2 files changed, 65 insertions, 15 deletions
diff --git a/fml/lib/FML/Install.pm b/fml/lib/FML/Install.pm index 511abdee..1f8f61b8 100644 --- a/fml/lib/FML/Install.pm +++ b/fml/lib/FML/Install.pm @@ -4,13 +4,14 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Install.pm,v 1.10 2003/12/26 14:51:37 fukachan Exp $ +# $FML: Install.pm,v 1.11 2004/01/21 03:45:03 fukachan Exp $ # package FML::Install; use strict; -use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD $debug); +use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD + $install_root $debug); use Carp; use FileHandle; use File::Spec; @@ -18,6 +19,10 @@ use File::Copy; use File::Basename; +# default ('' == '/') +$install_root = ''; + + =head1 NAME FML::Install - utility functions used in installation @@ -93,6 +98,21 @@ sub new } +# Descriptions: change install_root directory. +# Arguments: OBJ($self) STR($dir) +# Side Effects: update $install_root gloval variable. +# Return Value: none +sub set_install_root +{ + my ($self, $dir) = @_; + + if (defined $dir) { + $install_root = $dir; + print STDERR "\tinstall_root = $install_root\n"; + } +} + + # XXX-TODO: check uid, gid method @@ -217,7 +237,8 @@ sub install_main_cf # XXX src = relative path, dst = absolute path my $src = File::Spec->catfile("fml", "etc", "main.cf"); my $config_dir = $self->path( 'config_dir' ); - my $dst = File::Spec->catfile($config_dir, "main.cf"); + my $dst = File::Spec->catfile($install_root, + $config_dir, "main.cf"); if (-f $dst) { print STDERR "skipping $dst (debug)\n" if $debug; @@ -252,7 +273,7 @@ sub install_sample_cf_files for my $file (@$samples) { # XXX src = relative path, dst = absolute path my $src = File::Spec->catfile("fml", "etc", $file); - my $dst = File::Spec->catfile($config_dir, $file); + my $dst = File::Spec->catfile($install_root, $config_dir, $file); if (-f $dst) { print STDERR "skipping $dst (debug)\n" if $debug; @@ -296,7 +317,7 @@ sub install_default_config_files for my $file (@$nl_template_files) { # XXX src = relative path, dst = absolute path my $src = File::Spec->catfile("fml", "etc", $file); - my $dst = File::Spec->catfile($config_dir, $file); + my $dst = File::Spec->catfile($install_root, $config_dir, $file); # always override. $self->convert($src, $dst, 0644); @@ -315,7 +336,7 @@ sub install_default_config_files for my $file (@$template_files) { # XXX src = relative path, dst = absolute path my $src = File::Spec->catfile("fml", "etc", $file); - my $dst = File::Spec->catfile($config_dir, $file); + my $dst = File::Spec->catfile($install_root, $config_dir, $file); # always override. $self->convert($src, $dst, 0644); @@ -335,7 +356,8 @@ sub install_mtree_dir my $config = $self->{ _config }; # XXX src = relative path, dst = absolute path - my $dst_dir = File::Spec->catfile($self->path( 'default_config_dir' ), + my $dst_dir = File::Spec->catfile($install_root, + $self->path( 'default_config_dir' ), "mtree"); my $src_dir = File::Spec->catfile("fml", "etc", "mtree"); @@ -367,7 +389,7 @@ sub install_lib_dir { my ($self) = @_; my $config = $self->{ _config }; - my $dst_dir = $self->path( 'lib_dir' ); + my $dst_dir = File::Spec->catfile($install_root, $self->path('lib_dir')); my $src_dir = ''; print STDERR "updating $dst_dir\n"; @@ -392,7 +414,8 @@ sub install_libexec_dir # XXX src = relative path, dst = absolute path my $src_dir = File::Spec->catfile("fml", "libexec"); - my $dst_dir = $self->path( 'libexec_dir' ); + my $dst_dir = File::Spec->catfile($install_root, + $self->path( 'libexec_dir' )); print STDERR "updating $dst_dir\n"; $self->copy_dir( $src_dir, $dst_dir ); @@ -409,7 +432,8 @@ sub install_data_dir # XXX src = relative path, dst = absolute path my $src_dir = File::Spec->catfile("fml", "share"); - my $dst_dir = $self->path( 'data_dir' ); + my $dst_dir = File::Spec->catfile($install_root, + $self->path( 'data_dir' )); print STDERR "updating $dst_dir\n"; $self->copy_dir( $src_dir, $dst_dir ); @@ -437,7 +461,7 @@ sub install_bin_programs for my $prog (@$progs) { # XXX src = relative path, dst = absolute path my $src = File::Spec->catfile("fml", "bin", $prog); - my $dst = File::Spec->catfile($dst_dir, $prog); + my $dst = File::Spec->catfile($install_root, $dst_dir, $prog); print STDERR "updating $dst\n" if $debug; unless (-f $dst) { @@ -502,7 +526,8 @@ sub need_resymlink_loader # XXX src = relative path, dst = absolute path my $loader = File::Spec->catfile("fml", "libexec", "loader"); my $libexec_dir = $config->{ libexec_dir }; - my $cur_loader = File::Spec->catfile($libexec_dir, "loader"); + my $cur_loader = File::Spec->catfile($install_root, + $libexec_dir, "loader"); if ($debug) { print STDERR "cur $cur_loader\n"; @@ -554,7 +579,8 @@ sub install_loader # XXX src = relative path, dst = absolute path my $loader = File::Spec->catfile("fml", "libexec", "loader"); my $libexec_dir = $config->{ libexec_dir }; - my $cur_loader = File::Spec->catfile($libexec_dir, "loader"); + my $cur_loader = File::Spec->catfile($install_root, + $libexec_dir, "loader"); my $tmp = $cur_loader . ".$$"; $self->_copy($loader, $tmp); @@ -579,8 +605,10 @@ sub resymlink_loader { my ($self) = @_; my $config = $self->{ _config }; - my $libexec_dir = $config->{ libexec_dir }; + my $libexec_dir = File::Spec->catfile($install_root, + $config->{ libexec_dir }); my $cur_loader = File::Spec->catfile($libexec_dir, "loader"); + my $bin_programs = $config->get_as_array_ref('bin_programs'); my $exec_programs = $config->get_as_array_ref('libexec_programs'); diff --git a/install.pl.in b/install.pl.in index fa8c7cb7..6957bebc 100755 --- a/install.pl.in +++ b/install.pl.in @@ -5,12 +5,13 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: install.pl.in,v 1.3 2003/01/29 14:22:53 fukachan Exp $ +# $FML: install.pl.in,v 1.4 2003/01/30 03:33:16 fukachan Exp $ # use strict; use Carp; use lib qw(fml/lib cpan/lib img/lib); +use vars qw($install_root); # Run this from the top-level fml source directory. $ENV{'PATH'} = '/usr/xpg4/bin:/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc'; @@ -24,6 +25,7 @@ if ($0 eq __FILE__) { croak("Usage: $0 install.cf\n"); } else { + _init(); _install( $ARGV[0] ); } } @@ -34,6 +36,17 @@ else { exit 0; +# Descriptions: initialize some variables. +# Arguments: none +# Side Effects: set $install_root +# Return Value: none +sub _init +{ + # inherit enviromental variable + $install_root = $ENV{ 'install_root' } || ''; +} + + # Descriptions: install fml8 # Arguments: STR($cf) # Side Effects: install a lot of files: bin, lib, libexec/ and share/. @@ -47,6 +60,11 @@ sub _install my $installer = new FML::Install; my $config = $installer->load_install_cf( $cf ); + # change install_root if needed. + if ($install_root) { + $installer->set_install_root($install_root); + } + printf $format, "version", $installer->get_version() if $debug; $installer->is_valid_owner( $config->{ owner } ); @@ -57,6 +75,10 @@ sub _install my $list = $config->get_as_array_ref('mandatory_dirs'); for my $dir (@$list) { my $path = $installer->path($dir); + if ($install_root) { + $path = File::Spec->catfile($install_root, $path); + } + printf $format, $dir, $path if $debug; unless (-d $path) { $installer->mkdir($path); |
