3
0
Fork 0
forked from mirrors/nixpkgs

nix-generate-from-cpan: Hack to handle non-UTF-8 META.yml files

This commit is contained in:
Eelco Dolstra 2013-06-16 18:34:32 +02:00
parent ccda14879e
commit 15c1ca9d21
2 changed files with 9 additions and 3 deletions

View file

@ -3,7 +3,7 @@
stdenv.mkDerivation {
name = "nix-generate-from-cpan-1";
buildInputs = [ makeWrapper perl perlPackages.YAML perlPackages.JSON ];
buildInputs = [ makeWrapper perl perlPackages.YAMLLibYAML perlPackages.JSON ];
unpackPhase = "true";
buildPhase = "true";

View file

@ -2,7 +2,7 @@
use strict;
use CPANPLUS::Backend;
use YAML;
use YAML::XS;
use JSON;
my $module_name = $ARGV[0];
@ -50,7 +50,13 @@ print STDERR "unpacked to: $pkg_path\n";
my $meta;
if (-e "$pkg_path/META.yml") {
$meta = YAML::LoadFile("$pkg_path/META.yml");
eval {
$meta = YAML::XS::LoadFile("$pkg_path/META.yml");
};
if ($@) {
system("iconv -f windows-1252 -t utf-8 '$pkg_path/META.yml' > '$pkg_path/META.yml.tmp'");
$meta = YAML::XS::LoadFile("$pkg_path/META.yml.tmp");
}
}
print STDERR "metadata: ", encode_json($meta), "\n";