pkg_create actually does want to mess with the plist before reading it, so introduce append_plist to give the old behavior and unbreak pkg_create.diff -r1.19.2.3 -r1.19.2.4 pkgsrc/pkgtools/pkg_install/files/create/perform.c
(joerg)
@@ -1,27 +1,27 @@ | @@ -1,27 +1,27 @@ | |||
1 | /* $NetBSD: perform.c,v 1.19.2.3 2008/08/10 22:08:16 joerg Exp $ */ | 1 | /* $NetBSD: perform.c,v 1.19.2.4 2008/08/11 15:58:15 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 | #ifndef lint | 10 | #ifndef lint | |
11 | #if 0 | 11 | #if 0 | |
12 | static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp"; | 12 | static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp"; | |
13 | #else | 13 | #else | |
14 | __RCSID("$NetBSD: perform.c,v 1.19.2.3 2008/08/10 22:08:16 joerg Exp $"); | 14 | __RCSID("$NetBSD: perform.c,v 1.19.2.4 2008/08/11 15:58:15 joerg Exp $"); | |
15 | #endif | 15 | #endif | |
16 | #endif | 16 | #endif | |
17 | 17 | |||
18 | /* | 18 | /* | |
19 | * FreeBSD install - a package for the installation and maintainance | 19 | * FreeBSD install - a package for the installation and maintainance | |
20 | * of non-core utilities. | 20 | * of non-core utilities. | |
21 | * | 21 | * | |
22 | * Redistribution and use in source and binary forms, with or without | 22 | * Redistribution and use in source and binary forms, with or without | |
23 | * modification, are permitted provided that the following conditions | 23 | * modification, are permitted provided that the following conditions | |
24 | * are met: | 24 | * are met: | |
25 | * 1. Redistributions of source code must retain the above copyright | 25 | * 1. Redistributions of source code must retain the above copyright | |
26 | * notice, this list of conditions and the following disclaimer. | 26 | * notice, this list of conditions and the following disclaimer. | |
27 | * 2. Redistributions in binary form must reproduce the above copyright | 27 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -162,26 +162,28 @@ pkg_perform(const char *pkg) | @@ -162,26 +162,28 @@ pkg_perform(const char *pkg) | |||
162 | sanity_check(); | 162 | sanity_check(); | |
163 | if (Verbose && !PlistOnly) | 163 | if (Verbose && !PlistOnly) | |
164 | printf("Creating package %s\n", pkg); | 164 | printf("Creating package %s\n", pkg); | |
165 | get_dash_string(&Comment); | 165 | get_dash_string(&Comment); | |
166 | get_dash_string(&Desc); | 166 | get_dash_string(&Desc); | |
167 | if (IS_STDIN(Contents)) | 167 | if (IS_STDIN(Contents)) | |
168 | pkg_in = stdin; | 168 | pkg_in = stdin; | |
169 | else { | 169 | else { | |
170 | pkg_in = fopen(Contents, "r"); | 170 | pkg_in = fopen(Contents, "r"); | |
171 | if (!pkg_in) | 171 | if (!pkg_in) | |
172 | errx(2, "unable to open contents file '%s' for input", Contents); | 172 | errx(2, "unable to open contents file '%s' for input", Contents); | |
173 | } | 173 | } | |
174 | 174 | |||
175 | plist.head = plist.tail = NULL; | |||
176 | ||||
175 | /* If a SrcDir override is set, add it now */ | 177 | /* If a SrcDir override is set, add it now */ | |
176 | if (SrcDir) { | 178 | if (SrcDir) { | |
177 | if (Verbose && !PlistOnly) | 179 | if (Verbose && !PlistOnly) | |
178 | printf("Using SrcDir value of %s\n", (realprefix) ? realprefix : SrcDir); | 180 | printf("Using SrcDir value of %s\n", (realprefix) ? realprefix : SrcDir); | |
179 | add_plist(&plist, PLIST_SRC, SrcDir); | 181 | add_plist(&plist, PLIST_SRC, SrcDir); | |
180 | } | 182 | } | |
181 | 183 | |||
182 | /* Stick the dependencies, if any, at the top */ | 184 | /* Stick the dependencies, if any, at the top */ | |
183 | if (Pkgdeps) | 185 | if (Pkgdeps) | |
184 | register_depends(&plist, Pkgdeps, 0); | 186 | register_depends(&plist, Pkgdeps, 0); | |
185 | 187 | |||
186 | /* | 188 | /* | |
187 | * Put the build dependencies after the dependencies. | 189 | * Put the build dependencies after the dependencies. | |
@@ -197,27 +199,27 @@ pkg_perform(const char *pkg) | @@ -197,27 +199,27 @@ pkg_perform(const char *pkg) | |||
197 | while (Pkgcfl) { | 199 | while (Pkgcfl) { | |
198 | cp = strsep(&Pkgcfl, " \t\n"); | 200 | cp = strsep(&Pkgcfl, " \t\n"); | |
199 | if (*cp) { | 201 | if (*cp) { | |
200 | add_plist(&plist, PLIST_PKGCFL, cp); | 202 | add_plist(&plist, PLIST_PKGCFL, cp); | |
201 | if (Verbose && !PlistOnly) | 203 | if (Verbose && !PlistOnly) | |
202 | printf(" %s", cp); | 204 | printf(" %s", cp); | |
203 | } | 205 | } | |
204 | } | 206 | } | |
205 | if (Verbose && !PlistOnly) | 207 | if (Verbose && !PlistOnly) | |
206 | printf(".\n"); | 208 | printf(".\n"); | |
207 | } | 209 | } | |
208 | 210 | |||
209 | /* Slurp in the packing list */ | 211 | /* Slurp in the packing list */ | |
210 | read_plist(&plist, pkg_in); | 212 | append_plist(&plist, pkg_in); | |
211 | 213 | |||
212 | if (pkg_in != stdin) | 214 | if (pkg_in != stdin) | |
213 | fclose(pkg_in); | 215 | fclose(pkg_in); | |
214 | 216 | |||
215 | /* Prefix should override the packing list */ | 217 | /* Prefix should override the packing list */ | |
216 | if (Prefix) { | 218 | if (Prefix) { | |
217 | delete_plist(&plist, FALSE, PLIST_CWD, NULL); | 219 | delete_plist(&plist, FALSE, PLIST_CWD, NULL); | |
218 | add_plist_top(&plist, PLIST_CWD, Prefix); | 220 | add_plist_top(&plist, PLIST_CWD, Prefix); | |
219 | } | 221 | } | |
220 | /* | 222 | /* | |
221 | * Run down the list and see if we've named it, if not stick in a name | 223 | * Run down the list and see if we've named it, if not stick in a name | |
222 | * at the top. | 224 | * at the top. | |
223 | */ | 225 | */ |
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lib.h,v 1.42.2.13 2008/08/05 22:56:24 joerg Exp $ */ | 1 | /* $NetBSD: lib.h,v 1.42.2.14 2008/08/11 15:58:15 joerg Exp $ */ | |
2 | 2 | |||
3 | /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ | 3 | /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier 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 | |
@@ -327,26 +327,27 @@ plist_t *last_plist(package_t *); | @@ -327,26 +327,27 @@ plist_t *last_plist(package_t *); | |||
327 | plist_t *find_plist(package_t *, pl_ent_t); | 327 | plist_t *find_plist(package_t *, pl_ent_t); | |
328 | char *find_plist_option(package_t *, char *); | 328 | char *find_plist_option(package_t *, char *); | |
329 | void plist_delete(package_t *, Boolean, pl_ent_t, char *); | 329 | void plist_delete(package_t *, Boolean, pl_ent_t, char *); | |
330 | void free_plist(package_t *); | 330 | void free_plist(package_t *); | |
331 | void mark_plist(package_t *); | 331 | void mark_plist(package_t *); | |
332 | void csum_plist_entry(char *, plist_t *); | 332 | void csum_plist_entry(char *, plist_t *); | |
333 | void add_plist(package_t *, pl_ent_t, const char *); | 333 | void add_plist(package_t *, pl_ent_t, const char *); | |
334 | void add_plist_top(package_t *, pl_ent_t, const char *); | 334 | void add_plist_top(package_t *, pl_ent_t, const char *); | |
335 | void delete_plist(package_t *, Boolean, pl_ent_t, char *); | 335 | void delete_plist(package_t *, Boolean, pl_ent_t, char *); | |
336 | void write_plist(package_t *, FILE *, char *); | 336 | void write_plist(package_t *, FILE *, char *); | |
337 | void stringify_plist(package_t *, char **, size_t *, const char *); | 337 | void stringify_plist(package_t *, char **, size_t *, const char *); | |
338 | void parse_plist(package_t *, const char *); | 338 | void parse_plist(package_t *, const char *); | |
339 | void read_plist(package_t *, FILE *); | 339 | void read_plist(package_t *, FILE *); | |
340 | void append_plist(package_t *, FILE *); | |||
340 | int delete_package(Boolean, Boolean, package_t *, Boolean, const char *); | 341 | int delete_package(Boolean, Boolean, package_t *, Boolean, const char *); | |
341 | 342 | |||
342 | /* Package Database */ | 343 | /* Package Database */ | |
343 | int pkgdb_open(int); | 344 | int pkgdb_open(int); | |
344 | void pkgdb_close(void); | 345 | void pkgdb_close(void); | |
345 | int pkgdb_store(const char *, const char *); | 346 | int pkgdb_store(const char *, const char *); | |
346 | char *pkgdb_retrieve(const char *); | 347 | char *pkgdb_retrieve(const char *); | |
347 | int pkgdb_dump(void); | 348 | int pkgdb_dump(void); | |
348 | int pkgdb_remove(const char *); | 349 | int pkgdb_remove(const char *); | |
349 | int pkgdb_remove_pkg(const char *); | 350 | int pkgdb_remove_pkg(const char *); | |
350 | char *pkgdb_refcount_dir(void); | 351 | char *pkgdb_refcount_dir(void); | |
351 | char *_pkgdb_getPKGDB_FILE(char *, unsigned); | 352 | char *_pkgdb_getPKGDB_FILE(char *, unsigned); | |
352 | const char *_pkgdb_getPKGDB_DIR(void); | 353 | const char *_pkgdb_getPKGDB_DIR(void); |
@@ -1,27 +1,27 @@ | @@ -1,27 +1,27 @@ | |||
1 | /* $NetBSD: plist.c,v 1.17.4.9 2008/08/10 22:09:38 joerg Exp $ */ | 1 | /* $NetBSD: plist.c,v 1.17.4.10 2008/08/11 15:58:15 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 | #ifndef lint | 10 | #ifndef lint | |
11 | #if 0 | 11 | #if 0 | |
12 | static const char *rcsid = "from FreeBSD Id: plist.c,v 1.24 1997/10/08 07:48:15 charnier Exp"; | 12 | static const char *rcsid = "from FreeBSD Id: plist.c,v 1.24 1997/10/08 07:48:15 charnier Exp"; | |
13 | #else | 13 | #else | |
14 | __RCSID("$NetBSD: plist.c,v 1.17.4.9 2008/08/10 22:09:38 joerg Exp $"); | 14 | __RCSID("$NetBSD: plist.c,v 1.17.4.10 2008/08/11 15:58:15 joerg Exp $"); | |
15 | #endif | 15 | #endif | |
16 | #endif | 16 | #endif | |
17 | 17 | |||
18 | /* | 18 | /* | |
19 | * FreeBSD install - a package for the installation and maintainance | 19 | * FreeBSD install - a package for the installation and maintainance | |
20 | * of non-core utilities. | 20 | * of non-core utilities. | |
21 | * | 21 | * | |
22 | * Redistribution and use in source and binary forms, with or without | 22 | * Redistribution and use in source and binary forms, with or without | |
23 | * modification, are permitted provided that the following conditions | 23 | * modification, are permitted provided that the following conditions | |
24 | * are met: | 24 | * are met: | |
25 | * 1. Redistributions of source code must retain the above copyright | 25 | * 1. Redistributions of source code must retain the above copyright | |
26 | * notice, this list of conditions and the following disclaimer. | 26 | * notice, this list of conditions and the following disclaimer. | |
27 | * 2. Redistributions in binary form must reproduce the above copyright | 27 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -343,37 +343,34 @@ parse_plist(package_t *pkg, const char * | @@ -343,37 +343,34 @@ parse_plist(package_t *pkg, const char * | |||
343 | } | 343 | } | |
344 | } else { | 344 | } else { | |
345 | cmd = PLIST_FILE; | 345 | cmd = PLIST_FILE; | |
346 | } | 346 | } | |
347 | add_plist(pkg, cmd, cp); | 347 | add_plist(pkg, cmd, cp); | |
348 | free(cp); | 348 | free(cp); | |
349 | } | 349 | } | |
350 | } | 350 | } | |
351 | 351 | |||
352 | /* | 352 | /* | |
353 | * Read a packing list from a file | 353 | * Read a packing list from a file | |
354 | */ | 354 | */ | |
355 | void | 355 | void | |
356 | read_plist(package_t *pkg, FILE * fp) | 356 | append_plist(package_t *pkg, FILE * fp) | |
357 | { | 357 | { | |
358 | char pline[MaxPathSize]; | 358 | char pline[MaxPathSize]; | |
359 | char *cp; | 359 | char *cp; | |
360 | int cmd; | 360 | int cmd; | |
361 | int len; | 361 | int len; | |
362 | int free_cp; | 362 | int free_cp; | |
363 | 363 | |||
364 | pkg->head = NULL; | |||
365 | pkg->tail = NULL; | |||
366 | ||||
367 | while (fgets(pline, MaxPathSize, fp) != (char *) NULL) { | 364 | while (fgets(pline, MaxPathSize, fp) != (char *) NULL) { | |
368 | for (len = strlen(pline); len && | 365 | for (len = strlen(pline); len && | |
369 | isspace((unsigned char) pline[len - 1]);) { | 366 | isspace((unsigned char) pline[len - 1]);) { | |
370 | pline[--len] = '\0'; | 367 | pline[--len] = '\0'; | |
371 | } | 368 | } | |
372 | if (len == 0) { | 369 | if (len == 0) { | |
373 | continue; | 370 | continue; | |
374 | } | 371 | } | |
375 | free_cp = 0; | 372 | free_cp = 0; | |
376 | if (*(cp = pline) == CMD_CHAR) { | 373 | if (*(cp = pline) == CMD_CHAR) { | |
377 | if ((cmd = plist_cmd(pline + 1, &cp)) == FAIL) { | 374 | if ((cmd = plist_cmd(pline + 1, &cp)) == FAIL) { | |
378 | warnx("Unrecognised PLIST command `%s'", pline); | 375 | warnx("Unrecognised PLIST command `%s'", pline); | |
379 | continue; | 376 | continue; | |
@@ -382,26 +379,35 @@ read_plist(package_t *pkg, FILE * fp) | @@ -382,26 +379,35 @@ read_plist(package_t *pkg, FILE * fp) | |||
382 | free(cp); | 379 | free(cp); | |
383 | cp = NULL; | 380 | cp = NULL; | |
384 | } | 381 | } | |
385 | free_cp = 1; | 382 | free_cp = 1; | |
386 | } else { | 383 | } else { | |
387 | cmd = PLIST_FILE; | 384 | cmd = PLIST_FILE; | |
388 | } | 385 | } | |
389 | add_plist(pkg, cmd, cp); | 386 | add_plist(pkg, cmd, cp); | |
390 | if (free_cp) | 387 | if (free_cp) | |
391 | free(cp); | 388 | free(cp); | |
392 | } | 389 | } | |
393 | } | 390 | } | |
394 | 391 | |||
392 | void | |||
393 | read_plist(package_t *pkg, FILE * fp) | |||
394 | { | |||
395 | pkg->head = NULL; | |||
396 | pkg->tail = NULL; | |||
397 | ||||
398 | append_plist(pkg, fp); | |||
399 | } | |||
400 | ||||
395 | /* | 401 | /* | |
396 | * Write a packing list to a file, converting commands to ASCII equivs | 402 | * Write a packing list to a file, converting commands to ASCII equivs | |
397 | */ | 403 | */ | |
398 | void | 404 | void | |
399 | write_plist(package_t *pkg, FILE * fp, char *realprefix) | 405 | write_plist(package_t *pkg, FILE * fp, char *realprefix) | |
400 | { | 406 | { | |
401 | plist_t *p; | 407 | plist_t *p; | |
402 | const cmd_t *cmdp; | 408 | const cmd_t *cmdp; | |
403 | 409 | |||
404 | for (p = pkg->head; p; p = p->next) { | 410 | for (p = pkg->head; p; p = p->next) { | |
405 | if (p->type == PLIST_FILE) { | 411 | if (p->type == PLIST_FILE) { | |
406 | /* Fast-track files - these are the most common */ | 412 | /* Fast-track files - these are the most common */ | |
407 | (void) fprintf(fp, "%s\n", p->name); | 413 | (void) fprintf(fp, "%s\n", p->name); |