pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkg_install/files pkg_install-20120128:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/fef25868651a
branches:  trunk
changeset: 598655:fef25868651a
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sat Jan 28 12:33:04 2012 +0000

description:
pkg_install-20120128:
- Explicitly stat(2) if mkdir failed. errno detection doesn't work e.g.
on Solaris (PR 45289)
- Provide a stable order for package names that only differe in the base
name, not the version number.

diffstat:

 pkgtools/pkg_install/files/add/perform.c  |  33 ++++++++++++++++++++----------
 pkgtools/pkg_install/files/lib/opattern.c |   8 +++++-
 pkgtools/pkg_install/files/lib/version.h  |   4 +-
 3 files changed, 30 insertions(+), 15 deletions(-)

diffs (130 lines):

diff -r ae527edca1d7 -r fef25868651a pkgtools/pkg_install/files/add/perform.c
--- a/pkgtools/pkg_install/files/add/perform.c  Sat Jan 28 12:14:08 2012 +0000
+++ b/pkgtools/pkg_install/files/add/perform.c  Sat Jan 28 12:33:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: perform.c,v 1.100 2011/08/05 07:04:28 agc Exp $        */
+/*     $NetBSD: perform.c,v 1.101 2012/01/28 12:33:04 joerg 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.100 2011/08/05 07:04:28 agc Exp $");
+__RCSID("$NetBSD: perform.c,v 1.101 2012/01/28 12:33:04 joerg Exp $");
 
 /*-
  * Copyright (c) 2003 Grant Beattie <grant%NetBSD.org@localhost>
@@ -42,6 +42,7 @@
  */
 
 #include <sys/utsname.h>
+#include <sys/stat.h>
 #if HAVE_ERR_H
 #include <err.h>
 #endif
@@ -169,16 +170,21 @@
 mkdir_p(const char *path)
 {
        char *p, *cur_end;
-       int done;
+       int done, saved_errno;
+       struct stat sb;
 
        /*
         * Handle the easy case of direct success or
         * pre-existing directory first.
         */
-       if (mkdir(path, 0777) == 0 || errno == EEXIST)
+       if (mkdir(path, 0777) == 0)
                return 0;
-       if (errno != ENOENT)
+       if (stat(path, &sb) == 0) {
+               if (S_ISDIR(sb.st_mode))
+                       return 0;
+               errno = ENOTDIR;
                return -1;
+       }
 
        cur_end = p = xstrdup(path);
 
@@ -198,21 +204,26 @@
                done = (*cur_end == '\0');
                *cur_end = '\0';
 
-               /*
-                * ENOENT can only happen if something else races us,
-                * in which case we should better give up.
-                */
-               if (mkdir(p, 0777) == -1 && errno != EEXIST) {
+               if (mkdir(p, 0777) == -1) {
+                       saved_errno = errno;
+                       if (stat(path, &sb) == 0) {
+                               if (S_ISDIR(sb.st_mode))
+                                       goto pass;
+                               errno = ENOTDIR;
+                       } else {
+                               errno = saved_errno;
+                       }
                        free(p);
                        return -1;
                }
+pass:
                if (done)
                        break;
                *cur_end = '/';
        }
 
        free(p);
-       return 0;       
+       return 0;
 }
 
 /*
diff -r ae527edca1d7 -r fef25868651a pkgtools/pkg_install/files/lib/opattern.c
--- a/pkgtools/pkg_install/files/lib/opattern.c Sat Jan 28 12:14:08 2012 +0000
+++ b/pkgtools/pkg_install/files/lib/opattern.c Sat Jan 28 12:33:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opattern.c,v 1.5 2009/02/02 12:35:01 joerg Exp $       */
+/*     $NetBSD: opattern.c,v 1.6 2012/01/28 12:33:05 joerg Exp $       */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -7,7 +7,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: opattern.c,v 1.5 2009/02/02 12:35:01 joerg Exp $");
+__RCSID("$NetBSD: opattern.c,v 1.6 2012/01/28 12:33:05 joerg Exp $");
 
 /*
  * FreeBSD install - a package for the installation and maintainance
@@ -204,6 +204,10 @@
 
        if (dewey_cmp(first_version + 1, DEWEY_GT, second_version + 1))
                return 1;
+       else if (dewey_cmp(first_version + 1, DEWEY_LT, second_version + 1))
+               return 2;
+       else if (strcmp(first_pkg, second_pkg) < 0)
+               return 1;
        else
                return 2;
 }
diff -r ae527edca1d7 -r fef25868651a pkgtools/pkg_install/files/lib/version.h
--- a/pkgtools/pkg_install/files/lib/version.h  Sat Jan 28 12:14:08 2012 +0000
+++ b/pkgtools/pkg_install/files/lib/version.h  Sat Jan 28 12:33:04 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: version.h,v 1.162 2011/08/05 07:04:28 agc Exp $        */
+/*     $NetBSD: version.h,v 1.163 2012/01/28 12:33:05 joerg 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 20110805
+#define PKGTOOLS_VERSION 20120128
 
 #endif /* _INST_LIB_VERSION_H_ */



Home | Main Index | Thread Index | Old Index