pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc lintpkgsrc: fix hardcoded paths



details:   https://anonhg.NetBSD.org/pkgsrc/rev/03be70c8c752
branches:  trunk
changeset: 383025:03be70c8c752
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Aug 10 22:43:54 2022 +0000

description:
lintpkgsrc: fix hardcoded paths

No matter whether lintpkgsrc is built in batch mode, its PREFIX must
always be the actual prefix, not the hardcoded /usr/pkg, as there may
also be bulk builds with --prefix=/opt/pkg. Same for mk.conf.

diffstat:

 pkgtools/lintpkgsrc/Makefile            |   9 ++++-
 pkgtools/lintpkgsrc/files/lintpkgsrc.0  |  51 ++++++++++++++++----------------
 pkgtools/lintpkgsrc/files/lintpkgsrc.1  |  16 +++++-----
 pkgtools/lintpkgsrc/files/lintpkgsrc.pl |  30 +++++++++---------
 4 files changed, 55 insertions(+), 51 deletions(-)

diffs (279 lines):

diff -r 720f77df4620 -r 03be70c8c752 pkgtools/lintpkgsrc/Makefile
--- a/pkgtools/lintpkgsrc/Makefile      Wed Aug 10 21:54:46 2022 +0000
+++ b/pkgtools/lintpkgsrc/Makefile      Wed Aug 10 22:43:54 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.48 2022/08/10 20:16:55 rillig Exp $
+# $NetBSD: Makefile,v 1.49 2022/08/10 22:43:54 rillig Exp $
 
 PKGNAME=       lintpkgsrc-2022.08.10
 CATEGORIES=    pkgtools
@@ -21,11 +21,16 @@
 SUBST_CLASSES+=                lp
 SUBST_STAGE.lp=                post-configure
 SUBST_FILES.lp+=       lintpkgsrc.0 lintpkgsrc.1 lintpkgsrc.pl
-SUBST_SED.lp+=         -e 's;@PKGSRCDIR@;${BATCH:D/usr/pkgsrc:U${PKGSRCDIR}};g'
+SUBST_SED.lp+=         -e 's,_\(.\)@_.M_.A_.K_.E_.C_.O_.N_.F_.@,${MAKECONF:C,(.),_\\\\1\1,g},g'
+SUBST_SED.lp+=         -e 's,_\(.\)@_.P_.R_.E_.F_.I_.X_.@,${PREFIX:C,(.),_\\\\1\1,g},g'
 SUBST_VARS.lp+=                MAKE
+SUBST_VARS.lp+=                MAKECONF
 SUBST_VARS.lp+=                PERL5
+SUBST_VARS.lp+=                PKGSRCDIR
+SUBST_VARS.lp+=                PKG_INFO
 SUBST_VARS.lp+=                PKG_SYSCONFDIR
 SUBST_VARS.lp+=                PREFIX
+SUBST_VARS.lp+=                X11BASE
 
 .include "../../mk/bsd.prefs.mk"
 
diff -r 720f77df4620 -r 03be70c8c752 pkgtools/lintpkgsrc/files/lintpkgsrc.0
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.0    Wed Aug 10 21:54:46 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.0    Wed Aug 10 22:43:54 2022 +0000
@@ -1,4 +1,4 @@
-LINTPKGSRC(1)               General Commands Manual              LINTPKGSRC(1)
+LINTPKGSRC(1)           NetBSD General Commands Manual           LINTPKGSRC(1)
 
 NNAAMMEE
      lliinnttppkkggssrrcc -- verifier for the pkgsrc tree
@@ -10,8 +10,8 @@
 DDEESSCCRRIIPPTTIIOONN
      lliinnttppkkggssrrcc tries to verify the entire contents of the pkgsrc tree.
      lliinnttppkkggssrrcc uses simple regular-expression matching for verifying files
-     that make up a pkgsrc directory.  Note that it does NOT implement a
-     complete Makefile parser.
+     that make up a pkgsrc directory.  Note that it does NOT implement a com-
+     plete Makefile parser.
 
    OOppttiioonnss
      --BB            List packages marked as BROKEN.
@@ -31,29 +31,29 @@
                    a set of similarly configured machines (in the absence of
                    extra copies of the pkgsrc tree) both quick and possible.
 
-     --gg _p_k_g_s_r_c_m_a_p  Generate pkgsrcmap file containing an entry for each
-                   package of `pkgname pkgdir pkgver'.
+     --gg _p_k_g_s_r_c_m_a_p  Generate pkgsrcmap file containing an entry for each pack-
+                   age of `pkgname pkgdir pkgver'.
 
      --hh            Basic help and usage.
 
      --II _f_i_l_e       Imports the data to construct the internal database for
                    checking the installed versions of packages, among other
                    things, against the current version found in pkgsrc.  This
