pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc/files lintpkgsrc: don't chdir unne...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/db4c1c32e525
branches:  trunk
changeset: 383267:db4c1c32e525
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue Aug 16 19:15:43 2022 +0000

description:
lintpkgsrc: don't chdir unnecessarily

Previously, combining the options '-u' and '-E relative-path' did not
work.

diffstat:

 pkgtools/lintpkgsrc/files/lintpkgsrc.pl |  18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diffs (75 lines):

diff -r d5fe72aa6e4d -r db4c1c32e525 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Tue Aug 16 19:07:53 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Tue Aug 16 19:15:43 2022 +0000
@@ -1,5 +1,5 @@
 #!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.100 2022/08/16 19:07:53 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.101 2022/08/16 19:15:43 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -1007,8 +1007,10 @@
 
 
 sub chdir_or_fail($dir) {
+       my $prev_dir = getcwd() or die;
        debug("chdir: $dir");
        chdir($dir) or fail("Cannot chdir($dir): $!\n");
+       return $prev_dir;
 }
 
 sub load_pkgdb_from_cache($fname) {
@@ -1196,8 +1198,7 @@
                }
 
                verbose("checksum mismatches\n");
-               my $prev_cwd = getcwd() or die;
-               chdir_or_fail($pkgdistdir);
+               my $prev_dir = chdir_or_fail($pkgdistdir);
                foreach my $sum (keys %sumfiles) {
                        if ($sum eq 'Size') {
                                foreach my $file (@{$sumfiles{$sum}}) {
@@ -1231,7 +1232,7 @@
                        waitpid($pid, 0) || fail "xargs digest $sum";
                        waitpid($pid2, 0) || fail 'pipe write to xargs';
                }
-               chdir_or_fail($prev_cwd);
+               chdir_or_fail($prev_dir);
        }
 
        sort keys %unref_distfiles;
@@ -1404,10 +1405,9 @@
        }
 
        if ($opt{r}) {
-               chdir_or_fail("$pkgdistdir");
                verbose("Unlinking 'orphaned' distfiles\n");
                foreach my $distfile (@orphan) {
-                       unlink($distfile)
+                       unlink("$pkgdistdir/$distfile")
                }
        }
 }
@@ -1431,10 +1431,9 @@
        }
 
        if ($opt{r}) {
-               chdir_or_fail("$pkgdistdir");
                verbose("Unlinking 'parented' distfiles\n");
                foreach my $distfile (@parent) {
-                       unlink($distfile);
+                       unlink("$pkgdistdir/$distfile");
                }
        }
 }
@@ -1588,8 +1587,9 @@
                    or fail('Cannot determine ' . $pkgver->pkgbase . ' directory');
 
                print "$pkgsrcdir/$pkgpath\n";
-               chdir_or_fail("$pkgsrcdir/$pkgpath");
+               my $prev_dir = chdir_or_fail("$pkgsrcdir/$pkgpath");
                system("$conf_make fetch-list | sh");
+               chdir_or_fail($prev_dir);
        }
 }
 



Home | Main Index | Thread Index | Old Index