NetBSD Problem Report #42267

From Ephaeton@gmx.net  Wed Nov  4 16:55:31 2009
Return-Path: <Ephaeton@gmx.net>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id D0ADD63BA4E
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  4 Nov 2009 16:55:31 +0000 (UTC)
Message-Id: <20091104165525.4393B13645@agamemnon.entropie.local>
Date: Wed,  4 Nov 2009 11:55:25 -0500 (EST)
From: Ephaeton@gmx.net
Reply-To: Ephaeton@gmx.net
To: gnats-bugs@gnats.NetBSD.org
Subject: pkg_comp: quick exit if pkg is installed already (patch)
X-Send-Pr-Version: 3.95

>Number:         42267
>Category:       pkg
>Synopsis:       pkg_comp: quick exit if pkg is installed already (patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 04 17:00:00 +0000 2009
>Last-Modified:  Fri Nov 06 10:45:01 +0000 2009
>Originator:     Martin S. Weber
>Release:        NetBSD 5.0_STABLE
>Organization:

>Environment:


System: NetBSD agamemnon.entropie.local 5.0_STABLE NetBSD 5.0_STABLE (AGAMEMNON5) #0: Sat Jun 27 14:44:07 EDT 2009 root@agamemnon.entropie.local:/home/netbsd/obj/sys/arch/i386/compile/AGAMEMNON5 i386
Architecture: i386
Machine: i386
>Description:

(copied from the following email: 
 http://mail-index.netbsd.org/tech-pkg/2009/11/03/msg004188.html
, PR'd by req of JMMV.)

myself:
``I've noticed a little annoyance for pkg_comp: if you give it a
list of packages that are installed already, it will a) try to
build these packages nonetheless, and b) note that this package
is "in error", because the install target failed. In fact everything
is fine though. This can be provoked two ways:
1) pkg_comp build (a package that is installed in chroot already)
2) pkg_comp build (list of package names including dependencies)

The first case is obvious, the second builds the dependencies as
required, but if your dependencies come later in the invocation
(say, you are taking the list of packages to build from a pkgchk.conf,
which is alphabetically sorted, not topologically) ... stuff "fails".''

JMMV:
``(...)
Yeah, except this will not catch cases where the installed package is
older than the newest one.(...)''

myself:
``(...)
Intentionally. I expect an error in that case: if I build binary packages
with pkg_comp I expect a binary package whose version matches that in
the underlying pkgsrc. I do want an error in that case.(...) ''


>How-To-Repeat:
	pkg_chk -g
	pkg_comp build $(grep -v '^#' /usr/pkgsrc/pkgchk.conf)

>Fix:


Index: files/pkg_comp.sh
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh,v
retrieving revision 1.35
diff -u -r1.35 pkg_comp.sh
--- files/pkg_comp.sh	13 May 2009 10:40:24 -0000	1.35
+++ files/pkg_comp.sh	4 Nov 2009 16:53:26 -0000
@@ -729,6 +729,10 @@
         statfile="$prefix.stat"
         init_script $script
         cat >> $script <<EOF
+if pkg_info -qe "\$(make show-var VARNAME=PKGNAME)" ; then
+	echo "PKG_COMP ==> $p is already installed!"
+	exit 0
+fi
 cd /usr/pkgsrc/$p
 make $BUILD_TARGET
 if [ \$? != 0 ]; then