-                   database provides most or all of the data required for
-                   running lliinnttppkkggssrrcc with any combination of --BB, --OO, --RR, --SS,
-                   --dd, --gg, --ii, --pp, or --uu.
+                   database provides most or all of the data required for run-
+                   ning lliinnttppkkggssrrcc with any combination of --BB, --OO, --RR, --SS, --dd,
+                   --gg, --ii, --pp, or --uu.
 
      --ii            Check the version of each installed package against the
                    current version in pkgsrc.
 
      --KK _P_A_C_K_A_G_E_S   Override binary packages base directory, normally set from
-                   _/_e_t_c_/_m_k_._c_o_n_f or defaulted to _$_{_P_K_G_S_R_C_D_I_R_}_/_p_a_c_k_a_g_e_s.
+                   _@_M_A_K_E_C_O_N_F_@ or defaulted to _$_{_P_K_G_S_R_C_D_I_R_}_/_p_a_c_k_a_g_e_s.
 
                    Note: lintpkgsrc treats _P_A_C_K_A_G_E_S slightly differently to
-                   the pkgsrc build system.  --pp and --RR check for binary
-                   packages in any depth of PACKAGES subdirs - this allows
-                   packages for all architectures/OS versions to be checked
-                   simultaneously with an _/_e_t_c_/_m_k_._c_o_n_f construct of the form:
+                   the pkgsrc build system.  --pp and --RR check for binary pack-
+                   ages in any depth of PACKAGES subdirs - this allows pack-
+                   ages for all architectures/OS versions to be checked simul-
+                   taneously with a _@_M_A_K_E_C_O_N_F_@ construct of the form:
 
                    .ifdef LINTPKGSRC
                    PACKAGES=${PKGSRCDIR}/packages
@@ -82,8 +82,8 @@
      --oo            Report any old distfiles (not referenced by any package's
                    distinfo file).
 
-     --PP _P_K_G_S_R_C_D_I_R  Set base of pkgsrc tree, normally set from _/_e_t_c_/_m_k_._c_o_n_f or
-                   defaulted to _/_u_s_r_/_p_k_g_s_r_c.
+     --PP _P_K_G_S_R_C_D_I_R  Set base of pkgsrc tree, normally set from _@_M_A_K_E_C_O_N_F_@ or
+                   defaulted to _@_P_R_E_F_I_X_@.
 
      --pp            Report any old binary packages in any subdirs of _P_A_C_K_A_G_E_S.
 
@@ -92,11 +92,11 @@
                    This is intended to help those making binary packages
                    available for ftp.
 
-     --rr            Remove distfiles which are not referenced from any
-                   package's distinfo file, or have an incorrect checksum
-                   (usually due to an interrupted download), and any old
-                   binary packages.  To remove any given type, additionally
-                   specify the --oo, --mm, or --pp flags respectively.
+     --rr            Remove distfiles which are not referenced from any pack-
+                   age's distinfo file, or have an incorrect checksum (usually
+                   due to an interrupted download), and any old binary pack-
+                   ages.  To remove any given type, additionally specify the
+                   --oo, --mm, or --pp flags respectively.
 
      --SS            List packages missing from category _S_U_B_D_I_R lists.
 
@@ -117,11 +117,10 @@
 
 BBUUGGSS
      The --RR and --pp options default to using _P_A_C_K_A_G_E_S as the base directory
