From 99871d087ece629865bb654d7a184139f4c2fe27 Mon Sep 17 00:00:00 2001 From: grant Date: Tue, 13 Jan 2004 08:30:34 +0000 Subject: [PATCH] use ${MACHINE_ARCH} instead of what uname() puts into utsname.machine. the former represents the CPU architecture, which is what is recorded in binary packages. also allow the OS name to be overridden, as pkgsrc doesn't always use the value of utsname.sysname. bump version to 20030113. --- usr.sbin/pkg_install/add/Makefile | 4 +++- usr.sbin/pkg_install/add/perform.c | 36 +++++++++++++----------------- usr.sbin/pkg_install/lib/lib.h | 6 ++++- usr.sbin/pkg_install/lib/version.h | 4 ++-- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile index 0430f60bf5e6..09850ba9fdf2 100644 --- a/usr.sbin/pkg_install/add/Makefile +++ b/usr.sbin/pkg_install/add/Makefile @@ -1,7 +1,9 @@ -# $NetBSD: Makefile,v 1.5 2001/09/25 10:28:16 agc Exp $ +# $NetBSD: Makefile,v 1.6 2004/01/13 08:30:34 grant Exp $ # Original from FreeBSD, no rcs id. PROG= pkg_add SRCS= main.c perform.c futil.c extract.c verify.c +CPPFLAGS+= -DMACHINE_ARCH=\"${MACHINE_ARCH}\" + .include diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index 9538c9ed0644..7b44e4b6da42 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -1,11 +1,11 @@ -/* $NetBSD: perform.c,v 1.92 2004/01/04 01:47:35 hubertf Exp $ */ +/* $NetBSD: perform.c,v 1.93 2004/01/13 08:30:34 grant Exp $ */ #include #ifndef lint #if 0 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp"; #else -__RCSID("$NetBSD: perform.c,v 1.92 2004/01/04 01:47:35 hubertf Exp $"); +__RCSID("$NetBSD: perform.c,v 1.93 2004/01/13 08:30:34 grant Exp $"); #endif #endif @@ -272,23 +272,23 @@ pkg_do(const char *pkg) goto bomb; } - if (uname(&host_uname) == 0) { + if (uname(&host_uname) < 0) { + warnx("uname() failed."); + if (!Force) { + warnx("aborting."); + goto bomb; + } + } else { int osbad = 0; - /* handle Darwin's uname(3) on powerpc writing - * "Power Macintosh" in struct uname.machine. - */ - if (strcmp(host_uname.machine, "Power Macintosh") == 0) - strcpy(host_uname.machine, "powerpc"); /* it fits */ - /* If either the OS or arch are different, bomb */ - if (strcmp(host_uname.sysname, buildinfo[BI_OPSYS]) != 0 || - strcmp(host_uname.machine, buildinfo[BI_MACHINE_ARCH]) != 0) + if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) != 0 || + strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) != 0) osbad = 2; /* If OS and arch are the same, warn if version differs */ - if (strcmp(host_uname.sysname, buildinfo[BI_OPSYS]) == 0 && - strcmp(host_uname.machine, buildinfo[BI_MACHINE_ARCH]) == 0) { + if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) == 0 && + strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) == 0) { if (strcmp(host_uname.release, buildinfo[BI_OS_VERSION]) != 0) osbad = 1; } else @@ -300,20 +300,14 @@ pkg_do(const char *pkg) buildinfo[BI_OPSYS], buildinfo[BI_MACHINE_ARCH], buildinfo[BI_OS_VERSION], - host_uname.sysname, - host_uname.machine, + OPSYS_NAME, + MACHINE_ARCH, host_uname.release); } if (!Force && (osbad >= 2)) { warnx("aborting."); goto bomb; } - } else { - warnx("uname() failed."); - if (!Force) { - warnx("aborting."); - goto bomb; - } } /* diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index dfe8ec436fd8..e6ec8a0cc949 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.65 2003/12/20 03:31:56 grant Exp $ */ +/* $NetBSD: lib.h,v 1.66 2004/01/13 08:30:34 grant Exp $ */ /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ @@ -52,6 +52,10 @@ #define FALSE (0) #endif +#ifndef OPSYS_NAME +#define OPSYS_NAME "NetBSD" +#endif + /* Usually "rm", but often "echo" during debugging! */ #define REMOVE_CMD "rm" diff --git a/usr.sbin/pkg_install/lib/version.h b/usr.sbin/pkg_install/lib/version.h index 94bf2e979f6c..fec5d6a62236 100644 --- a/usr.sbin/pkg_install/lib/version.h +++ b/usr.sbin/pkg_install/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.41 2004/01/06 15:51:44 hubertf Exp $ */ +/* $NetBSD: version.h,v 1.42 2004/01/13 08:30:34 grant Exp $ */ /* * Copyright (c) 2001 Thomas Klausner. All rights reserved. @@ -33,6 +33,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION "20040106" +#define PKGTOOLS_VERSION "20040113" #endif /* _INST_LIB_VERSION_H_ */