From 2f919846c259cf2a7013095179804e3add95de23 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 30 Sep 2013 19:04:35 +0200 Subject: [PATCH] Split up configure script --- Makefile | 1 + packages_gluon | 2 +- scripts/configure.pl | 36 +++--------------------------------- scripts/generate.pl | 30 ++++++++++++++++++++++++++++++ scripts/generate.sh | 4 +--- 5 files changed, 36 insertions(+), 37 deletions(-) create mode 100644 scripts/generate.pl diff --git a/Makefile b/Makefile index 462a7675..6eb0a117 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,7 @@ export FEEDS export GLUON_GENERATE := $(GLUONDIR)/scripts/generate.sh +export GLUON_CONFIGURE := $(GLUONDIR)/scripts/configure.pl feeds: FORCE diff --git a/packages_gluon b/packages_gluon index c57f81b7..65769f82 160000 --- a/packages_gluon +++ b/packages_gluon @@ -1 +1 @@ -Subproject commit c57f81b7c4a498828e54e8026a9178dbc639d87b +Subproject commit 65769f82507c9771de137451aaa2a45c57708dc3 diff --git a/scripts/configure.pl b/scripts/configure.pl index 50c5237c..4ef2d131 100755 --- a/scripts/configure.pl +++ b/scripts/configure.pl @@ -4,37 +4,7 @@ use warnings; use strict; -my %config; +our $CONFIG = do $ENV{GLUONDIR} . '/site/site.conf'; -sub add_config { - my ($prefix, $c) = @_; - - foreach my $key (keys $c) { - my $val = $c->{$key}; - - if (ref($val) eq 'HASH') { - add_config($key . '.', $val); - } - unless (ref($val)) { - $config{'@' . $prefix . $key . '@'} = $val; - } - } -} - -sub read_config { - my $input = shift; - my $CONFIG = do $input; - add_config('', $CONFIG); -} - - -read_config 'site/site.conf'; - - -my $regex = join '|', map {quotemeta} keys %config; - - -for (<>) { - s/($regex)/${config{$1}}/g; - print; -} +my $script = shift @ARGV; +do $script; diff --git a/scripts/generate.pl b/scripts/generate.pl new file mode 100644 index 00000000..4c0723c8 --- /dev/null +++ b/scripts/generate.pl @@ -0,0 +1,30 @@ +use warnings; + + +my %config; + +sub add_config { + my ($prefix, $c) = @_; + + foreach my $key (keys $c) { + my $val = $c->{$key}; + + if (ref($val) eq 'HASH') { + add_config($key . '.', $val); + } + unless (ref($val)) { + $config{'@' . $prefix . $key . '@'} = $val; + } + } +} + +add_config('', $CONFIG); + + +my $regex = join '|', map {quotemeta} keys %config; + + +for (<>) { + s/($regex)/${config{$1}}/g; + print; +} diff --git a/scripts/generate.sh b/scripts/generate.sh index 1db9c40c..667df400 100755 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -4,8 +4,6 @@ set -e declare -a IN -GLUONDIR="$(dirname "$0")/.." - for ((i = 1; i < $#; i++)); do IN[$i]="${!i}" @@ -23,7 +21,7 @@ for S in "${IN[@]}"; do ( D="$(dirname "$FILE")" mkdir -p "$OUT/$D" - (cd "$GLUONDIR"; scripts/configure.pl) < "$FILE" > "$OUT/$FILE" + (cd "$GLUONDIR"; scripts/configure.pl scripts/generate.pl) < "$FILE" > "$OUT/$FILE" chmod --reference="$FILE" "$OUT/$FILE" done ); done