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/create Pull up revision 1.19:



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

description:
Pull up revision 1.19:
  Bring closer to /usr/share/misc/style with the aid of indent(1).  (hubertf)

diffstat:

 usr.sbin/pkg_install/create/perform.c |  554 +++++++++++++++++----------------
 1 files changed, 278 insertions(+), 276 deletions(-)

diffs (truncated from 622 to 300 lines):

diff -r 4a8b2b2e5d19 -r 6cce5b55fba1 usr.sbin/pkg_install/create/perform.c
--- a/usr.sbin/pkg_install/create/perform.c     Mon Sep 13 22:02:00 1999 +0000
+++ b/usr.sbin/pkg_install/create/perform.c     Mon Sep 13 22:03:32 1999 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.17.2.1 1999/08/22 17:41:45 he Exp $      */
+/*     $NetBSD: perform.c,v 1.17.2.2 1999/09/13 22:03:32 he Exp $      */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.38 1997/10/13 15:03:51 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.17.2.1 1999/08/22 17:41:45 he Exp $");
+__RCSID("$NetBSD: perform.c,v 1.17.2.2 1999/09/13 22:03:32 he Exp $");
 #endif
 #endif
 
@@ -43,84 +43,84 @@
 static void
 make_dist(char *home, char *pkg, char *suffix, package_t *plist)
 {
-    char tball[FILENAME_MAX];
-    plist_t *p;
-    int ret;
-    char *args[50];    /* Much more than enough. */
-    int nargs = 0;
-    int pipefds[2];
-    FILE *totar;
-    pid_t pid;
+       char    tball[FILENAME_MAX];
+       plist_t *p;
+       int     ret;
+       char   *args[50];       /* Much more than enough. */
+       int     nargs = 0;
+       int     pipefds[2];
+       FILE   *totar;
+       pid_t   pid;
 
-    args[nargs++] = TAR_CMD;   /* argv[0] */
+       args[nargs++] = TAR_CMD;/* argv[0] */
 
-    if (*pkg == '/')
-       (void) snprintf(tball, sizeof(tball), "%s.%s", pkg, suffix);
-    else
-       (void) snprintf(tball, sizeof(tball), "%s/%s.%s", home, pkg, suffix);
+       if (*pkg == '/')
+               (void) snprintf(tball, sizeof(tball), "%s.%s", pkg, suffix);
+       else
+               (void) snprintf(tball, sizeof(tball), "%s/%s.%s", home, pkg, suffix);
 
-    args[nargs++] = "-c";
-    args[nargs++] = "-f";
-    args[nargs++] = tball;
-    if (strchr(suffix, 'z'))   /* Compress/gzip? */
-       args[nargs++] = "-z";
-    if (Dereference)
-       args[nargs++] = "-h";
-    if (ExcludeFrom) {
-       args[nargs++] = "-X";
-       args[nargs++] = ExcludeFrom;
-    }
-    args[nargs++] = "-T";      /* Take filenames from file instead of args. */
-    args[nargs++] = "-";       /* Use stdin for the file. */
-    args[nargs] = NULL;
+       args[nargs++] = "-c";
+       args[nargs++] = "-f";
+       args[nargs++] = tball;
+       if (strchr(suffix, 'z'))/* Compress/gzip? */
+               args[nargs++] = "-z";
+       if (Dereference)
+               args[nargs++] = "-h";
+       if (ExcludeFrom) {
+               args[nargs++] = "-X";
+               args[nargs++] = ExcludeFrom;
+       }
+       args[nargs++] = "-T";   /* Take filenames from file instead of args. */
+       args[nargs++] = "-";    /* Use stdin for the file. */
+       args[nargs] = NULL;
 
-    if (Verbose)
-       printf("Creating gzip'd %s ball in '%s'\n", TAR_CMD, tball);
+       if (Verbose)
+               printf("Creating gzip'd %s ball in '%s'\n", TAR_CMD, tball);
 
-    /* Set up a pipe for passing the filenames, and fork off a tar process. */
-    if (pipe(pipefds) == -1) {
-       cleanup(0);
-       errx(2, "cannot create pipe");
-    }
-    if ((pid = fork()) == -1) {
-       cleanup(0);
-       errx(2, "cannot fork process for %s", TAR_CMD);
-    }
-    if (pid == 0) {    /* The child */
-       dup2(pipefds[0], 0);
-       close(pipefds[0]);
-       close(pipefds[1]);
-       execv(TAR_FULLPATHNAME, args);
-       cleanup(0);
-       errx(2, "failed to execute %s command", TAR_CMD);
-    }
+       /* Set up a pipe for passing the filenames, and fork off a tar process. */
+       if (pipe(pipefds) == -1) {
+               cleanup(0);
+               errx(2, "cannot create pipe");
+       }
+       if ((pid = fork()) == -1) {
+               cleanup(0);
+               errx(2, "cannot fork process for %s", TAR_CMD);
+       }
+       if (pid == 0) {         /* The child */
+               dup2(pipefds[0], 0);
+               close(pipefds[0]);
+               close(pipefds[1]);
+               execv(TAR_FULLPATHNAME, args);
+               cleanup(0);
+               errx(2, "failed to execute %s command", TAR_CMD);
+       }
 
-    /* Meanwhile, back in the parent process ... */
-    close(pipefds[0]);
-    if ((totar = fdopen(pipefds[1], "w")) == NULL) {
-       cleanup(0);
-       errx(2, "fdopen failed");
-    }
+       /* Meanwhile, back in the parent process ... */
+       close(pipefds[0]);
+       if ((totar = fdopen(pipefds[1], "w")) == NULL) {
+               cleanup(0);
+               errx(2, "fdopen failed");
+       }
 
-    fprintf(totar, "%s\n", CONTENTS_FNAME);
-    fprintf(totar, "%s\n", COMMENT_FNAME);
-    fprintf(totar, "%s\n", DESC_FNAME);
+       fprintf(totar, "%s\n", CONTENTS_FNAME);
+       fprintf(totar, "%s\n", COMMENT_FNAME);
+       fprintf(totar, "%s\n", DESC_FNAME);
 
-    if (Install) {
-       fprintf(totar, "%s\n", INSTALL_FNAME);
-    }
-    if (DeInstall) {
-       fprintf(totar, "%s\n", DEINSTALL_FNAME);
-    }
-    if (Require) {
-       fprintf(totar, "%s\n", REQUIRE_FNAME);
-    }
-    if (Display) {
-       fprintf(totar, "%s\n", DISPLAY_FNAME);
-    }
-    if (Mtree) {
-       fprintf(totar, "%s\n", MTREE_FNAME);
-    }
+       if (Install) {
+               fprintf(totar, "%s\n", INSTALL_FNAME);
+       }
+       if (DeInstall) {
+               fprintf(totar, "%s\n", DEINSTALL_FNAME);
+       }
+       if (Require) {
+               fprintf(totar, "%s\n", REQUIRE_FNAME);
+       }
+       if (Display) {
+               fprintf(totar, "%s\n", DISPLAY_FNAME);
+       }
+       if (Mtree) {
+               fprintf(totar, "%s\n", MTREE_FNAME);
+       }
        if (BuildVersion) {
                (void) fprintf(totar, "%s\n", BUILD_VERSION_FNAME);
        }
@@ -128,243 +128,245 @@
                (void) fprintf(totar, "%s\n", BUILD_INFO_FNAME);
        }
 
