Subject: misc/11826: YP makefile to handle several amd maps
To: None <gnats-bugs@gnats.netbsd.org>
From: None <anthony.mallet@ficus.yi.org>
List: netbsd-bugs
Date: 12/27/2000 09:52:16
>Number:         11826
>Category:       misc
>Synopsis:       Makefile.yp (in /var/yp) should handle several amd maps
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 27 09:52:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Anthony Mallet
>Release:        NetBSD-1.5 - Dec 27, 2000
>Organization:
	
>Environment:
	
System: NetBSD ficus 1.5.1_ALPHA NetBSD 1.5.1_ALPHA (FICUS) #1: Sun Nov 19 20:50:47 CET 2000 troot@ficus:/usr/src/sys/arch/i386/compile/FICUS i386


>Description:
	
The makefile bundled with ypinit (usr.sbin/ypserv/ypinit/Makefile.yp)
doesn't handle several amd maps explicitely. (it considers there is only
one map named amd.home).

I propose the patch below that defines a new variable AMDMAPS that contains
the list of maps to be shared with yp. Map names are relative to
AMDDIR. Users can then alter the list of maps (which is still defined by
default to the single amd.home map) to suit their needs.

>How-To-Repeat:
	
Create several amd maps and try to share them with yp :)

>Fix:
	
This patch is to be applied to usr.sbin/ypserv/ypinit/Makefile.yp in the
source tree

--- Makefile.yp.orig	Sun Oct 29 17:19:50 2000
+++ Makefile.yp	Sat Dec 23 18:19:22 2000
@@ -21,6 +21,7 @@
 YPDBDIR=	/var/yp
 DIR=		/etc
 AMDDIR=		/etc/amd
+AMDMAPS=	amd.home
 DOMAIN=		"`/usr/bin/basename ${.CURDIR}`"
 
 AWK=		/usr/bin/awk
@@ -46,7 +47,7 @@
 # We have a rule for ypservers, but we don't build it by default, since
 # it seldom changes (only when slaves are added/deleted).
 
-all: passwd aliases amd.home ethers group hosts netgroup networks rpc
services protocols netid
+all: passwd aliases ${AMDMAPS} ethers group hosts netgroup networks rpc
services protocols netid
 
 
 passwd.time: ${DIR}/master.passwd
@@ -116,8 +117,8 @@
 		${ECHO} "couldn't find ${.ALLSRC}"; \
 	fi
 
-
-amd.home.time: ${AMDDIR}/amd.home
+.for MAP in ${AMDMAPS}
+${MAP}.time: ${AMDDIR}/${MAP}
 	-@if [ -f ${.ALLSRC} ]; then \
 		${SED} -e "s/#.*$$//" -e "/^$$/d" ${.ALLSRC} | \
 		${AWK} '{ \
@@ -133,18 +134,19 @@
 				else \
 				    printf("%s ", $$i); \
 			}' | \
-		${SORT} | ${MAKEDBM} - amd.home; \
+		${SORT} | ${MAKEDBM} - ${MAP}; \
 		${TOUCH} ${.TARGET}; \
-		${ECHO} "updated amd.homŽ; \
+		${ECHO} "updated ${.ALLSRC}"; \
 		if [ ! ${NOPUSH} ]; then \
-			${YPPUSH} -d ${DOMAIN} amd.home; \
-			${ECHO} "pushed amd.homŽ; \
+			${YPPUSH} -d ${DOMAIN} ${MAP}; \
+			${ECHO} "pushed ${.ALLSRC}"; \
 		else \
 			: ; \
 		fi \
 	else \
 		${ECHO} "couldn't find ${.ALLSRC}"; \
 	fi
+.endfor
 
 
 ethers.time: ${DIR}/ethers
@@ -347,7 +349,9 @@
 group: group.time
 hosts: hosts.time
 aliases: aliases.time
-amd.home: amd.home.time
+.for MAP in ${AMDMAPS}
+${MAP}: ${MAP}.time
+.endfor
 ethers: ethers.time
 netgroup: netgroup.time
 networks: networks.time
@@ -361,7 +365,9 @@
 ${DIR}/group:
 ${DIR}/hosts:
 ${DIR}/mail/aliases:
-${AMDDIR}/amd.home:
+.for MAP in ${AMDMAPS}
+${AMDDIR}/${MAP}:
+.endfor
 ${DIR}/ethers:
 ${DIR}/master.passwd:
 ${DIR}/netgroup:
>Release-Note:
>Audit-Trail:
>Unformatted: