@@ -7,6 +7,7 @@ use CAF::FileWriter;
77use CAF::Process;
88use EDG::WP4::CCM::Path qw( unescape) ;
99
10+ use File::Temp qw( tempdir) ;
1011use Readonly;
1112use parent qw( NCM::Component CAF::Path) ;
1213our $EC = LC::Exception::Context-> new-> will_store_all;
@@ -803,6 +804,8 @@ sub default_options
803804
804805 my ($current , $currargs ) = $self -> get_current_arguments($default );
805806
807+ my @default_options ;
808+
806809 # If we want full control of the arguments:
807810 if ($fullcontrol ) {
808811 # Check if the arguments we want to add are the same we have
@@ -846,12 +849,12 @@ sub default_options
846849 $arguments -> {remove } = {};
847850 };
848851
849- my @options = $self -> grubby_arguments_options($arguments );
850- if (@options ) {
851- if ($self -> grubby([' --update-kernel' , $default , @options ], success => 1)) {
852- $self -> info(" fullcontrol set args with '@options ' for default kernel $default " );
852+ @default_options = $self -> grubby_arguments_options($arguments );
853+ if (@default_options ) {
854+ if ($self -> grubby([' --update-kernel' , $default , @default_options ], success => 1)) {
855+ $self -> info(" fullcontrol set args with '@default_options ' for default kernel $default " );
853856 } else {
854- $self -> error(" fullcontrol cannot set args with '@options ' for default kernel $default " );
857+ $self -> error(" fullcontrol cannot set args with '@default_options ' for default kernel $default " );
855858 return ;
856859 }
857860 } else {
@@ -860,19 +863,33 @@ sub default_options
860863 }
861864 } else {
862865 # If we want no full control of the arguments
863- my @options = $self -> grubby_arguments_options($arguments );
864- if (@options ) {
865- if ($self -> grubby([' --update-kernel' , $default , @options ], success => 1)) {
866- $self -> info(" set args with '@options ' for default kernel $default " );
866+ @default_options = $self -> grubby_arguments_options($arguments );
867+ if (@default_options ) {
868+ if ($self -> grubby([' --update-kernel' , $default , @default_options ], success => 1)) {
869+ $self -> info(" set args with '@default_options ' for default kernel $default " );
867870 } else {
868- $self -> error(" cannot set args with '@options ' for default kernel $default " );
871+ $self -> error(" cannot set args with '@default_options ' for default kernel $default " );
869872 return ;
870873 }
871874 } else {
872875 $self -> verbose(" No kernel arguments set" );
873876 }
874877 }
875878
879+ if ($tree -> {for_next }) {
880+ # Set default options for "next" kernel that will be installed with e.g. new rpm.
881+ # This involves updating /etc/default/grub and /etc/kernel/cmdline
882+ # As there is no direct way in grubby to only update these files,
883+ # we use hack to pass ALL kernels and point to empty bootloader dir
884+ my $bls_tmpdir = tempdir(" ncm-grub-bls-XXXXXX" , TMPDIR => 1, CLEANUP => 1);
885+ if ($self -> grubby([' --bls-directory' , $bls_tmpdir , ' --update-kernel' , ' ALL' , @default_options ], success => 1)) {
886+ $self -> info(" set args with '@default_options ' for next kernel" );
887+ } else {
888+ $self -> error(" cannot set args with '@default_options ' for next kernel" );
889+ return ;
890+ }
891+ }
892+
876893 return SUCCESS;
877894}
878895
0 commit comments