From 2e6d60e619c016a2d7cf3a0bfe9c0b82e290f8c8 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Thu, 3 Nov 2005 14:47:09 +0000 Subject: Remove more MDK::Common vestigia --- urpm/ldap.pm | 16 +++++++++++++++- urpm/util.pm | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'urpm') diff --git a/urpm/ldap.pm b/urpm/ldap.pm index 79710654..510107ea 100644 --- a/urpm/ldap.pm +++ b/urpm/ldap.pm @@ -78,11 +78,25 @@ sub check_ldap_medium($) { return $medium->{name} && $medium->{clear_url}; } +sub get_vars_from_sh { + my $filename = $_[0]; + my %l; + open my $fh, $filename or return (); + local $_; + while (<$fh>) { + s/#.*//; s/^\s*//; s/\s*$// + my ($key, $val) = /^(\w+)=(.*)/ or next; + $val =~ s/^(["'])(.*)\1$/$2/; + $l{$key} = $val; + } + %l; +} + sub read_ldap_cache($%) { my ($urpm, %options) = @_; foreach (glob("$urpm->{cachedir}/ldap/*")) { ! -f $_ and next; - my %medium = getVarsFromSh($_); + my %medium = get_vars_from_sh($_); next if !check_ldap_medium(\%medium); $urpm->probe_medium(\%medium, %options) and push @{$urpm->{media}}, \%medium; } diff --git a/urpm/util.pm b/urpm/util.pm index 0423a094..008f2e89 100644 --- a/urpm/util.pm +++ b/urpm/util.pm @@ -7,6 +7,7 @@ our @EXPORT = qw(quotespace unquotespace remove_internal_name reduce_pathname offset_pathname md5sum untaint + difference2 ); #- quoting/unquoting a string that may be containing space chars. @@ -94,6 +95,8 @@ sub move { rename($file, $dest) or !system("/bin/mv", "-f", $file, $dest); } +sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} } + 1; __END__ -- cgit v1.2.1