-    for (p = plist->head; p; p = p->next) {
-       if (p->type == PLIST_FILE)
-           fprintf(totar, "%s\n", p->name);
-       else if (p->type == PLIST_CWD || p->type == PLIST_SRC)
-           fprintf(totar, "-C\n%s\n", p->name);
-       else if (p->type == PLIST_IGNORE)
-            p = p->next;
-    }
+       for (p = plist->head; p; p = p->next) {
+               if (p->type == PLIST_FILE)
+                       fprintf(totar, "%s\n", p->name);
+               else if (p->type == PLIST_CWD || p->type == PLIST_SRC)
+                       fprintf(totar, "-C\n%s\n", p->name);
+               else if (p->type == PLIST_IGNORE)
+                       p = p->next;
+       }
 
-    fclose(totar);
-    wait(&ret);
-    /* assume either signal or bad exit is enough for us */
-    if (ret) {
-       cleanup(0);
-       errx(2, "%s command failed with code %d", TAR_CMD, ret);
-    }
+       fclose(totar);
+       wait(&ret);
+       /* assume either signal or bad exit is enough for us */
+       if (ret) {
+               cleanup(0);
+               errx(2, "%s command failed with code %d", TAR_CMD, ret);
+       }
 }
 
 static void
 sanity_check(void)
 {
-    if (!Comment) {
-       cleanup(0);
-       errx(2, "required package comment string is missing (-c comment)");
-    }
-    if (!Desc) {
-       cleanup(0);
-       errx(2, "required package description string is missing (-d desc)");
-    }
-    if (!Contents) {
-       cleanup(0);
-       errx(2, "required package contents list is missing (-f [-]file)");
-    }
+       if (!Comment) {
+               cleanup(0);
+               errx(2, "required package comment string is missing (-c comment)");
+       }
+       if (!Desc) {
+               cleanup(0);
+               errx(2, "required package description string is missing (-d desc)");
+       }
+       if (!Contents) {
+               cleanup(0);
+               errx(2, "required package contents list is missing (-f [-]file)");
+       }
 }
 
 
