diff options
Diffstat (limited to 'tools/drakx-in-chroot')
| -rwxr-xr-x | tools/drakx-in-chroot | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/tools/drakx-in-chroot b/tools/drakx-in-chroot index 852792349..6565ec9e0 100755 --- a/tools/drakx-in-chroot +++ b/tools/drakx-in-chroot @@ -16,16 +16,18 @@ my $COMPRESSED_FILE_REL = $COMPRESSED_LOCATION_REL . 'mdkinst.sqfs'; my $AUTO_INSTALL_ROOTED = '/tmp/auto_inst.cfg.pl'; my $DEFCFG_ROOTED = '/tmp/defcfg.pl'; my $RPMSRATE_ROOTED = '/tmp/rpmsrate'; -my $resolution = '800x600'; +my $resolution = '1024x768'; my ($disk_iso_repository, $repository_uri); @ARGV >= 2 or die "usage: drakx-in-chroot <root of distrib> <dir to install to> [options]\n \nOptions specific to drakx-in-chroot: --flang XX use XX locale --disk-iso path of a distro - --resolution=XXXxYYYY (eg: --resolution=1024x768)\n + --resolution=XXXxYYYY (eg: --resolution=800x600)\n --repository=<path> path of packages repository --text text mode installer + --depth=XX set screen color depth + --stage2-update X,Y will mount --bind X on Y "; (my $repository, my $dir, @ARGV) = @ARGV; @@ -40,7 +42,9 @@ foreach (@ARGV) { } elsif (/--gdb/) { $wrapper = "gdb -q --args"; } elsif (/--strace/) { - $wrapper = "strace -e file"; + $wrapper = "strace -e file $ENV{STRACE_OPTIONS}"; + } elsif (/--depth=(.*)/) { + $resolution .= "x$1"; } } my ($repository_without_arch, $repository_arch) = basename($repository) eq arch() ? (dirname($repository), '/' . arch()) : ($repository, ''); @@ -52,15 +56,18 @@ if ($>) { $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; } +my @mounts; +my $_b = before_leaving { sys("$sudo umount $_") foreach reverse @mounts }; + undef $ENV{TMPDIR}; # prevent packdrake faillure on creating temporary files if (-d $SLASH_LOCATION) { - umount_all() == 0 or exit(1); + umount_all(1) == 0 or exit(1); sys("$sudo rm -rf $SLASH_LOCATION/var/lib/rpm $SLASH_LOCATION/dev/mapper"); rm_rf($SLASH_LOCATION); } -mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/dev/usb', '/etc', '/var', '/proc', '/sys', '/run', $STAGE2_LOCATION_ROOTED, $MEDIA_LOCATION_ROOTED, $prefix_ROOTED; +mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/etc', '/var', '/proc', '/sys', '/run', $STAGE2_LOCATION_ROOTED, $MEDIA_LOCATION_ROOTED, $prefix_ROOTED; sys("$sudo rm -rf $dir") if $ENV{CLEAN}; -e $dir or sys("$sudo mkdir -p $dir"); @@ -73,19 +80,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 -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 @@ -94,19 +102,18 @@ 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() } symlinkf('media' . $repository_arch, "$SLASH_LOCATION$IMAGE_LOCATION_ROOTED"); create_initial_symlinks(); -create_initial_devices(); apply_stage2_updates(); @@ -128,14 +135,14 @@ eval { cp_af('/etc/resolv.conf', "$SLASH_LOCATION/etc/resolv.conf") }; } my $Xnest_pid; -my $Xnest_bin = find { whereis_binary($_) } 'Xephyr', 'Xnest'; -if (!-f ($SLASH_LOCATION . $AUTO_INSTALL_ROOTED) && $Xnest_bin && join('', @ARGV) !~ /--text/) { +if (!-f ($SLASH_LOCATION . $AUTO_INSTALL_ROOTED) && join('', @ARGV) !~ /--text/) { + my $Xnest_bin = find { whereis_binary($_) } 'Xephyr', 'Xnest' or die "Xephyr not found! Please install x11-server-xephyr!\n"; my $DISPLAY = ':8'; $Xnest_pid = fork(); if (!$Xnest_pid) { exec $Xnest_bin, $DISPLAY, '-ac', ($Xnest_bin eq 'Xephyr' ? '-screen' : '-geometry'), $resolution or die "Xnest failed\n"; } - $ENV{DISPLAY} = '127.0.0.1' . $DISPLAY; + $ENV{DISPLAY} = $DISPLAY; } if (my $pid = fork()) { @@ -145,8 +152,8 @@ if (my $pid = fork()) { } else { $ENV{TERM} = 'linux'; # we only have terminfo for terminal "linux" $ENV{HOME} = '/'; - # to kept sync with gi/mdk-stage1/init.c::env: - $ENV{LD_LIBRARY_PATH}='/lib:/usr/lib:/mnt/lib:/mnt/usr/lib:/usr/X11R6/lib:/mnt/usr/X11R6/lib:/lib64:/usr/lib64:/usr/X11R6/lib64:/mnt/lib64:/mnt/usr/lib64:/mnt/usr/X11R6/lib64'; + # to kept sync with mdk-stage1/init.c::env: + $ENV{LD_LIBRARY_PATH}='/lib:/usr/lib:/mnt/lib:/mnt/usr/lib:/lib64:/usr/lib64:/mnt/lib64:/mnt/usr/lib64'; if ($remote_repository) { $ENV{URLPREFIX} = $repository; } @@ -173,7 +180,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")) { @@ -184,8 +191,8 @@ sub create_initial_symlinks() { symlink $from, $to or die "symlinking $to failed\n"; } } - $from = "$STAGE2_LOCATION_ROOTED/usr"; - $to = "$SLASH_LOCATION/usr"; + my $from = "$STAGE2_LOCATION_ROOTED/usr"; + my $to = "$SLASH_LOCATION/usr"; symlink $from, $to or die "symlinking $to failed\n"; foreach ('bin', 'sbin', 'lib', 'lib64') { $from = "usr/$_"; @@ -194,14 +201,21 @@ sub create_initial_symlinks() { } } -sub create_initial_devices() { - sys("$sudo cp -a /dev/{mem,null,random,urandom,tty} $SLASH_LOCATION/dev"); +sub mount { + my ($from, $mntpt, @opts) = @_; + push @mounts, $mntpt; + sys("$sudo mount $from $mntpt " . join(' ', @opts)); } -sub umount_all() { +sub umount_all { + my ($b_umount_dev_too) = @_; my $err; clean_stage2_updates(); - my @procs = ('/proc', '/sys/kernel/debug', '/sys', '/run/udev', '/run/blkid', '/run/initramfs', '/run'); + my @procs = (qw(/proc /sys/kernel/debug /sys /run/udev /run/blkid /run/initramfs /run)); + # special case for !draklive case (else a 2nd run would fail): + if ($b_umount_dev_too && cat_('/proc/mounts') =~ m! $SLASH_LOCATION/dev !) { + system_verbose "$sudo umount $SLASH_LOCATION/dev" and rm_rf("$SLASH_LOCATION/dev"); + } foreach ((map { "$prefix_ROOTED$_" } @procs, '/dev', ''), @procs, $STAGE2_LOCATION_ROOTED, $LOOP_MOUNT_POINT, $MEDIA_LOCATION_ROOTED, $IMAGE_LOCATION_ROOTED) { my $dir = "$SLASH_LOCATION$_"; rmdir $dir; @@ -253,7 +267,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; |
