From 15c1ca9d2111ba5796c45881d654d1726e9d8e0d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 16 Jun 2013 18:34:32 +0200 Subject: [PATCH] nix-generate-from-cpan: Hack to handle non-UTF-8 META.yml files --- maintainers/scripts/nix-generate-from-cpan.nix | 2 +- maintainers/scripts/nix-generate-from-cpan.pl | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/maintainers/scripts/nix-generate-from-cpan.nix b/maintainers/scripts/nix-generate-from-cpan.nix index 59a9b89bbe7c..fffe11f1a5fc 100644 --- a/maintainers/scripts/nix-generate-from-cpan.nix +++ b/maintainers/scripts/nix-generate-from-cpan.nix @@ -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"; diff --git a/maintainers/scripts/nix-generate-from-cpan.pl b/maintainers/scripts/nix-generate-from-cpan.pl index 86749bcac690..1eb6c51a16af 100755 --- a/maintainers/scripts/nix-generate-from-cpan.pl +++ b/maintainers/scripts/nix-generate-from-cpan.pl @@ -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";