-/* Clean up those things that would otherwise hang around */
+/*
+ * Clean up those things that would otherwise hang around
+ */
 void
 cleanup(int sig)
 {
-    static int alreadyCleaning;
-    void (*oldint)(int);
-    void (*oldhup)(int);
-    oldint = signal(SIGINT, SIG_IGN);
-    oldhup = signal(SIGHUP, SIG_IGN);
+       static int alreadyCleaning;
+       void    (*oldint) (int);
+       void    (*oldhup) (int);
+       oldint = signal(SIGINT, SIG_IGN);
+       oldhup = signal(SIGHUP, SIG_IGN);
 
-    if (!alreadyCleaning) {
-       alreadyCleaning = 1;
-       if (sig)
-           printf("Signal %d received, cleaning up.\n", sig);
-       leave_playpen(home);
-       if (sig)
-           exit(1);
-    }
-    signal(SIGINT, oldint);
-    signal(SIGHUP, oldhup);
+       if (!alreadyCleaning) {
+               alreadyCleaning = 1;
+               if (sig)
+                       printf("Signal %d received, cleaning up.\n", sig);
+               leave_playpen(home);
+               if (sig)
+                       exit(1);
+       }
+       signal(SIGINT, oldint);
+       signal(SIGHUP, oldhup);
 }
 
 int
 pkg_perform(lpkg_head_t *pkgs)
 {
-    char *pkg;
-    char *cp;
-    FILE *pkg_in, *fp;
-    package_t plist;
-    char *suffix;  /* What we tack on to the end of the finished package */
-    lpkg_t *lpp;
+       char   *pkg;
+       char   *cp;
+       FILE   *pkg_in, *fp;
+       package_t plist;
+       char   *suffix;         /* What we tack on to the end of the finished package */
+       lpkg_t *lpp;
 
-    lpp = TAILQ_FIRST(pkgs);
-    pkg = lpp->lp_name;                        /* Only one arg to create */
+       lpp = TAILQ_FIRST(pkgs);
+       pkg = lpp->lp_name;     /* Only one arg to create */
 



Home | Main Index | Thread Index | Old Index