summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm.pm120
-rwxr-xr-xurpmi35
-rw-r--r--urpmi.spec8
3 files changed, 111 insertions, 52 deletions
diff --git a/urpm.pm b/urpm.pm
index afe08022..73bb2136 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -93,31 +93,31 @@ sub read_config {
local (*F, $_);
open F, $urpm->{config}; #- no filename can be allowed on some case
while (<F>) {
- chomp; s/#.*$//; s/\s*$//;
- /^\s*(.*?[^\\])\s+(?:(.*?[^\\])\s+)?{$/ and do { #- urpmi.cfg format extention
+ chomp; s/#.*$//; s/^\s*//; s/\s*$//;
+ /^(.*?[^\\])\s+(?:(.*?[^\\])\s+)?{$/ and do { #- urpmi.cfg format extention
my $medium = { name => unquotespace($1), clear_url => unquotespace($2) };
while (<F>) {
- chomp; s/#.*$//; s/\s*$//;
- /^\s*hdlist\s*:\s*(.*)$/ and $medium->{hdlist} = $1, next;
- /^\s*with_hdlist\s*:\s*(.*)$/ and $medium->{with_hdlist} = $1, next;
- /^\s*list\s*:\s*(.*)$/ and $medium->{list} = $1, next;
- /^\s*removable\s*:\s*(.*)$/ and $medium->{removable} = $1, next;
- /^\s*ignore\s*$/ and $medium->{ignore} = 1, next;
- /^\s*modified\s*$/ and $medium->{modified} = 1, next;
- /^\s*}$/ and last;
- /^\s*$/ or $urpm->{error}("syntax error at line $. in $urpm->{config}");
+ chomp; s/#.*$//; s/^\s*//; s/\s*$//;
+ /^hdlist\s*:\s*(.*)$/ and $medium->{hdlist} = $1, next;
+ /^with_hdlist\s*:\s*(.*)$/ and $medium->{with_hdlist} = $1, next;
+ /^list\s*:\s*(.*)$/ and $medium->{list} = $1, next;
+ /^removable\s*:\s*(.*)$/ and $medium->{removable} = $1, next;
+ /^ignore\s*$/ and $medium->{ignore} = 1, next;
+ /^modified\s*$/ and $medium->{modified} = 1, next;
+ $_ eq '}' and last;
+ $_ and $urpm->{error}("syntax error at line $. in $urpm->{config}");
}
$urpm->probe_medium($medium) and push @{$urpm->{media}}, $medium;
next; };
- /^\s*(.*?[^\\])\s+(.*?[^\\])\s+with\s+(.*)$/ and do { #- urpmi.cfg old format for ftp
+ /^(.*?[^\\])\s+(.*?[^\\])\s+with\s+(.*)$/ and do { #- urpmi.cfg old format for ftp
my $medium = { name => unquotespace($1), clear_url => unquotespace($2), with_hdlist => unquotespace($3) };
$urpm->probe_medium($medium) and push @{$urpm->{media}}, $medium;
next; };
- /^\s*(.*?[^\\])\s+(?:(.*?[^\\])\s*)?$/ and do { #- urpmi.cfg old format (assume hdlist.<name>.cz2?)
+ /^(.*?[^\\])\s+(?:(.*?[^\\])\s*)?$/ and do { #- urpmi.cfg old format (assume hdlist.<name>.cz2?)
my $medium = { name => unquotespace($1), clear_url => unquotespace($2) };
$urpm->probe_medium($medium) and push @{$urpm->{media}}, $medium;
next; };
- /^\s*$/ or $urpm->{error}("syntax error at line $. in [$urpm->{config}]");
+ $_ and $urpm->{error}("syntax error at line $. in [$urpm->{config}]");
}
close F;
@@ -178,6 +178,7 @@ sub read_config {
#- probe medium to be used, take old medium into account too.
sub probe_medium {
my ($urpm, $medium) = @_;
+ local $_;
my $existing_medium;
foreach (@{$urpm->{media}}) {
@@ -200,12 +201,12 @@ sub probe_medium {
#- there is a little more to do at this point as url is not known, inspect directly list file for it.
unless ($medium->{url} || $medium->{clear_url}) {
my %probe;
- local (*F, $_);
- open F, "$urpm->{statedir}/$medium->{list}";
- while (<F>) {
+ local *L;
+ open L, "$urpm->{statedir}/$medium->{list}";
+ while (<L>) {
/^(.*)\/[^\/]*/ and $probe{$1} = undef;
}
- close F;
+ close L;
foreach (sort { length($a) <=> length($b) } keys %probe) {
if ($medium->{url}) {
$medium->{url} eq substr($_, 0, length($medium->{url})) or
@@ -217,7 +218,7 @@ sub probe_medium {
}
$medium->{url} or
$medium->{ignore} || $urpm->{error}("unable to inspect list file for \"$medium->{name}\", medium ignored"),
- $medium->{ignore} = 1, last;
+ $medium->{ignore} = 1; #, last; keeping it cause perl to exit caller loop ...
}
$medium->{url} ||= $medium->{clear_url};
$medium;
@@ -274,7 +275,7 @@ sub add_medium {
#- the directory given does not exist or may be accessible
#- by mounting some other. try to figure out these directory and
#- mount everything necessary.
- $urpm->try_mounting($dir);
+ $urpm->try_mounting($dir, 'mount');
#- check if directory is somewhat normalized so that we can get back hdlist,
#- check it that case if depslist, compss and provides file are also
@@ -393,7 +394,7 @@ sub update_media {
#- the directory given does not exist and may be accessible
#- by mounting some other. try to figure out these directory and
#- mount everything necessary.
- $urpm->try_mounting($dir);
+ $urpm->try_mounting($dir, 'mount');
#- if the source hdlist is present and we are not forcing using rpms file
if (!$options{force} && $medium->{with_hdlist} && -e "$dir/$medium->{with_hdlist}") {
@@ -593,10 +594,10 @@ sub update_media {
#- check for necessity of mounting some directory to get access
sub try_mounting {
- my ($urpm, $dir) = @_;
+ my ($urpm, $dir, $mode) = @_;
if (!-e $dir) {
- my ($fdir, $pdir, $v, %fstab) = $dir;
+ my ($fdir, $pdir, $v, %fstab, @possible_mount_point) = $dir;
#- read /etc/fstab and check for existing mount point.
local (*F, $_);
@@ -624,14 +625,20 @@ sub try_mounting {
}
}
- #- check the presence of parent directory to mount directory.
+ #- check the possible mount point.
foreach (split '/', $fdir) {
length($_) or next;
$pdir .= "/$_";
foreach ($pdir, "$pdir/") {
- exists $fstab{$_} && !$fstab{$_} and $fstab{$pdir} = 1, `mount $pdir 2>/dev/null`;
+ exists $fstab{$_} and push @possible_mount_point, $_;
}
}
+
+ #- try to mount or unmount according to mode.
+ $mode eq 'unmount' and @possible_mount_point = reverse @possible_mount_point;
+ foreach (@possible_mount_point) {
+ $fstab{$_} == ($mode ne 'mount') and $fstab{$_} = ($mode eq 'mount'), `$mode '$_' 2>/dev/null`;
+ }
}
-e $dir;
}
@@ -693,6 +700,42 @@ sub write_base_files {
$urpm->{log}("write compss file [$urpm->{compss}]");
}
+#- relocate depslist array to use only the most recent packages,
+#- reorder info hashes too in the same manner.
+sub relocate_depslist {
+ my ($urpm) = @_;
+
+ $urpm->{params}->relocate_depslist;
+}
+
+#- register local packages for being installed, keep track of source.
+sub register_local_packages {
+ my ($urpm, @files) = @_;
+ my @names;
+
+ #- examine each rpm and build the depslist for them using current
+ #- depslist and provides environment.
+ foreach (@files) {
+ /(.*\/)?(.*)-([^-]*)-([^-]*)\.[^.]+\.rpm$/ or $urpm->{error}("invalid rpm file name [$_]"), next;
+ $urpm->{params}->read_rpms($_);
+
+ #- update info according to version and release, for source tracking.
+ $urpm->{params}{info}{$2} or $urpm->{error}("rpm file is not accessible with rpm file [$_]"), next;
+ $urpm->{params}{info}{$2}{version} eq $3 or $urpm->{error}("rpm file [$_] has not right version"), next;
+ $urpm->{params}{info}{$2}{release} eq $4 or $urpm->{error}("rpm file [$_] has not right release"), next;
+ $urpm->{params}{info}{$2}{source} = $1 ? $_ : "./$_";
+
+ #- keep in mind this package has to be installed.
+ push @names, "$2-$3-$4";
+ }
+
+ #- compute depslist associated.
+ $urpm->{params}->compute_depslist;
+
+ #- return package names...
+ @names;
+}
+
#- search packages registered by their name by storing their id into packages hash.
sub search_packages {
my ($urpm, $packages, $names, %options) = @_;
@@ -746,16 +789,15 @@ sub search_packages {
#- package are identified by their id.
sub compute_closure {
my ($urpm, $packages, $installed, $select_choices) = @_;
+ my ($id, @packages) = (undef, keys %$packages);
#- select first level of packages, as in packages list will only be
#- examined deps of each.
- @{$packages}{keys %$packages} = ();
+ @{$packages}{@packages} = ();
#- at this level, compute global closure of what is requested, regardless of
#- choices for which all package in the choices are taken and their dependancies.
#- allow iteration over a modifying list.
- my $id;
- my @packages = keys %$packages;
while (defined($id = shift @packages)) {
#- get a relocated id if possible, by this way.
$id = $urpm->{params}{depslist}[$id]{id};
@@ -785,6 +827,7 @@ sub compute_closure {
}
}
} else {
+ local $_ = $urpm->{params}{depslist}[$_]{id};
if (ref $packages->{$_}) {
#- all the choices associated here have to be dropped, need to copy else
#- there could be problem with foreach on a modifying list.
@@ -948,14 +991,17 @@ sub get_source_packages {
foreach (keys %$packages) {
exists $select{$_} and next;
- #- error found as a package has not be selected.
- $error = 1;
-
#- try to find which one.
my $pkg = $urpm->{params}{depslist}[$_];
if ($pkg) {
- $urpm->{error}("package $pkg->{name}-$pkg->{version}-$pkg->{release} is not found");
+ if ($pkg->{source}) {
+ push @local_sources, $pkg->{source};
+ } else {
+ $error = 1;
+ $urpm->{error}("package $pkg->{name}-$pkg->{version}-$pkg->{release} is not found, ids=($_,$pkg->{id})");
+ }
} else {
+ $error = 1;
$urpm->{error}("internal error for selecting unknown package for id=$_");
}
}
@@ -987,9 +1033,9 @@ sub upload_source_packages {
#- the directory given does not exist or may be accessible
#- by mounting some other. try to figure out these directory and
#- mount everything necessary.
- unless ($urpm->try_mounting($dir)) {
- system("eject", $device); #- umount too... TODO
- $ask_for_medium->($medium->{name}) or last;
+ unless ($urpm->try_mounting($dir, 'mount')) {
+ $urpm->try_mounting($dir, 'unmount'); system("eject", $device);
+ $ask_for_medium->($medium->{name}, $medium->{removable}) or last;
}
}
if (-e $dir) {
@@ -1068,10 +1114,8 @@ sub upload_source_packages {
close F or $urpm->{error}("cannot get distant rpms files (maybe wget is missing?)");
}
- #- need verification of available files... TODO
-
#- return the list of rpm file that have to be installed, they are all local now.
- @sources;
+ @$local_sources, @sources;
}
diff --git a/urpmi b/urpmi
index fb06e9fa..37b99494 100755
--- a/urpmi
+++ b/urpmi
@@ -25,7 +25,7 @@ my $auto = 0;
my $force = 0;
my $X = 0;
my $all = 0;
-my $rpm_opt = "-U";
+my $rpm_opt = "-Uvh";
my $datadir = "/var/lib/urpmi";
my $uid;
@@ -56,6 +56,7 @@ for (@ARGV) {
/[\?h]/ and do { usage; next };
/a/ and do { $all = 1; next };
/v/ and do { $rpm_opt = "-Uvh"; next };
+ /q/ and do { $rpm_opt = "-U"; next };
die "urpmi: unknown option \"-$1\", check usage with --help\n"; } next };
@nextargv and do { my $r = shift @nextargv; $r and $$r = $_; next };
/\.rpm$/ and do { -r $_ or print STDERR "urpmi: cannot read rpm file \"$_\"\n", next;
@@ -81,22 +82,20 @@ $urpm->read_depslist;
if (@files) {
$uid == 0 or die _("Only superuser is allowed to install local packages");
+ #- sanity check of pathname.
+ m|^/| or $_ = "./$_" foreach @files;
+
#- read provides file which is needed only to compute incremental
#- dependancies, of files provided.
$urpm->read_provides;
- #- compute depslist of files provided on command line.
- $urpm->{params}->read_rpms($_) foreach @files;
- $urpm->{params}->compute_depslist;
-
- #- gets full names of packages, sanity check of pathname.
- m|(.*/)?(.*)\.[^.]+\.rpm$| and push @names, $2 foreach @files;
- m|^/| or $_ = "./$_" foreach @files;
+ #- build closure with local package and return list of names.
+ push @names, $urpm->register_local_packages(@files);
}
#- reparse whole internal depslist to match against newer packages only.
-# TO MOVE TO urpm management of ignored medium
-$urpm->{params}->relocate_depslist();
+#- ignored medium MUST HAVE BEEN taken into account for building hdlist before!
+$urpm->relocate_depslist;
#- search the packages according the selection given by the user,
@@ -169,9 +168,19 @@ unless ($local_sources || $list) {
exit 1;
}
-my @sources = $urpm->upload_source_packages($local_sources, $list, sub {
- die "not implemented yet... change medium";
- });
+my @sources = $urpm->upload_source_packages($local_sources, $list, 'force_local', sub {
+ my $msg = _("Please insert the medium named \"%s\" on device [%s]", @_);
+ my $msg2 = _("Press enter when it's done...");
+ if ($X) {
+ my $ok = _("Ok");
+ my $cancel = _("Cancel");
+ `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg"`;
+ !$?;
+ } else {
+ print SAVEOUT "$msg\n$msg2 ";
+ <STDIN>; 1;
+ }
+ });
my $something_was_installed;
diff --git a/urpmi.spec b/urpmi.spec
index 465e4eac..d7e95342 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 1.4
-Release: 4mdk
+Release: 5mdk
License: GPL
Source0: %{name}.tar.bz2
Summary: User mode rpm install
@@ -113,6 +113,12 @@ autoirpm.uninstall
%changelog
+* Tue Jan 30 2001 François Pons <fpons@mandrakesoft.com> 1.4-5mdk
+- added medium change code.
+- fixed urpmi with local file.
+- changed default option to verbose when invoking rpm.
+
+
* Thu Jan 25 2001 François Pons <fpons@mandrakesoft.com> 1.4-4mdk
- added code to search for source rpms file to install.
- modified manipulation of ignore flag, keep media name unique.