Commit 748ed254 authored by Tails developers's avatar Tails developers

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.
parent 29f440cb
......@@ -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
......
......@@ -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
......
......@@ -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
......
#!/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);
......@@ -16,6 +16,7 @@ Depends: ${misc:Depends},
eatmydata,
gettext,
ikiwiki,
libyaml-perl,
live-build (>= 2.0.3),
perlmagick,
po4a,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment