diff options
author | bsiegert <bsiegert@pkgsrc.org> | 2014-11-24 09:41:25 +0000 |
---|---|---|
committer | bsiegert <bsiegert@pkgsrc.org> | 2014-11-24 09:41:25 +0000 |
commit | a342493018c26392fe9f88349204ad74f081f2e4 (patch) | |
tree | 6d37540e11bb064e90ca8594fc0be883e636c0ab /pkgtools | |
parent | 692e34e9a2bd875d1282d241e962cf56266c9e10 (diff) | |
download | pkgsrc-a342493018c26392fe9f88349204ad74f081f2e4.tar.gz |
New lintpkgsrc release. It contains the -y and -z parameters provided by
Adrian Portelli ten years ago in PR pkg/25451.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/lintpkgsrc/Makefile | 5 | ||||
-rw-r--r-- | pkgtools/lintpkgsrc/files/lintpkgsrc.0 | 14 | ||||
-rw-r--r-- | pkgtools/lintpkgsrc/files/lintpkgsrc.1 | 9 | ||||
-rwxr-xr-x | pkgtools/lintpkgsrc/files/lintpkgsrc.pl | 129 |
4 files changed, 146 insertions, 11 deletions
diff --git a/pkgtools/lintpkgsrc/Makefile b/pkgtools/lintpkgsrc/Makefile index aa864a57270..bb5dd4b49d0 100644 --- a/pkgtools/lintpkgsrc/Makefile +++ b/pkgtools/lintpkgsrc/Makefile @@ -1,7 +1,6 @@ -# $NetBSD: Makefile,v 1.17 2014/10/09 14:06:49 wiz Exp $ +# $NetBSD: Makefile,v 1.18 2014/11/24 09:41:25 bsiegert Exp $ -PKGNAME= lintpkgsrc-4.86 -PKGREVISION= 2 +PKGNAME= lintpkgsrc-4.87 CATEGORIES= pkgtools MAINTAINER= pkgsrc-users@NetBSD.org diff --git a/pkgtools/lintpkgsrc/files/lintpkgsrc.0 b/pkgtools/lintpkgsrc/files/lintpkgsrc.0 index 9ee45180428..e66c3c7a611 100644 --- a/pkgtools/lintpkgsrc/files/lintpkgsrc.0 +++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.0 @@ -1,10 +1,11 @@ -LINTPKGSRC(1) NetBSD General Commands Manual LINTPKGSRC(1) + +LINTPKGSRC(1) BSD General Commands Manual LINTPKGSRC(1) NNAAMMEE lliinnttppkkggssrrcc -- verifier for the pkgsrc tree SSYYNNOOPPSSIISS - lliinnttppkkggssrrcc [--BBDDLLOORRSSVVddhhiillmmoopprruu] [--EE _f_i_l_e] [--gg _p_k_g_s_r_c_m_a_p] [--II _f_i_l_e] + lliinnttppkkggssrrcc [--BBDDLLOORRSSVVddhhiillmmoopprruuyyzz] [--EE _f_i_l_e] [--gg _p_k_g_s_r_c_m_a_p] [--II _f_i_l_e] [--KK _P_A_C_K_A_G_E_S] [--MM _D_I_S_T_D_I_R] [--PP _P_K_G_S_R_C_D_I_R] [_m_a_k_e_f_i_l_e _._._.] DDEESSCCRRIIPPTTIIOONN @@ -111,8 +112,13 @@ DDEESSCCRRIIPPTTIIOONN known vulnerabilities, based on the data in _$_{_P_K_G_S_R_C_D_I_R_}_/_d_i_s_t_f_i_l_e_s_/_p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s. + --yy Remove orphaned distfiles, i.e. those that do not belong to + any currently installed package. + + --zz Remove distfiles for currently installed packages. + AAUUTTHHOORRSS - David Brownlee <abs@netbsd.org> + David Brownlee <_a_b_s_@_n_e_t_b_s_d_._o_r_g> BBUUGGSS The --RR, --VV, and --pp options default to using _P_A_C_K_A_G_E_S as the base direc- @@ -128,4 +134,4 @@ BBUUGGSS Potentially others, but non serious to date. -pkgsrc November 8, 2005 pkgsrc + November 8, 2005 diff --git a/pkgtools/lintpkgsrc/files/lintpkgsrc.1 b/pkgtools/lintpkgsrc/files/lintpkgsrc.1 index 740c2116670..09a6b6cdec3 100644 --- a/pkgtools/lintpkgsrc/files/lintpkgsrc.1 +++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: lintpkgsrc.1,v 1.2 2013/07/20 21:50:53 wiz Exp $ +.\" $NetBSD: lintpkgsrc.1,v 1.3 2014/11/24 09:41:25 bsiegert Exp $ .\" .\" Copyright (c) 1999 by David Brownlee (abs@netbsd.org) .\" Absolutely no warranty. @@ -10,7 +10,7 @@ .Nd verifier for the pkgsrc tree .Sh SYNOPSIS .Nm -.Op Fl BDLORSVdhilmopru +.Op Fl BDLORSVdhilmopruyz .Op Fl E Ar file .Op Fl g Ar pkgsrcmap .Op Fl I Ar file @@ -161,6 +161,11 @@ List any prebuilt packages in any subdirs of .Em PACKAGES with known vulnerabilities, based on the data in .Pa ${PKGSRCDIR}/distfiles/pkg-vulnerabilities . +.It Fl y +Remove orphaned distfiles, i.e. those that do not belong to any +currently installed package. +.It Fl z +Remove distfiles for currently installed packages. .El .Sh AUTHORS .An David Brownlee Aq Mt abs@netbsd.org diff --git a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl index 88625cfe12d..3827d431699 100755 --- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl +++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl @@ -1,6 +1,6 @@ #! @PERL@ -# $NetBSD: lintpkgsrc.pl,v 1.3 2013/02/09 18:51:56 mspo Exp $ +# $NetBSD: lintpkgsrc.pl,v 1.4 2014/11/24 09:41:25 bsiegert Exp $ # Written by David Brownlee <abs@netbsd.org>. # @@ -42,7 +42,7 @@ $ENV{PATH} .= ":/bin:/usr/bin:/sbin:/usr/sbin:${conf_prefix}/sbin:${conf_prefix}/bin"; if ( - !getopts( 'BDE:I:K:LM:OP:RSVdg:himopru', \%opt ) + !getopts( 'BDE:I:K:LM:OP:RSVdg:himopruyz', \%opt ) || $opt{h} || !( defined $opt{d} @@ -60,6 +60,8 @@ if ( || defined $opt{S} || defined $opt{V} || defined $opt{E} + || defined $opt{y} + || defined $opt{z} ) ) { @@ -119,6 +121,127 @@ sub main() { } } + # Remove all distfiles that are / are not part of an installed package + if ($opt{y} || $opt{z}) + { + my(@pkgs, @installed, %distfiles, @pkgdistfiles, @dldistfiles); + my(@tmpdistfiles, @orphan, $found, @parent); + + @pkgs = list_installed_packages(); + scan_pkgsrc_makefiles($pkgsrcdir); + + # list the installed packages and the directory they live in + foreach my $pkgname (sort @pkgs) + { + if ($pkgname =~ /^([^*?[]+)-([\d*?[].*)/) + { + foreach my $pkgver ($pkglist->pkgver($1)) + { + $pkgver->var('dir') =~ /-current/ && next; + push(@installed, $pkgver); + last; + } + } + } + + # distfiles belonging to the currently installed packages + foreach my $pkgver (sort @installed) + { + if (open(DISTINFO, "$pkgsrcdir/" .$pkgver->var('dir'). "/distinfo")) + { + while( <DISTINFO> ) + { + if (m/^(\w+) ?\(([^\)]+)\) = (\S+)/) + { + my($dn); + if ($2 =~ /^patch-[a-z0-9]+$/) + { next; } + $dn = $2; + # Strip leading ./ which sometimes gets added + # because of DISTSUBDIR=. + $dn =~ s/^(\.\/)*//; + if (!defined $distfiles{$dn}) + { + $distfiles{$dn}{name} = $dn; + push (@pkgdistfiles, $dn); + } + } + } + close(DISTINFO); + } + } + + # distfiles downloaded on the current system + @tmpdistfiles = listdir("$pkgdistdir"); + foreach my $tmppkg (@tmpdistfiles) + { + if ($tmppkg ne "pkg-vulnerabilities") + { push (@dldistfiles, $tmppkg); } + } + + # sort the two arrays to make searching a bit faster + @dldistfiles = sort { $a cmp $b } @dldistfiles; + @pkgdistfiles = sort { $a cmp $b } @pkgdistfiles; + + if ($opt{y}) + { + # looking for files that are downloaded on the current system + # but do not belong to any currently installed package i.e. orphaned + $found = 0; + foreach my $dldf (@dldistfiles) + { + foreach my $pkgdf (@pkgdistfiles) + { + if ($dldf eq $pkgdf) + { $found = 1; } + } + if ($found != 1) + { + push (@orphan, $dldf); + print "Orphaned file: $dldf\n"; + } + $found = 0; + } + + if ($opt{r}) + { + safe_chdir("$pkgdistdir"); + verbose("Unlinking 'orphaned' distfiles\n"); + foreach my $distfile (@orphan) + { unlink($distfile) } + } + } + + if ($opt{z}) + { + # looking for files that are downloaded on the current system + # but belong to a currently installed package i.e. parented + $found = 0; + foreach my $pkgdf (@pkgdistfiles) + { + foreach my $dldf (@dldistfiles) + { + if ($pkgdf eq $dldf) + { $found = 1; } + } + if ($found == 1) + { + push (@parent, $pkgdf); + print "Parented file: $pkgdf\n"; + } + $found = 0; + } + } + + if ($opt{r}) + { + safe_chdir("$pkgdistdir"); + verbose("Unlinking 'parented' distfiles\n"); + foreach my $distfile (@parent) + { unlink($distfile) } + } + } + # List BROKEN packages if ( $opt{B} ) { scan_pkgsrc_makefiles($pkgsrcdir); @@ -1608,6 +1731,8 @@ opts: Installed package options: Distfile options: -i : Check version against pkgsrc -m : List distinfo mismatches -u : As -i + fetch dist (may change) -o : List obsolete (no distinfo) + -y : Remove orphan distfiles + -z : Remove installed distfiles Prebuilt package options: Makefile options: -p : List old/obsolete -B : List packages marked as 'BROKEN' |