Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/usr.sbin/pkg_install/delete Pull up revisions 1.26-1.27:



details:   https://anonhg.NetBSD.org/src/rev/0d3860345d85
branches:  netbsd-1-4
changeset: 469383:0d3860345d85
user:      he <he%NetBSD.org@localhost>
date:      Mon Sep 13 22:09:03 1999 +0000

description:
Pull up revisions 1.26-1.27:
  Provide full pathnames for chgrp and chown, fixing PR#8250.
  Bring closer to /usr/share/misc/style with the aid of indent(1).
(hubertf)

diffstat:

 usr.sbin/pkg_install/delete/perform.c |  920 +++++++++++++++++----------------
 1 files changed, 465 insertions(+), 455 deletions(-)

diffs (truncated from 1039 to 300 lines):

diff -r 28addd5f1df0 -r 0d3860345d85 usr.sbin/pkg_install/delete/perform.c
--- a/usr.sbin/pkg_install/delete/perform.c     Mon Sep 13 22:06:59 1999 +0000
+++ b/usr.sbin/pkg_install/delete/perform.c     Mon Sep 13 22:09:03 1999 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.23.2.1 1999/08/22 17:54:55 he Exp $      */
+/*     $NetBSD: perform.c,v 1.23.2.2 1999/09/13 22:09:03 he Exp $      */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.15 1997/10/13 15:03:52 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.23.2.1 1999/08/22 17:54:55 he Exp $");
+__RCSID("$NetBSD: perform.c,v 1.23.2.2 1999/09/13 22:09:03 he Exp $");
 #endif
 #endif
 
@@ -65,8 +65,8 @@
 
 /* In which direction to search in require_find() */
 typedef enum {
-    FIND_UP, FIND_DOWN
-} rec_find_t;
+       FIND_UP, FIND_DOWN
+}       rec_find_t;
 
 static int require_find_recursive_up(lpkg_t *);
 static int require_find_recursive_down(lpkg_t *, package_t *);
@@ -87,549 +87,559 @@
 static void
 sanity_check(char *pkg)
 {
-    if (!fexists(CONTENTS_FNAME)) {
-       cleanup(0);
-       errx(2, "installed package %s has no %s file!", pkg, CONTENTS_FNAME);
-    }
+       if (!fexists(CONTENTS_FNAME)) {
+               cleanup(0);
+               errx(2, "installed package %s has no %s file!",
+                    pkg, CONTENTS_FNAME);
+       }
 }
 
 void
 cleanup(int sig)
 {
-    /* Nothing to do */
-    if(sig)    /* in case this is ever used as a signal handler */
-       exit(1);
+       /* Nothing to do */
+       if (sig)                /* in case this is ever used as a signal handler */
+               exit(1);
 }
 
