From glebius@cell.sick.ru  Mon Dec 22 04:55:14 2003
Return-Path: <glebius@cell.sick.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1182916A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 22 Dec 2003 04:55:14 -0800 (PST)
Received: from cell.sick.ru (cell.sick.ru [217.72.144.68])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6B6DE43D5D
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 22 Dec 2003 04:55:12 -0800 (PST)
	(envelope-from glebius@cell.sick.ru)
Received: from cell.sick.ru (glebius@localhost [127.0.0.1])
	by cell.sick.ru (8.12.9/8.12.8) with ESMTP id hBMCt9AB087994
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO);
	Mon, 22 Dec 2003 15:55:09 +0300 (MSK)
	(envelope-from glebius@cell.sick.ru)
Received: (from glebius@localhost)
	by cell.sick.ru (8.12.9/8.12.6/Submit) id hBMCt8rU087993;
	Mon, 22 Dec 2003 15:55:08 +0300 (MSK)
Message-Id: <200312221255.hBMCt8rU087993@cell.sick.ru>
Date: Mon, 22 Dec 2003 15:55:08 +0300 (MSK)
From: Gleb Smirnoff <glebius@cell.sick.ru>
Reply-To:
To: FreeBSD-gnats-submit@freebsd.org
Cc: glebius@cell.sick.ru
Subject: small error in modules installation
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         60503
>Category:       misc
>Synopsis:       [modules] small error in modules installation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 22 05:00:35 PST 2003
>Closed-Date:    Wed Nov 24 01:35:20 UTC 2010
>Last-Modified:  Wed Nov 24 01:35:20 UTC 2010
>Originator:     Gleb Smirnoff
>Release:        FreeBSD 4.9-PRERELEASE i386
>Organization:
Bestcom ISP
>Environment:
System: FreeBSD cell.sick.ru 4.9-PRERELEASE FreeBSD 4.9-PRERELEASE #0: Fri Sep 19 10:22:46 MSD 2003 root@fade.bestcom.ru:/usr/obj/usr/src/sys/NUCLEUS i386
>Description:

	When ${KMODDIR}, usually /modules, does not exist modules installation
	process does not fail, but all modules are written into file /modules,
	overwriting each other.

>How-To-Repeat:

	su-2.05b# rm -rf /modules
	su-2.05b# cd /usr/src/sys/modules/if_gif
	su-2.05b# make
		...
	su-2.05b# make install
	install -o root -g wheel -m 555   if_gif.ko /modules
	su-2.05b# file /modules 
	/modules: ELF 32-bit LSB shared object, Intel 80386, version 1 (FreeBSD), not stripped

	make installkernel will write all modules into one file "/modules".
>Fix:

--- kmod.mk.orig	Mon Dec 22 15:29:59 2003
+++ kmod.mk	Mon Dec 22 15:43:49 2003
@@ -183,6 +183,9 @@
 realinstall: _kmodinstall
 .ORDER: beforeinstall _kmodinstall
 _kmodinstall:
+.if !exists(${KMODDIR})
+	@mkdir -p ${KMODDIR};
+.endif
 	${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
 	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
 .endif !target(realinstall)
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ceri 
Responsible-Changed-When: Mon Dec 22 06:37:38 PST 2003 
Responsible-Changed-Why:  
Over to Ruslan, who seems to like working on the build infrastructure. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60503 
Responsible-Changed-From-To: ru->freebsd-bugs 
Responsible-Changed-By: ru 
Responsible-Changed-When: Mon Dec 22 07:21:51 PST 2003 
Responsible-Changed-Why:  
We don't normally create directories in .mk files, and this 
problem is the same as not having /sbin before attempting to 
install into it -- i.e., there's more than one way to shoot 
yourself in the foot. 

We usually populate hierarchy with mtree(8), during the 
installworld.  One "fix" to the problem may be to "make 
hierarchy" during the installkernel part of Makefile.inc1. 

The patch in the PR is not quite right, as it does not 
account for DESTDIR. 

Since this problem is well-known to me, and I don't know 
of any solution that I'd like to see committed, I'm 
returning the ownership back to the pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60503 
State-Changed-From-To: open->closed 
State-Changed-By: arundel 
State-Changed-When: Wed Nov 24 01:29:40 UTC 2010 
State-Changed-Why:  
As Ruslan noticed there are millions of wonderful ways of shooting yourself in 
the foot. Deleting the directory ${KMODDIR} points to is one of them. For the 
average user kernel module will be installed to /boot/kernel/ which will be 
created by mtree. if you decide to either delete that directory or point 
${KMODDIR} to a non-existing directory you *will* run into problems. FreeBSD 
doesn't keep you from doing such magical tricks, but you cannot expect it to 
have a safety belt for every imaginable situation. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=60503 
>Unformatted:
