pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/libkver Update to version 0.4.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/12beace2dbc6
branches:  trunk
changeset: 464607:12beace2dbc6
user:      seb <seb%pkgsrc.org@localhost>
date:      Sat Dec 13 17:45:59 2003 +0000

description:
Update to version 0.4.

Libkver is now run-time configurable, see installed kver(3), it now
installs in LOCALBASE and uses install/deinstall scripts to replace/restore
/sbin/sysctl if needed.

diffstat:

 pkgtools/libkver/DEINSTALL               |   12 +
 pkgtools/libkver/DESCR                   |    2 +-
 pkgtools/libkver/INSTALL                 |   12 +
 pkgtools/libkver/Makefile                |   26 +++-
 pkgtools/libkver/PLIST                   |    9 +-
 pkgtools/libkver/files/Makefile          |    5 +-
 pkgtools/libkver/files/Makefile.inc      |   32 +---
 pkgtools/libkver/files/lib/Makefile      |    5 +-
 pkgtools/libkver/files/lib/kver.3        |   47 +++++++
 pkgtools/libkver/files/lib/kver.c        |  190 +++++++++++++++++++++---------
 pkgtools/libkver/files/lib/shlib_version |    4 +-
 pkgtools/libkver/files/sysctl/Makefile   |    4 +-
 12 files changed, 248 insertions(+), 100 deletions(-)

diffs (truncated from 517 to 300 lines):

diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/DEINSTALL
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libkver/DEINSTALL        Sat Dec 13 17:45:59 2003 +0000
@@ -0,0 +1,12 @@
+# $NetBSD: DEINSTALL,v 1.1 2003/12/13 17:45:59 seb Exp $
+
+HAS_SYSCTL=@HAS_SYSCTL@
+
+case ${STAGE} in
+DEINSTALL)
+       if ${HAS_SYSCTL} && [ -f /sbin/sysctl.pre-${PKGBASE} ]; then
+               ${RM} -f /sbin/sysctl                           &&      \
+               ${MV} /sbin/sysctl.pre-${PKGBASE} /sbin/sysctl  &&      \
+               ${ECHO} "/sbin/sysctl.pre-${PKGBASE} has been restored as /sbin/sysctl"
+       fi
+esac
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/DESCR
--- a/pkgtools/libkver/DESCR    Sat Dec 13 17:21:00 2003 +0000
+++ b/pkgtools/libkver/DESCR    Sat Dec 13 17:45:59 2003 +0000
@@ -2,7 +2,7 @@
 sysctl(1) (when needed i.e. when the original one is statically linked)
 so that the real version numbers and strings of the running NetBSD
 kernel as returned by sysctl(3) and uname(3) are overridden by
-those fixed during compilation.
+those the library is configured to report.
 
 This is useful for -among other things- building packages in
 sandboxed/chrooted environment for a different NetBSD release than the
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/INSTALL
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libkver/INSTALL  Sat Dec 13 17:45:59 2003 +0000
@@ -0,0 +1,12 @@
+# $NetBSD: INSTALL,v 1.1 2003/12/13 17:45:59 seb Exp $
+
+HAS_SYSCTL=@HAS_SYSCTL@
+
+case ${STAGE} in
+POST-INSTALL)
+       if ${HAS_SYSCTL}; then
+               ${MV} /sbin/sysctl /sbin/sysctl.pre-${PKGBASE} &&       \
+               ${CP} -p ${PKG_PREFIX}/sbin/sysctl /sbin/sysctl &&      \
+               ${ECHO} "/sbin/sysctl has been moved as /sbin/sysctl.pre-${PKGBASE}"
+       fi
+esac
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/Makefile
--- a/pkgtools/libkver/Makefile Sat Dec 13 17:21:00 2003 +0000
+++ b/pkgtools/libkver/Makefile Sat Dec 13 17:45:59 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2003/10/27 20:31:42 seb Exp $
+# $NetBSD: Makefile,v 1.8 2003/12/13 17:45:59 seb Exp $
 
 DISTNAME=              libkver-${VERSION}
 CATEGORIES=            pkgtools
