Browse Source

Split up configure script

Matthias Schiffer 10 years ago
parent
commit
2f919846c2
5 changed files with 36 additions and 37 deletions
  1. 1 0
      Makefile
  2. 1 1
      packages_gluon
  3. 3 33
      scripts/configure.pl
  4. 30 0
      scripts/generate.pl
  5. 1 3
      scripts/generate.sh

+ 1 - 0
Makefile

@@ -117,6 +117,7 @@ export FEEDS
 
 
 export GLUON_GENERATE := $(GLUONDIR)/scripts/generate.sh
+export GLUON_CONFIGURE := $(GLUONDIR)/scripts/configure.pl
 
 
 feeds: FORCE

+ 1 - 1
packages_gluon

@@ -1 +1 @@
-Subproject commit c57f81b7c4a498828e54e8026a9178dbc639d87b
+Subproject commit 65769f82507c9771de137451aaa2a45c57708dc3

+ 3 - 33
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;

+ 30 - 0
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;
+}

+ 1 - 3
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