PERFORCE change 181848 for review
Julien Laffaye
jlaffaye at FreeBSD.org
Wed Aug 4 21:23:25 UTC 2010
http://p4web.freebsd.org/@@181848?ac=10
Change 181848 by jlaffaye at jlaffaye-chulak on 2010/08/04 21:23:05
Abort a complete package installation if a package in the set failed to install.
A 'already installed with the same version' error is not a valid justification
to abort a complete package installation.
Thus, extract_archive() returns a special error code in this case.
Affected files ...
.. //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/complete.c#2 edit
.. //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/extract.c#14 edit
.. //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/perform.c#13 edit
Differences ...
==== //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/complete.c#2 (text+ko) ====
@@ -49,14 +49,19 @@
archive_read_finish(a);
return (1);
}
- retcode += extract_package(a, &pkg, data->fname);
+ retcode = extract_package(a, &pkg, data->fname);
free_plist(&pkg);
+ if (retcode == 1) {
+ warnx("aborting complete package installation.");
+ archive_read_finish(a);
+ return (1);
+ }
}
archive_read_finish(a);
}
- return (retcode);
+ return (0);
}
static ssize_t
==== //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/extract.c#14 (text+ko) ====
@@ -36,8 +36,17 @@
char db_dir_tmp[FILENAME_MAX];
char db_dir[FILENAME_MAX];
+/*
+ * Extract and parse the plist of a package archive.
+ * The archive `a' must be opened by libarchive, with its internal iterator
+ * at CONTENTS_FNAME position. `archive_entry' must be a valid libarchive
+ * representation of this entry.
+ * The plist is stored in `pkg'.
+ * Returns 0 on success, 1 otherwise.
+ */
int
-extract_plist(struct archive *a, struct archive_entry *entry, Package *pkg) {
+extract_plist(struct archive *a, struct archive_entry *entry, Package *pkg)
+{
char *plist_buf;
ssize_t s;
int retcode;
@@ -65,6 +74,12 @@
return (0);
}
+/*
+ * Extract a package `fname' already opened via libarchive in `a'.
+ * The internal libarchive iterator of `a' must be at the plist entry position.
+ * Returns 0 on success, 1 on error, 2 if the package is already installed with
+ * the same version.
+ */
int
extract_package(struct archive *a, Package *pkg, const char *fname)
{
@@ -111,10 +126,14 @@
* See if we're already registered either with the same name (the same
* version) or some other version with the same origin.
*/
- if ((isinstalledpkg(pkg->name) > 0 ||
- matchbyorigin(pkg->origin, NULL) != NULL) && !Force) {
- warnx("package '%s' or its older version already installed%s",
- pkg->name, FailOnAlreadyInstalled ? "" : " (ignored)");
+ if (!Force && isinstalledpkg(pkg->name) > 0) {
+ warnx("package '%s' already installed%s", pkg->name,
+ FailOnAlreadyInstalled ? "!" : " (ignored)");
+ if (FailOnAlreadyInstalled == TRUE)
+ return (2);
+ } else if (!Force && matchbyorigin(pkg->origin, NULL) != NULL) {
+ warnx("an other version of '%s' is already installed%s",
+ pkg->origin, FailOnAlreadyInstalled ? "!" : " (ignored)");
if (FailOnAlreadyInstalled == TRUE)
return (1);
}
==== //depot/projects/soc2010/pkg_complete/usr.sbin/pkg_install/add/perform.c#13 (text+ko) ====
@@ -110,7 +110,8 @@
retcode = 1;
goto cleanup;
}
- retcode = extract_package(a, &pkg, fname);
+ if (extract_package(a, &pkg, fname) != 0)
+ retcode = 1;
free_plist(&pkg);
} else if (strcmp(pathname, PKG_COMPLETE_FNAME) == 0) {
if (Verbose)
More information about the p4-projects
mailing list