package pkgs; # $Id$
use strict;
use MDK::Common::System;
use URPM;
use URPM::Resolve;
use URPM::Signature;
use common;
use install_any;
use run_program;
use detect_devices;
use log;
use fs;
use loopback;
use c;
our %preferred = map { $_ => undef } qw(lilo perl-base gstreamer-oss openjade ctags glibc curl sane-backends postfix mdkkdm gcc gcc-cpp gcc-c++ proftpd ghostscript-X vim-minimal kernel db1 db2 libxpm4 zlib1 libncurses5 harddrake cups apache);
#- lower bound on the left ( aka 90 means [90-100[ )
our %compssListDesc = (
5 => N_("must have"),
4 => N_("important"),
3 => N_("very nice"),
2 => N_("nice"),
1 => N_("maybe"),
);
#- constant for small transaction.
our $limitMinTrans = 13;
#- package to ignore, typically in Application CD. OBSOLETED ?
my %ignoreBadPkg = (
'civctp-demo' => 1,
'eus-demo' => 1,
'myth2-demo' => 1,
'heretic2-demo' => 1,
'heroes3-demo' => 1,
'rt2-demo' => 1,
);
sub packageMedium {
my ($packages, $p) = @_; $p or die "invalid package from\n" . backtrace();
foreach (values %{$packages->{mediums}}) {
defined $_->{start} && defined $_->{end} or next;
$p->id >= $_->{start} && $p->id <= $_->{end} and return $_;
}
return {};
}
sub cleanHeaders() {
rm_rf("$::prefix/tmp/headers") if -e "$::prefix/tmp/headers";
}
#- get all headers from an hdlist file.
sub extractHeaders {
my ($pkgs, $media) = @_;
my %medium2pkgs;
cleanHeaders();
foreach (@$pkgs) {
foreach my $medium (values %$media) {
$_->id >= $medium->{start} && $_->id <= $medium->{end} or next;
push @{$medium2pkgs{$medium->{medium}} ||= []}, $_;
}
}
foreach (keys %medium2pkgs) {
my $medium = $media->{$_};
eval {
require packdrake;
my $packer = new packdrake("/tmp/$medium->{hdlist}", quiet => 1);
$packer->extract_archive("$::prefix/tmp/headers", map { $_->header_filename } @{$medium2pkgs{$_}});
};
}
foreach (@$pkgs) {
my $f = "$::prefix/tmp/headers/" . $_->header_filename;
$_->update_header($f) or log::l("unable to open header file $f"), next;
log::l("read header file $f");
}
}
sub isSupplCDMedium($) {
my ($medium) = @_;
$medium->{method} eq 'cdrom' && $medium->{medium} =~ /^\d+s$/;
}
#- TODO BEFORE TODO
#- size and correction size functions for packages.
my $B = 1.20873;
my $C = 4.98663; #- does not take hdlist's into account as getAvailableSpace will do it.
sub correctSize { $B * $_[0] + $C }
sub invCorrectSize { ($_[0] - $C) / $B }
|