>Audit-Trail:
From: "Martin S. Weber" <Ephaeton@gmx.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/42267: pkg_comp: quick exit if pkg is installed already (patch)
Date: Wed, 4 Nov 2009 12:19:54 -0500

 Ooops, should've cvs diff -u the whole directory. sorry. Here we go:

 Index: Makefile
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_comp/Makefile,v
 retrieving revision 1.43
 diff -u -r1.43 Makefile
 --- Makefile	9 Apr 2009 00:48:12 -0000	1.43
 +++ Makefile	4 Nov 2009 17:18:44 -0000
 @@ -1,6 +1,6 @@
  # $NetBSD: Makefile,v 1.43 2009/04/09 00:48:12 joerg Exp $

 -DISTNAME=	pkg_comp-1.31
 +DISTNAME=	pkg_comp-1.32
  CATEGORIES=	pkgtools
  MASTER_SITES=	# empty
  DISTFILES=	# empty
 Index: files/pkg_comp.sh
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh,v
 retrieving revision 1.35
 diff -u -r1.35 pkg_comp.sh
 --- files/pkg_comp.sh	13 May 2009 10:40:24 -0000	1.35
 +++ files/pkg_comp.sh	4 Nov 2009 17:18:44 -0000
 @@ -729,6 +729,10 @@
          statfile="$prefix.stat"
          init_script $script
          cat >> $script <<EOF
 +if pkg_info -qe "\$(make show-var VARNAME=PKGNAME)" ; then
 +	echo "PKG_COMP ==> $p is already installed!"
 +	exit 0
 +fi
  cd /usr/pkgsrc/$p
  make $BUILD_TARGET
  if [ \$? != 0 ]; then

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/42267: pkg_comp: quick exit if pkg is installed already (patch)
Date: Thu, 05 Nov 2009 05:32:07 +0700

     Date:        Wed,  4 Nov 2009 17:00:01 +0000 (UTC)
     From:        Ephaeton@gmx.net
     Message-ID:  <20091104170001.5452463BA4E@www.NetBSD.org>

   | This can be provoked two ways:
   | 1) pkg_comp build (a package that is installed in chroot already)
   | 2) pkg_comp build (list of package names including dependencies)

 I'm not sure that this can really be regarded as a defect in pkg_comp
 or that it should be fixed there.   What you're describing is exactly
 true of pkgsrc, if you change "pkg_comp build" into "make install"
 for the relevant package.

 pkg_comp is a great way to build packages, but I'm not sure we should
 really be making it behave differently than pkgsrc does

 kre

From: "Martin S. Weber" <Ephaeton@gmx.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/42267: pkg_comp: quick exit if pkg is installed already (patch)
Date: Thu, 5 Nov 2009 13:39:09 -0500

 On Wed, Nov 04, 2009 at 10:35:02PM +0000, Robert Elz wrote:
 >  I'm not sure that this can really be regarded as a defect in pkg_comp
 >  or that it should be fixed there.   What you're describing is exactly
 >  true of pkgsrc, if you change "pkg_comp build" into "make install"
 >  for the relevant package.

 Well, then, let's fix the install target to silently succeed if the package
 is installed already. It's quite ridiculous that it's failing in that case
 anyways! Especially if the fix is that trivial.

 Regards,

 -Martin

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/42267: pkg_comp: quick exit if pkg is installed already (patch)
Date: Fri, 06 Nov 2009 17:40:28 +0700

     Date:        Thu,  5 Nov 2009 18:40:03 +0000 (UTC)
     From:        "Martin S. Weber" <Ephaeton@gmx.net>
     Message-ID:  <20091105184003.BE4D763C403@www.NetBSD.org>

   |  Well, then, let's fix the install target to silently succeed if the package
   |  is installed already.

 That could be done, but probably not as a result of this PR, you'd want
 to submit a change request for pkgsrc itself (it is probably something in
 pkgsrc/mk/install/* - but that's a guess).

   | It's quite ridiculous that it's failing in that case
   |  anyways! Especially if the fix is that trivial.

 The difficulty of the fix has little to do with whether the problem is
 a bug or not - sometimes we live with bugs because fixing them is hard,
 but I doubt anyone believes that here.

 I suspect it is more that people actually like an error when they try
 and install something that is installed already, rather than just to be
 silently ignored.   To me it is not obvious that either way is right.

 To perhaps avoid the issue, if you want, I can send you copies of the
 scripts I use (which use pkg_comp - of course) that avoid the problems
 you're seeing - that is, that make sure that whatever I ask to be built,
 the right things get built, in the right order, so that it has now been
 a very long time since I've had anything fail the way you described (yes,
 that used to bug me as well...)

 My scripts aren't really distribution quality, you'd need to do a little
 editing to fix path names that apply to me, that you'd want different
 (anyone would want different - even I often want different!) which are
 just built in (but mostly via shell var assignments, not sprinkled throughout).

 Lastly, I believe in an almost empty pkg_comp sandbox, so the scripts like
 to frequently destroy/recreate it - unpacking existing binary packages
 for dependencies is generally fast, and this way the binary packages that
 get built avoid having hidden dependencies upon other stuff that the
 configure nonsense just happened to find lying around....   I use pkgsrc
 modular xorg, but the scripts don't know that, I have used them with the
 standard X releases as well, that's just a pkg_comp config issue, you still
 need to do that the normal way.   But if this style of working isn't what
 you want, my scripts might not be what you need (they might provide a
 starting point though).

 kre

 ps: offer applies to anyone else who uses pkg_comp, or would like to, if
 you're not a pkg_comp user, they'd be useless to you.

>Unformatted:


 	pkg_comp.sh rev 1.35

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.