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