summaryrefslogtreecommitdiff
path: root/bin/pkglist2preseed
blob: 696398cc06999b575cdb4c3c014cfa41f6186b02 (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. -e 's,chroot\s+/target\s+,,g;'\
  22. -e 's,/target/,/,g;'\
  23. < $altinfile \
  24. > $altoutfile~
  25. mv -f $altoutfile~ $altoutfile
  26. perl -p \
  27. -e 's,__PKGDESC__,$ENV{"pkgdesc"},;'\
  28. -e 's,__PKGLIST__,$ENV{"pkglist"},;'\
  29. -e 's,__TWEAKDESC__,$ENV{"tweakdesc"},;'\
  30. -e 's,__TWEAKLIST__,$ENV{"tweaklist"},;'\
  31. < $infile \
  32. > $outfile~
  33. mv -f $outfile~ $outfile