summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2012-01-28 12:33:04 +0000
committerjoerg <joerg@pkgsrc.org>2012-01-28 12:33:04 +0000
commit45b09d2281018e867b106a4c0e14eacbbb59e12c (patch)
tree5ebc22766e4028d3f501a384d20960228b538d89 /pkgtools
parentab21f9829f084e6753a2d84ec8f929533f367a33 (diff)
downloadpkgsrc-45b09d2281018e867b106a4c0e14eacbbb59e12c.tar.gz
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 (limited to 'pkgtools')
-rw-r--r--pkgtools/pkg_install/files/add/perform.c33
-rw-r--r--pkgtools/pkg_install/files/lib/opattern.c8
-rw-r--r--pkgtools/pkg_install/files/lib/version.h4
3 files changed, 30 insertions, 15 deletions
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c
index 3be2f04f8b0..0c13ab02491 100644
--- a/pkgtools/pkg_install/files/add/perform.c
+++ b/pkgtools/pkg_install/files/add/perform.c
@@ -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>
@@ -42,6 +42,7 @@ __RCSID("$NetBSD: perform.c,v 1.100 2011/08/05 07:04:28 agc Exp $");
*/
#include <sys/utsname.h>
+#include <sys/stat.h>
#if HAVE_ERR_H
#include <err.h>
#endif
@@ -169,16 +170,21 @@ static int
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 @@ mkdir_p(const char *path)
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 --git a/pkgtools/pkg_install/files/lib/opattern.c b/pkgtools/pkg_install/files/lib/opattern.c
index 3861f3250ae..2b18f21a14c 100644
--- a/pkgtools/pkg_install/files/lib/opattern.c
+++ b/pkgtools/pkg_install/files/lib/opattern.c
@@ -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 @@ pkg_order(const char *pattern, const char *first_pkg, const char *second_pkg)
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 --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h
index 488decacaf7..6dd2820e601 100644
--- a/pkgtools/pkg_install/files/lib/version.h
+++ b/pkgtools/pkg_install/files/lib/version.h
@@ -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_ */