@@ -10,24 +10,38 @@
 COMMENT=       Shared library and sysctl(1) replacement to override system version
 
 USE_BUILDLINK2=                # defined
+USE_PKGINSTALL=                YES
 
 NO_PKGTOOLS_REQD_CHECK=        # defined
 NO_CHECKSUM=           # defined
 NO_MTREE=              # defined
-NO_PKG_REGISTER=       # defined
-NO_PACKAGE=            Deinstallation is not permitted
 
-VERSION=               0.3
+VERSION=               0.4
 
 ONLY_FOR_PLATFORM=     NetBSD-*-*
 
 .include "../../mk/bsd.prefs.mk"
 
-.if defined(KVER_OSRELEASE)
-MAKE_ENV+=     KVER_OSRELEASE=${KVER_OSRELEASE}
+LDD_SYSCTL!=    ldd /sbin/sysctl 2>&1
+MAKE_ENV+=     LDD_SYSCTL=${LDD_SYSCTL:Q} # save another ldd run
+.if empty(LDD_SYSCTL:M*libc*)
+PLIST_SUBST+=          HAS_SYSCTL=
+FILES_SUBST+=          HAS_SYSCTL=true
+.else
+PLIST_SUBST+=          HAS_SYSCTL="@comment "
+FILES_SUBST+=          HAS_SYSCTL=false
 .endif
 
+INSTALL_EXTRA_TMPL+=   ${.CURDIR}/INSTALL
+DEINSTALL_EXTRA_TMPL+= ${.CURDIR}/DEINSTALL
+
 do-extract:
        @${CP} -Rp ${FILESDIR} ${WRKSRC}
 
+pre-install:
+       ${INSTALL_DATA_DIR} ${PREFIX}/lib
+.if empty(LDD_SYSCTL:M*libc*)
+       ${INSTALL_DATA_DIR} ${PREFIX}/sbin
+.endif
+
 .include "../../mk/bsd.pkg.mk"
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/PLIST
--- a/pkgtools/libkver/PLIST    Sat Dec 13 17:21:00 2003 +0000
+++ b/pkgtools/libkver/PLIST    Sat Dec 13 17:45:59 2003 +0000
@@ -1,1 +1,8 @@
-@comment $NetBSD: PLIST,v 1.1.1.1 2003/07/11 14:50:37 seb Exp $
+@comment $NetBSD: PLIST,v 1.2 2003/12/13 17:45:59 seb Exp $
+lib/libkver.a
+lib/libkver.so
+lib/libkver.so.1
+lib/libkver.so.1.0
+man/cat3/kver.0
+man/man3/kver.3
+${HAS_SYSCTL}sbin/sysctl
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/files/Makefile
--- a/pkgtools/libkver/files/Makefile   Sat Dec 13 17:21:00 2003 +0000
+++ b/pkgtools/libkver/files/Makefile   Sat Dec 13 17:45:59 2003 +0000
@@ -1,11 +1,12 @@
-#      $NetBSD: Makefile,v 1.2 2003/07/20 15:37:47 seb Exp $
+#      $NetBSD: Makefile,v 1.3 2003/12/13 17:45:59 seb Exp $
 
 SUBDIR=                lib
 
+.ifndef(LDD_SYSCTL)
 LDD_SYSCTL!=   ldd /sbin/sysctl 2>&1
+.endif
 .if empty(LDD_SYSCTL:M*libc*)
 SUBDIR+=       sysctl
 .endif
 
 .include <bsd.subdir.mk>
-.include "${.CURDIR}/Makefile.inc"
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/files/Makefile.inc
--- a/pkgtools/libkver/files/Makefile.inc       Sat Dec 13 17:21:00 2003 +0000
+++ b/pkgtools/libkver/files/Makefile.inc       Sat Dec 13 17:45:59 2003 +0000
@@ -1,27 +1,11 @@
-#      $NetBSD: Makefile.inc,v 1.3 2003/10/27 20:31:42 seb Exp $
-
-.include <bsd.own.mk>
+#      $NetBSD: Makefile.inc,v 1.4 2003/12/13 17:45:59 seb Exp $
 
