@@ -23,7 +23,6 @@ $Data::Dumper::Indent = 1;
2323$Data::Dumper::Sortkeys = 1;
2424$Data::Dumper::Purity = 1;
2525
26- use Config::IniFiles;
2726use Sort::Versions;
2827use YAML::PP;
2928use boolean;
@@ -46,17 +45,15 @@ sub groupKernels;
4645sub pruneVersions ;
4746sub purgeFiles ;
4847sub verboseUnlink ;
49- sub convertConfig ;
50- sub convertImageConfig ;
5148
5249BEGIN {
5350 $SIG {INT } = \&cleanupMount;
5451 $SIG {TERM } = \&cleanupMount;
5552}
5653
5754my ( %runConf , %config );
58- my $default_config = " /etc/zfsbootmenu/config.yaml" ;
5955
56+ $runConf {config } = " /etc/zfsbootmenu/config.yaml" ;
6057$runConf {bootdir } = " /boot" ;
6158$runConf {usecpio } = false;
6259
@@ -68,7 +65,6 @@ GetOptions(
6865 " bootdir|b=s" => \$runConf {bootdir },
6966 " confd|C=s" => \$runConf {confd },
7067 " cmdline|l=s" => \$runConf {cmdline },
71- " migrate|m:s" => \$runConf {migrate },
7268 " config|c=s" => \$runConf {config },
7369 " enable" => \$runConf {enable },
7470 " disable" => \$runConf {disable },
@@ -81,37 +77,6 @@ GetOptions(
8177 },
8278);
8379
84- unless ( nonempty $runConf {config } ) {
85- $runConf {config } = $default_config ;
86-
87- # Implicitly request migration if default config does not exist
88- unless ( defined $runConf {migrate } or -f $runConf {config } ) {
89- printf " Configuration %s does not exist, attempting to migrate\n " , $runConf {config };
90- $runConf {migrate } = " /etc/zfsbootmenu/config.ini" ;
91- }
92- }
93-
94- # If migration explicitly requested or no config file exists, convert it
95- if ( defined $runConf {migrate } ) {
96- my $inifile ;
97-
98- if ( nonempty $runConf {migrate } ) {
99- $inifile = $runConf {migrate };
100- } else {
101- $inifile = $runConf {config };
102- $inifile =~ s / (\. yaml)?$/ .ini/ i ;
103- }
104-
105- # If possible, make a backup of an existing output file
106- my $conf_backup = sprintf ( " %s .backup" , $runConf {config } );
107- if ( -f $runConf {config } and safeCopy( $runConf {config }, $conf_backup ) ) {
108- printf " Created backup %s -> %s \n " , $runConf {config }, $conf_backup ;
109- }
110-
111- convertConfig( $inifile , $runConf {config } ) or exit 1;
112- exit 0;
113- }
114-
11580if ( -r $runConf {config } ) {
11681 eval {
11782 local $SIG {' __DIE__' };
@@ -120,20 +85,6 @@ if ( -r $runConf{config} ) {
12085 } or do {
12186 my $error = <<"EOF" ;
12287Unable to parse configuration $runConf {config} as YAML.
123-
124- If this is a legacy configuration, migrate to the new format by running
125-
126- $0 --migrate $runConf {config} [ --config <output> ],
127-
128- where `<output>` is the desired location of the converted file. If you
129- omit the `--config` option, an output location
130-
131- $default_config
132-
133- will be used by default.
134-
135- ----
136-
13788EOF
13889 print $error ;
13990
@@ -1034,62 +985,6 @@ sub verboseUnlink {
1034985 }
1035986}
1036987
1037- sub convertConfig {
1038- my ( $inifile , $configfile ) = @_ ;
1039-
1040- unless ( -r $inifile ) {
1041- printf " Unable to read legacy configuration file %s \n " , $inifile ;
1042- exit 1;
1043- }
1044-
1045- print " Migrating $inifile to $configfile \n " ;
1046-
1047- my %ini_config ;
1048- tie %ini_config , ' Config::IniFiles' , ( -file => $inifile );
1049-
1050- my $yaml = YAML::PP-> new(
1051- boolean => ' boolean' ,
1052- header => 0,
1053- );
1054-
1055- # Force boolean
1056- $ini_config {Global }{ManageImages } = boolean( $ini_config {Global }{ManageImages } );
1057-
1058- # Convert the component and EFI image sections to the new format
1059- convertImageConfig $ini_config {Components };
1060- convertImageConfig $ini_config {EFI };
1061-
1062- # Move syslinux to be a sub section of Components
1063- $ini_config {Components }{syslinux } = dclone( $ini_config {syslinux } );
1064- $ini_config {Components }{syslinux }{Enabled } = boolean( $ini_config {Components }{syslinux }{CreateConfig } );
1065- delete $ini_config {Components }{syslinux }{CreateConfig };
1066- delete $ini_config {syslinux };
1067-
1068- $yaml -> dump_file( $configfile , \%ini_config );
1069-
1070- printf " Please verify the converted file %s \n " , $configfile ;
1071- }
1072-
1073- sub convertImageConfig {
1074- my $section = shift ;
1075-
1076- $section -> {Enabled } = boolean( $section -> {Copies } > 0 );
1077- $section -> {Enabled } = boolean( $section -> {Copies } > 0 );
1078-
1079- if ( $section -> {Versioned } ) {
1080- if ( $section -> {Copies } > 1 ) {
1081- $section -> {Versions } = int $section -> {Copies };
1082- } else {
1083- $section -> {Versions } = true;
1084- }
1085- } else {
1086- $section -> {Versions } = false;
1087- }
1088-
1089- delete $section -> {Versioned };
1090- delete $section -> {Copies };
1091- }
1092-
1093988sub Log {
1094989 my $entry = shift ;
1095990
@@ -1173,10 +1068,6 @@ Specify the path to search for kernel files; default: I</boot>
11731068
11741069Specify the path to a configuration file; default: I</etc/zfsbootmenu/config.yaml >
11751070
1176- =item B<--migrate|-m > [I<ini-config > ]
1177-
1178- Migrate a legacy INI file to the new YAML format, writing the converted file to the path specified by B<--config > . If I<ini-config > is not specified, a default path is chosen by removing any I<.yaml > suffix in the B<--config > path and appending a I<.ini > suffix.
1179-
11801071=item B<--enable >
11811072
11821073Set the I<Global.ManageImages > option to true, enabling image generation.
0 commit comments