Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 02 Dec 1998 04:23:12 -0800
From:      "Jordan K. Hubbard" <jkh@zippy.cdrom.com>
To:        John Birrell <jb@cimlogic.com.au>
Cc:        dillon@apollo.backplane.com, current@FreeBSD.ORG
Subject:   Re: Uh oh... 
Message-ID:  <7403.912601392@zippy.cdrom.com>
In-Reply-To: Your message of "Wed, 02 Dec 1998 22:58:38 %2B1100." <199812021158.WAA08572@cimlogic.com.au> 

next in thread | previous in thread | raw e-mail | index | archive | help
> ... and group. We should test for each user and group defined in the
> src/etc files and add them if they don't exist in the installed system.
> This would make bootstrapping FreeBSD sources on a NetBSD system easier
> too. [Uh oh, I guess they're going to yell at me again. They seem to react
> badly when I say these things. 8-)]

Hmmm.  Just off the top of my head (and my shell wizardry skills are a
bit rusty so please excuse the roughness of this), are you suggesting
something like this:

Index: Makefile.inc1
===================================================================
RCS file: /home/ncvs/src/Makefile.inc1,v
retrieving revision 1.46
diff -u -u -r1.46 Makefile.inc1
--- Makefile.inc1	1998/11/28 13:14:58	1.46
+++ Makefile.inc1	1998/12/02 12:17:34
@@ -260,6 +260,12 @@
 .endif
 	@echo
 	@echo "--------------------------------------------------------------"
+	@echo ">>> Making required new users and groups"
+	@echo "--------------------------------------------------------------"
+	@awk -F: '{printf("if ! grep -q ^%s: /etc/master.passwd; then pw useradd %s -u %d -g %d; fi\n", $1, $1, $3, $4); }' ${.CURDIR}/etc/master.passwd | sh
+	@awk -F: '{printf("if ! grep -q ^%s: /etc/group; then pw groupadd %s -g %d; fi\n", $1, $1, $4); }' ${.CURDIR}/etc/group | sh
+	@echo
+	@echo "--------------------------------------------------------------"
 	@echo ">>> Making hierarchy"
 	@echo "--------------------------------------------------------------"
 	mkdir -p ${WORLDTMP}

?

If so, I'd be interested in seeing a more polished version of the
above committed by somebody in this discussion (it can be me, if
necessary, I'm just giving others ample opportunity for it to be them
instead :-).  The "fix" above has some immediate problems with it,
most notably the hardcoded references to awk and sh as well as the
missing ${DESTDIR} in front of /etc/master.passwd and /etc/group.
That's a casualty of the single quotes around awk's command line arg
which would prevent a ${DESTDIR} in the obvious places from expanding,
and I am too tired at the moment to even contemplate the more advanced
shell wizardry required to cons up more suitable arguments to awk.

.. and I'm sure the perl weenies could easily figure out some way to
do it in even less characters. :-)

- Jordan

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7403.912601392>