summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2014-10-21 23:33:35 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2014-10-23 00:21:24 +0200
commita7065e441c7f46cf430ad9f2aa4ea6f7e48906ac (patch)
tree654d5399ffb8ff5c924e30e84a8916709e35540a /tools
parent1b94db0c531b1d9f7a3fc095a5b646fccffc20ec (diff)
downloaddrakx-a7065e441c7f46cf430ad9f2aa4ea6f7e48906ac.tar
drakx-a7065e441c7f46cf430ad9f2aa4ea6f7e48906ac.tar.gz
drakx-a7065e441c7f46cf430ad9f2aa4ea6f7e48906ac.tar.bz2
drakx-a7065e441c7f46cf430ad9f2aa4ea6f7e48906ac.tar.xz
drakx-a7065e441c7f46cf430ad9f2aa4ea6f7e48906ac.zip
introduce mount() function
more readable & needed for next commit
Diffstat (limited to 'tools')
-rwxr-xr-xtools/drakx-in-chroot29
1 files changed, 17 insertions, 12 deletions
diff --git a/tools/drakx-in-chroot b/tools/drakx-in-chroot
index 223ebb78b..e289ebbaf 100755
--- a/tools/drakx-in-chroot
+++ b/tools/drakx-in-chroot
@@ -77,20 +77,20 @@ if ($remote_repository) {
sys("curl --silent -o $local_mdkinst $repository/$COMPRESSED_FILE_REL");
mount_mdkinst($local_mdkinst);
} elsif (-d "$repository/$LIVE_LOCATION_REL") {
- sys("$sudo mount -o bind $repository/$LIVE_LOCATION_REL $STAGE2_LOCATION");
+ mount("$repository/$LIVE_LOCATION_REL", $STAGE2_LOCATION, "-o bind");
} elsif (-e "$repository/$COMPRESSED_FILE_REL") {
mount_mdkinst("$repository/$COMPRESSED_FILE_REL");
}
-sys("$sudo mount -o bind $dir $SLASH_LOCATION$prefix_ROOTED");
+mount($dir, "$SLASH_LOCATION$prefix_ROOTED", "-o bind");
$repository_uri ||= $repository_without_arch if !$remote_repository;
-sys("$sudo mount -o bind $repository_uri $SLASH_LOCATION$MEDIA_LOCATION_ROOTED") if $repository_uri;
+mount($repository_uri, "$SLASH_LOCATION$MEDIA_LOCATION_ROOTED", "-o bind") if $repository_uri;
-sys("$sudo mount --bind -o ro /dev $SLASH_LOCATION/dev");
-sys("$sudo mount -t proc none $SLASH_LOCATION/proc");
-sys("$sudo mount -t sysfs none $SLASH_LOCATION/sys");
-sys("$sudo mount -t debugfs none $SLASH_LOCATION/sys/kernel/debug");
-sys("$sudo mount -t tmpfs none $SLASH_LOCATION/run");
+mount('/dev', "$SLASH_LOCATION/dev", " --bind -o ro");
+mount('none', "$SLASH_LOCATION/proc", "-t proc");
+mount('none', "$SLASH_LOCATION/sys", "-t sysfs");
+mount('none', "$SLASH_LOCATION/sys/kernel/debug", "-t debugfs");
+mount('none', "$SLASH_LOCATION/run", "-t tmpfs");
# - Ensure we mount the udev run dir for various extra metadata from udevadm
# - If dracut has been used (and thus udev has yummy metadata) make sure
@@ -99,13 +99,13 @@ sys("$sudo mount -t tmpfs none $SLASH_LOCATION/run");
foreach my $dir (qw(initramfs udev blkid)) {
next if !-d "/run/$dir";
mkdir_p("$SLASH_LOCATION/run/$dir");
- sys("$sudo mount -o bind /run/$dir $SLASH_LOCATION/run/$dir");
+ mount("/run/$dir", "$SLASH_LOCATION/run/$dir", "-o bind");
}
if ($disk_iso_repository) {
my $repository_arch = $repository_arch || 'i586';
mkdir_p($LOOP_MOUNT_POINT);
- sys("$sudo mount -o loop,ro $disk_iso_repository $LOOP_MOUNT_POINT");
+ mount($disk_iso_repository, $LOOP_MOUNT_POINT, "-o loop,ro");
symlinkf('loop/' . $repository_arch, "$SLASH_LOCATION$IMAGE_LOCATION_ROOTED"); # FIXME: arch()
}
@@ -177,7 +177,7 @@ sub sys { &system_verbose; $? and die qq(running "@_" failed: $?\n) }
sub mount_mdkinst {
my ($mdkinst) = @_;
- sys("$sudo mount -t squashfs -o loop,ro $mdkinst $STAGE2_LOCATION");
+ mount($mdkinst, $STAGE2_LOCATION, "-t squashfs -o loop,ro");
}
sub create_initial_symlinks() {
foreach (cat_or_die("$STAGE2_LOCATION/usr/share/symlinks")) {
@@ -198,6 +198,11 @@ sub create_initial_symlinks() {
}
}
+sub mount {
+ my ($from, $mntpt, @opts) = @_;
+ sys("$sudo mount $from $mntpt " . join(' ', @opts));
+}
+
sub umount_all() {
my $err;
clean_stage2_updates();
@@ -253,7 +258,7 @@ sub apply_stage2_updates() {
undef $ARGV[$::i+1];
undef $ARGV[$::i+2];
push @stage2_updates, $dest;
- sys("$sudo mount --bind $file $STAGE2_LOCATION/$dest");
+ mount($file, "$STAGE2_LOCATION/$dest", " --bind");
}
}
} @ARGV;