summaryrefslogtreecommitdiff
path: root/bin/pkglist2preseed
blob: c93debe23253987ed29399503f526a0430d69512 (plain)
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use autodie qw(:all);;
  5. use Path::Tiny;
  6. my $infile = path($ARGV[0]);
  7. my $outfile = path($ARGV[1]);
  8. my @pkgfiles = split( ' ', $ARGV[2] );
  9. my @tweakfiles = split( ' ', $ARGV[3] );
  10. my $outdir = $outfile->parent;
  11. my $altinfile = path( $infile->parent, 'script.sh.in' );
  12. my $altoutfile = path( $outdir, 'script.sh' );
  13. my ($pkgdesc, $pkglist);
  14. foreach (@pkgfiles) {
  15. foreach (path($_)->lines) {
  16. chomp;
  17. /^[#]{2} (.*)/ and $pkgdesc .= "# $1\n";
  18. /^[#]{1} (.*)/ and $pkgdesc .= "# * $1\n";
  19. /^[^#]+/ and $pkglist .= "$_ ";
  20. };
  21. };
  22. chomp $pkgdesc;
  23. my ($tweakdesc, $tweaklist);
  24. foreach (@tweakfiles) {
  25. foreach (path($_)->lines) {
  26. chomp;
  27. /^[#]{2} (.*)/ and $tweakdesc .= "# $1\n";
  28. /^[#]{1} (.*)/ and $tweakdesc .= "# * $1\n";
  29. /^(?!#)\s*(.+)/ and $tweaklist .= "$1;"
  30. };
  31. };
  32. chomp $tweakdesc;
  33. $outdir->mkpath;
  34. $_ = $altinfile->slurp;
  35. s,__PKGDESC__,$pkgdesc,;
  36. s,__PKGLIST__,$pkglist,;
  37. s,__TWEAKDESC__,$tweakdesc,;
  38. s,__TWEAKLIST__,$tweaklist,;
  39. s,chroot\s+/target\s+,,g;
  40. s,/target/,/,g;
  41. $altoutfile->spew($_);
  42. $_ = $infile->slurp;
  43. s,__PKGDESC__,$pkgdesc,;
  44. s,__PKGLIST__,$pkglist,;
  45. s,__TWEAKDESC__,$tweakdesc,;
  46. s,__TWEAKLIST__,$tweaklist,;
  47. $outfile->spew($_);
  48. 1;