summaryrefslogtreecommitdiff
path: root/bin/pkglist2preseed
blob: b9d530488d9ef25eba8c66b4ccd02188a20fe320 (plain)
  1. #!/bin/sh
  2. set -eu
  3. infile="$1"
  4. outfile="$2"
  5. pkgfiles="$3"
  6. tweakfiles="$4"
  7. pkgdesc=$(perl -nE '/^[#]{2} (.*)/ and say "# $1"; /^[#]{1} (.*)/ and say "# * $1"' $pkgfiles) #'
  8. pkglist=$(perl -ne 'chomp; /^[^#]+/ and print "$_ "' $pkgfiles)
  9. tweakdesc=$(perl -nE '/^[#]{2} (.*)/ and say "# $1"; /^[#]{1} (.*)/ and say "# * $1"' $tweakfiles) #'
  10. tweaklist=$(perl -ne 'chomp; /^(?!#)\s*(.+)/ and print "$1;"' $tweakfiles)
  11. export pkgdesc pkglist tweakdesc tweaklist
  12. mkdir -p $(dirname $outfile)
  13. perl -p \
  14. -e 's,__PKGDESC__,$ENV{"pkgdesc"},;'\
  15. -e 's,__PKGLIST__,$ENV{"pkglist"},;'\
  16. -e 's,__TWEAKDESC__,$ENV{"tweakdesc"},;'\
  17. -e 's,__TWEAKLIST__,$ENV{"tweaklist"},;'\
  18. < $infile \
  19. > $outfile~
  20. mv -f $outfile~ $outfile