-SUPPORTED_KVER_OSRELEASES+=    1.5
-SUPPORTED_KVER_OSRELEASES+=    1.5.1
-SUPPORTED_KVER_OSRELEASES+=    1.5.2
-SUPPORTED_KVER_OSRELEASES+=    1.5.3
-SUPPORTED_KVER_OSRELEASES+=    1.6
-SUPPORTED_KVER_OSRELEASES+=    1.6.1
-SUPPORTED_KVER_OSRELEASES+=    1.6.2
-KVER_OSREVISION.1.5=   105000000
-KVER_OSREVISION.1.5.1= 105000100
-KVER_OSREVISION.1.5.2= 105000200
-KVER_OSREVISION.1.5.3= 105000300
-KVER_OSREVISION.1.6=   106000000
-KVER_OSREVISION.1.6.1= 106000100
-KVER_OSREVISION.1.6.2= 106000200
-
-.if defined(KVER_OSRELEASE) && !empty(SUPPORTED_KVER_OSRELEASES:M${KVER_OSRELEASE})
-CFLAGS+=       -D_KVER_OSREVISION=${KVER_OSREVISION.${KVER_OSRELEASE}}
+.if defined(PREFIX)
+# build from pkgsrc
+LIBDIR=         ${PREFIX}/lib
+BINDIR=                ${PREFIX}/sbin
+MANDIR=                ${PREFIX}/man
 .else
-.BEGIN:
-       @echo "You must define KVER_OSRELEASE to be one of:"
-       @echo "${SUPPORTED_KVER_OSRELEASES}"
-       @false
+# build outside pkgsrc
+BINDIR=                /sbin
 .endif
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/files/lib/Makefile
--- a/pkgtools/libkver/files/lib/Makefile       Sat Dec 13 17:21:00 2003 +0000
+++ b/pkgtools/libkver/files/lib/Makefile       Sat Dec 13 17:45:59 2003 +0000
@@ -1,9 +1,10 @@
-#      $NetBSD: Makefile,v 1.1.1.1 2003/07/11 14:50:37 seb Exp $
+#      $NetBSD: Makefile,v 1.2 2003/12/13 17:45:59 seb Exp $
 
 NOPROFILE=      # defined
 NOLINT=         # defined
-USE_SHLIBDIR=   yes
+MKPICINSTALL=  no
 LIB=   kver
+MAN=   kver.3
 SRCS=  kver.c
 
 .include <bsd.lib.mk>
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/files/lib/kver.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libkver/files/lib/kver.3 Sat Dec 13 17:45:59 2003 +0000
@@ -0,0 +1,47 @@
+.\" $NetBSD: kver.3,v 1.1 2003/12/13 17:45:59 seb Exp $
+.\"
+.Dd December 13, 2003
+.Os
+.Dt KVER 3
+.Sh NAME
+.Nm kver
+.Nd override system version library
+.Sh SYNOPSIS
+LD_PRELOAD=.../libkver.so uname -a
+.Sh DESCRIPTION
+The
+.Nm
+library provides implementations of
+.Xr sysctl 3 and
+.Xr uname 3 that
+shadow the real implementation and could be configured to override the
+information identifying the current system.
+The library is usually loaded by the run-time link-editor via the
+LD_PRELOAD hook.
+.Pp
+This is useful for -among other things- building packages in a sandboxe,
+chrooted environment for a different
+.Nx
+release then the system hosting the sandbox.
+.Pp
+The library must be configured for reporting a specific
+.Nx
+release or else it emits a warning message on the standard error output.
+The value of the environment variable
+.Ev LIBKVER_OSRELEASE
+or the ``name'' of the file referenced by the symbolic link named
+.Pa /libkver_osrelease
+are checked in that order for the
+.Nx
+release number the library should reports information for.
+.Sh EXAMPLES
+.Dl env LD_PRELOAD=/lib/libkver.so LIBKVER_OSRELEASE=1.5 uname -r
+.Pp
+.Dl ln -s 1.6.2 /libkver_osrelease
+.Dl env LD_PRELOAD=/lib/libkver.so uname -r
+.Sh SEE ALSO
+.Xr ld.so 1 ,
+.Xr sysctl 3 ,
+.Xr uname 3
+.Sh AUTHORS
+.An Stoned Elipot Aq seb%netbsd.org@localhost
diff -r cb0979c62083 -r 12beace2dbc6 pkgtools/libkver/files/lib/kver.c
--- a/pkgtools/libkver/files/lib/kver.c Sat Dec 13 17:21:00 2003 +0000
+++ b/pkgtools/libkver/files/lib/kver.c Sat Dec 13 17:45:59 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kver.c,v 1.3 2003/10/27 20:31:42 seb Exp $     */
+/*     $NetBSD: kver.c,v 1.4 2003/12/13 17:45:59 seb Exp $     */
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -7,40 +7,36 @@
 #include <assert.h>
 #include <errno.h>
 #include <string.h>
