perform.c (178753) | perform.c (206043) |
---|---|
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 178753 2008-05-03 22:56:50Z pav $"); | 22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/delete/perform.c 206043 2010-04-01 14:27:29Z flz $"); |
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(char *, char *); --- 96 unchanged lines hidden (view full) --- 127 int i, len; 128 int isinstalled; 129 /* support for separate pre/post install scripts */ 130 int new_m = 0, dep_count = 0; 131 const char *pre_script = DEINSTALL_FNAME; 132 const char *post_script, *pre_arg, *post_arg; 133 struct reqr_by_entry *rb_entry; 134 struct reqr_by_head *rb_list; | 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(char *, char *); --- 96 unchanged lines hidden (view full) --- 127 int i, len; 128 int isinstalled; 129 /* support for separate pre/post install scripts */ 130 int new_m = 0, dep_count = 0; 131 const char *pre_script = DEINSTALL_FNAME; 132 const char *post_script, *pre_arg, *post_arg; 133 struct reqr_by_entry *rb_entry; 134 struct reqr_by_head *rb_list; |
135 int fd; 136 struct stat sb; |
|
135 136 if (!pkg || !(len = strlen(pkg))) 137 return 1; 138 if (pkg[len - 1] == '/') 139 pkg[len - 1] = '\0'; 140 141 /* Reset some state */ 142 if (Plist.head) --- 73 unchanged lines hidden (view full) --- 216 217 if (!p) { 218 warnx("package '%s' doesn't have a prefix", pkg); 219 return 1; 220 } 221 222 setenv(PKG_PREFIX_VNAME, p->name, 1); 223 | 137 138 if (!pkg || !(len = strlen(pkg))) 139 return 1; 140 if (pkg[len - 1] == '/') 141 pkg[len - 1] = '\0'; 142 143 /* Reset some state */ 144 if (Plist.head) --- 73 unchanged lines hidden (view full) --- 218 219 if (!p) { 220 warnx("package '%s' doesn't have a prefix", pkg); 221 return 1; 222 } 223 224 setenv(PKG_PREFIX_VNAME, p->name, 1); 225 |
224 if (fexists(REQUIRE_FNAME)) { | 226 if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) { 227 fstat(fd, &sb); 228 fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ 229 close(fd); |
225 if (Verbose) 226 printf("Executing 'require' script.\n"); | 230 if (Verbose) 231 printf("Executing 'require' script.\n"); |
227 vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */ | |
228 if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) { 229 warnx("package %s fails requirements %s", pkg, 230 Force ? "" : "- not deleted"); 231 if (!Force) 232 return 1; 233 } 234 } 235 --- 9 unchanged lines hidden (view full) --- 245 } else if (fexists(DEINSTALL_FNAME)) { 246 post_script = DEINSTALL_FNAME; 247 pre_arg = "DEINSTALL"; 248 post_arg = "POST-DEINSTALL"; 249 } else { 250 post_script = pre_arg = post_arg = NULL; 251 } 252 | 232 if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) { 233 warnx("package %s fails requirements %s", pkg, 234 Force ? "" : "- not deleted"); 235 if (!Force) 236 return 1; 237 } 238 } 239 --- 9 unchanged lines hidden (view full) --- 249 } else if (fexists(DEINSTALL_FNAME)) { 250 post_script = DEINSTALL_FNAME; 251 pre_arg = "DEINSTALL"; 252 post_arg = "POST-DEINSTALL"; 253 } else { 254 post_script = pre_arg = post_arg = NULL; 255 } 256 |
253 if (!NoDeInstall && pre_script != NULL && fexists(pre_script)) { | 257 if (!NoDeInstall && pre_script != NULL && (fd = open(pre_script, O_RDWR)) != -1) { |
254 if (Fake) 255 printf("Would execute de-install script at this point.\n"); 256 else { | 258 if (Fake) 259 printf("Would execute de-install script at this point.\n"); 260 else { |
257 vsystem("/bin/chmod +x %s", pre_script); /* make sure */ | 261 fstat(fd, &sb); 262 fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ 263 close(fd); |
258 if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) { 259 warnx("deinstall script returned error status"); 260 if (!Force) 261 return 1; 262 } 263 } 264 } 265 --- 55 unchanged lines hidden (view full) --- 321 "couldn't entirely delete package (perhaps the packing list is\n" 322 "incorrectly specified?)"); 323 324 if (chdir(LogDir) == FAIL) { 325 warnx("unable to change directory to %s! deinstall failed", LogDir); 326 return 1; 327 } 328 | 264 if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) { 265 warnx("deinstall script returned error status"); 266 if (!Force) 267 return 1; 268 } 269 } 270 } 271 --- 55 unchanged lines hidden (view full) --- 327 "couldn't entirely delete package (perhaps the packing list is\n" 328 "incorrectly specified?)"); 329 330 if (chdir(LogDir) == FAIL) { 331 warnx("unable to change directory to %s! deinstall failed", LogDir); 332 return 1; 333 } 334 |
329 if (!NoDeInstall && post_script != NULL && fexists(post_script)) { | 335 if (!NoDeInstall && post_script != NULL && (fd = open(post_script, O_RDWR)) != -1) { |
330 if (Fake) 331 printf("Would execute post-deinstall script at this point.\n"); 332 else { | 336 if (Fake) 337 printf("Would execute post-deinstall script at this point.\n"); 338 else { |
333 vsystem("/bin/chmod +x %s", post_script); /* make sure */ | 339 fstat(fd, &sb); 340 fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ 341 close(fd); |
334 if (vsystem("./%s %s %s", post_script, pkg, post_arg)) { 335 warnx("post-deinstall script returned error status"); 336 if (!Force) 337 return 1; 338 } 339 } 340 } 341 --- 76 unchanged lines hidden --- | 342 if (vsystem("./%s %s %s", post_script, pkg, post_arg)) { 343 warnx("post-deinstall script returned error status"); 344 if (!Force) 345 return 1; 346 } 347 } 348 } 349 --- 76 unchanged lines hidden --- |