tech-pkg archive

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

Re: Making it easier to get and use pkgsrc



On Sat, Dec 11, 2010 at 10:56:11PM +0100, Jean-Yves Migeon wrote:
> - suppress warning when pkg_add'ing packages where build and target
> system have different minor revisions (e.g. NetBSD-5.0.2 vs
> NetBSD-5.1.RC4, for example)

To set a good example of coding vs. talking ;) I've improved the
version check so pkg_add doesn't warn about adding packages from
nearly the same opsys version.

In particular, this currently accepts (on NetBSD) any of foo_ALPHA*,
foo_BETA*, foo_RC*, foo_STABLE*, foo_PATCH* the same as foo.
Support for more platforms should be easy to add.

I'm not so sure about accepting 5.0 vs. 5.1, as you suggest above, so
I left that out for now.
 Thomas
Index: files/add/perform.c
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
retrieving revision 1.98
diff -u -r1.98 perform.c
--- files/add/perform.c 14 Sep 2010 22:26:18 -0000      1.98
+++ files/add/perform.c 12 Dec 2010 01:51:26 -0000
@@ -13,6 +13,7 @@
  * Copyright (c) 2005 Dieter Baron <dillo%NetBSD.org@localhost>
  * Copyright (c) 2007 Roland Illig <rillig%NetBSD.org@localhost>
  * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>
+ * Copyright (c) 2010 Thomas Klausner <wiz%NetBSD.org@localhost>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -128,6 +129,43 @@
 static int pkg_do(const char *, int, int);
 
 static int
+end_of_version(const char *opsys, const char *version_end)
+{
+    if (*version_end == '\0')
+       return 1;
+
+    if (strcmp(opsys, "NetBSD") == 0) {
+       if (strncmp(version_end, "_ALPHA", 6) == 0
+           || strncmp(version_end, "_BETA", 5) == 0
+           || strncmp(version_end, "_RC", 3) == 0
+           || strncmp(version_end, "_STABLE", 7) == 0
+           || strncmp(version_end, "_PATCH", 6) == 0)
+           return 1;
+    }
+
+    return 0;
+}
+
+static int
+compatible_platform(const char *opsys, const char *host, const char *package)
+{
+    int i = 0;
+
+    /* returns 1 if host and package operating system match */
+    if (strcmp(host, package) == 0)
+       return 1;
+
+    /* find offset of first difference */
+    for (i=0; (host[i] != '\0') && (host[i] == package[i]);)
+       i++;
+
+    if (end_of_version(opsys, host+i) && end_of_version(opsys, package+i))
+       return 1;
+
+    return 0;
+}
+
+static int
 mkdir_p(const char *path)
 {
        char *p, *cur_end;
@@ -869,7 +907,8 @@
                fatal = 0;
 
        if (fatal ||
-           strcmp(host_uname.release, pkg->buildinfo[BI_OS_VERSION]) != 0) {
+           compatible_platform(OPSYS_NAME, host_uname.release,
+                               pkg->buildinfo[BI_OS_VERSION]) != 1) {
                warnx("Warning: package `%s' was built for a platform:",
                    pkg->pkgname);
                warnx("%s/%s %s (pkg) vs. %s/%s %s (this host)",
Index: files/lib/version.h
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/lib/version.h,v
retrieving revision 1.159
diff -u -r1.159 version.h
--- files/lib/version.h 22 Nov 2010 09:00:13 -0000      1.159
+++ files/lib/version.h 12 Dec 2010 01:51:26 -0000
@@ -27,6 +27,6 @@
 #ifndef _INST_LIB_VERSION_H_
 #define _INST_LIB_VERSION_H_
 
-#define PKGTOOLS_VERSION 20101122
+#define PKGTOOLS_VERSION 20101212
 
 #endif /* _INST_LIB_VERSION_H_ */


Home | Main Index | Thread Index | Old Index