-
-#define KVER_VERSION_FMT "NetBSD %.6s (GENERIC) #0: %.40s  root@localhost:/sys/arch/%.20s/compile/GENERIC"
+#include <err.h>
+#include <stdlib.h>
+#include <ctype.h>
 
-/* _KVER_DATE is not really the real release date but the
-   date of src/sys/sys/param.h's revision tagged for the release */
+#define KVER_VERSION_FMT "NetBSD %s (LIBKVER) #0: Tue Jan 19 00:00:00 UTC 2038 root@localhost:/sys/arch/%s/compile/LIBKVER"
 
-#if   _KVER_OSREVISION == 105000000
-#  define _KVER_OSRELEASE "1.5"
-#  define _KVER_DATE "Wed Dec  6 00:00:00 UTC 2000"
-#elif _KVER_OSREVISION == 105000100
-#  define _KVER_OSRELEASE "1.5.1"
-#  define _KVER_DATE "Wed Jul 11 00:00:00 UTC 2001"
-#elif _KVER_OSREVISION == 105000200
-#  define _KVER_OSRELEASE "1.5.2"
-#  define _KVER_DATE "Thu Sep 13 00:00:00 UTC 2001"
-#elif _KVER_OSREVISION == 105000300
-#  define _KVER_OSRELEASE "1.5.3"
-#  define _KVER_DATE "Mon Jul 22 00:00:00 UTC 2002"
-#elif _KVER_OSREVISION == 106000000
-#  define _KVER_OSRELEASE "1.6"
-#  define _KVER_DATE "Sat Sep 14 00:00:00 UTC 2002"
-#elif _KVER_OSREVISION == 106000100
-#  define _KVER_OSRELEASE "1.6.1";
-#  define _KVER_DATE "Mon Apr 21 00:00:00 UTC 2003"
-#elif _KVER_OSREVISION == 106000200
-#  define _KVER_OSRELEASE "1.6.2";
-#  define _KVER_DATE "Tue Jan 19 00:00:00 UTC 2038"
-#else
-#error You must define _KVER_OSREVISION
+#define KVER_NOT_INITIALIZED_OSRELEASE -2
+#define KVER_INVALID_OSRELEASE -1
+
+#ifndef PATH_LIBKVER_OSRELEASE
+#define PATH_LIBKVER_OSRELEASE "/libkver_osrelease"
+#endif
+#ifndef VAR_LIBKVER_OSRELEASE
+#define VAR_LIBKVER_OSRELEASE "LIBKVER_OSRELEASE"
 #endif
 
-static char *kver_osrelease = _KVER_OSRELEASE;
-static char *kver_date = _KVER_DATE;
-static int kver_osrevision = _KVER_OSREVISION;
+static struct kver {
+       char osrelease[_SYS_NMLN];
+       int osrevision;
+       char version[_SYS_NMLN];
+}    kver = {
+       "", KVER_NOT_INITIALIZED_OSRELEASE, ""
+};



Home | Main Index | Thread Index | Old Index