NetBSD Problem Report #16885
Received: (qmail 5316 invoked from network); 18 May 2002 17:18:24 -0000
Message-Id: <200205181719.g4IHJbj17320@snowdrop.l8s.co.uk>
Date: Sat, 18 May 2002 18:19:37 +0100 (BST)
From: david@l8s.co.uk
Reply-To: david@l8s.co.uk
To: gnats-bugs@gnats.netbsd.org
Subject: Linked files are added to METALOG when program isn't rebuilt
X-Send-Pr-Version: 3.95
>Number: 16885
>Category: toolchain
>Synopsis: Linked files are added to METALOG when program isn't rebuilt
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lukem
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 18 17:19:00 +0000 2002
>Closed-Date: Sun Jul 20 14:50:45 +0000 2003
>Last-Modified: Sun Jul 20 14:51:00 +0000 2003
>Originator: David Laight
>Release: NetBSD 1.5ZC
>Organization:
None
>Environment:
System: NetBSD snowdrop 1.5ZC NetBSD 1.5ZC (GENERIC) #10: Thu May 16 12:50:04 BST 2002 dsl@snowdrop:/oldroot/usr/bsd-current/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
When a program that has multiple names is installed, the hard links
are regenerated on every build.
For UNPRIVED builds this adds records to the METALOG file during
UPDATE builds - even though the entry for the program itself isn't
in the METALOG file.
This is doubly annoying because the entries for the links are
incorrect :-(
>How-To-Repeat:
rerun 'build.sh -d -u -U -D $DESTDIR -O $OBJDIR' and note that
entries for commands with synonyms are added to METALOG even
though the programs aren't rebuild.
(eg usr/bin/at has links atq, atrm and batch)
>Fix:
Change bsd.links.mk so that ${INSTALL_LINK} is only executed when the
file inode numbers are different.
I've also changed the SYMLINKS copy to save exec'ing awk for
every symlink.
The subshells are no longer needed as there is no requirement
to redirect the output. I also don't understand rev 1.12!
Index: bsd.links.mk
===================================================================
RCS file: /cvsroot/sharesrc/share/mk/bsd.links.mk,v
retrieving revision 1.19
diff -u -r1.19 bsd.links.mk
--- bsd.links.mk 2002/04/30 14:29:01 1.19
+++ bsd.links.mk 2002/05/18 17:10:34
@@ -11,30 +11,30 @@
##### Install rules
linksinstall:: realinstall
.if !empty(SYMLINKS)
- @(set ${SYMLINKS}; \
- while test $$# -ge 2; do \
- l=$$1; shift; \
- t=${DESTDIR}$$1; shift; \
- if [ -h $$t ]; then \
- cur=`ls -ld $$t | awk '{print $$NF}'` ; \
- if [ "$$cur" = "$$l" ]; then \
- continue ; \
- fi; \
- fi; \
- echo "$$t -> $$l"; \
- rm -rf $$t; ${INSTALL_SYMLINK} $$l $$t; \
- done; )
+ @ l=; for t in ${SYMLINKS}; do \
+ [ -z "$$l" ] && { l=$$t; continue; }; \
+ t=${DESTDIR}$$t; \
+ lt=; \
+ [ -h "$$t" ] && { set -- `ls -lnd $$t`; eval lt=\$${$$#}; }; \
+ [ "$${lt}" != "$$l" ] && { \
+ echo "$$t -> $$l"; \
+ rm -rf $$t; ${INSTALL_SYMLINK} $$l $$t; \
+ }; \
+ l=; \
+ done;
.endif
.if !empty(LINKS)
- @(set ${LINKS}; \
- echo ".include <bsd.own.mk>"; \
- while test $$# -ge 2; do \
- l=${DESTDIR}$$1; shift; \
- t=${DESTDIR}$$1; shift; \
- echo "realall: $$t"; \
- echo "$$t!"; \
- echo " @echo \"$$t -> $$l\""; \
- echo " @rm -f $$t; ${INSTALL_LINK} $$l $$t"; \
- done; \
- ) | ${MAKE} -f- all
+ @ l=; for t in ${LINKS}; do \
+ t=${DESTDIR}$$t; \
+ [ -z "$$l" ] && { l=$$t; continue; }; \
+ [ -f "$$t" ] && { set -- `ls -lind $$t`; ti=$$1; } || ti=; \
+ [ -f "$$l" ] && { set -- `ls -lind $$l`; li=$$1; } || li=; \
+ [ -n "$$li" -a "$$ti" != "$$li" ] && { \
+ echo "$$t -> $$l"; \
+ rm -f $$t; ${INSTALL_LINK} $$l $$t; \
+ }; \
+ l=; \
+ done;
.endif
>Release-Note:
>Audit-Trail:
From: David Laight <david@l8s.co.uk>
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: Re: toolchain/16885: Linked files are added to METALOG when program isn't rebuilt
Date: Mon, 20 May 2002 16:54:18 +0100
Revisiting this file I spotted a much cleaner way to
do the check for linked files:
> + @ l=; for t in ${LINKS}; do \
> + t=${DESTDIR}$$t; \
> + [ -z "$$l" ] && { l=$$t; continue; }; \
> + [ "$$l" -ef "$$t" ] || { \
> + echo "$$t -> $$l"; \
> + rm -f $$t; ${INSTALL_LINK} $$l $$t; \
> + }; \
> + l=; \
> + done;
David
--
David Laight: david@l8s.co.uk
State-Changed-From-To: open->closed
State-Changed-By: lukem
State-Changed-When: Sun Jul 20 14:49:53 UTC 2003
State-Changed-Why:
I've solved this, albiet using stat(1) instead of the non-standard test -ef.
(I made stat a host tool because it's useful for this and other similar
purposes)
Responsible-Changed-From-To: toolchain-manager->lukem
Responsible-Changed-By: lukem
Responsible-Changed-When: Sun Jul 20 14:49:53 UTC 2003
Responsible-Changed-Why:
From: Luke Mewburn <lukem@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: pr/16885 CVS commit: src/share/mk
Date: Sun, 20 Jul 2003 14:49:45 +0000 (UTC)
Module Name: src
Committed By: lukem
Date: Sun Jul 20 14:49:44 UTC 2003
Modified Files:
src/share/mk: bsd.links.mk
Log Message:
LINKS: use stat -qf '%d %i' $l to read the device & inode # of the source
and target (and rely upon a non-zero exit value to indicate a missing file),
instead instead of unconditionally installing the link.
SYMLINKS: use stat -qf '%Y' $l to read a symlink's target (and rely upon
a non-zero exit value to indicate a missing file or non-symlink),
instead of test -h $l && ls -ld $l | awk '{print $NF}' , since
the former is quicker and more concise.
This resolves PR toolchain/16885 from David Laight.
To generate a diff of this commit:
cvs rdiff -r1.21 -r1.22 src/share/mk/bsd.links.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(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.