Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openwrt/buildscripts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-07-27 21:41:02 +0300
committerJo-Philipp Wich <jow@openwrt.org>2015-07-27 21:53:32 +0300
commit011ee0e816c1322a37249283c3eb9b262c55297a (patch)
treede78d936f28479b200d6ae871c96200377f4b109
parenteda9fb5a6ead2ec0e697fdc29d0895891c4ff4bd (diff)
Add central configuration file and config parser helper
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-rw-r--r--.gitignore1
-rw-r--r--shared/config.pm92
-rw-r--r--shared/relman.cfg.example42
3 files changed, 135 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 16d3c4d..509e88c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
.cache
+shared/relman.cfg
diff --git a/shared/config.pm b/shared/config.pm
new file mode 100644
index 0000000..57ae371
--- /dev/null
+++ b/shared/config.pm
@@ -0,0 +1,92 @@
+package config;
+
+use Exporter 'import';
+
+@EXPORT = qw(%conf);
+
+our %conf;
+
+if (open CONF, "< shared/relman.cfg")
+{
+ while (defined(my $line = readline CONF))
+ {
+ chomp $line;
+
+ if ($line =~ m!^\s*(\w+)(\{\w+\}|\[\d+\])?\s*=\s*(\S|\S.*\S)\s*$!)
+ {
+ my ($key, $idx, $val) = ($1, $2, $3);
+
+ $val =~ s!\$(\w+|\{\w+\})!
+ exists($conf{$1}) ? $conf{$1} :
+ (exists($ENV{$1}) ? $ENV{$1} : '')
+ !eg;
+
+ if ($idx && $idx =~ m!^\{(\w+)\}$!)
+ {
+ $conf{$key} = { }
+ unless exists($conf{$key}) && ref($conf{$key}) eq 'HASH';
+
+ $conf{$key}{$1} = $val;
+ }
+ elsif ($idx && $idx =~ m!^\[(\d+)\]$!)
+ {
+ $conf{$key} = [ ]
+ unless exists($conf{$key}) && ref($conf{$key}) eq 'ARRAY';
+
+ $conf{$key}[int($1)] = $val;
+ }
+ else
+ {
+ $conf{$key} = $val;
+ }
+ }
+ }
+
+ close CONF;
+}
+else
+{
+ die "Unable to open configuration: $!\n";
+}
+
+sub sq($)
+{
+ my $s = $_[0];
+ $s =~ s/'/'"'"'/g;
+
+ return $s;
+}
+
+unless (caller)
+{
+ foreach my $key (sort keys %conf)
+ {
+ if (ref($conf{$key}) eq 'HASH')
+ {
+ foreach my $skey (sort keys %{$conf{$key}})
+ {
+ printf("%s_%s='%s'\n",
+ uc($key), uc($skey), sq($conf{$key}{$skey}));
+ }
+ }
+ elsif (ref($conf{$key}) eq 'ARRAY')
+ {
+ printf("%s='", uc($key));
+
+ my $first = 1;
+ foreach my $val (@{$conf{$key}})
+ {
+ printf("%s%s", $first ? '' : ' ', sq($val));
+ $first = 0;
+ }
+
+ printf("'\n");
+ }
+ else
+ {
+ printf("%s='%s'\n", uc($key), sq($conf{$key}));
+ }
+ }
+}
+
+1;
diff --git a/shared/relman.cfg.example b/shared/relman.cfg.example
new file mode 100644
index 0000000..abf8ecd
--- /dev/null
+++ b/shared/relman.cfg.example
@@ -0,0 +1,42 @@
+# This is an example configuration for the release management scripts.
+# Rename the file to `relman.cfg` and adjust the values as needed.
+
+# Common release properties
+release_tag = CC 15.05-rc3
+release_name = Chaos Calmer 15.05 Release Candicate 3
+release_url = openwrt@downloads.openwrt.org:chaos_calmer/15.05-rc3
+# release_url = https://downloads.openwrt.org/chaos_calmer/15.05-rc3
+# release_url = file:///CC/sync/chaos_calmer/15.05-rc3
+
+# Cache/build directory
+cache_dir = $PWD/.cache
+
+# SSH identity (used for rsync)
+ssh_ident = $HOME/.ssh/id_rsa_openwrt_rsync
+
+# File glob patterns (used for rsync/lftp)
+pattern{sdk} = OpenWrt-SDK-*.tar.bz2
+pattern{feed} = Packages.*
+
+# Recipient list for package update notifications
+recipients_standard[0] = openwrt-devel@lists.openwrt.org
+recipients_standard[1] = openwrt-users@lists.openwrt.org
+
+# Recipient list for security critical updates
+recipients_security[0] = openwrt-security-announce@lists.openwrt.org
+recipients_security[1] = openwrt-devel@lists.openwrt.org
+recipients_security[2] = openwrt-users@lists.openwrt.org
+
+# Mapping of feed names to respective online source browser
+commitlink{base} = http://git.openwrt.org/?p=15.05/openwrt.git;a=commit;h=%s
+commitlink{luci} = https://github.com/openwrt/luci/commit/%s
+commitlink{management} = https://github.com/openwrt-management/packages/commit/%s
+commitlink{packages} = https://github.com/openwrt/packages/commit/%s
+commitlink{routing} = https://github.com/openwrt-routing/packages/commit/%s
+commitlink{telephony} = https://github.com/openwrt/telephony/commit/%s
+
+# SMTP settings for mail notifications
+smtp{from} = example@openwrt.org
+smtp{host} = mail.example.org
+smtp{user} = example
+smtp{pass} = secret