summaryrefslogtreecommitdiffstats
path: root/perl-install/pkgs.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-08-27 10:58:06 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-08-27 10:58:06 +0000
commit69907ed1e861483d4063a1eec3662690681651a7 (patch)
tree57be1d65269228481701e476bcf25c4a06ba6366 /perl-install/pkgs.pm
parent0a2ecf8b913dea899159f455cd5b9db7d39e6031 (diff)
downloaddrakx-backup-do-not-use-69907ed1e861483d4063a1eec3662690681651a7.tar
drakx-backup-do-not-use-69907ed1e861483d4063a1eec3662690681651a7.tar.gz
drakx-backup-do-not-use-69907ed1e861483d4063a1eec3662690681651a7.tar.bz2
drakx-backup-do-not-use-69907ed1e861483d4063a1eec3662690681651a7.tar.xz
drakx-backup-do-not-use-69907ed1e861483d4063a1eec3662690681651a7.zip
no_comment
Diffstat (limited to 'perl-install/pkgs.pm')
-rw-r--r--perl-install/pkgs.pm64
1 files changed, 33 insertions, 31 deletions
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index d10713c5b..e377cf361 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -8,6 +8,7 @@ use common qw(:common :file);
use install_any;
use log;
use smp;
+use pkgs;
use fs;
use lang;
@@ -85,11 +86,10 @@ sub set($$$) {
$val ? &select($packages, $p) : unselect($packages, $p);
}
-sub psUsingDirectory(;$) {
- my ($dirname) = @_;
+sub psUsingDirectory() {
+ my $dirname = install_any::imageGetFile('');
my %packages;
- $dirname ||= install_any::imageGetFile('');
log::l("scanning $dirname for packages");
foreach (all("$dirname")) {
my ($name, $version, $release) = /(.*)-([^-]+)-([^-.]+)\.[^.]+\.rpm/ or log::l("skipping $_"), next;
@@ -102,6 +102,31 @@ sub psUsingDirectory(;$) {
\%packages;
}
+sub psUsingHdlist() {
+ my $file = install_any::imageGetFile('hdlist');
+ my ($noSeek, $end, %packages) = 0;
+
+ local *F;
+ sysopen F, $file, 0 or die "error opening header file $file: $!";
+
+ $end = sysseek F, 0, 2 or die "seek failed";
+ sysseek F, 0, 0 or die "seek failed";
+
+ while (sysseek(F, 0, 1) < $end) {
+ my $header = c::headerRead(fileno F, 1) or die "error reading header at offset ", sysseek(F, 0, 1);
+
+ my $name = c::headerGetEntry($header, 'name');
+
+ $packages{$name} = {
+ name => $name, version => c::headerGetEntry($header, 'version'), release => c::headerGetEntry($header, 'release'),
+ header => $header, selected => 0, deps => [],
+ };
+ }
+ log::l("psUsingHdlist read " . scalar keys(%packages) . " headers");
+
+ \%packages;
+}
+
sub chop_version($) {
first($_[0] =~ /(.*)-[^-]+-[^-.]+/) || $_[0];
}
@@ -172,34 +197,6 @@ sub setCompssSelected($$$) {
}
}
-sub addHdlistInfos {
- my ($fd, $noSeek) = @_;
- my %packages;
- my $end;
- my $file;
- local *F;
- sysopen F, $file, 0 or die "error opening header file $file: $!";
-
- $end = sysseek $fd, 0, 2 or die "seek failed";
- sysseek $fd, 0, 0 or die "seek failed";
-
- while (sysseek($fd, 0, 1) <= $end) {
- my $header = c::headerRead(fileno($fd), 1);
- unless ($header) {
- $noSeek and last;
- die "error reading header at offset ", sysseek($fd, 0, 1);
- }
-
- c::headerGetEntry($header, 'name');
-
- $noSeek or $end <= sysseek($fd, 0, 1) and last;
- }
-
- log::l("psFromHeaderListDesc read " . scalar keys(%packages) . " headers");
-
- \%packages;
-}
-
sub init_db {
my ($prefix, $isUpgrade) = @_;
@@ -241,6 +238,11 @@ sub install {
foreach my $p (@$toInstall) {
$p->{installed} = 1;
+ $p->{file} ||= install_any::imageGetFile(sprintf "%s-%s-%s.%s.rpm",
+ $p->{name},
+ $p->{version},
+ $p->{release},
+ c::headerGetEntry(getHeader($p), 'arch'));
c::rpmtransAddPackage($trans, getHeader($p), $p->{file}, $isUpgrade);
$nb++;
$total += $p->{size};
href='#n295'>295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
package fs; # $Id$

use diagnostics;
use strict;

use common;
use log;
use devices;
use fs::type;
use fs::get;
use fs::format;
use fs::mount_options;
use fs::loopback;
use fs::mount;
use run_program;
use detect_devices;
use modules;
use fsedit;


sub read_fstab {
    my ($prefix, $file, @reading_options) = @_;

    if (member('keep_default', @reading_options)) {
	push @reading_options, 'freq_passno', 'keep_device_LABEL', 'keep_device_UUID';
    }

    my %comments;
    my $comment;
    my @l = grep {
	if (/^Filename\s*Type\s*Size/) {
	    0; #- when reading /proc/swaps
	} elsif (/^\s*#/) {
	    $comment .= chomp_($_) . "\n";
	    0;
	} else {
	    $comments{$_} = $comment if $comment;
	    $comment = '';
	    1;
	}
    } cat_("$prefix$file");

    #- attach comments at the end of fstab to the previous line
    $comments{$l[-1]} = $comment if $comment;

    map {
	my ($dev, $mntpoint, $fs_type, $options, $freq, $passno) = split;
	my $comment = $comments{$_};

	$options = 'defaults' if $options eq 'rw'; # clean-up for mtab read

	if ($fs_type eq 'supermount') {
	    log::l("dropping supermount");
	    $options = join(",", grep {
		if (/fs=(.*)/) {
		    $fs_type = $1;

		    #- with supermount, the type could be something like ext2:vfat
		    #- but this can not be done without supermount, so switching to "auto"
		    $fs_type = 'auto' if $fs_type =~ /:/;

		    0;
		} elsif (/dev=(.*)/) {
		    $dev = $1;
		    0;
		} elsif ($_ eq '--') {
		    0;
		} else {
		    1;
		}
	    } split(',', $options));
	} elsif ($fs_type eq 'smb') {
	    # prefering type "smbfs" over "smb"
	    $fs_type = 'smbfs';
	}
	s/\\040/ /g foreach $mntpoint, $dev, $options;

	my $h = { 
		 mntpoint => $mntpoint, fs_type => $fs_type,
		 options => $options, comment => $comment,
		 if_(member('keep_freq_passno', @reading_options), freq => $freq, passno => $passno),
		};

	put_in_hash($h, fs::wild_device::to_subpart($dev));

	if ($h->{device_LABEL} && !$h->{device_alias} && member('keep_device_LABEL', @reading_options)) {
	    $h->{prefer_device_LABEL} = 1;
	} elsif ($h->{device_UUID} && !$h->{device_alias} && member('keep_device_UUID', @reading_options)) {
	    $h->{prefer_device_UUID} = 1;
	} else {
	    $h->{prefer_device} = 1;
	}

	if ($h->{options} =~ /credentials=/ && !member('verbatim_credentials', @reading_options)) {
	    require fs::remote::smb;
	    #- remove credentials=file with username=foo,password=bar,domain=zoo
	    #- the other way is done in fstab_to_string
	    my ($options, $unknown) = fs::mount_options::unpack($h);
	    my $file = delete $options->{'credentials='};
	    my $credentials = fs::remote::smb::read_credentials_raw($file);
	    if ($credentials->{username}) {
		$options->{"$_="} = $credentials->{$_} foreach qw(username password domain);
		fs::mount_options::pack($h, $options, $unknown);
	    }
	}

	$h;
    } @l;
}

sub merge_fstabs {
    my ($loose, $fstab, @l) = @_;

    foreach my $p (@$fstab) {
	my ($l1, $l2) = partition { fs::get::is_same_hd($_, $p) } @l;
	my ($p2) = @$l1 or next;
	@l = @$l2;

	$p->{mntpoint} = $p2->{mntpoint} if delete $p->{unsafeMntpoint};

	if (!$loose) {
	    $p->{fs_type} = $p2->{fs_type} if $p2->{fs_type};
	    $p->{options} = $p2->{options} if $p2->{options};
	    add2hash($p, $p2);
	} else {
	    $p->{isMounted} ||= $p2->{isMounted};
	    $p->{real_mntpoint} ||= $p2->{real_mntpoint};
	}