From owner-freebsd-ports@FreeBSD.ORG Sat Jan 8 07:13:27 2005 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C0A8E16A4CE for ; Sat, 8 Jan 2005 07:13:27 +0000 (GMT) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5FBFE43D2F for ; Sat, 8 Jan 2005 07:13:27 +0000 (GMT) (envelope-from rodrigc@crodrigues.org) Received: from h00609772adf0.ne.client2.attbi.com ([66.30.114.143]) by comcast.net (sccrmhc13) with ESMTP id <20050108071326016002342je>; Sat, 8 Jan 2005 07:13:26 +0000 Received: from h00609772adf0.ne.client2.attbi.com (localhost [127.0.0.1]) j087DPds032400; Sat, 8 Jan 2005 02:13:25 -0500 (EST) (envelope-from rodrigc@h00609772adf0.ne.client2.attbi.com) Received: (from rodrigc@localhost)j087DOru032399; Sat, 8 Jan 2005 02:13:24 -0500 (EST) (envelope-from rodrigc) Date: Sat, 8 Jan 2005 02:13:24 -0500 From: Craig Rodrigues To: Kris Kennaway Message-ID: <20050108071324.GA32371@crodrigues.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i cc: freebsd-ports@freebsd.org Subject: Hack to sysctl kern.osreldate, for ports cluster X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jan 2005 07:13:27 -0000 Hi, On http://pointyhat.freebsd.org/errorlogs/ it states that sysctl should not be used to determine the version of FreeBSD, and that uname(1) or the OSVERSION variable should be used instead. While a valid thing to do, this is another detail for port maintainers to keep track of. What do you think of this hack to sysctl, which cats /usr/include/sys/param.h to get the value of kern.osreldate, instead of going to the true kernel sysctl variable? --- sbin/sysctl/sysctl.c.orig Sat Jan 8 01:34:41 2005 +++ sbin/sysctl/sysctl.c Sat Jan 8 01:57:13 2005 @@ -568,8 +568,14 @@ printf("%d", *(int *)p); else printf("%d.%dC", (*(int *)p - 2732) / 10, (*(int *)p - 2732) % 10); - } else - printf(hflag ? "%'d" : "%d", *(int *)p); + } else { +#ifdef PORTS_HACK + if (strcmp("kern.osreldate", name ) == 0) { + system("awk '/^#define __FreeBSD_version/ { print $3 }' /usr/include/sys/param.h"); + } else +#endif /* PORTS_HACK */ + printf(hflag ? "%'d" : "%d", *(int *)p); + } val = " "; len -= sizeof(int); p += sizeof(int); -- Craig Rodrigues rodrigc@crodrigues.org