pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/libkver Add the ability for libkver to overri...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b9b03d5a820f
branches:  trunk
changeset: 610612:b9b03d5a820f
user:      apb <apb%pkgsrc.org@localhost>
date:      Wed Oct 31 14:41:55 2012 +0000

description:
Add the ability for libkver to override all four of ostype, osrelease,
machine, and machine_arch.  Add a helper script to simplify use of
libkver.  Set VERSION=0.7.

An earlier version of this change was reviewed by seb%NetBSD.org@localhost.

diffstat:

 pkgtools/libkver/Makefile            |   13 +-
 pkgtools/libkver/PLIST               |    5 +-
 pkgtools/libkver/files/Makefile      |    4 +-
 pkgtools/libkver/files/kver/Makefile |    4 +
 pkgtools/libkver/files/kver/kver.8   |  145 ++++++++++++++++++++
 pkgtools/libkver/files/kver/kver.sh  |  247 +++++++++++++++++++++++++++++++++++
 pkgtools/libkver/files/lib/kver.3    |  142 +++++++++++++++++--
 pkgtools/libkver/files/lib/kver.c    |  190 ++++++++++++++++++++++----
 8 files changed, 697 insertions(+), 53 deletions(-)

diffs (truncated from 923 to 300 lines):

diff -r eae8cb001b90 -r b9b03d5a820f pkgtools/libkver/Makefile
--- a/pkgtools/libkver/Makefile Wed Oct 31 13:09:48 2012 +0000
+++ b/pkgtools/libkver/Makefile Wed Oct 31 14:41:55 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.31 2012/09/11 23:19:35 asau Exp $
+# $NetBSD: Makefile,v 1.32 2012/10/31 14:41:55 apb Exp $
 
 DISTNAME=              libkver-${VERSION}
 CATEGORIES=            pkgtools
@@ -18,7 +18,7 @@
 NO_PKGTOOLS_REQD_CHECK=        yes
 USE_BSD_MAKEFILE=      yes
 
-VERSION=               0.6
+VERSION=               0.7
 
 ONLY_FOR_PLATFORM=     NetBSD-*-*
 
@@ -34,7 +34,14 @@
 FILES_SUBST+=          HAS_SYSCTL=false
 .endif
 
-INSTALLATION_DIRS+=    lib man/man3 man/cat3
+SUBST_CLASSES+=         paths
+SUBST_FILES.paths=      kver/kver.sh kver/kver.8 lib/kver.3
+SUBST_SED.paths+=       -e 's,@PREFIX@,${PREFIX},g'
+SUBST_SED.paths+=       -e 's,@SH@,${SH},g'
+SUBST_STAGE.paths=      post-patch
+
+INSTALLATION_DIRS+=    sbin ${PKGMANDIR}/man8 ${PKGMANDIR}/cat8
+INSTALLATION_DIRS+=    lib ${PKGMANDIR}/man3 ${PKGMANDIR}/cat3
 .if empty(LDD_SYSCTL:M*libc*)
 INSTALLATION_DIRS+=    sbin
 .endif
diff -r eae8cb001b90 -r b9b03d5a820f pkgtools/libkver/PLIST
--- a/pkgtools/libkver/PLIST    Wed Oct 31 13:09:48 2012 +0000
+++ b/pkgtools/libkver/PLIST    Wed Oct 31 14:41:55 2012 +0000
@@ -1,8 +1,11 @@
-@comment $NetBSD: PLIST,v 1.3 2008/04/12 22:43:09 jlam Exp $
+@comment $NetBSD: PLIST,v 1.4 2012/10/31 14:41:55 apb Exp $
 lib/libkver.a
 lib/libkver.so
 lib/libkver.so.1
 lib/libkver.so.1.0
 man/cat3/kver.0
+man/cat8/kver.0
 man/man3/kver.3
+man/man8/kver.8
+sbin/kver
 ${PLIST.sysctl}sbin/sysctl
diff -r eae8cb001b90 -r b9b03d5a820f pkgtools/libkver/files/Makefile
--- a/pkgtools/libkver/files/Makefile   Wed Oct 31 13:09:48 2012 +0000
+++ b/pkgtools/libkver/files/Makefile   Wed Oct 31 14:41:55 2012 +0000
@@ -1,6 +1,6 @@
-#      $NetBSD: Makefile,v 1.3 2003/12/13 17:45:59 seb Exp $
+#      $NetBSD: Makefile,v 1.4 2012/10/31 14:41:55 apb Exp $
 
-SUBDIR=                lib
+SUBDIR=                kver lib
 
 .ifndef(LDD_SYSCTL)
 LDD_SYSCTL!=   ldd /sbin/sysctl 2>&1
