pkg_install-20100130: Add -U for pkg_add. It works similar to -u, but replaces an already installed version.diff -r1.17 -r1.18 pkgsrc/pkgtools/pkg_install/files/add/add.h
(joerg)
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: add.h,v 1.17 2010/01/22 13:30:41 joerg Exp $ */ | 1 | /* $NetBSD: add.h,v 1.18 2010/01/30 20:09:34 joerg Exp $ */ | |
2 | 2 | |||
3 | /* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp */ | 3 | /* from FreeBSD Id: add.h,v 1.8 1997/02/22 16:09:15 peter Exp */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * FreeBSD install - a package for the installation and maintainance | 6 | * FreeBSD install - a package for the installation and maintainance | |
7 | * of non-core utilities. | 7 | * of non-core utilities. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -27,22 +27,23 @@ | @@ -27,22 +27,23 @@ | |||
27 | 27 | |||
28 | extern char *Destdir; | 28 | extern char *Destdir; | |
29 | extern char *OverrideMachine; | 29 | extern char *OverrideMachine; | |
30 | extern char *Prefix; | 30 | extern char *Prefix; | |
31 | extern char *View; | 31 | extern char *View; | |
32 | extern char *Viewbase; | 32 | extern char *Viewbase; | |
33 | extern Boolean NoView; | 33 | extern Boolean NoView; | |
34 | extern Boolean NoInstall; | 34 | extern Boolean NoInstall; | |
35 | extern Boolean NoRecord; | 35 | extern Boolean NoRecord; | |
36 | extern Boolean Force; | 36 | extern Boolean Force; | |
37 | extern Boolean Automatic; | 37 | extern Boolean Automatic; | |
38 | extern int LicenseCheck; | 38 | extern int LicenseCheck; | |
39 | extern int Replace; | 39 | extern int Replace; | |
40 | extern int ReplaceSame; | |||
40 | 41 | |||
41 | extern Boolean ForceDepends; | 42 | extern Boolean ForceDepends; | |
42 | 43 | |||
43 | int make_hierarchy(char *); | 44 | int make_hierarchy(char *); | |
44 | void apply_perms(char *, char **, int); | 45 | void apply_perms(char *, char **, int); | |
45 | 46 | |||
46 | int pkg_perform(lpkg_head_t *); | 47 | int pkg_perform(lpkg_head_t *); | |
47 | 48 | |||
48 | #endif /* _INST_ADD_H_INCLUDE */ | 49 | #endif /* _INST_ADD_H_INCLUDE */ |
@@ -1,23 +1,23 @@ | @@ -1,23 +1,23 @@ | |||
1 | /* $NetBSD: main.c,v 1.23 2010/01/22 13:30:41 joerg Exp $ */ | 1 | /* $NetBSD: main.c,v 1.24 2010/01/30 20:09:34 joerg Exp $ */ | |
2 | 2 | |||
3 | #if HAVE_CONFIG_H | 3 | #if HAVE_CONFIG_H | |
4 | #include "config.h" | 4 | #include "config.h" | |
5 | #endif | 5 | #endif | |
6 | #include <nbcompat.h> | 6 | #include <nbcompat.h> | |
7 | #if HAVE_SYS_CDEFS_H | 7 | #if HAVE_SYS_CDEFS_H | |
8 | #include <sys/cdefs.h> | 8 | #include <sys/cdefs.h> | |
9 | #endif | 9 | #endif | |
10 | __RCSID("$NetBSD: main.c,v 1.23 2010/01/22 13:30:41 joerg Exp $"); | 10 | __RCSID("$NetBSD: main.c,v 1.24 2010/01/30 20:09:34 joerg Exp $"); | |
11 | 11 | |||
12 | /* | 12 | /* | |
13 | * | 13 | * | |
14 | * FreeBSD install - a package for the installation and maintainance | 14 | * FreeBSD install - a package for the installation and maintainance | |
15 | * of non-core utilities. | 15 | * of non-core utilities. | |
16 | * | 16 | * | |
17 | * Redistribution and use in source and binary forms, with or without | 17 | * Redistribution and use in source and binary forms, with or without | |
18 | * modification, are permitted provided that the following conditions | 18 | * modification, are permitted provided that the following conditions | |
19 | * are met: | 19 | * are met: | |
20 | * 1. Redistributions of source code must retain the above copyright | 20 | * 1. Redistributions of source code must retain the above copyright | |
21 | * notice, this list of conditions and the following disclaimer. | 21 | * notice, this list of conditions and the following disclaimer. | |
22 | * 2. Redistributions in binary form must reproduce the above copyright | 22 | * 2. Redistributions in binary form must reproduce the above copyright | |
23 | * notice, this list of conditions and the following disclaimer in the | 23 | * notice, this list of conditions and the following disclaimer in the | |
@@ -29,41 +29,42 @@ __RCSID("$NetBSD: main.c,v 1.23 2010/01/ | @@ -29,41 +29,42 @@ __RCSID("$NetBSD: main.c,v 1.23 2010/01/ | |||
29 | * This is the add module. | 29 | * This is the add module. | |
30 | * | 30 | * | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #if HAVE_ERR_H | 33 | #if HAVE_ERR_H | |
34 | #include <err.h> | 34 | #include <err.h> | |
35 | #endif | 35 | #endif | |
36 | #if HAVE_SYS_PARAM_H | 36 | #if HAVE_SYS_PARAM_H | |
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #endif | 38 | #endif | |
39 | #include "lib.h" | 39 | #include "lib.h" | |
40 | #include "add.h" | 40 | #include "add.h" | |
41 | 41 | |||
42 | static char Options[] = "AIK:LP:RVW:fhm:np:t:uvw:"; | 42 | static char Options[] = "AIK:LP:RVW:fhm:np:t:Uuvw:"; | |
43 | 43 | |||
44 | char *Destdir = NULL; | 44 | char *Destdir = NULL; | |
45 | char *OverrideMachine = NULL; | 45 | char *OverrideMachine = NULL; | |
46 | char *Prefix = NULL; | 46 | char *Prefix = NULL; | |
47 | char *View = NULL; | 47 | char *View = NULL; | |
48 | char *Viewbase = NULL; | 48 | char *Viewbase = NULL; | |
49 | Boolean NoView = FALSE; | 49 | Boolean NoView = FALSE; | |
50 | Boolean NoInstall = FALSE; | 50 | Boolean NoInstall = FALSE; | |
51 | Boolean NoRecord = FALSE; | 51 | Boolean NoRecord = FALSE; | |
52 | Boolean Automatic = FALSE; | 52 | Boolean Automatic = FALSE; | |
53 | Boolean ForceDepends = FALSE; | 53 | Boolean ForceDepends = FALSE; | |
54 | 54 | |||
55 | int LicenseCheck = 0; | 55 | int LicenseCheck = 0; | |
56 | int Replace = 0; | 56 | int Replace = 0; | |
57 | int ReplaceSame = 0; | |||
57 | 58 | |||
58 | static void | 59 | static void | |
59 | usage(void) | 60 | usage(void) | |
60 | { | 61 | { | |
61 | (void) fprintf(stderr, "%s\n%s\n%s\n%s\n", | 62 | (void) fprintf(stderr, "%s\n%s\n%s\n%s\n", | |
62 | "usage: pkg_add [-AfhILnRuVv] [-C config] [-P destdir] [-K pkg_dbdir]", | 63 | "usage: pkg_add [-AfhILnRuVv] [-C config] [-P destdir] [-K pkg_dbdir]", | |
63 | " [-m machine] [-p prefix] [-s verification-type", | 64 | " [-m machine] [-p prefix] [-s verification-type", | |
64 | " [-W viewbase] [-w view]\n", | 65 | " [-W viewbase] [-w view]\n", | |
65 | " [[ftp|http]://[user[:password]@]host[:port]][/path/]pkg-name ..."); | 66 | " [[ftp|http]://[user[:password]@]host[:port]][/path/]pkg-name ..."); | |
66 | exit(1); | 67 | exit(1); | |
67 | } | 68 | } | |
68 | 69 | |||
69 | int | 70 | int | |
@@ -110,26 +111,32 @@ main(int argc, char **argv) | @@ -110,26 +111,32 @@ main(int argc, char **argv) | |||
110 | case 'm': | 111 | case 'm': | |
111 | OverrideMachine = optarg; | 112 | OverrideMachine = optarg; | |
112 | break; | 113 | break; | |
113 | 114 | |||
114 | case 'n': | 115 | case 'n': | |
115 | Fake = TRUE; | 116 | Fake = TRUE; | |
116 | Verbose = TRUE; | 117 | Verbose = TRUE; | |
117 | break; | 118 | break; | |
118 | 119 | |||
119 | case 'p': | 120 | case 'p': | |
120 | Prefix = optarg; | 121 | Prefix = optarg; | |
121 | break; | 122 | break; | |
122 | 123 | |||
124 | case 'U': | |||
125 | ReplaceSame = 1; | |||
126 | if (!Replace) | |||
127 | Replace = 1; | |||
128 | break; | |||
129 | ||||
123 | case 'u': | 130 | case 'u': | |
124 | Replace++; | 131 | Replace++; | |
125 | break; | 132 | break; | |
126 | 133 | |||
127 | case 'V': | 134 | case 'V': | |
128 | show_version(); | 135 | show_version(); | |
129 | /* NOTREACHED */ | 136 | /* NOTREACHED */ | |
130 | 137 | |||
131 | case 'v': | 138 | case 'v': | |
132 | Verbose = TRUE; | 139 | Verbose = TRUE; | |
133 | break; | 140 | break; | |
134 | 141 | |||
135 | case 'W': | 142 | case 'W': |
@@ -1,22 +1,22 @@ | @@ -1,22 +1,22 @@ | |||
1 | /* $NetBSD: perform.c,v 1.92 2010/01/22 13:30:41 joerg Exp $ */ | 1 | /* $NetBSD: perform.c,v 1.93 2010/01/30 20:09:34 joerg Exp $ */ | |
2 | #if HAVE_CONFIG_H | 2 | #if HAVE_CONFIG_H | |
3 | #include "config.h" | 3 | #include "config.h" | |
4 | #endif | 4 | #endif | |
5 | #include <nbcompat.h> | 5 | #include <nbcompat.h> | |
6 | #if HAVE_SYS_CDEFS_H | 6 | #if HAVE_SYS_CDEFS_H | |
7 | #include <sys/cdefs.h> | 7 | #include <sys/cdefs.h> | |
8 | #endif | 8 | #endif | |
9 | __RCSID("$NetBSD: perform.c,v 1.92 2010/01/22 13:30:41 joerg Exp $"); | 9 | __RCSID("$NetBSD: perform.c,v 1.93 2010/01/30 20:09:34 joerg Exp $"); | |
10 | 10 | |||
11 | /*- | 11 | /*- | |
12 | * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> | 12 | * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> | |
13 | * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org> | 13 | * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org> | |
14 | * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org> | 14 | * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org> | |
15 | * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg@NetBSD.org> | 15 | * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg@NetBSD.org> | |
16 | * All rights reserved. | 16 | * All rights reserved. | |
17 | * | 17 | * | |
18 | * Redistribution and use in source and binary forms, with or without | 18 | * Redistribution and use in source and binary forms, with or without | |
19 | * modification, are permitted provided that the following conditions | 19 | * modification, are permitted provided that the following conditions | |
20 | * are met: | 20 | * are met: | |
21 | * | 21 | * | |
22 | * 1. Redistributions of source code must retain the above copyright | 22 | * 1. Redistributions of source code must retain the above copyright | |
@@ -74,26 +74,27 @@ struct pkg_meta { | @@ -74,26 +74,27 @@ struct pkg_meta { | |||
74 | char *meta_preserve; | 74 | char *meta_preserve; | |
75 | char *meta_views; | 75 | char *meta_views; | |
76 | char *meta_installed_info; | 76 | char *meta_installed_info; | |
77 | }; | 77 | }; | |
78 | 78 | |||
79 | struct pkg_task { | 79 | struct pkg_task { | |
80 | char *pkgname; | 80 | char *pkgname; | |
81 | 81 | |||
82 | const char *prefix; | 82 | const char *prefix; | |
83 | char *install_prefix; | 83 | char *install_prefix; | |
84 | 84 | |||
85 | char *logdir; | 85 | char *logdir; | |
86 | char *install_logdir; | 86 | char *install_logdir; | |
87 | char *install_logdir_real; | |||
87 | char *other_version; | 88 | char *other_version; | |
88 | 89 | |||
89 | package_t plist; | 90 | package_t plist; | |
90 | 91 | |||
91 | struct pkg_meta meta_data; | 92 | struct pkg_meta meta_data; | |
92 | 93 | |||
93 | struct archive *archive; | 94 | struct archive *archive; | |
94 | struct archive_entry *entry; | 95 | struct archive_entry *entry; | |
95 | 96 | |||
96 | char *buildinfo[BI_ENUM_COUNT]; | 97 | char *buildinfo[BI_ENUM_COUNT]; | |
97 | 98 | |||
98 | size_t dep_length, dep_allocated; | 99 | size_t dep_length, dep_allocated; | |
99 | char **dependencies; | 100 | char **dependencies; | |
@@ -328,33 +329,47 @@ dup_value(const char *line, const char * | @@ -328,33 +329,47 @@ dup_value(const char *line, const char * | |||
328 | val = xmalloc(eol - key); | 329 | val = xmalloc(eol - key); | |
329 | memcpy(val, key + 1, eol - key - 1); | 330 | memcpy(val, key + 1, eol - key - 1); | |
330 | val[eol - key - 1] = '\0'; | 331 | val[eol - key - 1] = '\0'; | |
331 | return val; | 332 | return val; | |
332 | } | 333 | } | |
333 | 334 | |||
334 | static int | 335 | static int | |
335 | check_already_installed(struct pkg_task *pkg) | 336 | check_already_installed(struct pkg_task *pkg) | |
336 | { | 337 | { | |
337 | char *filename; | 338 | char *filename; | |
338 | int fd; | 339 | int fd; | |
339 | 340 | |||
340 | if (Force) | 341 | if (Force) | |
341 | return -1; | 342 | return 1; | |
342 | 343 | |||
343 | filename = pkgdb_pkg_file(pkg->pkgname, CONTENTS_FNAME); | 344 | filename = pkgdb_pkg_file(pkg->pkgname, CONTENTS_FNAME); | |
344 | fd = open(filename, O_RDONLY); | 345 | fd = open(filename, O_RDONLY); | |
345 | free(filename); | 346 | free(filename); | |
346 | if (fd == -1) | 347 | if (fd == -1) | |
347 | return -1; | 348 | return 1; | |
349 | ||||
350 | if (ReplaceSame) { | |||
351 | struct stat sb; | |||
352 | ||||
353 | pkg->install_logdir_real = pkg->install_logdir; | |||
354 | pkg->install_logdir = xasprintf("%s.xxxxxx", pkg->install_logdir); | |||
355 | if (stat(pkg->install_logdir, &sb) == 0) { | |||
356 | warnx("package `%s' already has a temporary update " | |||
357 | "directory `%s', remove it manually", | |||
358 | pkg->pkgname, pkg->install_logdir); | |||
359 | return -1; | |||
360 | } | |||
361 | return 1; | |||
362 | } | |||
348 | 363 | |||
349 | /* We can only arrive here for explicitly requested packages. */ | 364 | /* We can only arrive here for explicitly requested packages. */ | |
350 | if (!Automatic && is_automatic_installed(pkg->pkgname)) { | 365 | if (!Automatic && is_automatic_installed(pkg->pkgname)) { | |
351 | if (Fake || | 366 | if (Fake || | |
352 | mark_as_automatic_installed(pkg->pkgname, 0) == 0) | 367 | mark_as_automatic_installed(pkg->pkgname, 0) == 0) | |
353 | warnx("package `%s' was already installed as " | 368 | warnx("package `%s' was already installed as " | |
354 | "dependency, now marked as installed " | 369 | "dependency, now marked as installed " | |
355 | "manually", pkg->pkgname); | 370 | "manually", pkg->pkgname); | |
356 | } else { | 371 | } else { | |
357 | warnx("package `%s' already recorded as installed", | 372 | warnx("package `%s' already recorded as installed", | |
358 | pkg->pkgname); | 373 | pkg->pkgname); | |
359 | } | 374 | } | |
360 | close(fd); | 375 | close(fd); | |
@@ -362,26 +377,31 @@ check_already_installed(struct pkg_task | @@ -362,26 +377,31 @@ check_already_installed(struct pkg_task | |||
362 | 377 | |||
363 | } | 378 | } | |
364 | 379 | |||
365 | static int | 380 | static int | |
366 | check_other_installed(struct pkg_task *pkg) | 381 | check_other_installed(struct pkg_task *pkg) | |
367 | { | 382 | { | |
368 | FILE *f, *f_pkg; | 383 | FILE *f, *f_pkg; | |
369 | size_t len; | 384 | size_t len; | |
370 | char *pkgbase, *iter, *filename; | 385 | char *pkgbase, *iter, *filename; | |
371 | package_t plist; | 386 | package_t plist; | |
372 | plist_t *p; | 387 | plist_t *p; | |
373 | int status; | 388 | int status; | |
374 | 389 | |||
390 | if (pkg->install_logdir_real) { | |||
391 | pkg->other_version = xstrdup(pkg->pkgname); | |||
392 | return 0; | |||
393 | } | |||
394 | ||||
375 | pkgbase = xstrdup(pkg->pkgname); | 395 | pkgbase = xstrdup(pkg->pkgname); | |
376 | 396 | |||
377 | if ((iter = strrchr(pkgbase, '-')) == NULL) { | 397 | if ((iter = strrchr(pkgbase, '-')) == NULL) { | |
378 | free(pkgbase); | 398 | free(pkgbase); | |
379 | warnx("Invalid package name %s", pkg->pkgname); | 399 | warnx("Invalid package name %s", pkg->pkgname); | |
380 | return -1; | 400 | return -1; | |
381 | } | 401 | } | |
382 | *iter = '\0'; | 402 | *iter = '\0'; | |
383 | pkg->other_version = find_best_matching_installed_pkg(pkgbase); | 403 | pkg->other_version = find_best_matching_installed_pkg(pkgbase); | |
384 | free(pkgbase); | 404 | free(pkgbase); | |
385 | if (pkg->other_version == NULL) | 405 | if (pkg->other_version == NULL) | |
386 | return 0; | 406 | return 0; | |
387 | 407 | |||
@@ -1100,27 +1120,27 @@ pkg_register_views(struct pkg_task *pkg) | @@ -1100,27 +1120,27 @@ pkg_register_views(struct pkg_task *pkg) | |||
1100 | (void *)NULL); | 1120 | (void *)NULL); | |
1101 | } | 1121 | } | |
1102 | 1122 | |||
1103 | static int | 1123 | static int | |
1104 | preserve_meta_data_file(struct pkg_task *pkg, const char *name) | 1124 | preserve_meta_data_file(struct pkg_task *pkg, const char *name) | |
1105 | { | 1125 | { | |
1106 | char *old_file, *new_file; | 1126 | char *old_file, *new_file; | |
1107 | int rv; | 1127 | int rv; | |
1108 | 1128 | |||
1109 | if (Fake) | 1129 | if (Fake) | |
1110 | return 0; | 1130 | return 0; | |
1111 | 1131 | |||
1112 | old_file = pkgdb_pkg_file(pkg->other_version, name); | 1132 | old_file = pkgdb_pkg_file(pkg->other_version, name); | |
1113 | new_file = pkgdb_pkg_file(pkg->pkgname, name); | 1133 | new_file = xasprintf("%s/%s", pkg->install_logdir, name); | |
1114 | rv = 0; | 1134 | rv = 0; | |
1115 | if (rename(old_file, new_file) == -1 && errno != ENOENT) { | 1135 | if (rename(old_file, new_file) == -1 && errno != ENOENT) { | |
1116 | warn("Can't move %s from %s to %s", name, old_file, new_file); | 1136 | warn("Can't move %s from %s to %s", name, old_file, new_file); | |
1117 | rv = -1; | 1137 | rv = -1; | |
1118 | } | 1138 | } | |
1119 | free(old_file); | 1139 | free(old_file); | |
1120 | free(new_file); | 1140 | free(new_file); | |
1121 | return rv; | 1141 | return rv; | |
1122 | } | 1142 | } | |
1123 | 1143 | |||
1124 | static int | 1144 | static int | |
1125 | start_replacing(struct pkg_task *pkg) | 1145 | start_replacing(struct pkg_task *pkg) | |
1126 | { | 1146 | { | |
@@ -1343,55 +1363,67 @@ pkg_do(const char *pkgpath, int mark_aut | @@ -1343,55 +1363,67 @@ pkg_do(const char *pkgpath, int mark_aut | |||
1343 | tmpdir = getenv("TMPDIR"); | 1363 | tmpdir = getenv("TMPDIR"); | |
1344 | if (tmpdir == NULL) | 1364 | if (tmpdir == NULL) | |
1345 | tmpdir = "/tmp"; | 1365 | tmpdir = "/tmp"; | |
1346 | 1366 | |||
1347 | free(pkg->install_logdir); | 1367 | free(pkg->install_logdir); | |
1348 | pkg->install_logdir = xasprintf("%s/pkg_install.XXXXXX", tmpdir); | 1368 | pkg->install_logdir = xasprintf("%s/pkg_install.XXXXXX", tmpdir); | |
1349 | /* XXX pkg_add -u... */ | 1369 | /* XXX pkg_add -u... */ | |
1350 | if (mkdtemp(pkg->install_logdir) == NULL) { | 1370 | if (mkdtemp(pkg->install_logdir) == NULL) { | |
1351 | warn("mkdtemp failed"); | 1371 | warn("mkdtemp failed"); | |
1352 | goto clean_memory; | 1372 | goto clean_memory; | |
1353 | } | 1373 | } | |
1354 | } | 1374 | } | |
1355 | 1375 | |||
1356 | if (check_already_installed(pkg) == 0) { | 1376 | switch (check_already_installed(pkg)) { | |
1377 | case 0: | |||
1357 | status = 0; | 1378 | status = 0; | |
1358 | goto clean_memory; | 1379 | goto clean_memory; | |
1380 | case 1: | |||
1381 | break; | |||
1382 | case -1: | |||
1383 | goto clean_memory; | |||
1359 | } | 1384 | } | |
1360 | 1385 | |||
1361 | if (check_platform(pkg)) | 1386 | if (check_platform(pkg)) | |
1362 | goto clean_memory; | 1387 | goto clean_memory; | |
1363 | 1388 | |||
1364 | if (check_other_installed(pkg)) | 1389 | if (check_other_installed(pkg)) | |
1365 | goto clean_memory; | 1390 | goto clean_memory; | |
1366 | 1391 | |||
1367 | if (check_explicit_conflict(pkg)) | 1392 | if (check_explicit_conflict(pkg)) | |
1368 | goto clean_memory; | 1393 | goto clean_memory; | |
1369 | 1394 | |||
1370 | if (check_implicit_conflict(pkg)) | 1395 | if (check_implicit_conflict(pkg)) | |
1371 | goto clean_memory; | 1396 | goto clean_memory; | |
1372 | 1397 | |||
1373 | if (pkg->other_version != NULL) { | 1398 | if (pkg->other_version != NULL) { | |
1374 | /* | 1399 | /* | |
1375 | * Replacing an existing package. | 1400 | * Replacing an existing package. | |
1376 | * Write meta-data, get rid of the old version, | 1401 | * Write meta-data, get rid of the old version, | |
1377 | * install/update dependencies and finally extract. | 1402 | * install/update dependencies and finally extract. | |
1378 | */ | 1403 | */ | |
1379 | if (write_meta_data(pkg)) | 1404 | if (write_meta_data(pkg)) | |
1380 | goto nuke_pkgdb; | 1405 | goto nuke_pkgdb; | |
1381 | 1406 | |||
1382 | if (start_replacing(pkg)) | 1407 | if (start_replacing(pkg)) | |
1383 | goto nuke_pkgdb; | 1408 | goto nuke_pkgdb; | |
1384 | 1409 | |||
1410 | if (pkg->install_logdir_real) { | |||
1411 | rename(pkg->install_logdir, pkg->install_logdir_real); | |||
1412 | free(pkg->install_logdir); | |||
1413 | pkg->install_logdir = pkg->install_logdir_real; | |||
1414 | pkg->install_logdir_real = NULL; | |||
1415 | } | |||
1416 | ||||
1385 | if (check_dependencies(pkg)) | 1417 | if (check_dependencies(pkg)) | |
1386 | goto nuke_pkgdb; | 1418 | goto nuke_pkgdb; | |
1387 | } else { | 1419 | } else { | |
1388 | /* | 1420 | /* | |
1389 | * Normal installation. | 1421 | * Normal installation. | |
1390 | * Install/update dependencies first and | 1422 | * Install/update dependencies first and | |
1391 | * write the current package to disk afterwards. | 1423 | * write the current package to disk afterwards. | |
1392 | */ | 1424 | */ | |
1393 | if (check_dependencies(pkg)) | 1425 | if (check_dependencies(pkg)) | |
1394 | goto clean_memory; | 1426 | goto clean_memory; | |
1395 | 1427 | |||
1396 | if (write_meta_data(pkg)) | 1428 | if (write_meta_data(pkg)) | |
1397 | goto nuke_pkgdb; | 1429 | goto nuke_pkgdb; | |
@@ -1428,38 +1460,41 @@ nuke_pkg: | @@ -1428,38 +1460,41 @@ nuke_pkg: | |||
1428 | if (!Fake) { | 1460 | if (!Fake) { | |
1429 | if (pkg->other_version) { | 1461 | if (pkg->other_version) { | |
1430 | warnx("Updating of %s to %s failed.", | 1462 | warnx("Updating of %s to %s failed.", | |
1431 | pkg->other_version, pkg->pkgname); | 1463 | pkg->other_version, pkg->pkgname); | |
1432 | warnx("Remember to run pkg_admin rebuild-tree after fixing this."); | 1464 | warnx("Remember to run pkg_admin rebuild-tree after fixing this."); | |
1433 | } | 1465 | } | |
1434 | delete_package(FALSE, &pkg->plist, FALSE, Destdir); | 1466 | delete_package(FALSE, &pkg->plist, FALSE, Destdir); | |
1435 | } | 1467 | } | |
1436 | 1468 | |||
1437 | nuke_pkgdb: | 1469 | nuke_pkgdb: | |
1438 | if (!Fake) { | 1470 | if (!Fake) { | |
1439 | if (recursive_remove(pkg->install_logdir, 1)) | 1471 | if (recursive_remove(pkg->install_logdir, 1)) | |
1440 | warn("Couldn't remove %s", pkg->install_logdir); | 1472 | warn("Couldn't remove %s", pkg->install_logdir); | |
1473 | free(pkg->install_logdir_real); | |||
1441 | free(pkg->install_logdir); | 1474 | free(pkg->install_logdir); | |
1442 | free(pkg->logdir); | 1475 | free(pkg->logdir); | |
1476 | pkg->install_logdir_real = NULL; | |||
1443 | pkg->install_logdir = NULL; | 1477 | pkg->install_logdir = NULL; | |
1444 | pkg->logdir = NULL; | 1478 | pkg->logdir = NULL; | |
1445 | } | 1479 | } | |
1446 | 1480 | |||
1447 | clean_memory: | 1481 | clean_memory: | |
1448 | if (pkg->logdir != NULL && NoRecord && !Fake) { | 1482 | if (pkg->logdir != NULL && NoRecord && !Fake) { | |
1449 | if (recursive_remove(pkg->install_logdir, 1)) | 1483 | if (recursive_remove(pkg->install_logdir, 1)) | |
1450 | warn("Couldn't remove %s", pkg->install_logdir); | 1484 | warn("Couldn't remove %s", pkg->install_logdir); | |
1451 | } | 1485 | } | |
1452 | free(pkg->install_prefix); | 1486 | free(pkg->install_prefix); | |
1487 | free(pkg->install_logdir_real); | |||
1453 | free(pkg->install_logdir); | 1488 | free(pkg->install_logdir); | |
1454 | free(pkg->logdir); | 1489 | free(pkg->logdir); | |
1455 | free_buildinfo(pkg); | 1490 | free_buildinfo(pkg); | |
1456 | free_plist(&pkg->plist); | 1491 | free_plist(&pkg->plist); | |
1457 | free_meta_data(pkg); | 1492 | free_meta_data(pkg); | |
1458 | if (pkg->archive) | 1493 | if (pkg->archive) | |
1459 | archive_read_finish(pkg->archive); | 1494 | archive_read_finish(pkg->archive); | |
1460 | free(pkg->other_version); | 1495 | free(pkg->other_version); | |
1461 | free(pkg->pkgname); | 1496 | free(pkg->pkgname); | |
1462 | clean_find_archive: | 1497 | clean_find_archive: | |
1463 | free(pkg); | 1498 | free(pkg); | |
1464 | return status; | 1499 | return status; | |
1465 | } | 1500 | } |
@@ -1,41 +1,41 @@ | @@ -1,41 +1,41 @@ | |||
1 | .\" $NetBSD: pkg_add.1,v 1.41 2010/01/22 13:30:41 joerg Exp $ | 1 | .\" $NetBSD: pkg_add.1,v 1.42 2010/01/30 20:09:34 joerg Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" FreeBSD install - a package for the installation and maintenance | 3 | .\" FreeBSD install - a package for the installation and maintenance | |
4 | .\" of non-core utilities. | 4 | .\" of non-core utilities. | |
5 | .\" | 5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | 6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | 7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | 8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | 9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | 10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | 12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | 13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" | 14 | .\" | |
15 | .\" Jordan K. Hubbard | 15 | .\" Jordan K. Hubbard | |
16 | .\" | 16 | .\" | |
17 | .\" | 17 | .\" | |
18 | .\" @(#)pkg_add.1 | 18 | .\" @(#)pkg_add.1 | |
19 | .\" | 19 | .\" | |
20 | .Dd January 22, 2010 | 20 | .Dd January 30, 2010 | |
21 | .Dt PKG_ADD 1 | 21 | .Dt PKG_ADD 1 | |
22 | .Os | 22 | .Os | |
23 | .Sh NAME | 23 | .Sh NAME | |
24 | .Nm pkg_add | 24 | .Nm pkg_add | |
25 | .Nd a utility for installing and upgrading software package distributions | 25 | .Nd a utility for installing and upgrading software package distributions | |
26 | .Sh SYNOPSIS | 26 | .Sh SYNOPSIS | |
27 | .Nm | 27 | .Nm | |
28 | .Op Fl AfILnRuVv | 28 | .Op Fl AfILnRUuVv | |
29 | .Op Fl K Ar pkg_dbdir | 29 | .Op Fl K Ar pkg_dbdir | |
30 | .Op Fl m Ar machine | 30 | .Op Fl m Ar machine | |
31 | .Op Fl P Ar destdir | 31 | .Op Fl P Ar destdir | |
32 | .Op Fl p Ar prefix | 32 | .Op Fl p Ar prefix | |
33 | .Op Fl W Ar viewbase | 33 | .Op Fl W Ar viewbase | |
34 | .Op Fl w Ar view | 34 | .Op Fl w Ar view | |
35 | .Ar Oo Oo Li ftp|http Oc Ns Li :// Ns Oo Ar user Oc Ns \ | 35 | .Ar Oo Oo Li ftp|http Oc Ns Li :// Ns Oo Ar user Oc Ns \ | |
36 | Oo Li \&: Ns Ar password Oc \ | 36 | Oo Li \&: Ns Ar password Oc \ | |
37 | Ns Li @ Oc Ns Ar host Ns Oo Li \&: Ns Ar port Oc Ns \ | 37 | Ns Li @ Oc Ns Ar host Ns Oo Li \&: Ns Ar port Oc Ns \ | |
38 | Oo Li / Ns Ar path/ Oc Ns Ar pkg-name ... | 38 | Oo Li / Ns Ar path/ Oc Ns Ar pkg-name ... | |
39 | .Sh DESCRIPTION | 39 | .Sh DESCRIPTION | |
40 | The | 40 | The | |
41 | .Nm | 41 | .Nm | |
@@ -145,30 +145,33 @@ Prefix all file and directory names with | @@ -145,30 +145,33 @@ Prefix all file and directory names with | |||
145 | .Ar destdir . | 145 | .Ar destdir . | |
146 | For packages without install scripts this has the same behavior as | 146 | For packages without install scripts this has the same behavior as | |
147 | using | 147 | using | |
148 | .Xr chroot 8 . | 148 | .Xr chroot 8 . | |
149 | .It Fl p Ar prefix | 149 | .It Fl p Ar prefix | |
150 | Override the prefix stored in the package with | 150 | Override the prefix stored in the package with | |
151 | .Ar prefix . | 151 | .Ar prefix . | |
152 | .It Fl R | 152 | .It Fl R | |
153 | Do not record the installation of a package. | 153 | Do not record the installation of a package. | |
154 | This implies | 154 | This implies | |
155 | .Fl I . | 155 | .Fl I . | |
156 | This means that you cannot deinstall it later, so only use this option if | 156 | This means that you cannot deinstall it later, so only use this option if | |
157 | you know what you are doing! | 157 | you know what you are doing! | |
158 | .It Fl U | |||
159 | Replace an already installed version from a package. | |||
160 | Implies | |||
161 | .Fl u . | |||
158 | .It Fl u | 162 | .It Fl u | |
159 | If the package that's being installed is already installed, | 163 | If the package that's being installed is already installed, | |
160 | an update is performed. | 164 | an update is performed. | |
161 | It is currently not possible to update to an identical version. | |||
162 | If this is specified twice, then any dependent packages that are | 165 | If this is specified twice, then any dependent packages that are | |
163 | too old will also be updated to fulfill the dependency. | 166 | too old will also be updated to fulfill the dependency. | |
164 | See below for a more detailed description of the process. | 167 | See below for a more detailed description of the process. | |
165 | .It Fl V | 168 | .It Fl V | |
166 | Print version number and exit. | 169 | Print version number and exit. | |
167 | .It Fl v | 170 | .It Fl v | |
168 | Turn on verbose output. | 171 | Turn on verbose output. | |
169 | .It Fl W Ar viewbase | 172 | .It Fl W Ar viewbase | |
170 | Passed down to | 173 | Passed down to | |
171 | .Xr pkg_view 1 | 174 | .Xr pkg_view 1 | |
172 | for managed views. | 175 | for managed views. | |
173 | .It Fl w Ar view | 176 | .It Fl w Ar view | |
174 | Passed down to | 177 | Passed down to |
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: version.h,v 1.147 2010/01/26 15:48:13 joerg Exp $ */ | 1 | /* $NetBSD: version.h,v 1.148 2010/01/30 20:09:34 joerg Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 Thomas Klausner. All rights reserved. | 4 | * Copyright (c) 2001 Thomas Klausner. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -17,16 +17,16 @@ | @@ -17,16 +17,16 @@ | |||
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | 25 | */ | |
26 | 26 | |||
27 | #ifndef _INST_LIB_VERSION_H_ | 27 | #ifndef _INST_LIB_VERSION_H_ | |
28 | #define _INST_LIB_VERSION_H_ | 28 | #define _INST_LIB_VERSION_H_ | |
29 | 29 | |||
30 | #define PKGTOOLS_VERSION "20100126" | 30 | #define PKGTOOLS_VERSION "20100130" | |
31 | 31 | |||
32 | #endif /* _INST_LIB_VERSION_H_ */ | 32 | #endif /* _INST_LIB_VERSION_H_ */ |