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 delete 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 delete module. 18 * 19 */ 20 21#include <sys/cdefs.h> |
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/delete/perform.c 96388 2002-05-11 03:48:49Z alfred $"); | 22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/delete/perform.c 96392 2002-05-11 04:17:55Z alfred $"); |
23 24#include <err.h> 25#include "lib.h" 26#include "delete.h" 27 28static int pkg_do(char *); 29static void sanity_check(char *); 30static void undepend(PackingList, char *); --- 41 unchanged lines hidden (view full) --- 72 /* 73 * Copy values from the rb_list queue into argv-like NULL 74 * terminated list because requiredby() uses some static 75 * storage, while pkg_do() below will call this function, 76 * thus blowing our rb_list away. 77 */ 78 rbtmp = rb = alloca((errcode + 1) * sizeof(*rb)); 79 if (rb == NULL) { | 23 24#include <err.h> 25#include "lib.h" 26#include "delete.h" 27 28static int pkg_do(char *); 29static void sanity_check(char *); 30static void undepend(PackingList, char *); --- 41 unchanged lines hidden (view full) --- 72 /* 73 * Copy values from the rb_list queue into argv-like NULL 74 * terminated list because requiredby() uses some static 75 * storage, while pkg_do() below will call this function, 76 * thus blowing our rb_list away. 77 */ 78 rbtmp = rb = alloca((errcode + 1) * sizeof(*rb)); 79 if (rb == NULL) { |
80 warnx("%s(): alloca() failed", __FUNCTION__); | 80 warnx("%s(): alloca() failed", __func__); |
81 err_cnt++; 82 continue; 83 } 84 STAILQ_FOREACH(rb_entry, rb_list, link) { 85 *rbtmp = alloca(strlen(rb_entry->pkgname) + 1); 86 if (*rbtmp == NULL) { | 81 err_cnt++; 82 continue; 83 } 84 STAILQ_FOREACH(rb_entry, rb_list, link) { 85 *rbtmp = alloca(strlen(rb_entry->pkgname) + 1); 86 if (*rbtmp == NULL) { |
87 warnx("%s(): alloca() failed", __FUNCTION__); | 87 warnx("%s(): alloca() failed", __func__); |
88 err_cnt++; 89 continue; 90 } 91 strcpy(*rbtmp, rb_entry->pkgname); 92 rbtmp++; 93 } 94 *rbtmp = NULL; 95 --- 39 unchanged lines hidden (view full) --- 135 136 if (!fexists(LogDir)) { 137 warnx("no such package '%s' installed", pkg); 138 return 1; 139 } 140 141 if (!getcwd(home, FILENAME_MAX)) { 142 cleanup(0); | 88 err_cnt++; 89 continue; 90 } 91 strcpy(*rbtmp, rb_entry->pkgname); 92 rbtmp++; 93 } 94 *rbtmp = NULL; 95 --- 39 unchanged lines hidden (view full) --- 135 136 if (!fexists(LogDir)) { 137 warnx("no such package '%s' installed", pkg); 138 return 1; 139 } 140 141 if (!getcwd(home, FILENAME_MAX)) { 142 cleanup(0); |
143 errx(2, "%s: unable to get current working directory!", __FUNCTION__); | 143 errx(2, "%s: unable to get current working directory!", __func__); |
144 } 145 146 if (chdir(LogDir) == FAIL) { 147 warnx("unable to change directory to %s! deinstall failed", LogDir); 148 return 1; 149 } 150 151 if (Interactive == TRUE) { --- 83 unchanged lines hidden (view full) --- 235 if (!Force) 236 return 1; 237 } 238 } 239 } 240 241 if (chdir(home) == FAIL) { 242 cleanup(0); | 144 } 145 146 if (chdir(LogDir) == FAIL) { 147 warnx("unable to change directory to %s! deinstall failed", LogDir); 148 return 1; 149 } 150 151 if (Interactive == TRUE) { --- 83 unchanged lines hidden (view full) --- 235 if (!Force) 236 return 1; 237 } 238 } 239 } 240 241 if (chdir(home) == FAIL) { 242 cleanup(0); |
243 errx(2, "%s: unable to return to working directory %s!", __FUNCTION__, | 243 errx(2, "%s: unable to return to working directory %s!", __func__, |
244 home); 245 } 246 247 /* 248 * Some packages aren't packed right, so we need to just ignore 249 * delete_package()'s status. Ugh! :-( 250 */ 251 if (delete_package(FALSE, CleanDirs, &Plist) == FAIL) --- 16 unchanged lines hidden (view full) --- 268 if (!Force) 269 return 1; 270 } 271 } 272 } 273 274 if (chdir(home) == FAIL) { 275 cleanup(0); | 244 home); 245 } 246 247 /* 248 * Some packages aren't packed right, so we need to just ignore 249 * delete_package()'s status. Ugh! :-( 250 */ 251 if (delete_package(FALSE, CleanDirs, &Plist) == FAIL) --- 16 unchanged lines hidden (view full) --- 268 if (!Force) 269 return 1; 270 } 271 } 272 } 273 274 if (chdir(home) == FAIL) { 275 cleanup(0); |
276 errx(2, "%s: unable to return to working directory %s!", __FUNCTION__, | 276 errx(2, "%s: unable to return to working directory %s!", __func__, |
277 home); 278 } 279 280 if (!Fake) { 281 if (vsystem("%s -r%c %s", REMOVE_CMD, Force ? 'f' : ' ', LogDir)) { 282 warnx("couldn't remove log entry in %s, deinstall failed", LogDir); 283 if (!Force) 284 return 1; --- 11 unchanged lines hidden (view full) --- 296 return 0; 297} 298 299static void 300sanity_check(char *pkg) 301{ 302 if (!fexists(CONTENTS_FNAME)) { 303 cleanup(0); | 277 home); 278 } 279 280 if (!Fake) { 281 if (vsystem("%s -r%c %s", REMOVE_CMD, Force ? 'f' : ' ', LogDir)) { 282 warnx("couldn't remove log entry in %s, deinstall failed", LogDir); 283 if (!Force) 284 return 1; --- 11 unchanged lines hidden (view full) --- 296 return 0; 297} 298 299static void 300sanity_check(char *pkg) 301{ 302 if (!fexists(CONTENTS_FNAME)) { 303 cleanup(0); |
304 errx(2, "%s: installed package %s has no %s file!", __FUNCTION__, | 304 errx(2, "%s: installed package %s has no %s file!", __func__, |
305 pkg, CONTENTS_FNAME); 306 } 307} 308 309void 310cleanup(int sig) 311{ 312 if (sig) --- 47 unchanged lines hidden --- | 305 pkg, CONTENTS_FNAME); 306 } 307} 308 309void 310cleanup(int sig) 311{ 312 if (sig) --- 47 unchanged lines hidden --- |