Subject: port-i386/2878: kgetent() in libkeycap tries to open $(DESTDIR)/usr/share/misc/keycap.pcvt if it was compiled with setting DESTDIR.
To: None <gnats-bugs@gnats.netbsd.org>
From: Kouichi Matsuda <kmatsuda@pingu.math.hokudai.ac.jp>
List: netbsd-bugs
Date: 10/21/1996 17:18:16
>Number:         2878
>Category:       port-i386
>Synopsis:       kgetent() in libkeycap tries to open $(DESTDIR)/usr/share/misc/keycap.pcvt if it was compiled with setting DESTDIR.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 21 01:35:01 1996
>Last-Modified:
>Originator:     Kouichi Matsuda
>Organization:
	Department of Mathematics, Faculty of Science, Hokkaido University
>Release:        NetBSD 1.2
>Environment:
System: NetBSD pingu.math.hokudai.ac.jp 1.2 NetBSD 1.2 (Julia) #203: Mon Oct 21 13:26:25 JST 1996 kmatsuda@pingu.math.hokudai.ac.jp:/usr/src/sys/arch/i386/compile/Julia i386

>Description:
	libkeycap in pcvt refers to $(DESTDIR)/usr/share/misc/keycap.pcvt
	(that is, kgetent() in keycap.c tries to open it)
	if it was compiled with setting DESTDIR.

	In src/sys/arch/i386/isa/pcvt/Util/keycap/Makefile, 
	-DKEYCAP_PATH=\"$(CAPPATH)\" is added to CFLAGS, 
	and CAPPATH is expanded to $(DESTDIR)/usr/share/misc/keycap.pcvt.
	kgetent() in keycap.c refers to KEYCAP_PATH and tries to open.

	So if it is compiled with DESTDIR (which is determined at compile time),
	for example, when we update binaries including pcvt utilities
	with DESTDIR, these pcvt utilities (currently `kcon' only)
	fail to open keycap file.

	For example, such kcon binary claims

	kcon: keycap database not found or not accessible!


	Moreover, if DESTDIR is set, saving old keycap.pcvt and installing
	new keycap.pcvt will fail. Because already ${CAPPATH} contains 
	$(DESTDIR) but in arch/i386/isa/pcvt/Util/keycap/Makefile, 

|beforeinstall:
|	@if [ ! -d ${DESTDIR}${LIBDIR} ]; then mkdir ${DESTDIR}${LIBDIR};fi
|	@${ECHO} "Saving old keycap database"
|	-mv -f ${DESTDIR}${CAPPATH} ${DESTDIR}${CAPPATH}.BAK

	so DESTDIR appears in ${DESTDIR}${CAPPATH} twice.
	Same thing occurs at 
	
|	install -c -m ${LIBMODE} -o ${LIBOWN} -g ${LIBGRP} \
|	${.CURDIR}/${KEYCAPSRC} ${DESTDIR}${CAPPATH}


>How-To-Repeat:
	Set DESTDIR really, make at arch/i386/isa/pcvt/Util,
	unset DESTDIR and make install.

	Use new kcon binary, it will claim as above.
	Because usually DESTDIR does not set and 
	$(DESTDIR)/usr/share/misc/keycap.pcvt does not exist.

>Fix:
	Delete $(DESTDIR) in the definition of CAPDIR,
	which is defined in src/sys/arch/i386/isa/pcvt/Util/keycap/Makefile.

diff -cr src/sys/arch/i386/isa/pcvt/Util/keycap/Makefile.orig src/sys/arch/i386/isa/pcvt/Util/keycap/Makefile
*** src/sys/arch/i386/isa/pcvt/Util/keycap/Makefile.orig	Sat Oct 14 11:01:44 1995
--- src/sys/arch/i386/isa/pcvt/Util/keycap/Makefile	Mon Oct 21 14:18:10 1996
***************
*** 1,5 ****
  LIB	=	keycap
! CAPDIR	=	$(DESTDIR)/usr/share/misc
  CAPPATH	=	$(CAPDIR)/keycap.pcvt
  KEYCAPSRC=	keycap.src
  CFLAGS	+=	-DKEYCAP_PATH=\"$(CAPPATH)\"
--- 1,5 ----
  LIB	=	keycap
! CAPDIR	=	/usr/share/misc
  CAPPATH	=	$(CAPDIR)/keycap.pcvt
  KEYCAPSRC=	keycap.src
  CFLAGS	+=	-DKEYCAP_PATH=\"$(CAPPATH)\"
>Audit-Trail:
>Unformatted: