NetBSD Problem Report #7590

Received: (qmail 13679 invoked from network); 16 May 1999 20:35:27 -0000
Message-Id: <199905162035.RAA10165@newbox.fundy.net>
Date: Sun, 16 May 1999 17:35:15 -0300 (ADT)
From: David Maxwell <david@fundy.net>
Reply-To: david@fundy.net
To: gnats-bugs@gnats.netbsd.org
Subject: Package locking for pkgsrc
X-Send-Pr-Version: 3.95

>Number:         7590
>Category:       pkg
>Synopsis:       code to allow multiple parallel pkgsrc makes friendlier
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    agc
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun May 16 13:50:01 +0000 1999
>Closed-Date:    Sat Jan 19 21:49:39 +0000 2002
>Last-Modified:  Sat Jan 19 21:49:39 +0000 2002
>Originator:     David Maxwell
>Release:        1.4
>Organization:

	Just me.
>Environment:

System: NetBSD newbox 1.4 NetBSD 1.4 (NEWBOX) #5: Sat May 15 13:02:28 ADT 1999 root@newbox:/usr/src/sys/arch/i386/compile/NEWBOX i386


>Description:

pkgsrc doesn't restrict multiple makes from trying to build the same package
at the same time. Since packages depend on each other all over the place,
it's easy to open a couple shells and start building packages that both
require say - perl, and have them clobber each other.
>How-To-Repeat:

Open two shells. cd /usr/pkgsrc/lang/perl5 in both, and make in both.

>Fix:

Here's some 'make code' that will fix this. I don't pretend to know the pksrc
system well enough to put it into the right part of bsd.pkg.mk

This will run standalone for testing purposes, as is. Remove the noted lines
for use in bsd.pkg.mk. Change the 10 seconds to something reasonable.

For CVS purposes, or whatever:
David Maxwell's (david@maxwell.net) implementation of an idea from Mike
Pelley (mike@pelley.com)

------------------------------------------------------------------------

# These are the basic variables used from bsd.pkg.mk
# They are only needed here for standalone testing of course.

ECHO?=          /bin/echo
ECHO_MSG?=              ${ECHO}
WRKDIR_BASENAME?=       work
TAIL?=		/usr/bin/tail	

# This one isn't in bsd.pkg.mk, but will be needed by this.
# About line 547

PS?=            /bin/ps

# Don't know why it would be, but might as well test.
# The Make is the parent of the shell.

.ifndef PPID
PPID!= ${PS} -p $$$$ -o ppid | ${TAIL} -1
.endif

# Just a single target for standalone testing. Move into
# Whatever section is appropriate.

# The environment variable PKG_NOWAITFORLOCK can be set if
# you prefer to have the build error out, rather than wait if
# it finds a locked package.

test:
.ifdef PKG_NOWAITFORLOCK
	@ shlock -f ${WRKDIR_BASENAME}/lockfile -p ${PPID} || ( ${ECHO_MSG} "The package is currently being built by another process." && exit 1 )
.else
	@-	while ( ! shlock -f ${WRKDIR_BASENAME}/lockfile -p ${PPID} ) ;  do \
		sleep 10 ; \
	echo "The package is currently being built by another process. Will retry in 10 seconds." ; done
.endif

	@ echo Managed to lock the package.

#	Sleep 30 seconds for standalone testing. Remove for bsd.pkg.mk
	@ sleep 30

#	Cleanup at end of process.
	@- rm ${WRKDIR_BASENAME}/lockfile


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: agc 
State-Changed-When: Sat Jan 19 13:48:31 PST 2002 
State-Changed-Why:  
I've just added some code to do coarse-grained locking to bsd.pkg.mk. 

Thanks for the nudge, and sorry to take so long to get around to this 
one. 


Responsible-Changed-From-To: pkg-manager->agc 
Responsible-Changed-By: agc 
Responsible-Changed-When: Sat Jan 19 13:48:31 PST 2002 
Responsible-Changed-Why:  
agc took responsibility for this one. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.