summaryrefslogtreecommitdiff
path: root/install.pl.in
blob: fa8c7cb7404e3e0171ad1589ff36ee49d8fae9f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#! @PERL@ -w
#-*- perl -*-
#
#  Copyright (C) 2003 Ken'ichi Fukamachi
#   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 $
#

use strict;
use Carp;
use lib qw(fml/lib cpan/lib img/lib);

# Run this from the top-level fml source directory.
$ENV{'PATH'} = '/usr/xpg4/bin:/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc';

my $debug = 0;

if ($0 eq __FILE__) {
    umask(022);

    unless (@ARGV) {
	croak("Usage: $0 install.cf\n");
    }
    else {
	_install( $ARGV[0] );
    }
}
else {
    croak("Usage: $0 install.cf\n");
}

exit 0;


# Descriptions: install fml8
#    Arguments: STR($cf)
# Side Effects: install a lot of files: bin, lib, libexec/ and share/.
# Return Value: none
sub _install
{
    my ($cf) = @_;
    my $format    = "%20s = %s\n";

    use FML::Install;
    my $installer = new FML::Install;
    my $config    = $installer->load_install_cf( $cf );

    printf $format, "version", $installer->get_version() if $debug;

    $installer->is_valid_owner( $config->{ owner } );
    $installer->is_valid_group( $config->{ group } );

    if ($installer->is_run_as_root()) {

	my $list = $config->get_as_array_ref('mandatory_dirs');
	for my $dir (@$list) {
	    my $path = $installer->path($dir);
	    printf $format, $dir, $path if $debug;
	    unless (-d $path) {
		$installer->mkdir($path);
	    }
	    else {
		print STDERR "ok $path\n" if $debug;
	    }
	}

	$installer->install_main_cf();
	$installer->install_sample_cf_files();
	$installer->install_default_config_files();
	$installer->install_mtree_dir();
	$installer->install_lib_dir();
	$installer->install_libexec_dir();
	$installer->install_data_dir();

	# install programs hereafter.
	$installer->install_bin_programs();

	# update loader.
	if ( $installer->need_resymlink_loader() ) {
	    $installer->install_loader();
	    $installer->resymlink_loader();
	}

	# set up ml_spool_dir such as /var/spool/ml if needed.
	$installer->setup_ml_spool_dir();
    }
    else {
	croak("Error: run $0 as root.\n");
    }
}