[perl-CPAN-Inject] Work around CPAN bug mangling working directory

Petr Pisar ppisar at fedoraproject.org
Thu Apr 24 10:43:39 UTC 2014


commit 66128023201f9e302e24484c1800bbd94c2caa50
Author: Petr Písař <ppisar at redhat.com>
Date:   Thu Apr 24 12:34:52 2014 +0200

    Work around CPAN bug mangling working directory

 ...king-directory-after-loading-CPAN-configu.patch |   66 ++++++++++++++++++++
 perl-CPAN-Inject.spec                              |    6 ++
 2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/CPAN-Inject-1.14-Restore-working-directory-after-loading-CPAN-configu.patch b/CPAN-Inject-1.14-Restore-working-directory-after-loading-CPAN-configu.patch
new file mode 100644
index 0000000..0baf696
--- /dev/null
+++ b/CPAN-Inject-1.14-Restore-working-directory-after-loading-CPAN-configu.patch
@@ -0,0 +1,66 @@
+From 77e5e5d05f5b4df313b89ed96d5cc2e7d335dac5 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
+Date: Thu, 24 Apr 2014 11:20:51 +0200
+Subject: [PATCH] Restore working directory after loading CPAN configuration
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Uninitialized CPAN can install local::lib and change working directory
+into last build directory (CPAN RT#52520).
+
+This is a work-around to restore the directory back.
+
+<https://rt.cpan.org/Public/Bug/Display.html?id=94963>
+
+Signed-off-by: Petr Písař <ppisar at redhat.com>
+---
+ Makefile.PL        |  1 +
+ lib/CPAN/Inject.pm | 12 ++++++++++++
+ 2 files changed, 13 insertions(+)
+
+diff --git a/Makefile.PL b/Makefile.PL
+index 9c49730..e1e8ee8 100644
+--- a/Makefile.PL
++++ b/Makefile.PL
+@@ -2,6 +2,7 @@ use inc::Module::Install 1.00;
+ 
+ name          'CPAN-Inject';
+ all_from      'lib/CPAN/Inject.pm';
++requires      'Cwd'             => '0';
+ requires      'File::Spec'      => '0.80';
+ requires      'File::stat'      => '1.00';
+ requires      'File::chmod'     => '0.30';
+diff --git a/lib/CPAN/Inject.pm b/lib/CPAN/Inject.pm
+index faec14c..86cf9ea 100644
+--- a/lib/CPAN/Inject.pm
++++ b/lib/CPAN/Inject.pm
+@@ -205,6 +205,10 @@ sub from_cpan_config {
+ 	# Load the CPAN module
+ 	require CPAN;
+ 
++	# Remember working directory in case CPAN will change it, RT#94963
++	require Cwd;
++	my $origin_working_directory = Cwd::getcwd;
++
+ 	# Support for different mechanisms depending on the version
+ 	# of CPAN that is in use.
+ 	if ( defined $CPAN::HandleConfig::VERSION ) {
+@@ -213,6 +217,14 @@ sub from_cpan_config {
+ 		CPAN::Config->load;
+ 	}
+ 
++	# Restore working directory in case CPAN has changed it, RT#94963
++	if ($origin_working_directory ne Cwd::getcwd) {
++		chdir $origin_working_directory or
++			warn "CPAN changed working directory " .
++				"and later restoration to " .
++				"$origin_working_directory failed: $!";
++	}
++
+ 	# Get the sources directory
+ 	my $sources = undef;
+ 	if ( defined $CPAN::Config->{keep_source_where} ) {
+-- 
+1.9.0
+
diff --git a/perl-CPAN-Inject.spec b/perl-CPAN-Inject.spec
index 46c1039..6a613ec 100644
--- a/perl-CPAN-Inject.spec
+++ b/perl-CPAN-Inject.spec
@@ -6,9 +6,12 @@ License:        GPL+ or Artistic
 Group:          Development/Libraries
 URL:            http://search.cpan.org/dist/CPAN-Inject/
 Source0:        http://www.cpan.org/authors/id/P/PS/PSHANGOV/CPAN-Inject-%{version}.tar.gz
+# Work around CPAN bug mangling working directory, bug #1084093, CPAN RT#94963
+Patch0:         CPAN-Inject-1.14-Restore-working-directory-after-loading-CPAN-configu.patch
 BuildArch:      noarch
 BuildRequires:  perl(CPAN) >= 1.36
 BuildRequires:  perl(CPAN::Checksums) >= 1.05
+BuildRequires:  perl(Cwd)
 BuildRequires:  perl(File::Basename) >= 2.6
 BuildRequires:  perl(File::chmod) >= 0.30
 BuildRequires:  perl(File::Copy) >= 2.02
@@ -23,6 +26,7 @@ BuildRequires:  perl(Test::More) >= 0.42
 BuildRequires:  perl(Test::Script) >= 1.02
 Requires:       perl(CPAN) >= 1.36
 Requires:       perl(CPAN::Checksums) >= 1.05
+Requires:       perl(Cwd)
 Requires:       perl(File::Basename) >= 2.6
 Requires:       perl(File::chmod) >= 0.30
 Requires:       perl(File::Copy) >= 2.02
@@ -39,6 +43,7 @@ created to add additional distributions into a minicpan mirror.
 
 %prep
 %setup -q -n CPAN-Inject-%{version}
+%patch0 -p1
 
 # Remove bundled libraries
 rm -r inc
@@ -69,6 +74,7 @@ make test </dev/null
 %changelog
 * Wed Apr 23 2014 Petr Pisar <ppisar at redhat.com> - 1.14-5
 - Run tests in a new home and noninteractively
+- Work around CPAN bug mangling working directory (bug #1084093)
 
 * Mon Aug 05 2013 Petr Pisar <ppisar at redhat.com> - 1.14-4
 - Perl 5.18 rebuild



More information about the perl-devel mailing list