Update "pkg_install" to version 20120128:

- pkg_install 20120128:
  - Explicitly stat(2) if mkdir failed. errno detection doesn't work e.g.
    on Solaris.
  - Provide a stable order for package names that only differe in the base
    name, not the version number.
- pkg_install 20110805:
  - Fix for pkg_delete on NFS from Anthony Mallet.
This commit is contained in:
tron 2012-02-19 17:46:46 +00:00
parent d24466683b
commit 9cc7e269b3
3 changed files with 32 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: perform.c,v 1.1.1.18 2011/02/18 22:32:28 aymeric Exp $ */
/* $NetBSD: perform.c,v 1.1.1.19 2012/02/19 17:46:46 tron 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.1.1.18 2011/02/18 22:32:28 aymeric Exp $");
__RCSID("$NetBSD: perform.c,v 1.1.1.19 2012/02/19 17:46:46 tron Exp $");
/*-
* Copyright (c) 2003 Grant Beattie <grant@NetBSD.org>
@ -42,6 +42,7 @@ __RCSID("$NetBSD: perform.c,v 1.1.1.18 2011/02/18 22:32:28 aymeric 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;
}
/*
@ -382,6 +393,7 @@ check_already_installed(struct pkg_task *pkg)
free(filename);
if (fd == -1)
return 1;
close(fd);
if (ReplaceSame) {
struct stat sb;
@ -411,7 +423,6 @@ check_already_installed(struct pkg_task *pkg)
warnx("package `%s' already recorded as installed",
pkg->pkgname);
}
close(fd);
return 0;
}

View File

@ -34,7 +34,7 @@
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
__RCSID("$NetBSD: pkg_delete.c,v 1.1.1.7 2010/02/03 14:23:46 joerg Exp $");
__RCSID("$NetBSD: pkg_delete.c,v 1.1.1.8 2012/02/19 17:46:46 tron Exp $");
#if HAVE_ERR_H
#include <err.h>
@ -307,7 +307,7 @@ struct find_leaves_data {
* Packages that are marked as not for deletion are not considered as
* leaves. For all other packages it is checked if at least one package
* that depended on them is to be removed AND no depending package remains.
* If that is the case, the package is appened to the sorted list.
* If that is the case, the package is appended to the sorted list.
* As this package can't have depending packages left, the topological order
* remains consistent.
*/
@ -338,7 +338,7 @@ find_new_leaves_iter(const char *pkg, void *cookie)
if (process_required_by(pkg, NULL, data->pkgs, 3) == 1) {
lpp = alloc_lpkg(pkg);
TAILQ_INSERT_TAIL(data->pkgs, lpp, lp_link);
data->progress = 0;
data->progress = 1;
}
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: opattern.c,v 1.1.1.2 2009/02/02 20:44:06 joerg Exp $ */
/* $NetBSD: opattern.c,v 1.1.1.3 2012/02/19 17:46:47 tron 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.1.1.2 2009/02/02 20:44:06 joerg Exp $");
__RCSID("$NetBSD: opattern.c,v 1.1.1.3 2012/02/19 17:46:47 tron 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;
}