From 53cd6ff1c597e75f94ea9ffc5f0c319e3fd92283 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 2 Mar 2014 21:53:02 +0100 Subject: Handle outfile and creation of dirs in preseed generator. --- Makefile | 6 +++--- bin/pkglist2preseed | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c4a178c..999c988 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,10 @@ profilefiles = $(patsubst %,content/%/preseed.cfg,$(profiles)) all: $(basefiles) $(topicfiles) $(profilefiles) $(basefiles): content/%/base/preseed.cfg : profiles/% profiles/%-z - bin/pkglist2preseed skel/preseed.cfg.in $^ > $@ + bin/pkglist2preseed skel/preseed.cfg.in $@ $^ $(topicfiles): content/desktop/%/preseed.cfg : profiles/desktop profiles/desktop-% profiles/desktop-z - bin/pkglist2preseed skel/preseed.cfg.in $^ > $@ + bin/pkglist2preseed skel/preseed.cfg.in $@ $^ $(profilefiles): content/%/preseed.cfg : profiles/% profiles/%-email $(desktoptopiclists) profiles/%-z - bin/pkglist2preseed skel/preseed.cfg.in $^ > $@ + bin/pkglist2preseed skel/preseed.cfg.in $@ $^ diff --git a/bin/pkglist2preseed b/bin/pkglist2preseed index 1691f4e..0e78b56 100755 --- a/bin/pkglist2preseed +++ b/bin/pkglist2preseed @@ -2,11 +2,15 @@ set -eu -skelfile="$1"; shift +infile="$1"; shift +outfile="$1"; shift +# remaining arguments are packagelist files pkgdesc=$(perl -nE '/^[#]{2} (.*)/ and say "# $1"; /^[#]{1} (.*)/ and say "# * $1"' "$@") #' pkglist=$(perl -ne 'chomp; /^[^#]+/ and print "$_ "' "$@") export pkgdesc pkglist -perl -pe 's,__PKGDESC__,$ENV{"pkgdesc"},;s,__PKGLIST__,$ENV{"pkglist"},' < $skelfile +mkdir -p $(dirname $outfile) +perl -pe 's,__PKGDESC__,$ENV{"pkgdesc"},;s,__PKGLIST__,$ENV{"pkglist"},' < $infile > $outfile~ +mv -f $outfile~ $outfile -- cgit v1.2.3