Date: Sat, 29 Jun 2002 22:10:21 GMT From: W Gerald Hicks <gehicks@gehicks.dyndns.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/40017: [patch] allows config(8) to specify config metadata directory Message-ID: <200206292210.g5TMALnk000540@gehicks.dyndns.org>
next in thread | raw e-mail | index | archive | help
>Number: 40017 >Category: kern >Synopsis: [patch] allows config(8) to specify config metadata directory >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Jun 29 15:10:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: W Gerald Hicks >Release: FreeBSD 5.0-CURRENT i386 >Organization: Glenayre Electronics >Environment: System: FreeBSD 5.0-CURRENT i386 >Description: config(8) presently requires that its metadata be stored in src/sys/conf. To facilitate OEM and other special builds (like picoBSD, sysinstall) this patch adds two new options -c and -s, each requiring a directory name as a parameter: config -d /oemdist/compile/OEM -s /oemdist/src/sys \ -c /oemdist/conf /oemdist/conf/OEM This example will generate a makefile into '/oemdist/compile/OEM' for kernel configuration file '/oemdist/conf/OEM' which references source code in '/oemdist/src/sys' and uses config metadata from '/oemdist/conf'. The patch also fixes up relevant makefiles and other files to make everything work with these options. >How-To-Repeat: Apply the patch :-) >Fix: Index: src/sys/conf/Makefile.alpha =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.alpha,v retrieving revision 1.123 diff -u -r1.123 Makefile.alpha --- src/sys/conf/Makefile.alpha 20 Feb 2002 23:35:49 -0000 1.123 +++ src/sys/conf/Makefile.alpha 29 Jun 2002 12:44:47 -0000 @@ -26,9 +26,12 @@ S= ../../.. .endif .endif -.include "$S/conf/kern.pre.mk" +.if !defined(CONFDIR) +CONFDIR= $S/conf/ +.endif +.include "${CONFDIR}kern.pre.mk" -SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ +SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T ${CONFDIR}ldscript.$M \ -e locorestart \ -export-dynamic -dynamic-linker /red/herring \ -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o @@ -92,4 +95,4 @@ %RULES -.include "$S/conf/kern.post.mk" +.include "${CONFDIR}kern.post.mk" Index: src/sys/conf/Makefile.i386 =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.i386,v retrieving revision 1.255 diff -u -r1.255 Makefile.i386 --- src/sys/conf/Makefile.i386 20 Feb 2002 23:35:49 -0000 1.255 +++ src/sys/conf/Makefile.i386 29 Jun 2002 12:44:47 -0000 @@ -28,7 +28,10 @@ S= ../../.. .endif .endif -.include "$S/conf/kern.pre.mk" +.if !defined(CONFDIR) +CONFDIR= $S/conf/ +.endif +.include "${CONFDIR}kern.pre.mk" MKMODULESENV+= MACHINE=i386 @@ -46,4 +49,4 @@ %RULES -.include "$S/conf/kern.post.mk" +.include "${CONFDIR}kern.post.mk" Index: src/sys/conf/Makefile.ia64 =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.ia64,v retrieving revision 1.50 diff -u -r1.50 Makefile.ia64 --- src/sys/conf/Makefile.ia64 19 May 2002 03:41:48 -0000 1.50 +++ src/sys/conf/Makefile.ia64 29 Jun 2002 12:44:47 -0000 @@ -30,7 +30,10 @@ S= ../../.. .endif .endif -.include "$S/conf/kern.pre.mk" +.if !defined(CONFDIR) +CONFDIR= $S/conf/ +.endif +.include "${CONFDIR}kern.pre.mk" ASM_CFLAGS= -x assembler-with-cpp -Wa,-x -DLOCORE ${CFLAGS} @@ -48,4 +51,4 @@ %RULES -.include "$S/conf/kern.post.mk" +.include "${CONFDIR}kern.post.mk" Index: src/sys/conf/Makefile.pc98 =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.pc98,v retrieving revision 1.156 diff -u -r1.156 Makefile.pc98 --- src/sys/conf/Makefile.pc98 20 Feb 2002 23:35:51 -0000 1.156 +++ src/sys/conf/Makefile.pc98 29 Jun 2002 12:44:47 -0000 @@ -28,7 +28,10 @@ S= ../../.. .endif .endif -.include "$S/conf/kern.pre.mk" +.if !defined(CONFDIR) +CONFDIR= $S/conf/ +.endif +.include "${CONFDIR}kern.pre.mk" EXTRA_KERNELDEP=rm -f ./machine ; ln -s $S/$M/include ./machine MKMODULESENV+= MACHINE=pc98 @@ -47,4 +50,4 @@ %RULES -.include "$S/conf/kern.post.mk" +.include "${CONFDIR}kern.post.mk" Index: src/sys/conf/Makefile.powerpc =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.powerpc,v retrieving revision 1.261 diff -u -r1.261 Makefile.powerpc --- src/sys/conf/Makefile.powerpc 24 Mar 2002 17:45:46 -0000 1.261 +++ src/sys/conf/Makefile.powerpc 29 Jun 2002 12:44:47 -0000 @@ -31,7 +31,10 @@ S= ../../.. .endif .endif -.include "$S/conf/kern.pre.mk" +.if !defined(CONFDIR) +CONFDIR= $S/conf/ +.endif +.include "${CONFDIR}kern.pre.mk" _OS!=uname .if ${_OS} != "FreeBSD" @@ -56,4 +59,4 @@ %RULES -.include "$S/conf/kern.post.mk" +.include "${CONFDIR}kern.post.mk" Index: src/sys/conf/Makefile.sparc64 =================================================================== RCS file: /home/ncvs/src/sys/conf/Makefile.sparc64,v retrieving revision 1.19 diff -u -r1.19 Makefile.sparc64 --- src/sys/conf/Makefile.sparc64 26 May 2002 15:55:28 -0000 1.19 +++ src/sys/conf/Makefile.sparc64 29 Jun 2002 12:44:47 -0000 @@ -34,7 +34,10 @@ S= ../../.. .endif .endif -.include "$S/conf/kern.pre.mk" +.if !defined(CONFDIR) +CONFDIR= $S/conf/ +.endif +.include "${CONFDIR}kern.pre.mk" # XXX: this should probably go somewhere else COPTS+= -mcmodel=medlow -msoft-float @@ -65,4 +68,4 @@ %RULES -.include "$S/conf/kern.post.mk" +.include "${CONFDIR}kern.post.mk" Index: src/sys/conf/kern.post.mk =================================================================== RCS file: /home/ncvs/src/sys/conf/kern.post.mk,v retrieving revision 1.20 diff -u -r1.20 kern.post.mk --- src/sys/conf/kern.post.mk 23 May 2002 07:25:01 -0000 1.20 +++ src/sys/conf/kern.post.mk 29 Jun 2002 12:44:47 -0000 @@ -111,7 +111,7 @@ rm -f .depend links: - egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ + egrep '#if' ${CFILES} | sed -f ${CONFDIR}defines | \ sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ sort -u | comm -23 - dontlink | \ @@ -120,7 +120,7 @@ kernel-tags: @[ -f .depend ] || { echo "you must make depend first"; exit 1; } - sh $S/conf/systags.sh + sh ${CONFDIR}systags.sh rm -f tags1 sed -e 's, ../, ,' tags > tags1 @@ -223,8 +223,8 @@ hints.o: hints.c ${NORMAL_C} -vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} - sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} +vers.c: ${CONFDIR}newvers.sh $S/sys/param.h ${SYSTEM_DEP} + sh ${CONFDIR}newvers.sh ${KERN_IDENT} ${IDENT} # XXX strictly, everything depends on Makefile because changes to ${PROF} # only appear there, but we don't handle that. Index: src/sys/conf/kern.pre.mk =================================================================== RCS file: /home/ncvs/src/sys/conf/kern.pre.mk,v retrieving revision 1.13 diff -u -r1.13 kern.pre.mk --- src/sys/conf/kern.pre.mk 16 Jun 2002 10:42:05 -0000 1.13 +++ src/sys/conf/kern.pre.mk 29 Jun 2002 12:44:47 -0000 @@ -81,12 +81,12 @@ SYSTEM_SFILES= $S/$M/$M/locore.s SYSTEM_DEP= Makefile ${SYSTEM_OBJS} SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} hints.o env.o config.o hack.So -SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \ +SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T ${CONFDIR}ldscript.$M \ -warn-common -export-dynamic -dynamic-linker /red/herring \ -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \ ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET} -SYSTEM_DEP+= $S/conf/ldscript.$M +SYSTEM_DEP+= ${CONFDIR}ldscript.$M # MKMODULESENV is set here so that port makefiles can augment # them. Index: src/usr.sbin/config/config.h =================================================================== RCS file: /home/ncvs/src/usr.sbin/config/config.h,v retrieving revision 1.51 diff -u -r1.51 config.h --- src/usr.sbin/config/config.h 20 Feb 2002 23:35:56 -0000 1.51 +++ src/usr.sbin/config/config.h 29 Jun 2002 12:44:47 -0000 @@ -155,6 +155,7 @@ extern int maxusers; extern char *PREFIX; /* Config file name - for error messages */ +extern char confdir[]; /* where is the config metadata? */ extern char srcdir[]; /* root of the kernel source tree */ #define eq(a,b) (!strcmp(a,b)) Index: src/usr.sbin/config/main.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/config/main.c,v retrieving revision 1.55 diff -u -r1.55 main.c --- src/usr.sbin/config/main.c 25 Feb 2002 21:59:57 -0000 1.55 +++ src/usr.sbin/config/main.c 29 Jun 2002 12:44:47 -0000 @@ -68,10 +68,13 @@ #endif #define CDIR "../compile/" +#define CONFDIR "../../conf/" char * PREFIX; char destdir[MAXPATHLEN]; char srcdir[MAXPATHLEN]; +char * srcdiropt; +char confdir[MAXPATHLEN] = CONFDIR; int debugging; int profiling; @@ -99,14 +102,23 @@ char *p; char xxx[MAXPATHLEN]; - while ((ch = getopt(argc, argv, "d:gp")) != -1) + while ((ch = getopt(argc, argv, "c:d:s:gp")) != -1) switch (ch) { + case 'c': + strlcpy(confdir, optarg, sizeof(confdir)); + len = strlen(confdir); + if(len && confdir[len - 1] != '/') + strlcat(confdir, "/", sizeof(confdir)); + break; case 'd': if (*destdir == '\0') strlcpy(destdir, optarg, sizeof(destdir)); else errx(2, "directory already set"); break; + case 's': + srcdiropt = strdup(optarg); + break; case 'g': debugging++; break; @@ -183,8 +195,10 @@ static void get_srcdir(void) { - - if (realpath("../..", srcdir) == NULL) + if(srcdiropt) { + if(realpath(srcdiropt, srcdir) == NULL) + errx(2, "Unable to find root of source tree"); + } else if (realpath("../..", srcdir) == NULL) errx(2, "Unable to find root of source tree"); } Index: src/usr.sbin/config/mkmakefile.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/config/mkmakefile.c,v retrieving revision 1.72 diff -u -r1.72 mkmakefile.c --- src/usr.sbin/config/mkmakefile.c 20 Feb 2002 23:35:56 -0000 1.72 +++ src/usr.sbin/config/mkmakefile.c 29 Jun 2002 12:44:47 -0000 @@ -126,7 +126,7 @@ char *s; read_files(); - snprintf(line, sizeof(line), "../../conf/Makefile.%s", machinename); + snprintf(line, sizeof(line), "%sMakefile.%s", confdir, machinename); ifp = fopen(line, "r"); if (ifp == 0) { snprintf(line, sizeof(line), "Makefile.%s", machinename); @@ -137,6 +137,7 @@ ofp = fopen(path("Makefile.new"), "w"); if (ofp == 0) err(1, "%s", path("Makefile.new")); + fprintf(ofp, "CONFDIR=%s\n", confdir); fprintf(ofp, "KERN_IDENT=%s\n", raisestr(ident)); fprintf(ofp, "IDENT="); if (profiling) @@ -324,7 +325,7 @@ printf("no ident line specified\n"); exit(1); } - (void) snprintf(fname, sizeof(fname), "../../conf/files"); + (void) snprintf(fname, sizeof(fname), "%sfiles", confdir); openit: fp = fopen(fname, "r"); if (fp == 0) @@ -343,7 +344,7 @@ if (first == 1) { first++; (void) snprintf(fname, sizeof(fname), - "../../conf/files.%s", machinename); + "%sfiles.%s", confdir, machinename); fp = fopen(fname, "r"); if (fp != 0) goto next; Index: src/usr.sbin/config/mkoptions.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/config/mkoptions.c,v retrieving revision 1.29 diff -u -r1.29 mkoptions.c --- src/usr.sbin/config/mkoptions.c 9 Dec 2001 01:57:05 -0000 1.29 +++ src/usr.sbin/config/mkoptions.c 29 Jun 2002 12:44:47 -0000 @@ -299,7 +299,7 @@ printf("no ident line specified\n"); exit(1); } - (void) snprintf(fname, sizeof(fname), "../../conf/options"); + (void) snprintf(fname, sizeof(fname), "%soptions", confdir); openit: fp = fopen(fname, "r"); if (fp == 0) { @@ -311,7 +311,8 @@ (void) fclose(fp); if (first == 1) { first++; - (void) snprintf(fname, sizeof fname, "../../conf/options.%s", machinename); + (void) snprintf(fname, sizeof fname, "%soptions.%s", + confdir, machinename); fp = fopen(fname, "r"); if (fp != 0) goto next; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206292210.g5TMALnk000540>