From cd3fd7727010115a3c1cbac2b5ca11c3a81a02a1 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 28 Jan 2005 18:09:52 +0000 Subject: Make urpmi support ISO images as removable media. --- urpm/sys.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'urpm') diff --git a/urpm/sys.pm b/urpm/sys.pm index 1ccc3b6e..8a5e0739 100644 --- a/urpm/sys.pm +++ b/urpm/sys.pm @@ -107,6 +107,26 @@ sub find_mntpoints { @mntpoints; } +#- returns the first unused loop device, or an empty string if none is found. +sub first_free_loopdev () { + open my $mounts, '/proc/mounts' or do { warn "Can't read /proc/mounts: $!\n"; return 1 }; + my %loopdevs = map { $_ => 1 } grep { ! -d $_ } glob('/dev/loop*'); + local *_; + while (<$mounts>) { + (our $dev) = split ' '; + delete $loopdevs{$dev} if $dev =~ m!^/dev/loop!; + } + close $mounts; + my @l = keys %loopdevs; + @l ? $l[0] : ''; +} + +sub trim_until_d { + my ($dir) = @_; + while ($dir && !-d $dir) { $dir =~ s,/[^/]*$,, } + $dir; +} + #- checks if the main filesystems are writeable for urpmi to install files in sub check_fs_writable () { open my $mounts, '/proc/mounts' or do { warn "Can't read /proc/mounts: $!\n"; return 1 }; -- cgit v1.2.1