diff options
-rw-r--r-- | perl-install/install2.pm | 9 | ||||
-rw-r--r-- | perl-install/install_steps_gtk.pm | 3 | ||||
-rw-r--r-- | perl-install/modules.pm | 4 | ||||
-rw-r--r-- | tools/drakx-in-chroot | 114 |
4 files changed, 123 insertions, 7 deletions
diff --git a/perl-install/install2.pm b/perl-install/install2.pm index 3bcde1464..deae9004b 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -112,7 +112,7 @@ sub selectMouse { sub setupSCSI { my ($clicked, $_ent_number, $auto) = @_; - if (!$::testing && !$::uml_install) { + if (!$::testing && !$::local_install) { -d '/lib/modules/' . c::kernel_version() || -s modules::cz_file() or die N("Can not access kernel modules corresponding to your kernel (file %s is missing), this generally means your boot floppy in not in sync with the Installation medium (please create a newer boot floppy)", modules::cz_file()); } @@ -294,7 +294,7 @@ sub addUser { #------------------------------------------------------------------------------ sub setupBootloader { my ($_clicked, $ent_number, $auto) = @_; - return if $::uml_install; + return if $::local_install; $o->{modules_conf}->write; @@ -407,7 +407,8 @@ sub main { text => sub { $o->{interactive} = "newt" }, stdio => sub { $o->{interactive} = "stdio" }, kickstart => sub { $::auto_install = $v }, - uml_install => sub { $::uml_install = 1 }, + local_install => sub { $::local_install = 1 }, + uml_install => sub { $::uml_install = $::local_install = 1 }, auto_install => sub { $::auto_install = $v }, simple_themes => sub { $o->{simple_themes} = 1 }, theme => sub { $o->{theme} = $v }, @@ -437,7 +438,7 @@ sub main { unlink $_ foreach "/modules/modules.mar", "/sbin/stage1"; } - log::openLog(($::testing || $o->{localInstall}) && 'debug.log'); + log::openLog($::testing && 'debug.log'); log::l("second stage install running (", install_any::drakx_version(), ")"); eval { output('/proc/sys/kernel/modprobe', "\n") } if !$::testing; #- disable kmod, otherwise we get a different behaviour in kernel vs kernel-BOOT diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index 764fae2f8..59f50ccdb 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -33,7 +33,8 @@ sub new($$) { $ENV{DISPLAY} ||= $o->{display} || ":0"; my $wanted_DISPLAY = $::testing && -x '/usr/X11R6/bin/Xnest' ? ':9' : $ENV{DISPLAY}; - if ($ENV{DISPLAY} =~ /^:\d/ && !$::testing || $ENV{DISPLAY} ne $wanted_DISPLAY) { #- is the display local or distant? + if (!$::local_install && + ($::testing ? $ENV{DISPLAY} ne $wanted_DISPLAY : $ENV{DISPLAY} =~ /^:\d/)) { #- is the display local or distant? my $f = "/tmp/Xconf"; if (!$::testing) { devices::make("/dev/kbd"); diff --git a/perl-install/modules.pm b/perl-install/modules.pm index 8f50b78e1..2735d09ea 100644 --- a/perl-install/modules.pm +++ b/perl-install/modules.pm @@ -56,7 +56,7 @@ sub cond_mapping_24_26 { # handles dependencies sub load_raw { my ($l, $h_options) = @_; - if ($::testing) { + if ($::testing || $::local_install) { log::l("i would load module $_ ($h_options->{$_})") foreach @$l; } elsif ($::isInstall && !$::move) { load_raw_install($l, $h_options); @@ -287,7 +287,7 @@ sub cz_file() { sub extract_modules { my ($dir, @modules) = @_; my $cz = cz_file(); - if (!-e $cz && !$::uml_install) { + if (!-e $cz && !$::local_install) { unlink $_ foreach glob_("/lib/modules*.cz*"); require install_any; install_any::getAndSaveFile("install/stage2/live$cz", $cz) or die "failed to get modules $cz: $!"; diff --git a/tools/drakx-in-chroot b/tools/drakx-in-chroot new file mode 100644 index 000000000..f93385b1c --- /dev/null +++ b/tools/drakx-in-chroot @@ -0,0 +1,114 @@ +#!/usr/bin/perl + +use MDK::Common; + +my $SLASH_LOCATION = '/tmp/drakx-in-chroot'; + +my $verbose = 0; +my $prefix_ROOTED = '/mnt'; +my $IMAGE_LOCATION_ROOTED = '/tmp/image'; +my $STAGE2_LOCATION_ROOTED = '/tmp/stage2'; +my $LIVE_LOCATION_REL = 'install/stage2/live/'; +my $CLP_LOCATION_REL = 'install/stage2/'; +my $CLP_FILE_REL = $CLP_LOCATION_REL . 'mdkinst.clp'; + +my ($repository, $dir) = @ARGV; +my $STAGE2_LOCATION = $SLASH_LOCATION . $STAGE2_LOCATION_ROOTED; + +my $sudo; +if ($>) { + $sudo = "sudo"; + $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; +} + +if (-d $SLASH_LOCATION) { + umount_all() == 0 or die "$SLASH_LOCATION is busy\n"; + rm_rf($SLASH_LOCATION); +} + +mkdir_p("$SLASH_LOCATION$_") foreach '/dev', '/etc', '/var', '/proc', $STAGE2_LOCATION_ROOTED, $IMAGE_LOCATION_ROOTED, $prefix_ROOTED; + +if (-d "$repository/$LIVE_LOCATION_REL") { + sys("$sudo mount -o bind $repository/$LIVE_LOCATION_REL $STAGE2_LOCATION"); +} elsif (-e "$repository/$CLP_FILE_REL") { + my $dev = find_free_loop(); + sys("$sudo losetup -r -e gz $dev $repository/$CLP_FILE_REL"); + sys("$sudo mount -r $dev $STAGE2_LOCATION"); +} + +sys("$sudo mount -o bind $dir $SLASH_LOCATION$prefix_ROOTED"); +sys("$sudo mount -t proc none $SLASH_LOCATION/proc"); +create_initial_symlinks(); +create_initial_devices(); + +output("$SLASH_LOCATION/etc/hosts", "127.0.0.1 localhost\n") if ! -e "$SLASH_LOCATION/etc/hosts"; + +if (whereis_binary('Xnest')) { + my $DISPLAY = ':8'; + system("Xnest $DISPLAY -ac -geometry 800x600 &"); + $ENV{DISPLAY} = $DISPLAY; +} + +if (my $pid = fork()) { + waitpid $pid, 0; + umount_all() == 0 or warn "umounting failed\n"; +} else { + $ENV{HOME} = '/'; + my $cmd = '/usr/bin/install2 --local_install'; + exec "$sudo chroot $SLASH_LOCATION $cmd" or die "exec $cmd in $SLASH_LOCATION failed\n"; +} + +sub system_verbose { warn join(' ', @_), "\n" if $verbose; system(@_) } +sub sys { &system_verbose; $? and die qq(running "@_" failed: $?\n) } + +sub find_free_loop() { + foreach (0..255) { + my $dev = "/dev/loop$_"; + system("$sudo losetup $dev >/dev/null 2>&1") != 0 or next; + warn "found $dev\n"; + return $dev; + } + die "no free loop found"; +} + +sub create_initial_symlinks() { + foreach (cat_or_die("$STAGE2_LOCATION/usr/share/symlinks")) { + my ($from, $to_) = split; + my $to = $SLASH_LOCATION . ($to_ || $from); + $from = "$STAGE2_LOCATION_ROOTED$from" if !$to_; + if (! -l $to) { + symlink $from, $to or die "symlinking $to failed\n"; + } + } +} + +sub create_initial_devices() { + foreach (cat_or_die("$STAGE2_LOCATION/usr/share/devices")) { + my ($node, $type, $major, $minor) = split; + sys("$sudo mknod $SLASH_LOCATION$node $type $major $minor") if ! -e "$SLASH_LOCATION$node"; + } +} + +sub umount_all() { + my $err; + my @procs = ('/proc/bus/usb', '/proc', '/sys'); + foreach ((map { "$prefix_ROOTED$_" } @procs, ''), @procs, $STAGE2_LOCATION_ROOTED, $IMAGE_LOCATION_ROOTED) { + my $dir = "$SLASH_LOCATION$_"; + rmdir $dir; + if (-d $dir) { + if (m!/proc/bus/usb!) { + system_verbose "$sudo umount $dir 2>/dev/null"; + next; + } + my ($loop) = cat_('/proc/mounts') =~ m!^(/dev/loop\d+) \Q$dir\E !m; + system_verbose "$sudo umount $dir"; + sys("$sudo losetup -d $loop") if $loop; + } + rmdir $dir; + if (-d $dir) { + warn "$dir is busy\n"; + $err++; + } + } + $err; +} |