pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/pkg_install/files



Module Name:    pkgsrc
Committed By:   riastradh
Date:           Fri Jan 26 03:24:49 UTC 2024

Modified Files:
        pkgsrc/pkgtools/pkg_install/files/add: Makefile.in add.h main.c
            perform.c
        pkgsrc/pkgtools/pkg_install/files/lib: version.h
Added Files:
        pkgsrc/pkgtools/pkg_install/files/add: parse_cross.c

Log Message:
pkg_install-20240125: Extend `-m' syntax to allow OPSYS too.

- If there's no slash `/', take it all as ${MACHINE_ARCH}.

- If there is a slash, then split it by `/' and ` ' into:

        ${OPSYS}/${MACHINE_ARCH} ${OPSYS_VERSION}

  For example:

        NetBSD/aarch64 10.0

All the variables are restricted to lie in a safe set [a-zA-Z0-9._-],
so the notation can be extended later.

No change to existing syntax (no MACHINE_ARCH has `/' in it, or
anything outside the safe set), and `-m' is generally only used with
cross builds anyway, so this shouldn't break existing cross builds
and should have no impact on native builds.

Proposed on tech-pkg:
https://mail-index.netbsd.org/tech-pkg/2024/01/13/msg028825.html


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 pkgsrc/pkgtools/pkg_install/files/add/Makefile.in
cvs rdiff -u -r1.19 -r1.20 pkgsrc/pkgtools/pkg_install/files/add/add.h
cvs rdiff -u -r1.32 -r1.33 pkgsrc/pkgtools/pkg_install/files/add/main.c
cvs rdiff -u -r0 -r1.1 pkgsrc/pkgtools/pkg_install/files/add/parse_cross.c
cvs rdiff -u -r1.121 -r1.122 pkgsrc/pkgtools/pkg_install/files/add/perform.c
cvs rdiff -u -r1.189 -r1.190 pkgsrc/pkgtools/pkg_install/files/lib/version.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkg_install/files/add/Makefile.in
diff -u pkgsrc/pkgtools/pkg_install/files/add/Makefile.in:1.34 pkgsrc/pkgtools/pkg_install/files/add/Makefile.in:1.35
--- pkgsrc/pkgtools/pkg_install/files/add/Makefile.in:1.34      Wed Oct 28 16:52:43 2020
+++ pkgsrc/pkgtools/pkg_install/files/add/Makefile.in   Fri Jan 26 03:24:49 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.in,v 1.34 2020/10/28 16:52:43 maya Exp $
+# $NetBSD: Makefile.in,v 1.35 2024/01/26 03:24:49 riastradh Exp $
 
 srcdir=                @srcdir@
 
@@ -37,7 +37,7 @@ INSTALL=      @INSTALL@
 
 PROG=          pkg_add
 
-OBJS=  main.o perform.o
+OBJS=  main.o parse_cross.o perform.o
 
 all: $(PROG)
 

Index: pkgsrc/pkgtools/pkg_install/files/add/add.h
diff -u pkgsrc/pkgtools/pkg_install/files/add/add.h:1.19 pkgsrc/pkgtools/pkg_install/files/add/add.h:1.20
--- pkgsrc/pkgtools/pkg_install/files/add/add.h:1.19    Tue Sep 14 22:26:18 2010
+++ pkgsrc/pkgtools/pkg_install/files/add/add.h Fri Jan 26 03:24:49 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: add.h,v 1.19 2010/09/14 22:26:18 gdt Exp $ */
+/* $NetBSD: add.h,v 1.20 2024/01/26 03:24:49 riastradh Exp $ */
 
 /* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp  */
 
@@ -27,6 +27,8 @@
 
 extern char *Destdir;
 extern char *OverrideMachine;
+extern char *OverrideOpsys;
+extern char *OverrideOSVersion;
 extern char *Prefix;
 extern char *View;
 extern char *Viewbase;
@@ -42,6 +44,8 @@ extern int ReplaceSame;
 extern Boolean ForceDepends;
 extern Boolean ForceDepending;
 
+void   parse_cross(const char *, char **, char **, char **);
+
 int     make_hierarchy(char *);
 void    apply_perms(char *, char **, int);
 

Index: pkgsrc/pkgtools/pkg_install/files/add/main.c
diff -u pkgsrc/pkgtools/pkg_install/files/add/main.c:1.32 pkgsrc/pkgtools/pkg_install/files/add/main.c:1.33
--- pkgsrc/pkgtools/pkg_install/files/add/main.c:1.32   Sun Dec 27 12:36:42 2015
+++ pkgsrc/pkgtools/pkg_install/files/add/main.c        Fri Jan 26 03:24:49 2024
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.32 2015/12/27 12:36:42 joerg Exp $  */
+/*     $NetBSD: main.c,v 1.33 2024/01/26 03:24:49 riastradh Exp $      */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -7,7 +7,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: main.c,v 1.32 2015/12/27 12:36:42 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.33 2024/01/26 03:24:49 riastradh Exp $");
 
 /*
  *
@@ -40,6 +40,8 @@ static char Options[] = "AC:DIK:P:RVfhm:
 
 char   *Destdir = NULL;
 char   *OverrideMachine = NULL;
+char   *OverrideOpsys = NULL;
+char   *OverrideOSVersion = NULL;
 char   *Prefix = NULL;
 Boolean NoInstall = FALSE;
 Boolean NoRecord = FALSE;
@@ -110,7 +112,8 @@ main(int argc, char **argv)
                        break;
 
                case 'm':
-                       OverrideMachine = optarg;
+                       parse_cross(optarg, &OverrideMachine, &OverrideOpsys,
+                           &OverrideOSVersion);
                        break;
 
                case 'n':

Index: pkgsrc/pkgtools/pkg_install/files/add/perform.c
diff -u pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.121 pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.122
--- pkgsrc/pkgtools/pkg_install/files/add/perform.c:1.121       Thu Oct 21 13:05:25 2021
+++ pkgsrc/pkgtools/pkg_install/files/add/perform.c     Fri Jan 26 03:24:49 2024
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.121 2021/10/21 13:05:25 jperkin Exp $    */
+/*     $NetBSD: perform.c,v 1.122 2024/01/26 03:24:49 riastradh Exp $  */
 #if HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -6,7 +6,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: perform.c,v 1.121 2021/10/21 13:05:25 jperkin Exp $");
+__RCSID("$NetBSD: perform.c,v 1.122 2024/01/26 03:24:49 riastradh Exp $");
 
 /*-
  * Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -893,19 +893,28 @@ check_platform(struct pkg_task *pkg)
 {
        struct utsname host_uname;
        const char *effective_arch;
+       const char *effective_opsys;
+       const char *effective_os_version;
        int fatal;
 
-       if (uname(&host_uname) < 0) {
-               if (Force) {
-                       warnx("uname() failed, continuing.");
-                       return 0;
-               } else {
-                       warnx("uname() failed, aborting.");
-                       return -1;
+        if (OverrideOpsys != NULL && OverrideOSVersion != NULL) {
+               effective_opsys = OverrideOpsys;
+               effective_os_version = OverrideOSVersion;
+       } else {
+               if (uname(&host_uname) < 0) {
+                       if (Force) {
+                               warnx("uname() failed, continuing.");
+                               return 0;
+                       } else {
+                               warnx("uname() failed, aborting.");
+                               return -1;
+                       }
                }
-       }
 
-       normalise_platform(&host_uname);
+               normalise_platform(&host_uname);
+               effective_opsys = OPSYS_NAME;
+               effective_os_version = host_uname.release;
+       }
 
        if (OverrideMachine != NULL)
                effective_arch = OverrideMachine;
@@ -913,14 +922,14 @@ check_platform(struct pkg_task *pkg)
                effective_arch = PKGSRC_MACHINE_ARCH;
 
        /* If either the OS or arch are different, bomb */
-       if (strcmp(OPSYS_NAME, pkg->buildinfo[BI_OPSYS]) ||
+       if (strcmp(effective_opsys, pkg->buildinfo[BI_OPSYS]) ||
            strcmp(effective_arch, pkg->buildinfo[BI_MACHINE_ARCH]) != 0)
                fatal = 1;
        else
                fatal = 0;
 
        if (fatal ||
-           compatible_platform(OPSYS_NAME, host_uname.release,
+           compatible_platform(effective_opsys, effective_os_version,
                                pkg->buildinfo[BI_OS_VERSION]) != 1) {
                warnx("Warning: package `%s' was built for a platform:",
                    pkg->pkgname);
@@ -928,9 +937,9 @@ check_platform(struct pkg_task *pkg)
                    pkg->buildinfo[BI_OPSYS],
                    pkg->buildinfo[BI_MACHINE_ARCH],
                    pkg->buildinfo[BI_OS_VERSION],
-                   OPSYS_NAME,
+                   effective_opsys,
                    effective_arch,
-                   host_uname.release);
+                   effective_os_version);
                if (!Force && fatal)
                        return -1;
        }

Index: pkgsrc/pkgtools/pkg_install/files/lib/version.h
diff -u pkgsrc/pkgtools/pkg_install/files/lib/version.h:1.189 pkgsrc/pkgtools/pkg_install/files/lib/version.h:1.190
--- pkgsrc/pkgtools/pkg_install/files/lib/version.h:1.189       Mon Nov 15 12:48:23 2021
+++ pkgsrc/pkgtools/pkg_install/files/lib/version.h     Fri Jan 26 03:24:49 2024
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.189 2021/11/15 12:48:23 jperkin Exp $    */
+/*     $NetBSD: version.h,v 1.190 2024/01/26 03:24:49 riastradh Exp $  */
 
 /*
  * Copyright (c) 2001 Thomas Klausner.  All rights reserved.
@@ -27,6 +27,6 @@
 #ifndef _INST_LIB_VERSION_H_
 #define _INST_LIB_VERSION_H_
 
-#define PKGTOOLS_VERSION 20211115
+#define PKGTOOLS_VERSION 20240125
 
 #endif /* _INST_LIB_VERSION_H_ */

Added files:

Index: pkgsrc/pkgtools/pkg_install/files/add/parse_cross.c
diff -u /dev/null pkgsrc/pkgtools/pkg_install/files/add/parse_cross.c:1.1
--- /dev/null   Fri Jan 26 03:24:49 2024
+++ pkgsrc/pkgtools/pkg_install/files/add/parse_cross.c Fri Jan 26 03:24:49 2024
@@ -0,0 +1,97 @@
+/*     $NetBSD: parse_cross.c,v 1.1 2024/01/26 03:24:49 riastradh Exp $        */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <nbcompat.h>
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+__RCSID("$NetBSD: parse_cross.c,v 1.1 2024/01/26 03:24:49 riastradh Exp $");
+
+#include "lib.h"
+#include "add.h"
+
+/*
+ * ${OPSYS}/${MACHINE_ARCH} ${OS_VERSION}
+ *
+ * or just
+ *
+ * ${MACHINE_ARCH}
+ */
+void
+parse_cross(const char *text, char **machine_arch, char **opsys,
+    char **os_version)
+{
+       static const char safeset[] = /* XXX */
+           "abcdefghijklmnopqrstuvwxyz"
+           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+           "0123456789"
+           "-._";
+       char *copy = xstrdup(text);
+       char *p = copy, *q, *r;
+
+       /*
+        * If there's no /, treat it as a single MACHINE_ARCH.
+        */
+       if (*(q = strchr(p, '/')) == '\0') {
+               *machine_arch = copy;
+               *opsys = NULL;
+               *os_version = NULL;
+       } else {
+               /*
+                * NUL-terminate at the slash so p := text[0..slash)
+                * is the OPSYS.
+                */
+               *q++ = '\0';
+
+               /*
+                * If there's no SPC, fail.
+                */
+               if (*(r = strchr(q, ' ')) == '\0') {
+                       goto fail;
+               }
+
+               /*
+                * NUL-terminate at the space so
+                *
+                *      q := text(slash..space)
+                *
+                * is the MACHINE_ARCH.
+                */
+               *r++ = '\0';
+
+               /*
+                * The rest is already NUL-terminated, so
+                *
+                *      r := text(space..NUL)
+                *
+                * is the OS_VERSION.
+                */
+               *opsys = p;
+               *machine_arch = q;
+               *os_version = r;
+       }
+
+       /*
+        * Verify that MACHINE_ARCH, and, if specified, OPSYS and
+        * OS_VERSION lie within the safe set, so we can reserve large
+        * amounts of the space of inputs for additional syntax.
+        * Ideally we would impose more constraints here with a
+        * regular expression to restrict the space even more, but
+        * this'll do for now.
+        */
+       if ((*machine_arch)[strspn(*machine_arch, safeset)] != '\0') {
+               goto fail;
+       }
+       if (*opsys != NULL && (*opsys)[strspn(*opsys, safeset)] != '\0') {
+               goto fail;
+       }
+       if (*os_version != NULL &&
+           (*os_version)[strspn(*os_version, safeset)] != '\0') {
+               goto fail;
+       }
+       return;
+
+fail:  errx(1, "Invalid -m argument: ${OPSYS}/${MACHINE_ARCH} ${OS_VERSION}");
+}



Home | Main Index | Thread Index | Old Index