Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: client/tools/boottool

Issue 4823005: Merge remote branch 'cros/upstream' into tempbranch (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: patch Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tests/tracing_microbenchmark/tracing_microbenchmark.py ('k') | conmux/drivers/reboot-apc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tools/boottool
diff --git a/client/tools/boottool b/client/tools/boottool
index 4dafbab4d4561101e25656ef3349b80a9ecc0a12..728e4ef4ff4d29cbcddc7c37f912830d8c8ca166 100755
--- a/client/tools/boottool
+++ b/client/tools/boottool
@@ -791,6 +791,38 @@ sub detect_architecture {
return $arch;
}
+=head3 detect_os_vendor()
+
+Input:
+Output: string
+
+This function determines the OS vendor (linux distribution breed).
+
+Return values: "Red Hat", "Fedora", "SUSE", "Ubuntu", "Debian", or
+"Unknown" if none of the predefined patterns could be found on the
+issue file.
+
+=cut
+
+sub detect_os_vendor {
+ my $vendor = "";
+ my $issue_file = '/etc/issue';
+ if ( not system("egrep 'Red Hat' $issue_file") ){
+ $vendor = 'Red Hat';
+ } elsif ( not system("egrep 'Fedora' $issue_file") ){
+ $vendor = 'Fedora';
+ } elsif ( not system("egrep 'SUSE' $issue_file") ){
+ $vendor = 'SUSE';
+ } elsif ( not system("egrep 'Ubuntu' $issue_file") ){
+ $vendor = 'Ubuntu';
+ } elsif ( not system("egrep 'Debian' $issue_file") ){
+ $vendor = 'Debian';
+ } else {
+ $vendor = 'Unknown';
+ }
+ return $vendor;
+}
+
=head3 detect_bootloader(['device1', 'device2', ...])
Input: devices to detect against (optional)
@@ -1595,20 +1627,31 @@ sub update_main_options{
sub boot_once {
my $self=shift;
my $entry_to_boot_once = shift;
+ my $detected_os_vendor = Linux::Bootloader::Detect::detect_os_vendor();
unless ( $entry_to_boot_once ) { print "No kernel\n"; return undef;}
$self->read();
my $default=$self->get_default();
- if ( $default == $self->_lookup($entry_to_boot_once)){
- warn "The default and once-boot kernels are the same. No action taken. \nSet default to something else, then re-try.\n";
- return undef;
- }
if ( $self->_get_bootloader_version() < 0.97 ){
warn "This function works for grub version 0.97 and up. No action taken. \nUpgrade, then re-try.\n";
return undef;
}
+ if ( $detected_os_vendor eq "Red Hat" or $detected_os_vendor eq "Fedora" ) {
+ # if not a number, do title lookup
+ if ( $entry_to_boot_once !~ /^\d+$/ ) {
+ $entry_to_boot_once = $self->_lookup($entry_to_boot_once);
+ return undef unless ( defined $entry_to_boot_once );
+ }
+
+ return `echo "savedefault --default=$entry_to_boot_once" --once | grub --batch`;
+ } else {
+ if ( $default == $self->_lookup($entry_to_boot_once)){
+ warn "The default and once-boot kernels are the same. No action taken. \nSet default to something else, then re-try.\n";
+ return undef;
+ }
+
$self->set_default('saved');
if ( ! -f '/boot/grub/default' ){
open FH, '>/boot/grub/default';
@@ -1635,7 +1678,7 @@ sub boot_once {
$self->update( 'update-kernel'=>"$entry_to_boot_once",'option'=>'','savedefault' => 'fallback' );
$self->update( 'update-kernel'=>"$default",'option'=>'', 'savedefault' => '' );
$self->write();
-
+ }
}
sub _get_bootloader_version {
« no previous file with comments | « client/tests/tracing_microbenchmark/tracing_microbenchmark.py ('k') | conmux/drivers/reboot-apc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698