diff -r eae8cb001b90 -r b9b03d5a820f pkgtools/libkver/files/kver/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libkver/files/kver/Makefile      Wed Oct 31 14:41:55 2012 +0000
@@ -0,0 +1,4 @@
+MAN=   kver.8
+SCRIPTS= kver.sh
+
+.include <bsd.prog.mk>
diff -r eae8cb001b90 -r b9b03d5a820f pkgtools/libkver/files/kver/kver.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libkver/files/kver/kver.8        Wed Oct 31 14:41:55 2012 +0000
@@ -0,0 +1,145 @@
+.\" $NetBSD: kver.8,v 1.1 2012/10/31 14:41:55 apb Exp $
+.\"
+.Dd October 31, 2012
+.Os
+.Dt KVER 8
+.Sh NAME
+.Nm kver
+.Nd run a command with overriden system version
+.Sh SYNOPSIS
+.Nm
+.Op Fl s Ar ostype
+.Op Fl r Ar osrelease
+.Op Fl m Ar machine
+.Op Fl p Ar machine_arch
+.Ar command
+.Op Ar argument ...
+.Sh DESCRIPTION
+The
+.Nm
+utility
+provides a simple wrapper around the
+.Xr kver 3
+library.
+It converts its options to environment variables understood by
+.Xr kver 3 ,
+sets the
+.Ev LD_PRELOAD
+environment variable to ensure that the
+.Xr kver 3
+library
+.Pq Pa @PREFIX@/lib/libkver.so
+is loaded,
+and executes the specified
+.Ar command
+with the specified
+.Ar argument Ns s .
+.Pp
+The following options are accepted:
+.Bl -tag -offset indent
+.It Fl s Ar ostype
+The operating system type, e.g.
+.Qq Nx .
+Sets the
+.Ev LIBKVER_OSTYPE
+environment variable.
+.It Fl r Ar osrelease
+The operating system release, e.g.
+.Qq "6.0_STABLE" .
+Sets the
+.Ev LIBKVER_OSRELEASE
+environment variable.
+.It Fl m Ar machine
+The operating hardware platform, e.g.
+.Dq "amd64" .
+Sets the
+.Ev LIBKVER_MACHINE
+environment variable.
+.It Fl p Ar machine_arch
+The machine processor architecture, e.g.
+.Dq "x86_64" .
+Sets the
+.Ev LIBKVER_MACHINE_ARCH
+environment variable.
+.El
+.Pp
+If the
+.Fl m Ar machine
+option is specified and the
+.Fl p Ar machine_arch
+option is not specified, then
+.Nm
+checks that
+.Ar machine
+is valid, and attempts to set an appropriate value for
+.Va machine_arch ;
+for example,
+.Dq "-m macppc"
+implies
+.Dq "-p powerpc" .
+Some aliases for
+.Ar machine Ns / Ns Ar machine_arch
+pairs are also supported; for example,
+.Dq "-m macppc64"
+is shorthand for
+.Dq "-m macppc -p powerpc64" .
+The way
+.Nm
+handles a
+.Ar machine
+name without a
+.Ar machine_arch
+name is intended to be identical to the way the
+.Pa build.sh
+script in the
+.Nx
+source tree handles the same situation.
+To pass arbitrary values of
+.Fl m Ar machine
+without any validation, you must also specify
+.Fl p Ar machine_arch .
+.Sh EXAMPLES
+.Bl -tag
+.It Li "kver -r 1.5 uname -r"
+Run the
+.Ql "uname -r"
+command with
+.Va osrelease
+set to
+.Ql 1.5 .
+.It Li "kver -m i386 chroot ."
+Run the
+.Ql "chroot ."
+command with
+.Va machine
+set to
+.Ql i386 
+and with
+.Va machine_arch
+set to
+.Ql i386
+(which is the default
+.Va machine_arch
+for that
+.Va machine ) .
+.It Li "kver -m evbmips sysctl hw.machine_arch"
+Error, because there is no default
+.Va machine_arch
+corresponding to
+.Dq "-m evbmips" .
+.It Li "kver -m evbmips -p mipseb sysctl hw.machine_arch"
+Run the
+.Ql "sysctl hw.machine_arch"
+command with
+.Va machine
+set to
+.Ql evbmips
+and
+.Va machine_arch
+set to
+.Ql mipseb .
+.El
+.Sh SEE ALSO
+.Xr kver 3
+.Sh AUTHORS
+.An Alan Barrett Aq apb%NetBSD.org@localhost
diff -r eae8cb001b90 -r b9b03d5a820f pkgtools/libkver/files/kver/kver.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/libkver/files/kver/kver.sh       Wed Oct 31 14:41:55 2012 +0000
@@ -0,0 +1,247 @@
+#!@SH@
+
+LIBKVER='@PREFIX@/lib/libkver.so'
+EX_USAGE=64
+nl='
+'
+tab='  '
+
+usage()
+{
+       cat <<ENDUSAGE;
+usage: $0 [-s ostype] [-r osrelease] [-m machine] [-p arch] command [args]
+ENDUSAGE
+}
+
+bomb()
+{
+       echo >&2 "$0: $*"
+       exit $EX_USAGE
+}
+
+# begin code copied from build.sh {{{
+
+# valid_MACHINE_ARCH -- A multi-line string, listing all valid
+# MACHINE/MACHINE_ARCH pairs.
+#
+# Each line contains a MACHINE and MACHINE_ARCH value, an optional ALIAS
+# which may be used to refer to the MACHINE/MACHINE_ARCH pair, and an
+# optional DEFAULT or NO_DEFAULT keyword.
+#
+# When a MACHINE corresponds to multiple possible values of
+# MACHINE_ARCH, then this table should list all allowed combinations.
+# If the MACHINE is associated with a default MACHINE_ARCH (to be
+# used when the user specifies the MACHINE but fails to specify the
+# MACHINE_ARCH), then one of the lines should have the "DEFAULT"
+# keyword.  If there is no default MACHINE_ARCH for a particular
+# MACHINE, then there should be a line with the "NO_DEFAULT" keyword,
+# and with a blank MACHINE_ARCH.
+#
+valid_MACHINE_ARCH='
+MACHINE=acorn26                MACHINE_ARCH=arm
+MACHINE=acorn32                MACHINE_ARCH=arm
+MACHINE=algor          MACHINE_ARCH=mips64el   ALIAS=algor64
+MACHINE=algor          MACHINE_ARCH=mipsel     DEFAULT
+MACHINE=alpha          MACHINE_ARCH=alpha
+MACHINE=amd64          MACHINE_ARCH=x86_64
+MACHINE=amiga          MACHINE_ARCH=m68k
+MACHINE=amigappc       MACHINE_ARCH=powerpc
+MACHINE=arc            MACHINE_ARCH=mips64el   ALIAS=arc64
+MACHINE=arc            MACHINE_ARCH=mipsel     DEFAULT
+MACHINE=atari          MACHINE_ARCH=m68k
+MACHINE=bebox          MACHINE_ARCH=powerpc
+MACHINE=cats           MACHINE_ARCH=arm        DEFAULT
+MACHINE=cats           MACHINE_ARCH=earm
+MACHINE=cesfic         MACHINE_ARCH=m68k
+MACHINE=cobalt         MACHINE_ARCH=mips64el   ALIAS=cobalt64
+MACHINE=cobalt         MACHINE_ARCH=mipsel     DEFAULT
+MACHINE=dreamcast      MACHINE_ARCH=sh3el
+MACHINE=emips          MACHINE_ARCH=mipseb
+MACHINE=evbarm         MACHINE_ARCH=arm        ALIAS=evbarm-el DEFAULT
+MACHINE=evbarm         MACHINE_ARCH=armeb      ALIAS=evbarm-eb
+MACHINE=evbarm         MACHINE_ARCH=earm       ALIAS=evbearm-el
+MACHINE=evbarm         MACHINE_ARCH=earmeb     ALIAS=evbearm-eb
+MACHINE=evbmips                MACHINE_ARCH=           NO_DEFAULT
+MACHINE=evbmips                MACHINE_ARCH=mips64eb   ALIAS=evbmips64-eb
+MACHINE=evbmips                MACHINE_ARCH=mips64el   ALIAS=evbmips64-el
+MACHINE=evbmips                MACHINE_ARCH=mipseb     ALIAS=evbmips-eb
+MACHINE=evbmips                MACHINE_ARCH=mipsel     ALIAS=evbmips-el
+MACHINE=evbppc         MACHINE_ARCH=powerpc    DEFAULT
+MACHINE=evbppc         MACHINE_ARCH=powerpc64  ALIAS=evbppc64
+MACHINE=evbsh3         MACHINE_ARCH=           NO_DEFAULT
+MACHINE=evbsh3         MACHINE_ARCH=sh3eb      ALIAS=evbsh3-eb
+MACHINE=evbsh3         MACHINE_ARCH=sh3el      ALIAS=evbsh3-el
+MACHINE=ews4800mips    MACHINE_ARCH=mipseb
+MACHINE=hp300          MACHINE_ARCH=m68k
+MACHINE=hp700          MACHINE_ARCH=hppa
+MACHINE=hpcarm         MACHINE_ARCH=arm



Home | Main Index | Thread Index | Old Index