File: Suse.pm

package info (click to toggle)
systeminstaller 1.04-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 748 kB
  • ctags: 261
  • sloc: perl: 5,769; makefile: 70
file content (179 lines) | stat: -rw-r--r-- 5,121 bytes parent folder | download | duplicates (2)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package SystemInstaller::Package::Suse;

#   $Header: /cvsroot/systeminstaller/systeminstaller/lib/SystemInstaller/Package/Suse.pm,v 1.21 2002/11/14 21:16:55 mchasal Exp $

#   Copyright (c) 2001 International Business Machines
 
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
 
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
 
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
#   Michael Chase-Salerno <mchasal@users.sf.net>
use strict;

use  File::Path;
use  File::Basename;
use SystemInstaller::Log qw(verbose get_verbose);
use SystemInstaller::PackageBest;
use SystemInstaller::Package::RpmNoScripts;
use SystemInstaller::Image qw(find_distro);
use Carp;
use File::Copy;
use Data::Dumper;

use vars qw($VERSION $config);

# The following two env vars are needed by mandrake.  They should not affect
# anyone else in a negative way

$ENV{SECURE_LEVEL} = 1;
 
$VERSION = sprintf("%d.%02d", q$Revision: 1.21 $ =~ /(\d+)\.(\d+)/);

#
## API FUNCTIONS
#

sub footprint {
# Look at a directory and determine if it looks like rpms.
# Input:        Directory name
# Returns:      Boolean of match
	my $class=shift;
        my $mode=shift;
        my $path=shift;
	my $rpmcmd=$main::config->rpm;
        if (($mode eq "install") || ($mode eq "post_install")) {
                if (glob "$path/aaa*.rpm") {
                        return 1;
                }
        }

        return 0;

} #footprint


sub files_install {
# Install the packages.
# Input:        image dir, filelist	
# Returns:	Boolean

	my $class=shift;
        my $imgpath=shift;
        my $pkgpath=shift;
        my @stages=@_;
        select(STDOUT);
        $|=1;

	
	# Install them
	my $rpmcmd=$main::config->rpm;
	my $rpmargs=$main::config->rpmargs;
	my $redir;
	if (get_verbose) {
		$redir="";
	} else {
		$redir=">/dev/null";
	}

        foreach my $stage (1..(scalar(@stages)-1)) {
                my @order=();
	        # Make a string of all the filenames
	        my $pkglist=join(" ",@{$stages[$stage]{FILES}});
                my $cmd="cd $pkgpath;$rpmcmd -ir $imgpath $rpmargs --noscripts --notriggers $stages[$stage]{ARGS} $pkglist";
                &verbose("Performing RPM stage $stage install, command is:");
                &verbose("$cmd");

                open (INSTALL,"$cmd |");
                while (<INSTALL>) {
                       unless (/^\%\%/) {
                               chomp;
                               print "$_\n" if &get_verbose;
                               unless (/ /) {
                                        push (@order,$_);
                               }
                       }
                }
	        unless (close(INSTALL)) {
                        carp("Rpm installation failed.");
		        return 0;
	        }
                my @forder;
                foreach my $pkg (@order) {
                        $pkg=~s/-[^-]*-[^-]*$//;
                        push(@forder,$stages[$stage]{PACKAGES}{$pkg});
                }
                &SystemInstaller::Package::RpmNoScripts::run_scriptlets($imgpath,$pkgpath,@forder);
        }

	return 1;
} #files_install

sub files_post_install {
# Rpm post install routine
# Input: imagedir, pkgdir
# Output: boolean
    my $class=shift;
    my $imagedir = shift;
    my $pkgdir = shift;
    my @file;
    # Here are some things that I know we need to do...

    # Generate shadow files
    if(-x "$imagedir/usr/sbin/pwconv") {
        system("chroot $imagedir /usr/sbin/pwconv");
    }
    if(-x "$imagedir/usr/sbin/grpconv") {
        system("chroot $imagedir /usr/sbin/grpconv");
    }

    
    # run ldconfig to ensure libraries are accounted for
    system("chroot $imagedir /sbin/ldconfig");

    # Run SuSEconfig to genrat all sorts of files.
    if(-x "$imagedir/sbin/SuSEconfig") {
        system("chroot $imagedir /sbin/SuSEconfig");
    }

    return 1;
} # files_post_install
### POD from here down

=head1 NAME
 
SystemInstaller::Package::Suse - Suse rpm package installation functions.
 
=head1 DESCRIPTION

This module provides the SystemInstall package API functions for Rpm based
installation. This module runs the post scriptlets after the installation of 
all files to circumvent some limitations. It can only be used with versions of
rpm that support the --nopost flag (4.0.3+).
This module provides the following API subroutines:
files_install.

See the SystemInstaller::Package manpage for details
on the API specification.

=head1 AUTHOR
 
Michael Chase-Salerno <mchasal@users.sf.net>
 
=head1 SEE ALSO

L<SystemInstaller::Package>
 
=cut

1;