Embedding a RCS token in uname -i
Karl Vogel
vogelke+unix at pobox.com
Wed Jun 22 22:39:40 UTC 2011
>> On Tue, 21 Jun 2011 20:21:46 -0600 (MDT),
>> Dennis Glatting <freebsd at penx.com> said:
D> My goal is to provide a mechanism where I can identify that kernels
D> built on a group of machines are running the same kernel built from a
D> configuration under RCS. How can I customized the current config and
D> build mechanisms to accomplish this?
Make your changes to the file GENERIC.in, run a small script to create
GENERIC with the stuff you want, and then do your build.
D> Is it a dumb idea?
I don't think so. See below for one way to do it; the script includes a
sanity check to make sure your build config file has been checked in.
--
Karl Vogel I don't speak for the USAF or my company
Mr. Rogers was an ordained minister. --item for a lull in conversation
---------------------------------------------------------------------------
me% cat -n GENERIC.in
1 # $Revision: 1.2 $ $Date: 2011/06/22 18:13:14 $
2
3 cpu HAMMER
4 ident GENERIC
5 ...
me% ./mkgen
me% cat -n GENERIC
1 # THIS FILE WAS AUTOMATICALLY GENERATED. GENERIC.in is under
2 # revision control, so please make your changes there.
3 #
4 # $Revision: 1.2 $ $Date: 2011/06/22 18:13:14 $
5
6 cpu HAMMER
7 ident GENERIC-1.2-20110622
8 ...
me% cat mkgen
#!/bin/ksh
#<mkgen: Get version and date info from GENERIC.in, write GENERIC
export PATH=/usr/local/bin:/bin:/usr/bin
in=GENERIC.in
out=GENERIC
if rcsdiff -q $in > /dev/null; then
echo updating $out
else
echo $in needs to be checked in
exit 0
fi
nawk -v ifile=$in 'BEGIN {
warn1 = "# THIS FILE WAS AUTOMATICALLY GENERATED. "
warn2 = "# revision control, so please make your changes there.\n#"
}
{
if ($0 ~ /Revision:/) {
print warn1, ifile, "is under"
print warn2
print
gsub("/"," ")
id = sprintf("%s-%s%s%s", $3, $6, $7, $8)
}
else if ($0 ~ /^ident/) { print $0 "-" id }
else print
}' $in > $out
exit 0
More information about the freebsd-questions
mailing list