From 806baff56ec4d00a45d49eb3ed42e108c4680fd6 Mon Sep 17 00:00:00 2001 From: freesource Date: Tue, 18 Feb 2003 18:14:43 +0000 Subject: [PATCH] Makes a more effecient root_fs_helper by not making logon mandatory, and using uml_mconsole halt for a quick halt rather than shutdown -h now. --- BootRoot/UML.pm | 14 ++++++++++++-- BootRoot/Yard.pm | 5 +++-- expect_uml | 21 +++++++++++++++++++++ pkg/rpm/gbootroot-mdk.spec | 5 +++++ pkg/rpm/gbootroot.spec | 5 +++++ 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/BootRoot/UML.pm b/BootRoot/UML.pm index 00add55..786d77a 100644 --- a/BootRoot/UML.pm +++ b/BootRoot/UML.pm @@ -7,6 +7,9 @@ # Changes: # 12/15/2001 Changed UML to BootRoot::UML # Can now set password to "" to allow no password. +# +# 02/18/2003 Now login isn't mandatory which allows login-free +# inits like /bin/bash. package BootRoot::UML; @@ -76,8 +79,11 @@ sub boot { $log = $me->open_log($log_file); $me->{expect_handle}->log_stdout(0); } - $me->{expect_handle}->expect(undef, "$me->{login_prompt}"); - $me->{expect_handle}->print("$me->{login}\n"); + + if ( $me->{login_prompt} ne "" ) { + $me->{expect_handle}->expect(undef, "$me->{login_prompt}"); + $me->{expect_handle}->print("$me->{login}\n"); + } # It's o.k. not to have a password .. password_prompt will be ignored. # --freesource @@ -86,7 +92,11 @@ sub boot { $me->{expect_handle}->print("$me->{password}\n"); } + $me->{expect_handle}->expect(undef, "-re", "$me->{prompt}"); + $me->{expect_handle}->print("echo Let's make you're root_fs!\r"); + $me->{expect_handle}->print("\r"); + return($log); } diff --git a/BootRoot/Yard.pm b/BootRoot/Yard.pm index 6ff70cc..8fc2f9a 100644 --- a/BootRoot/Yard.pm +++ b/BootRoot/Yard.pm @@ -1925,10 +1925,11 @@ sub create_expect_uml { if ( !$option{template} ) { $options = "root=/dev/ubd0 " . "mode=" . BootRoot::BootRoot::skas_or_tt() . " " . - $option{"uml-options"}; + $option{"uml-options"} . " umid=root_fs_helper init=/bin/bash"; } else { - $options = "root=/dev/ubd0 " . $option{"uml-options"}; + $options = "root=/dev/ubd0 " . $option{"uml-options"} . + " umid=root_fs_helper init=/bin/bash"; } my $filesystem; if ( $fs_type eq "genext2fs" ) { diff --git a/expect_uml b/expect_uml index d10e2f1..e971a81 100755 --- a/expect_uml +++ b/expect_uml @@ -56,6 +56,8 @@ if ( !$ARGV[0] ) { } my $arguments = "$ARGV[0] $ARGV[1] $ARGV[2]"; +$ARGV[2] =~ /umid=([\w_]+)\s*/; +my $umid = $1; my $mount_point = "$ARGV[3]"; my $preserve_ownership = "$ARGV[4]"; my $uml_kernel = "$ARGV[5]"; @@ -81,6 +83,9 @@ for ( 6 .. $#ARGV ) { } } + + +=pod my $uml = BootRoot::UML->new( login_prompt => "bootroot login: ", kernel => $uml_kernel, @@ -91,6 +96,19 @@ my $uml = prompt => "bootroot:.*# ", halt => "shutdown -h now" ); +=cut + + +my $uml = + BootRoot::UML->new( login_prompt => "", + kernel => $uml_kernel, + arguments => $arguments, + login => "root", + password_prompt => "Password: ", + password => "", + prompt => ".*# ", + halt => "shutdown -h now" + ); $uml->boot(); # Make the GID/UID 0 FS @@ -155,4 +173,7 @@ elsif ( $filesystem =~ /^mkfs\.jffs/ ) { } $uml->command("umount /mnt1; umount /mnt2"); +# The fast way +system "uml_mconsole $umid halt"; +# Fall through $uml->halt() diff --git a/pkg/rpm/gbootroot-mdk.spec b/pkg/rpm/gbootroot-mdk.spec index f3ddb72..bb5d5a3 100644 --- a/pkg/rpm/gbootroot-mdk.spec +++ b/pkg/rpm/gbootroot-mdk.spec @@ -87,6 +87,11 @@ Mandrake should use the mdk rpm. Distributions which require Gtk-Perl and only require perl for perl such as Red Hat should use the rpm not marked as mdk. +There are some variations on this theme. Suse is a Red Hat type of +distribution, however it prepends perl to Gtk-Perl, so if +perl-Gtk-Perl is installed on your system you can just add the +--nodeps option when doing an install. + %prep %setup -n gbootroot-%{version} diff --git a/pkg/rpm/gbootroot.spec b/pkg/rpm/gbootroot.spec index cbfc5e1..8baf36e 100644 --- a/pkg/rpm/gbootroot.spec +++ b/pkg/rpm/gbootroot.spec @@ -85,6 +85,11 @@ Mandrake should use the mdk rpm. Distributions which require Gtk-Perl and only require perl for perl such as Red Hat should use the rpm not marked as mdk. +There are some variations on this theme. Suse is a Red Hat type of +distribution, however it prepends perl to Gtk-Perl, so if +perl-Gtk-Perl is installed on your system you can just add the +--nodeps option when doing an install. + %prep %setup -n gbootroot-%{version}