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: rename safe_chdi...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d7450040605b
branches:  trunk
changeset: 382536:d7450040605b
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 30 16:26:14 2022 +0000

description:
lintpkgsrc: rename safe_chdir to chdir_or_fail

The word 'safe' was too ambiguous.
While here, remove the source code location from the error message.
This error is not expected to occur during normal usage.

diffstat:

 pkgtools/lintpkgsrc/files/lintpkgsrc.pl |  20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diffs (74 lines):

diff -r 2dc7fe545ae4 -r d7450040605b pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 16:20:18 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 16:26:14 2022 +0000
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.38 2022/07/30 15:11:26 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.39 2022/07/30 16:26:14 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -1148,15 +1148,11 @@
 }
 
 
-# chdir() || fail()
-#
-sub safe_chdir($) {
+sub chdir_or_fail($) {
        my ($dir) = @_;
 
        debug("chdir: $dir");
-       if (!chdir($dir)) {
-               fail("Unable to chdir($dir): $!");
-       }
+       chdir($dir) or fail("Cannot chdir($dir): $!\n");
 }
 
 sub load_pkgsrc_makefiles($) {
@@ -1331,7 +1327,7 @@
                }
 
                verbose("checksum mismatches\n");
-               safe_chdir($pkgdistdir);
+               chdir_or_fail($pkgdistdir);
                foreach my $sum (keys %sumfiles) {
                        if ($sum eq 'Size') {
                                foreach my $file (@{$sumfiles{$sum}}) {
@@ -1365,7 +1361,7 @@
                        waitpid($pid, 0) || fail "xargs digest $sum";
                        waitpid($pid2, 0) || fail "pipe write to xargs";
                }
-               safe_chdir('/'); # Do not want to stay in $pkgdistdir
+               chdir_or_fail('/'); # Do not want to stay in $pkgdistdir
        }
        (sort keys %bad_distfiles);
 }
@@ -1615,7 +1611,7 @@
                        }
 
                        if ($opt{r}) {
-                               safe_chdir("$pkgdistdir");
+                               chdir_or_fail("$pkgdistdir");
                                verbose("Unlinking 'orphaned' distfiles\n");
                                foreach my $distfile (@orphan) {
                                        unlink($distfile)
@@ -1642,7 +1638,7 @@
                }
 
                if ($opt{r}) {
-                       safe_chdir("$pkgdistdir");
+                       chdir_or_fail("$pkgdistdir");
                        verbose("Unlinking 'parented' distfiles\n");
                        foreach my $distfile (@parent) {
                                unlink($distfile);
@@ -1779,7 +1775,7 @@
                                }
 
                                print "$pkgsrcdir/$pkgdir\n";
-                               safe_chdir("$pkgsrcdir/$pkgdir");
+                               chdir_or_fail("$pkgsrcdir/$pkgdir");
                                system("$conf_make fetch-list | sh");
                        }
                }



Home | Main Index | Thread Index | Old Index