@@ -19,53 +19,44 @@ type ConfigureStep struct {
1919
2020var _ core.IStep = (* ConfigureStep )(nil )
2121
22- var defaultOptions = []string {"defconfig" }
23- var validOptions = []string {"defconfig" , "menuconfig" , "nconfig" , "oldconfig" }
24-
2522func (s * ConfigureStep ) Name () string {
2623 return "configure"
2724}
2825
2926func (s * ConfigureStep ) Execute () error {
3027 if s .ctx .ConfigOptions == nil {
31- s .log .Info ("No config options were detected, setting up default options ..." )
32- s .ctx .ConfigOptions = defaultOptions
33- }
34-
35- // TODO: better option than doing this
36- configOptions := s .ctx .ConfigOptions
37- for _ , opt := range configOptions {
38- if ! isValidOption (opt ) {
39- return fmt .Errorf ("invalid configuration option: %s" , opt )
40- }
28+ defaultConfigOptions := []string {"tinyconfig" }
29+ s .log .Warn ("Kernel config options not provided, defaulting to %s" , defaultConfigOptions )
30+ s .ctx .ConfigOptions = defaultConfigOptions
4131 }
4232
4333 if err := s .copyOldConfig (); err != nil {
4434 return fmt .Errorf ("failed to copy .config: %w" , err )
4535 }
4636
47- s .log .Info ("Configuring Linux kernel with: %v ..." , configOptions )
48-
4937 dir := s .ctx .Directory
5038 if err := os .Chdir (dir ); err != nil {
51- return fmt .Errorf ("failed to change directory to %s : %w" , dir , err )
39+ return fmt .Errorf ("failed to change directory to %q : %w" , dir , err )
5240 }
5341
54- for _ , opt := range configOptions {
55- cmd := exec .Command ("make" , opt )
42+ for _ , option := range s .ctx .ConfigOptions {
43+ s .log .Info ("Configuring Linux kernel with: 'make %s' ..." , option )
44+
45+ cmd := exec .Command ("make" , option )
5646 cmd .Stdout = os .Stdout
5747 cmd .Stderr = os .Stderr
5848
5949 if err := cmd .Run (); err != nil {
6050 return fmt .Errorf ("kernel configuration failed: %w" , err )
6151 }
6252 }
53+
6354 return nil
6455}
6556
6657func (s * ConfigureStep ) copyOldConfig () error {
6758 if s .ctx .OldConfigPath == "" {
68- s .log .Warn ("Skipping copy of old .config file " )
59+ s .log .Warn ("Old .config path not provided, skipping ... " )
6960 return nil
7061 }
7162
@@ -84,12 +75,3 @@ func (s *ConfigureStep) copyOldConfig() error {
8475 }
8576 return nil
8677}
87-
88- func isValidOption (option string ) bool {
89- for _ , validOption := range validOptions {
90- if option == validOption {
91- return true
92- }
93- }
94- return false
95- }
0 commit comments