-/* deppkgname is the pkg from which's +REQUIRED_BY file we are
+/*
+ * deppkgname is the pkg from which's +REQUIRED_BY file we are
  * about to remove pkg2delname. This function is called from
  * findmatchingname(), deppkgname is expanded from a (possible) pattern.
  */
 int
 undepend(const char *deppkgname, char *pkg2delname)
 {
-     char fname[FILENAME_MAX], ftmp[FILENAME_MAX];
-     char fbuf[FILENAME_MAX];
-     FILE *fp, *fpwr;
-     char *tmp;
-     int s;
+       char    fname[FILENAME_MAX], ftmp[FILENAME_MAX];
+       char    fbuf[FILENAME_MAX];
+       FILE   *fp, *fpwr;
+       char   *tmp;
+       int     s;
 
-     (void) snprintf(fname, sizeof(fname), "%s/%s/%s",
-        (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR,
-        deppkgname, REQUIRED_BY_FNAME);
-     fp = fopen(fname, "r");
-     if (fp == NULL) {
-        warnx("couldn't open dependency file `%s'", fname);
-        return 0;
-     }
-     (void) snprintf(ftmp, sizeof(ftmp), "%s.XXXXXX", fname);
-     s = mkstemp(ftmp);
-     if (s == -1) {
-        fclose(fp);
-        warnx("couldn't open temp file `%s'", ftmp);
-        return 0;
-     }
-     fpwr = fdopen(s, "w");
-     if (fpwr == NULL) {
-        close(s);
-        fclose(fp);
-        warnx("couldn't fdopen temp file `%s'", ftmp);
-        remove(ftmp);
-        return 0;
-     }
-     while (fgets(fbuf, sizeof(fbuf), fp) != NULL) {
-        if (fbuf[strlen(fbuf)-1] == '\n')
-            fbuf[strlen(fbuf)-1] = '\0';
-        if (strcmp(fbuf, pkg2delname))         /* no match */
-            fputs(fbuf, fpwr), putc('\n', fpwr);
-     }
-     (void) fclose(fp);
-     if (fchmod(s, 0644) == FAIL) {
-        warnx("error changing permission of temp file `%s'", ftmp);
-        fclose(fpwr);
-        remove(ftmp);
-        return 0;
-     }
-     if (fclose(fpwr) == EOF) {
-        warnx("error closing temp file `%s'", ftmp);
-        remove(ftmp);
-        return 0;
-     }
-     if (rename(ftmp, fname) == -1)
-        warnx("error renaming `%s' to `%s'", ftmp, fname);
-     remove(ftmp);                     /* just in case */
-     
-     return 0;
+       (void) snprintf(fname, sizeof(fname), "%s/%s/%s",
+           (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR,
+           deppkgname, REQUIRED_BY_FNAME);
+       fp = fopen(fname, "r");
+       if (fp == NULL) {
+               warnx("couldn't open dependency file `%s'", fname);
+               return 0;
+       }
+       (void) snprintf(ftmp, sizeof(ftmp), "%s.XXXXXX", fname);
+       s = mkstemp(ftmp);
+       if (s == -1) {
+               fclose(fp);
+               warnx("couldn't open temp file `%s'", ftmp);
+               return 0;
+       }
+       fpwr = fdopen(s, "w");
+       if (fpwr == NULL) {
+               close(s);
+               fclose(fp);
+               warnx("couldn't fdopen temp file `%s'", ftmp);
+               remove(ftmp);
+               return 0;
+       }
+       while (fgets(fbuf, sizeof(fbuf), fp) != NULL) {
+               if (fbuf[strlen(fbuf) - 1] == '\n')
+                       fbuf[strlen(fbuf) - 1] = '\0';
+               if (strcmp(fbuf, pkg2delname))  /* no match */
+                       fputs(fbuf, fpwr), putc('\n', fpwr);
+       }
+       (void) fclose(fp);
+       if (fchmod(s, 0644) == FAIL) {
+               warnx("error changing permission of temp file `%s'", ftmp);
+               fclose(fpwr);
+               remove(ftmp);
+               return 0;
+       }
+       if (fclose(fpwr) == EOF) {
+               warnx("error closing temp file `%s'", ftmp);
+               remove(ftmp);
+               return 0;
+       }
+       if (rename(ftmp, fname) == -1)
+               warnx("error renaming `%s' to `%s'", ftmp, fname);
+       remove(ftmp);           /* just in case */
+
+       return 0;
 }
 
-/* delete from directory 'home' all packages on lpkg_list
- * if tryall is set, ignore errors from pkg_delete */
+/*
+ * Delete from directory 'home' all packages on lpkg_list. 
+ * If tryall is set, ignore errors from pkg_delete(1).
+ */
 int
 require_delete(char *home, int tryall)
 {
-    lpkg_t *lpp;
-    int rv, fail;
-    char *tmp;
-    int oldcwd;
+       lpkg_t *lpp;
+       int     rv, fail;
+       char   *tmp;
+       int     oldcwd;
+
+       /* save cwd */
+       oldcwd = open(".", O_RDONLY, 0);
+       if (oldcwd == -1)
+               err(1, "cannot open \".\"");
+
+       (void) snprintf(pkgdir, sizeof(pkgdir), "%s",
+           (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR);
 
-    /* save cwd */
-    oldcwd=open(".", O_RDONLY, 0);
-    if (oldcwd == -1)
-       err(1, "cannot open \".\"");
+       /* walk list of things to delete */
+       fail = 0;
+       lpp = TAILQ_FIRST(&lpdelq);
+       for (; lpp; lpp = TAILQ_NEXT(lpp, lp_link)) {
+               /* go to the db dir */
+               if (chdir(pkgdir) == FAIL) {
+                       warnx("unable to change directory to %s, deinstall failed (1)",
+                           pkgdir);
+                       fail = 1;
+                       break;
+               }
 
-    (void)snprintf(pkgdir, sizeof(pkgdir), "%s",
-       (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR);
+               /* look to see if package was already deleted */
+               if (!fexists(lpp->lp_name)) {
+                       warnx("%s appears to have been deleted", lpp->lp_name);
+                       continue;
+               }
 
-    /* walk list of things to delete */
-    fail = 0;
-    lpp = TAILQ_FIRST(&lpdelq);
-    for (; lpp; lpp = TAILQ_NEXT(lpp, lp_link)) {
-       /* go to the db dir */
-       if (chdir(pkgdir) == FAIL) {
-           warnx("unable to change directory to %s, deinstall failed (1)",
-               pkgdir);
-           fail = 1;
-           break;
-       }
+               /* return home for execution of command */
+               if (chdir(home) == FAIL) {
+                       warnx("unable to change directory to %s, deinstall failed (2)", home);
+                       fail = 1;
+                       break;
+               }
+
+               if (Verbose)
+                       printf("deinstalling %s\n", lpp->lp_name);
 
-       /* look to see if package was already deleted */
-       if (!fexists(lpp->lp_name)) {
-           warnx("%s appears to have been deleted", lpp->lp_name);
-           continue;
-       }
+               /* delete the package */
+               if (Fake)
+                       rv = 0;
+               else
+                       rv = vsystem("%s %s %s %s %s %s %s %s %s", ProgramPath,
+                           Prefix ? "-p" : "",
+                           Prefix ? Prefix : "",
+                           Verbose ? "-v" : "",
+                           Force ? "-f" : "",
+                           NoDeInstall ? "-D" : "",
+                           CleanDirs ? "-d" : "",
+                           Fake ? "-n" : "",
+                           lpp->lp_name);
 
-       /* return home for execution of command */
-       if (chdir(home) == FAIL) {
-           warnx("unable to change directory to %s, deinstall failed (2)", home);
-           fail = 1;
-           break;
+               /* check for delete failure */
+               if (rv && !tryall) {
+                       fail = 1;
+                       warnx("had problem removing %s%s", lpp->lp_name,
+                           Force ? ", continuing" : "");
+                       if (!Force)
+                               break;
+               }
        }
 
-       if (Verbose)
-               printf("deinstalling %s\n", lpp->lp_name);
-
-       /* delete the package */
-       if (Fake)
-           rv = 0;
-       else
-           rv = vsystem("%s %s %s %s %s %s %s %s %s", ProgramPath,
-               Prefix ? "-p" : "",
-               Prefix ? Prefix : "",
-               Verbose ? "-v" : "",
-               Force ? "-f" : "",
-               NoDeInstall ? "-D" : "",
-               CleanDirs ? "-d" : "",
-               Fake ? "-n" : "",
-               lpp->lp_name);
+       /* cleanup list */
+       while ((lpp = TAILQ_FIRST(&lpdelq))) {
+               TAILQ_REMOVE(&lpdelq, lpp, lp_link);
+               free_lpkg(lpp);
+       }
 
-       /* check for delete failure */
-       if (rv && !tryall) {
-           fail = 1;
-           warnx("had problem removing %s%s", lpp->lp_name,
-               Force ? ", continuing" : "");



Home | Main Index | Thread Index | Old Index