-     from which to search for binary packages.  If this includes OS or
-     architecture information then packages for other OS/architecture
-     combinations will be missed.  In this case _P_A_C_K_A_G_E_S can be overridden
-     with --KK or set conditionally in _/_e_t_c_/_m_k_._c_o_n_f based on the value of
-     _L_I_N_T_P_K_G_S_R_C.
+     from which to search for binary packages.  If this includes OS or archi-
+     tecture information then packages for other OS/architecture combinations
+     will be missed.  In this case _P_A_C_K_A_G_E_S can be overridden with --KK or set
+     conditionally in _@_M_A_K_E_C_O_N_F_@ based on the value of _L_I_N_T_P_K_G_S_R_C.
 
      The `Makefile parsing' algorithm used to obtain package versions and
      DEPENDS information is geared towards speed rather than perfection,
@@ -130,4 +129,4 @@
 
      Potentially others, but non serious to date.
 
-LOCAL                          November 24, 2014                         LOCAL
+NetBSD 9.99                     August 10, 2022                    NetBSD 9.99
diff -r 720f77df4620 -r 03be70c8c752 pkgtools/lintpkgsrc/files/lintpkgsrc.1
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.1    Wed Aug 10 21:54:46 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.1    Wed Aug 10 22:43:54 2022 +0000
@@ -1,9 +1,9 @@
-.\"    $NetBSD: lintpkgsrc.1,v 1.5 2016/03/12 09:05:22 wiz Exp $
+.\"    $NetBSD: lintpkgsrc.1,v 1.6 2022/08/10 22:43:55 rillig Exp $
 .\"
 .\" Copyright (c) 1999 by David Brownlee (abs%netbsd.org@localhost)
 .\" Absolutely no warranty.
 .\"
-.Dd March 12, 2016
+.Dd August 10, 2022
 .Dt LINTPKGSRC 1
 .Sh NAME
 .Nm lintpkgsrc
@@ -73,7 +73,7 @@
 pkgsrc.
 .It Fl K Ar PACKAGES
 Override binary packages base directory, normally set from
-.Pa /etc/mk.conf
+.Pa @MAKECONF@
 or defaulted to
 .Pa ${PKGSRCDIR}/packages .
 .Pp
@@ -85,8 +85,8 @@
 .Fl R
 check for
 binary packages in any depth of PACKAGES subdirs - this allows packages for all
-architectures/OS versions to be checked simultaneously with an
-.Pa /etc/mk.conf
+architectures/OS versions to be checked simultaneously with a
+.Pa @MAKECONF@
 construct of the form:
 .Bd -literal
 \&.ifdef LINTPKGSRC
@@ -118,9 +118,9 @@
 Report any old distfiles (not referenced by any package's distinfo file).
 .It Fl P Ar PKGSRCDIR
 Set base of pkgsrc tree, normally set from
-.Pa /etc/mk.conf
+.Pa @MAKECONF@
 or defaulted to
-.Pa /usr/pkgsrc .
+.Pa @PREFIX@ .
 .It Fl p
 Report any old binary packages in any subdirs of
 .Em PACKAGES .
@@ -179,7 +179,7 @@
 can be overridden with
 .Fl K
 or set conditionally in
-.Pa /etc/mk.conf
+.Pa @MAKECONF@
 based on the value of
 .Em LINTPKGSRC .
 .Pp
diff -r 720f77df4620 -r 03be70c8c752 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Wed Aug 10 21:54:46 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Wed Aug 10 22:43:54 2022 +0000
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.71 2022/08/10 21:48:47 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.72 2022/08/10 22:43:55 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -158,9 +158,12 @@
 
 # Buildtime configuration
 my $conf_make = '@MAKE@';
+my $conf_makeconf = '@MAKECONF@';
+my $conf_pkg_info = '@PKG_INFO@';
 my $conf_pkgsrcdir = '@PKGSRCDIR@';
 my $conf_prefix = '@PREFIX@';
 my $conf_sysconfdir = '@PKG_SYSCONFDIR@';
+my $conf_x11base = '@X11BASE@';
 
 my (
     $pkgdb,                    # Database of pkgsrc packages
@@ -517,7 +520,7 @@
        push @incdirs, dirname($file);
 
        # Some Makefiles depend on these being set
-       if ($file eq '/etc/mk.conf') {
+       if ($file eq $conf_makeconf) {
                $vars{LINTPKGSRC} = 'YES';
        } else {
                %vars = %{$default_vars};
@@ -630,7 +633,7 @@
 
 sub get_default_makefile_vars() {
 
-       chomp($pkg_installver = `pkg_info -V 2>/dev/null || echo 20010302`);
+       chomp($pkg_installver = `$conf_pkg_info -V 2>/dev/null || echo 20010302`);
 
        chomp($_ = `uname -srm`);
        (
@@ -659,16 +662,12 @@
            : $conf_pkgsrcdir;
 
        $default_vars->{DESTDIR} = '';
-       $default_vars->{LOCALBASE} = '/usr/pkg';
-       $default_vars->{X11BASE} = '/usr/X11R6';
+       $default_vars->{LOCALBASE} = $conf_pkgsrcdir;
+       $default_vars->{X11BASE} = $conf_x11base;
 
        my ($vars);
-       if (-f '/etc/mk.conf' && ($vars = parse_makefile_vars('/etc/mk.conf', undef))) {
-               foreach my $var (keys %{$vars}) {
-                       $default_vars->{$var} = $vars->{$var};
-               }
-       } elsif (-f "$conf_sysconfdir/mk.conf" &&
-           ($vars = parse_makefile_vars("$conf_sysconfdir/mk.conf", undef))) {
+       if (-f $conf_makeconf &&
+           ($vars = parse_makefile_vars($conf_makeconf, undef))) {
                foreach my $var (keys %{$vars}) {
                        $default_vars->{$var} = $vars->{$var};
                }
@@ -744,8 +743,8 @@
 }
 
 sub list_installed_packages() {
-       open(PKG_INFO, 'pkg_info -e "*" |')
-           or fail("Unable to run pkg_info: $!");
+       open(PKG_INFO, "$conf_pkg_info -e '*' |")
+           or fail("Unable to run $conf_pkg_info: $!");
        chomp(my @pkgs = <PKG_INFO>);
        close(PKG_INFO);
        map { $_ = canonicalize_pkgname($_) } @pkgs;
@@ -1579,8 +1578,9 @@
        print "\nREQUIRED details for packages that could be updated:\n";
 
        foreach my $pkgver (@update) {
-               print $pkgver->pkgbase . ':';
-               if (open(PKGINFO, 'pkg_info -R ' . $pkgver->pkgbase . '|')) {
+               my $pkgbase = $pkgver->pkgbase;
+               print "$pkgbase:";
+               if (open(PKGINFO, "$conf_pkg_info -R $pkgbase |")) {
                        my ($list);
 
                        while (<PKGINFO>) {



Home | Main Index | Thread Index | Old Index