nix-generate-from-cpan: Hack to handle non-UTF-8 META.yml files
This commit is contained in:
parent
ccda14879e
commit
15c1ca9d21
|
@ -3,7 +3,7 @@
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "nix-generate-from-cpan-1";
|
name = "nix-generate-from-cpan-1";
|
||||||
|
|
||||||
buildInputs = [ makeWrapper perl perlPackages.YAML perlPackages.JSON ];
|
buildInputs = [ makeWrapper perl perlPackages.YAMLLibYAML perlPackages.JSON ];
|
||||||
|
|
||||||
unpackPhase = "true";
|
unpackPhase = "true";
|
||||||
buildPhase = "true";
|
buildPhase = "true";
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use CPANPLUS::Backend;
|
use CPANPLUS::Backend;
|
||||||
use YAML;
|
use YAML::XS;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
my $module_name = $ARGV[0];
|
my $module_name = $ARGV[0];
|
||||||
|
@ -50,7 +50,13 @@ print STDERR "unpacked to: $pkg_path\n";
|
||||||
|
|
||||||
my $meta;
|
my $meta;
|
||||||
if (-e "$pkg_path/META.yml") {
|
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";
|
print STDERR "metadata: ", encode_json($meta), "\n";
|
||||||
|
|
Loading…
Reference in a new issue