scripts/din2d
changeset 5 3e135449f797
child 20 3f164cb8d543
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/din2d	Wed Apr 08 21:58:06 2015 +0200
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+# Dockerfile.in -> Dockerfile
+# currently just resolve .include ..
+
+use strict;
+use warnings;
+use Cwd qw(abs_path);
+use File::Basename qw(dirname);
+use Getopt::Long;
+
+while (<>) {
+    /^\.include_if_exists\s+(.+?)\s*$/ or next;
+    $_ = "# from $1 {{\n" . do { 
+	my $file = abs_path(dirname($ARGV) . "/$1");
+	open(my $in, '<', $file) or die "Can't open $file: $!\n";
+	local $/ = undef;
+	<$in>;
+    } 
+    . "# }}\n";
+}
+continue {
+    print if defined;
+}