summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2011-04-15 11:48:55 +0200
committerTails developers <amnesia@boum.org>2011-04-15 11:49:55 +0200
commit748ed2548cdc15fe809b27515812b54a1441a6b4 (patch)
tree0b111896cfc789c529c1b89f3ecf0f862a6014a9
parent29f440cbb3cde1efa06d79b43b0e6863b8211c1f (diff)
Extract wiki's supported languages at build time.
Save this information to config/chroot_local-includes/etc/amnesia/environment so that it is available inside the Live system.
-rw-r--r--.gitignore1
-rwxr-xr-xauto/clean1
-rwxr-xr-xauto/config9
-rwxr-xr-xauto/scripts/ikiwiki-supported-languages69
-rw-r--r--debian/control1
5 files changed, 80 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index b34c621..86677eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@
/config/common
/config/source
/config/binary_local-includes/doc/amnesia/wiki
+/config/chroot_local-includes/etc/amnesia/environment
/config/chroot_local-includes/etc/amnesia/version
/config/chroot_local-includes/home/amnesia/.gnome2/nautilus-scripts
/config/chroot_local-includes/usr/share/amnesia/readahead-list
diff --git a/auto/clean b/auto/clean
index 9c8b5ec..3599eb1 100755
--- a/auto/clean
+++ b/auto/clean
@@ -19,6 +19,7 @@ if ls config/*/ > /dev/null 2>&1 ; then
fi
# files copied or created in the config stage
+rm -f config/chroot_local-includes/etc/amnesia/environment
rm -f config/chroot_local-includes/etc/amnesia/version
rm -f config/chroot_local-includes/usr/share/doc/amnesia/Changelog
rm -f config/chroot_local-includes/usr/share/doc/amnesia/amnesia.asc
diff --git a/auto/config b/auto/config
index 89bbee0..7cd19ca 100755
--- a/auto/config
+++ b/auto/config
@@ -48,8 +48,15 @@ elif [ "$hw_arch" = powerpc -o "$hw_arch" = powerpc64 ]; then
${@}
fi
+install -d config/chroot_local-includes/etc/amnesia/
+
+# environment
+TAILS_WIKI_SUPPORTED_LANGUAGES="$(ikiwiki-supported-languages ikiwiki.setup)"
+[ -n "$TAILS_WIKI_SUPPORTED_LANGUAGES" ] || exit 16
+echo "TAILS_WIKI_SUPPORTED_LANGUAGES='${TAILS_WIKI_SUPPORTED_LANGUAGES}'" \
+ >> config/chroot_local-includes/etc/amnesia/environment
+
# version
-mkdir -p config/chroot_local-includes/etc/amnesia/
echo "${AMNESIA_FULL_VERSION}" > config/chroot_local-includes/etc/amnesia/version
if git rev-list HEAD 2>&1 >/dev/null; then
git rev-list HEAD | head -n 1 >> config/chroot_local-includes/etc/amnesia/version
diff --git a/auto/scripts/ikiwiki-supported-languages b/auto/scripts/ikiwiki-supported-languages
new file mode 100755
index 0000000..d2da585
--- /dev/null
+++ b/auto/scripts/ikiwiki-supported-languages
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+=head1 NAME
+
+ikiwiki-supported-languages - extract languages supported by a given ikwiki
+
+=head1 SYNOPSIS
+
+B<ikiwiki-supported-languages> YAML_IKIWIKI_SETUP_FILE
+
+=head1 USAGE
+
+The ikiwiki setup file passed as an argument must be in YAML format.
+See http://ikiwiki.info/tips/yaml_setup_files/ if you want to convert yours.
+
+The ikiwiki po plugin must be enabled and properly configured.
+
+=head1 AUTHOR
+
+Tails developers <amnesia@boum.org>
+
+=head1 LICENSE AND COPYRIGHT
+
+Copyright (C) 2011 Tails developers <amnesia@boum.org>
+
+Licensed under the GNU GPL version 3 or any later version.
+
+=cut
+
+use strict;
+use warnings;
+use 5.10.1;
+
+use IkiWiki::Plugin::po;
+use YAML::Any qw{LoadFile};
+$YAML::Syck::ImplicitUnicode=1;
+
+sub usage {
+ "Usage: ikiwiki-supported-languages YAML_IKIWIKI_SETUP_FILE";
+}
+my $setupfile = shift;
+defined $setupfile || die(usage());
+$setupfile ne '' || die(usage());
+-e $setupfile || die "File '$setupfile' does not exist.";
+-f $setupfile || die "File '$setupfile' is not a regular file.";
+
+my $config = LoadFile($setupfile);
+ref($config) && ref($config) eq 'HASH'
+ || die "Could not load '$setupfile'. Is it really YAML?";
+
+for (qw{add_plugins po_master_language po_slave_languages}) {
+ exists($config->{$_}) && defined($config->{$_})
+ || die "$_ is not set";
+}
+
+grep { $_ eq 'po' } $config->{add_plugins}
+ || die "The po plugin is disabled.";
+
+ref($config->{po_slave_languages}) && ref($config->{po_slave_languages}) eq 'ARRAY'
+ || die "Invalid po_slave_languages format.";
+
+my @supported_lang_codes;
+for ($config->{po_master_language}, @{$config->{po_slave_languages}}) {
+ my ($code, $name) = IkiWiki::Plugin::po::splitlangpair($_);
+ defined $code && $code ne '' || die "invalid language format: '$_'";
+ push @supported_lang_codes, $code;
+}
+
+say join(' ', @supported_lang_codes);
diff --git a/debian/control b/debian/control
index 99ac24f..aefa7d42 100644
--- a/debian/control
+++ b/debian/control
@@ -16,6 +16,7 @@ Depends: ${misc:Depends},
eatmydata,
gettext,
ikiwiki,
+ libyaml-perl,
live-build (>= 2.0.3),
perlmagick,
po4a,