From f7ea0e336396a21bee6f16a33be14c8b798c512f Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 30 Jul 2014 13:46:35 +0200 Subject: Rewrite hint file parsing. --- bin/pkglist2preseed | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/bin/pkglist2preseed b/bin/pkglist2preseed index 0162726..b0d7902 100755 --- a/bin/pkglist2preseed +++ b/bin/pkglist2preseed @@ -15,27 +15,26 @@ my $outdir = $outfile->parent; my $altinfile = path( $infile->parent, 'script.sh.in' ); my $altoutfile = path( $outdir, 'script.sh' ); -my ($pkgdesc, @pkg); +my (@pkglines, $pkgdesc, @pkg); foreach (@pkgfiles) { - foreach (path($_)->lines) { - chomp; - /^[#]{2} (.*)/ and $pkgdesc .= "# $1\n"; - /^[#]{1} (.*)/ and $pkgdesc .= "# * $1\n"; - /^[^#]+/ and push @pkg, $_; - }; + push @pkglines, path($_)->lines; }; -chomp $pkgdesc; +grep { chomp } @pkglines; +grep { s/^[#]{1} (.*)/# * $1/ } @pkglines; +grep { s/^[#]{2} (.*)/# $1/ } @pkglines; +$pkgdesc = join "\n", grep { /^[#] / } @pkglines; +@pkg = grep { /^[^#]/ } @pkglines; -my ($tweakdesc, $tweaklist); +my (@tweaklines, $tweakdesc, $tweaklist); foreach (@tweakfiles) { - foreach (path($_)->lines) { - chomp; - /^[#]{2} (.*)/ and $tweakdesc .= "# $1\n"; - /^[#]{1} (.*)/ and $tweakdesc .= "# * $1\n"; - /^(?!#)\s*(.+)/ and $tweaklist .= "$1;" - }; + push @tweaklines, path($_)->lines; }; -chomp $tweakdesc; +grep { chomp } @tweaklines; +grep { s/^[#]{1} (.*)/# * $1/ } @tweaklines; +grep { s/^[#]{2} (.*)/# $1/ } @tweaklines; +$tweakdesc = join "\n", grep { /^[#] / } @tweaklines; +$tweaklist = join ";", grep { s/^(?!#)\s*(.+)/$1/ } @tweaklines; +$tweaklist .= ';'; my $pkglist = join( ' ', @pkg ); -- cgit v1.2.3