Sun Aug 14 03:18:37 2022 UTC ()
lintpkgsrc: properly clean up after chdir

When running 'lintpkgsrc -I tmp/lp-85 -yro', lintpkgsrc couldn't find
the cache file due to the intermediate chdir($pkgdistdir).


(rillig)
diff -r1.90 -r1.91 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl

cvs diff -r1.90 -r1.91 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl (expand / switch to context diff)
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl 2022/08/14 03:12:02 1.90
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl 2022/08/14 03:18:36 1.91
@@ -1,5 +1,5 @@
 #!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.90 2022/08/14 03:12:02 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.91 2022/08/14 03:18:36 rillig Exp $
 
 # Written by David Brownlee <abs@netbsd.org>.
 #
@@ -1191,6 +1191,7 @@
 		}
 
 		verbose("checksum mismatches\n");
+		my $prev_cwd = getcwd() or die;
 		chdir_or_fail($pkgdistdir);
 		foreach my $sum (keys %sumfiles) {
 			if ($sum eq 'Size') {
@@ -1225,7 +1226,7 @@
 			waitpid($pid, 0) || fail "xargs digest $sum";
 			waitpid($pid2, 0) || fail 'pipe write to xargs';
 		}
-		chdir_or_fail('/'); # Do not want to stay in $pkgdistdir
+		chdir_or_fail($prev_cwd);
 	}
 
 	sort keys %unref_distfiles;