Deleted Added
full compact
perform.c (96388) perform.c (96392)
1/*
2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 5 unchanged lines hidden (view full) ---

14 * Jordan K. Hubbard
15 * 18 July 1993
16 *
17 * This is the main body of the create module.
18 *
19 */
20
21#include <sys/cdefs.h>
1/*
2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 5 unchanged lines hidden (view full) ---

14 * Jordan K. Hubbard
15 * 18 July 1993
16 *
17 * This is the main body of the create module.
18 *
19 */
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/create/perform.c 96388 2002-05-11 03:48:49Z alfred $");
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/create/perform.c 96392 2002-05-11 04:17:55Z alfred $");
23
24#include "lib.h"
25#include "create.h"
26
27#include <err.h>
28#include <libgen.h>
29#include <signal.h>
30#include <stdlib.h>

--- 59 unchanged lines hidden (view full) ---

90 get_dash_string(&Desc);
91 if (!strcmp(Contents, "-"))
92 pkg_in = stdin;
93 else {
94 pkg_in = fopen(Contents, "r");
95 if (!pkg_in) {
96 cleanup(0);
97 errx(2, "%s: unable to open contents file '%s' for input",
23
24#include "lib.h"
25#include "create.h"
26
27#include <err.h>
28#include <libgen.h>
29#include <signal.h>
30#include <stdlib.h>

--- 59 unchanged lines hidden (view full) ---

90 get_dash_string(&Desc);
91 if (!strcmp(Contents, "-"))
92 pkg_in = stdin;
93 else {
94 pkg_in = fopen(Contents, "r");
95 if (!pkg_in) {
96 cleanup(0);
97 errx(2, "%s: unable to open contents file '%s' for input",
98 __FUNCTION__, Contents);
98 __func__, Contents);
99 }
100 }
101 plist.head = plist.tail = NULL;
102
103 /* Stick the dependencies, if any, at the top */
104 if (Pkgdeps) {
105 char **deps, *deporigin;
106 int i;

--- 7 unchanged lines hidden (view full) ---

114 cp = strpbrk(++cp, " \t\n")) {
115 ndeps++;
116 }
117
118 if (ndeps != 0) {
119 /* Create easy to use NULL-terminated list */
120 deps = alloca(sizeof(*deps) * ndeps + 1);
121 if (deps == NULL) {
99 }
100 }
101 plist.head = plist.tail = NULL;
102
103 /* Stick the dependencies, if any, at the top */
104 if (Pkgdeps) {
105 char **deps, *deporigin;
106 int i;

--- 7 unchanged lines hidden (view full) ---

114 cp = strpbrk(++cp, " \t\n")) {
115 ndeps++;
116 }
117
118 if (ndeps != 0) {
119 /* Create easy to use NULL-terminated list */
120 deps = alloca(sizeof(*deps) * ndeps + 1);
121 if (deps == NULL) {
122 errx(2, "%s: alloca() failed", __FUNCTION__);
122 errx(2, "%s: alloca() failed", __func__);
123 /* Not reached */
124 }
125 for (i = 0; Pkgdeps;) {
126 cp = strsep(&Pkgdeps, " \t\n");
127 if (*cp) {
128 deps[i] = cp;
129 i++;
130 }

--- 40 unchanged lines hidden (view full) ---

171 * Run down the list and see if we've named it, if not stick in a name
172 * at the top.
173 */
174 if (find_plist(&plist, PLIST_NAME) == NULL)
175 add_plist_top(&plist, PLIST_NAME, basename(pkg));
176
177 if (asprintf(&cp, "PKG_FORMAT_REVISION:%d.%d", PLIST_FMT_VER_MAJOR,
178 PLIST_FMT_VER_MINOR) == -1) {
123 /* Not reached */
124 }
125 for (i = 0; Pkgdeps;) {
126 cp = strsep(&Pkgdeps, " \t\n");
127 if (*cp) {
128 deps[i] = cp;
129 i++;
130 }

--- 40 unchanged lines hidden (view full) ---

171 * Run down the list and see if we've named it, if not stick in a name
172 * at the top.
173 */
174 if (find_plist(&plist, PLIST_NAME) == NULL)
175 add_plist_top(&plist, PLIST_NAME, basename(pkg));
176
177 if (asprintf(&cp, "PKG_FORMAT_REVISION:%d.%d", PLIST_FMT_VER_MAJOR,
178 PLIST_FMT_VER_MINOR) == -1) {
179 errx(2, "%s: asprintf() failed", __FUNCTION__);
179 errx(2, "%s: asprintf() failed", __func__);
180 }
181 add_plist_top(&plist, PLIST_COMMENT, cp);
182 free(cp);
183
184 /*
185 * We're just here for to dump out a revised plist for the FreeBSD ports
186 * hack. It's not a real create in progress.
187 */

--- 64 unchanged lines hidden (view full) ---

252 add_plist(&plist, PLIST_MTREE, MTREE_FNAME);
253 }
254
255 /* Finally, write out the packing list */
256 fp = fopen(CONTENTS_FNAME, "w");
257 if (!fp) {
258 cleanup(0);
259 errx(2, "%s: can't open file %s for writing",
180 }
181 add_plist_top(&plist, PLIST_COMMENT, cp);
182 free(cp);
183
184 /*
185 * We're just here for to dump out a revised plist for the FreeBSD ports
186 * hack. It's not a real create in progress.
187 */

--- 64 unchanged lines hidden (view full) ---

252 add_plist(&plist, PLIST_MTREE, MTREE_FNAME);
253 }
254
255 /* Finally, write out the packing list */
256 fp = fopen(CONTENTS_FNAME, "w");
257 if (!fp) {
258 cleanup(0);
259 errx(2, "%s: can't open file %s for writing",
260 __FUNCTION__, CONTENTS_FNAME);
260 __func__, CONTENTS_FNAME);
261 }
262 write_plist(&plist, fp);
263 if (fclose(fp)) {
264 cleanup(0);
265 errx(2, "%s: error while closing %s",
261 }
262 write_plist(&plist, fp);
263 if (fclose(fp)) {
264 cleanup(0);
265 errx(2, "%s: error while closing %s",
266 __FUNCTION__, CONTENTS_FNAME);
266 __func__, CONTENTS_FNAME);
267 }
268
269 /* And stick it into a tar ball */
270 make_dist(home, pkg, suf, &plist);
271
272 /* Cleanup */
273 free(Comment);
274 free(Desc);

--- 48 unchanged lines hidden (view full) ---

323 args[nargs] = NULL;
324
325 if (Verbose)
326 printf("Creating %star ball in '%s'\n", cname, tball);
327
328 /* Set up a pipe for passing the filenames, and fork off a tar process. */
329 if (pipe(pipefds) == -1) {
330 cleanup(0);
267 }
268
269 /* And stick it into a tar ball */
270 make_dist(home, pkg, suf, &plist);
271
272 /* Cleanup */
273 free(Comment);
274 free(Desc);

--- 48 unchanged lines hidden (view full) ---

323 args[nargs] = NULL;
324
325 if (Verbose)
326 printf("Creating %star ball in '%s'\n", cname, tball);
327
328 /* Set up a pipe for passing the filenames, and fork off a tar process. */
329 if (pipe(pipefds) == -1) {
330 cleanup(0);
331 errx(2, "%s: cannot create pipe", __FUNCTION__);
331 errx(2, "%s: cannot create pipe", __func__);
332 }
333 if ((pid = fork()) == -1) {
334 cleanup(0);
332 }
333 if ((pid = fork()) == -1) {
334 cleanup(0);
335 errx(2, "%s: cannot fork process for tar", __FUNCTION__);
335 errx(2, "%s: cannot fork process for tar", __func__);
336 }
337 if (pid == 0) { /* The child */
338 dup2(pipefds[0], 0);
339 close(pipefds[0]);
340 close(pipefds[1]);
341 execv("/usr/bin/tar", (char * const *)(uintptr_t)args);
342 cleanup(0);
336 }
337 if (pid == 0) { /* The child */
338 dup2(pipefds[0], 0);
339 close(pipefds[0]);
340 close(pipefds[1]);
341 execv("/usr/bin/tar", (char * const *)(uintptr_t)args);
342 cleanup(0);
343 errx(2, "%s: failed to execute tar command", __FUNCTION__);
343 errx(2, "%s: failed to execute tar command", __func__);
344 }
345
346 /* Meanwhile, back in the parent process ... */
347 close(pipefds[0]);
348 if ((totar = fdopen(pipefds[1], "w")) == NULL) {
349 cleanup(0);
344 }
345
346 /* Meanwhile, back in the parent process ... */
347 close(pipefds[0]);
348 if ((totar = fdopen(pipefds[1], "w")) == NULL) {
349 cleanup(0);
350 errx(2, "%s: fdopen failed", __FUNCTION__);
350 errx(2, "%s: fdopen failed", __func__);
351 }
352
353 fprintf(totar, "%s\n", CONTENTS_FNAME);
354 fprintf(totar, "%s\n", COMMENT_FNAME);
355 fprintf(totar, "%s\n", DESC_FNAME);
356
357 if (Install)
358 fprintf(totar, "%s\n", INSTALL_FNAME);

--- 19 unchanged lines hidden (view full) ---

378 p = p->next;
379 }
380
381 fclose(totar);
382 wait(&ret);
383 /* assume either signal or bad exit is enough for us */
384 if (ret) {
385 cleanup(0);
351 }
352
353 fprintf(totar, "%s\n", CONTENTS_FNAME);
354 fprintf(totar, "%s\n", COMMENT_FNAME);
355 fprintf(totar, "%s\n", DESC_FNAME);
356
357 if (Install)
358 fprintf(totar, "%s\n", INSTALL_FNAME);

--- 19 unchanged lines hidden (view full) ---

378 p = p->next;
379 }
380
381 fclose(totar);
382 wait(&ret);
383 /* assume either signal or bad exit is enough for us */
384 if (ret) {
385 cleanup(0);
386 errx(2, "%s: tar command failed with code %d", __FUNCTION__, ret);
386 errx(2, "%s: tar command failed with code %d", __func__, ret);
387 }
388}
389
390static void
391sanity_check()
392{
393 if (!Comment) {
394 cleanup(0);
395 errx(2, "%s: required package comment string is missing (-c comment)",
387 }
388}
389
390static void
391sanity_check()
392{
393 if (!Comment) {
394 cleanup(0);
395 errx(2, "%s: required package comment string is missing (-c comment)",
396 __FUNCTION__);
396 __func__);
397 }
398 if (!Desc) {
399 cleanup(0);
400 errx(2, "%s: required package description string is missing (-d desc)",
397 }
398 if (!Desc) {
399 cleanup(0);
400 errx(2, "%s: required package description string is missing (-d desc)",
401 __FUNCTION__);
401 __func__);
402 }
403 if (!Contents) {
404 cleanup(0);
405 errx(2, "%s: required package contents list is missing (-f [-]file)",
402 }
403 if (!Contents) {
404 cleanup(0);
405 errx(2, "%s: required package contents list is missing (-f [-]file)",
406 __FUNCTION__);
406 __func__);
407 }
408}
409
410
411/* Clean up those things that would otherwise hang around */
412void
413cleanup(int sig)
414{

--- 50 unchanged lines hidden ---
407 }
408}
409
410
411/* Clean up those things that would otherwise hang around */
412void
413cleanup(int sig)
414{

--- 50 unchanged lines hidden ---