mirror of https://github.com/fspc/gbootroot.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.3 KiB
65 lines
1.3 KiB
#!/usr/bin/perl
|
|
|
|
use BootRoot::UML;
|
|
|
|
if ( !$ARGV[0] ) {
|
|
|
|
die "expect_uml ubd0 ubd1 other-options mount-point preserve_permissions filesystem_command\n";
|
|
|
|
}
|
|
|
|
|
|
my $arguments = "$ARGV[0] $ARGV[1] $ARGV[2]";
|
|
my $mount_point = "$ARGV[3]";
|
|
my $preserve_permissions = "$ARGV[4]";
|
|
|
|
my $end = 6;
|
|
my $filesystem;
|
|
for ( 5 .. $#ARGV ) {
|
|
if ( $_ == 5 ) {
|
|
$filesystem = "$ARGV[5]";
|
|
# What to do with the rieserfs command
|
|
if ( $filesystem eq "mkreiserfs" ) {
|
|
$filesystem = $filesystem . " -f -f -q";
|
|
}
|
|
}
|
|
else {
|
|
if ( $ARGV[$end] ) {
|
|
$filesystem = $filesystem . " $ARGV[$end]";
|
|
$end++;
|
|
}
|
|
else {
|
|
last;
|
|
}
|
|
}
|
|
}
|
|
|
|
my $uml =
|
|
BootRoot::UML->new( login_prompt => "bootroot login: ",
|
|
arguments => $arguments,
|
|
login => "root",
|
|
password_prompt => "Password: ",
|
|
password => "",
|
|
prompt => "bootroot:.*# ",
|
|
halt => "shutdown -h now"
|
|
);
|
|
|
|
$uml->boot();
|
|
# Make the GID/UID 0 FS
|
|
$uml->command("$filesystem /dev/ubd/1");
|
|
$uml->command("mount /dev/ubd/1 /mnt1");
|
|
$uml->command("mount -t hostfs none -o $mount_point /mnt2");
|
|
$uml->command("cp -a /mnt2/* /mnt1");
|
|
if ( $preserve_permissions == 0 ) {
|
|
$uml->command("chown -R 0:0 /mnt1");
|
|
}
|
|
$uml->command("umount /mnt1; umount /mnt2");
|
|
$uml->halt();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|