Deleted Added
full compact
perform.c (81699) perform.c (84670)
1#ifndef lint
2static const char rcsid[] =
1#ifndef lint
2static const char rcsid[] =
3 "$FreeBSD: head/usr.sbin/pkg_install/add/perform.c 81699 2001-08-15 14:22:01Z sobomax $";
3 "$FreeBSD: head/usr.sbin/pkg_install/add/perform.c 84670 2001-10-08 17:01:35Z sobomax $";
4#endif
5
6/*
7 * FreeBSD install - a package for the installation and maintainance
8 * of non-core utilities.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions

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

23 *
24 */
25
26#include <err.h>
27#include <paths.h>
28#include "lib.h"
29#include "add.h"
30
4#endif
5
6/*
7 * FreeBSD install - a package for the installation and maintainance
8 * of non-core utilities.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions

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

23 *
24 */
25
26#include <err.h>
27#include <paths.h>
28#include "lib.h"
29#include "add.h"
30
31#include <libgen.h>
31#include <signal.h>
32#include <sys/wait.h>
33
34static int pkg_do(char *);
35static int sanity_check(char *);
36static char LogDir[FILENAME_MAX];
37static int zapLogDir; /* Should we delete LogDir? */
38

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

62 * to be hacked, I guess.. :) -jkh]
63 */
64static int
65pkg_do(char *pkg)
66{
67 char pkg_fullname[FILENAME_MAX];
68 char playpen[FILENAME_MAX];
69 char extract_contents[FILENAME_MAX];
32#include <signal.h>
33#include <sys/wait.h>
34
35static int pkg_do(char *);
36static int sanity_check(char *);
37static char LogDir[FILENAME_MAX];
38static int zapLogDir; /* Should we delete LogDir? */
39

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

63 * to be hacked, I guess.. :) -jkh]
64 */
65static int
66pkg_do(char *pkg)
67{
68 char pkg_fullname[FILENAME_MAX];
69 char playpen[FILENAME_MAX];
70 char extract_contents[FILENAME_MAX];
70 char *where_to, *tmp, *extract;
71 char *where_to, *extract;
71 FILE *cfile;
72 int code;
73 PackingList p;
74 struct stat sb;
75 int inPlace;
76 /* support for separate pre/post install scripts */
77 int new_m = 0;
78 char pre_script[FILENAME_MAX] = INSTALL_FNAME;

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

351 if (Verbose)
352 printf("Running pre-install for %s..\n", PkgName);
353 if (!Fake && vsystem("./%s %s %s", pre_script, PkgName, pre_arg)) {
354 warnx("install script returned error status");
355 unlink(pre_script);
356 code = 1;
357 goto success; /* nothing to uninstall yet */
358 }
72 FILE *cfile;
73 int code;
74 PackingList p;
75 struct stat sb;
76 int inPlace;
77 /* support for separate pre/post install scripts */
78 int new_m = 0;
79 char pre_script[FILENAME_MAX] = INSTALL_FNAME;

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

352 if (Verbose)
353 printf("Running pre-install for %s..\n", PkgName);
354 if (!Fake && vsystem("./%s %s %s", pre_script, PkgName, pre_arg)) {
355 warnx("install script returned error status");
356 unlink(pre_script);
357 code = 1;
358 goto success; /* nothing to uninstall yet */
359 }
359 if (new_m) unlink(pre_script);
360 }
361
362 /* Now finally extract the entire show if we're not going direct */
363 if (!inPlace && !Fake)
364 extract_plist(".", &Plist);
365
366 if (!Fake && fexists(MTREE_FNAME)) {
367 if (Verbose)
368 printf("Running mtree for %s..\n", PkgName);
369 p = find_plist(&Plist, PLIST_CWD);
370 if (Verbose)
371 printf("mtree -U -f %s -d -e -p %s >%s\n", MTREE_FNAME, p ? p->name : "/", _PATH_DEVNULL);
372 if (!Fake) {
373 if (vsystem("/usr/sbin/mtree -U -f %s -d -e -p %s >%s", MTREE_FNAME, p ? p->name : "/", _PATH_DEVNULL))
374 warnx("mtree returned a non-zero status - continuing");
375 }
360 }
361
362 /* Now finally extract the entire show if we're not going direct */
363 if (!inPlace && !Fake)
364 extract_plist(".", &Plist);
365
366 if (!Fake && fexists(MTREE_FNAME)) {
367 if (Verbose)
368 printf("Running mtree for %s..\n", PkgName);
369 p = find_plist(&Plist, PLIST_CWD);
370 if (Verbose)
371 printf("mtree -U -f %s -d -e -p %s >%s\n", MTREE_FNAME, p ? p->name : "/", _PATH_DEVNULL);
372 if (!Fake) {
373 if (vsystem("/usr/sbin/mtree -U -f %s -d -e -p %s >%s", MTREE_FNAME, p ? p->name : "/", _PATH_DEVNULL))
374 warnx("mtree returned a non-zero status - continuing");
375 }
376 unlink(MTREE_FNAME);
377 }
378
379 /* Run the installation script one last time? */
380 if (!NoInstall && fexists(post_script)) {
381 vsystem("chmod +x %s", post_script); /* make sure */
382 if (Verbose)
383 printf("Running post-install for %s..\n", PkgName);
384 if (!Fake && vsystem("./%s %s %s", post_script, PkgName, post_arg)) {
385 warnx("install script returned error status");
386 unlink(post_script);
387 code = 1;
388 goto fail;
389 }
376 }
377
378 /* Run the installation script one last time? */
379 if (!NoInstall && fexists(post_script)) {
380 vsystem("chmod +x %s", post_script); /* make sure */
381 if (Verbose)
382 printf("Running post-install for %s..\n", PkgName);
383 if (!Fake && vsystem("./%s %s %s", post_script, PkgName, post_arg)) {
384 warnx("install script returned error status");
385 unlink(post_script);
386 code = 1;
387 goto fail;
388 }
390 unlink(post_script);
391 }
392
393 /* Time to record the deed? */
394 if (!NoRecord && !Fake) {
395 char contents[FILENAME_MAX];
396 FILE *cfile;
397
398 if (getuid() != 0)

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

410 warnx("can't record package into '%s', you're on your own!",
411 LogDir);
412 bzero(LogDir, FILENAME_MAX);
413 code = 1;
414 goto success; /* close enough for government work */
415 }
416 /* Make sure pkg_info can read the entry */
417 vsystem("chmod a+rx %s", LogDir);
389 }
390
391 /* Time to record the deed? */
392 if (!NoRecord && !Fake) {
393 char contents[FILENAME_MAX];
394 FILE *cfile;
395
396 if (getuid() != 0)

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

408 warnx("can't record package into '%s', you're on your own!",
409 LogDir);
410 bzero(LogDir, FILENAME_MAX);
411 code = 1;
412 goto success; /* close enough for government work */
413 }
414 /* Make sure pkg_info can read the entry */
415 vsystem("chmod a+rx %s", LogDir);
416 move_file(".", DESC_FNAME, LogDir);
417 move_file(".", COMMENT_FNAME, LogDir);
418 if (fexists(INSTALL_FNAME))
419 move_file(".", INSTALL_FNAME, LogDir);
420 if (fexists(POST_INSTALL_FNAME))
421 move_file(".", POST_INSTALL_FNAME, LogDir);
418 if (fexists(DEINSTALL_FNAME))
419 move_file(".", DEINSTALL_FNAME, LogDir);
420 if (fexists(POST_DEINSTALL_FNAME))
421 move_file(".", POST_DEINSTALL_FNAME, LogDir);
422 if (fexists(REQUIRE_FNAME))
423 move_file(".", REQUIRE_FNAME, LogDir);
422 if (fexists(DEINSTALL_FNAME))
423 move_file(".", DEINSTALL_FNAME, LogDir);
424 if (fexists(POST_DEINSTALL_FNAME))
425 move_file(".", POST_DEINSTALL_FNAME, LogDir);
426 if (fexists(REQUIRE_FNAME))
427 move_file(".", REQUIRE_FNAME, LogDir);
428 if (fexists(DISPLAY_FNAME))
429 move_file(".", DISPLAY_FNAME, LogDir);
430 if (fexists(MTREE_FNAME))
431 move_file(".", MTREE_FNAME, LogDir);
424 sprintf(contents, "%s/%s", LogDir, CONTENTS_FNAME);
425 cfile = fopen(contents, "w");
426 if (!cfile) {
427 warnx("can't open new contents file '%s'! can't register pkg",
428 contents);
429 goto success; /* can't log, but still keep pkg */
430 }
431 write_plist(&Plist, cfile);
432 fclose(cfile);
432 sprintf(contents, "%s/%s", LogDir, CONTENTS_FNAME);
433 cfile = fopen(contents, "w");
434 if (!cfile) {
435 warnx("can't open new contents file '%s'! can't register pkg",
436 contents);
437 goto success; /* can't log, but still keep pkg */
438 }
439 write_plist(&Plist, cfile);
440 fclose(cfile);
433 move_file(".", DESC_FNAME, LogDir);
434 move_file(".", COMMENT_FNAME, LogDir);
435 if (fexists(DISPLAY_FNAME))
436 move_file(".", DISPLAY_FNAME, LogDir);
437 for (p = Plist.head; p ; p = p->next) {
438 if (p->type != PLIST_PKGDEP)
439 continue;
440 if (Verbose)
441 printf("Attempting to record dependency on package '%s'\n", p->name);
442 sprintf(contents, "%s/%s/%s", LOG_DIR, basename(p->name),
443 REQUIRED_BY_FNAME);
444 cfile = fopen(contents, "a");

--- 83 unchanged lines hidden ---
441 for (p = Plist.head; p ; p = p->next) {
442 if (p->type != PLIST_PKGDEP)
443 continue;
444 if (Verbose)
445 printf("Attempting to record dependency on package '%s'\n", p->name);
446 sprintf(contents, "%s/%s/%s", LOG_DIR, basename(p->name),
447 REQUIRED_BY_FNAME);
448 cfile = fopen(contents, "a");

--- 83 unchanged lines hidden ---