Fix defattr/attr screwup.
authorjbj <devnull@localhost>
Wed, 27 Jan 1999 19:40:01 +0000 (19:40 +0000)
committerjbj <devnull@localhost>
Wed, 27 Jan 1999 19:40:01 +0000 (19:40 +0000)
CVS patchset: 2767
CVS date: 1999/01/27 19:40:01

build/files.c
po/rpm.pot

index d44137c..12abd10 100644 (file)
@@ -111,10 +111,10 @@ static void freeAttrRec(AttrRec *ar) {
 }
 
 static void dupAttrRec(AttrRec *oar, AttrRec *nar) {
-    if (oar != nar) {
-       freeAttrRec(nar);
-       nar = oar;      /* structure assignment */
-    }
+    if (oar == nar)    /* XXX pathological paranoia */
+       return;
+    freeAttrRec(nar);
+    *nar = *oar;               /* structure assignment */
     if (nar->ar_fmodestr)
        nar->ar_fmodestr = strdup(nar->ar_fmodestr);
     if (nar->ar_dmodestr)
@@ -125,6 +125,18 @@ static void dupAttrRec(AttrRec *oar, AttrRec *nar) {
        nar->ar_group = strdup(nar->ar_group);
 }
 
+#if 0
+static void dumpAttrRec(const char *msg, AttrRec *ar) {
+    if (msg)
+       fprintf(stderr, "%s:\t", msg);
+    fprintf(stderr, "(%s, %s, %s, %s)\n",
+       ar->ar_fmodestr,
+       ar->ar_user,
+       ar->ar_group,
+       ar->ar_dmodestr);
+}
+#endif
+
 /* glob_pattern_p() taken from bash
  * Copyright (C) 1985, 1988, 1989 Free Software Foundation, Inc.
  *
@@ -316,7 +328,7 @@ static int parseForVerify(char *buf, struct FileList *fl)
                continue;
        }
        if (!strcmp(p, "not")) {
-           not = 1;
+           not ^= 1;
        } else {
            rpmError(RPMERR_BADSPEC, _("Invalid %s token: %s"), name, p);
            fl->processingFailed = 1;
@@ -803,30 +815,30 @@ static void genCpioListAndHeader(struct FileList *fl,
                               &(flp->gname), 1);
        headerAddOrAppendEntry(h, RPMTAG_FILEMTIMES, RPM_INT32_TYPE,
                               &(flp->fl_mtime), 1);
-    if (sizeof(flp->fl_mode) != sizeof(uint_16)) {
+      if (sizeof(flp->fl_mode) != sizeof(uint_16)) {
        uint_16 pmode = (uint_16)flp->fl_mode;
        headerAddOrAppendEntry(h, RPMTAG_FILEMODES, RPM_INT16_TYPE,
                               &(pmode), 1);
-    } else {
+      } else {
        headerAddOrAppendEntry(h, RPMTAG_FILEMODES, RPM_INT16_TYPE,
                               &(flp->fl_mode), 1);
-    }
-    if (sizeof(flp->fl_rdev) != sizeof(uint_16)) {
+      }
+      if (sizeof(flp->fl_rdev) != sizeof(uint_16)) {
        uint_16 prdev = (uint_16)flp->fl_rdev;
        headerAddOrAppendEntry(h, RPMTAG_FILERDEVS, RPM_INT16_TYPE,
                               &(prdev), 1);
-    } else {
+      } else {
        headerAddOrAppendEntry(h, RPMTAG_FILERDEVS, RPM_INT16_TYPE,
                               &(flp->fl_rdev), 1);
-    }
-    if (sizeof(flp->fl_dev) != sizeof(uint_32)) {
+      }
+      if (sizeof(flp->fl_dev) != sizeof(uint_32)) {
        uint_32 pdevice = (uint_32)flp->fl_dev;
        headerAddOrAppendEntry(h, RPMTAG_FILEDEVICES, RPM_INT32_TYPE,
                               &(pdevice), 1);
-    } else {
+      } else {
        headerAddOrAppendEntry(h, RPMTAG_FILEDEVICES, RPM_INT32_TYPE,
                               &(flp->fl_dev), 1);
-    }
+      }
        headerAddOrAppendEntry(h, RPMTAG_FILEINODES, RPM_INT32_TYPE,
                               &(flp->fl_ino), 1);
        headerAddOrAppendEntry(h, RPMTAG_FILELANGS, RPM_STRING_ARRAY_TYPE,
@@ -884,7 +896,6 @@ static void freeFileList(FileListRec *fileList, int count)
 
 static int addFile(struct FileList *fl, const char *name, struct stat *statp)
 {
-    FileListRec *flp;
     char fileName[BUFSIZ];
     char diskName[BUFSIZ];
     struct stat statbuf;
@@ -980,13 +991,16 @@ static int addFile(struct FileList *fl, const char *name, struct stat *statp)
        fileGname = getGname(fileGid);
     }
        
+#if 0  /* XXX this looks dumb to me */
     if (! (fileUname && fileGname)) {
        rpmError(RPMERR_BADSPEC, _("Bad owner/group: %s\n"), diskName);
        fl->processingFailed = 1;
        return RPMERR_BADSPEC;
     }
+#endif
     
-    rpmMessage(RPMMESS_DEBUG, _("File %d: %s\n"), fl->fileCount, fileName);
+    rpmMessage(RPMMESS_DEBUG, _("File %4d: 0%o %s.%s\t %s\n"), fl->fileCount,
+       fileMode, fileUname, fileGname, fileName);
 
     /* Add to the file list */
     if (fl->fileListRecsUsed == fl->fileListRecsAlloced) {
@@ -995,30 +1009,31 @@ static int addFile(struct FileList *fl, const char *name, struct stat *statp)
                        fl->fileListRecsAlloced * sizeof(*(fl->fileList)));
     }
            
-    flp = &fl->fileList[fl->fileListRecsUsed];
-
-    flp->fl_st = *statp;       /* structure assignment */
-    flp->fl_mode = fileMode;
-    flp->fl_uid = fileUid;
-    flp->fl_gid = fileGid;
-
-    flp->fileName = strdup(fileName);
-    flp->diskName = strdup(diskName);
-    flp->uname = fileUname;
-    flp->gname = fileGname;
-
-    if (fl->currentLang) {
-       flp->lang = strdup(fl->currentLang);
-    } else if (! parseForRegexLang(fileName, &lang)) {
-       flp->lang = strdup(lang);
-    } else {
-       flp->lang = strdup("");
-    }
+    {  FileListRec * flp = &fl->fileList[fl->fileListRecsUsed];
+
+       flp->fl_st = *statp;    /* structure assignment */
+       flp->fl_mode = fileMode;
+       flp->fl_uid = fileUid;
+       flp->fl_gid = fileGid;
+
+       flp->fileName = strdup(fileName);
+       flp->diskName = strdup(diskName);
+       flp->uname = fileUname;
+       flp->gname = fileGname;
+
+       if (fl->currentLang) {
+           flp->lang = strdup(fl->currentLang);
+       } else if (! parseForRegexLang(fileName, &lang)) {
+           flp->lang = strdup(lang);
+       } else {
+           flp->lang = strdup("");
+       }
 
-    flp->flags = fl->currentFlags;
-    flp->verifyFlags = fl->currentVerifyFlags;
+       flp->flags = fl->currentFlags;
+       flp->verifyFlags = fl->currentVerifyFlags;
 
-    fl->totalFileSize += flp->fl_size;
+       fl->totalFileSize += flp->fl_size;
+    }
 
     fl->fileListRecsUsed++;
     fl->fileCount++;
@@ -1075,28 +1090,24 @@ static int processPackageFiles(Spec spec, Package pkg,
     const char *fileName;
     char buf[BUFSIZ];
     FILE *f;
-
-    AttrRec specialDocAttrRec;
+    AttrRec specialDocAttrRec = empty_ar;      /* structure assignment */
     char *specialDoc = NULL;
     
-    specialDocAttrRec = empty_ar;
-
     pkg->cpioList = NULL;
     pkg->cpioCount = 0;
 
     if (pkg->fileFile) {
+       const char *ffn;
+
        /* XXX FIXME: add %{_buildsubdir} and use rpmGetPath() */
-       strcpy(buf, "%{_builddir}/");
-       expandMacros(spec, spec->macros, buf, sizeof(buf));
-       if (spec->buildSubdir) {
-           strcat(buf, spec->buildSubdir);
-           strcat(buf, "/");
-       }
-       strcat(buf, pkg->fileFile);
+       ffn = rpmGetPath("%{_builddir}/",
+           (spec->buildSubdir ? spec->buildSubdir : "") ,
+           "/", pkg->fileFile, NULL);
 
-       if ((f = fopen(buf, "r")) == NULL) {
+       if ((f = fopen(ffn, "r")) == NULL) {
            rpmError(RPMERR_BADFILENAME,
                     _("Could not open %%files file: %s"), pkg->fileFile);
+           FREE(ffn);
            return RPMERR_BADFILENAME;
        }
        while (fgets(buf, sizeof(buf), f)) {
@@ -1108,11 +1119,14 @@ static int processPackageFiles(Spec spec, Package pkg,
            appendStringBuf(pkg->fileList, buf);
        }
        fclose(f);
+       FREE(ffn);
     }
     
     /* Init the file list structure */
     
-    fl.buildRoot = spec->buildRoot ? spec->buildRoot : "";
+    /* XXX spec->buildRoot == NULL, then strdup("") is returned */
+    fl.buildRoot = rpmGetPath(spec->buildRoot, NULL);
+
     if (headerGetEntry(pkg->header, RPMTAG_DEFAULTPREFIX,
                       NULL, (void *)&fl.prefix, NULL)) {
        fl.prefix = strdup(fl.prefix);
@@ -1218,6 +1232,7 @@ static int processPackageFiles(Spec spec, Package pkg,
     }
     
     /* Clean up */
+    FREE(fl.buildRoot);
     FREE(fl.prefix);
 
     freeAttrRec(&fl.cur_ar);
index 698fbaa..c19da21 100644 (file)
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-01-26 16:30-0500\n"
+"POT-Creation-Date: 1999-01-27 14:31-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1537,172 +1537,172 @@ msgstr ""
 msgid "syntax error in expression"
 msgstr ""
 
-#: ../build/files.c:234
+#: ../build/files.c:244
 #, c-format
 msgid "TIMECHECK failure: %s\n"
 msgstr ""
 
-#: ../build/files.c:279 ../build/files.c:291 ../build/files.c:360
-#: ../build/files.c:372 ../build/files.c:398
+#: ../build/files.c:289 ../build/files.c:301 ../build/files.c:370
+#: ../build/files.c:382 ../build/files.c:409
 #, c-format
 msgid "Bad %s() syntax: %s"
 msgstr ""
 
-#: ../build/files.c:321
+#: ../build/files.c:331
 #, c-format
 msgid "Invalid %s token: %s"
 msgstr ""
 
-#: ../build/files.c:383
+#: ../build/files.c:393
 msgid "No files after %%defattr(): %s"
 msgstr ""
 
-#: ../build/files.c:408
+#: ../build/files.c:419
 #, c-format
 msgid "Bad %s() mode spec: %s"
 msgstr ""
 
-#: ../build/files.c:420
+#: ../build/files.c:431
 #, c-format
 msgid "Bad %s() dirmode spec: %s"
 msgstr ""
 
-#: ../build/files.c:471
+#: ../build/files.c:484
 msgid "Bad %%config() syntax: %s"
 msgstr ""
 
-#: ../build/files.c:489
+#: ../build/files.c:502
 msgid "Invalid %%config token: %s"
 msgstr ""
 
-#: ../build/files.c:512 ../build/files.c:524 ../build/files.c:537
+#: ../build/files.c:525 ../build/files.c:537 ../build/files.c:550
 msgid "Bad %%lang() syntax: %s"
 msgstr ""
 
-#: ../build/files.c:543
+#: ../build/files.c:556
 msgid "%%lang() entries are 2 characters: %s"
 msgstr ""
 
-#: ../build/files.c:549
+#: ../build/files.c:562
 msgid "Only one entry in %%lang(): %s"
 msgstr ""
 
-#: ../build/files.c:631
+#: ../build/files.c:644
 msgid "Hit limit for %%docdir"
 msgstr ""
 
-#: ../build/files.c:637
+#: ../build/files.c:650
 msgid "Only one arg for %%docdir"
 msgstr ""
 
 #. We already got a file -- error
-#: ../build/files.c:662
+#: ../build/files.c:675
 #, c-format
 msgid "Two files on one line: %s"
 msgstr ""
 
-#: ../build/files.c:675
+#: ../build/files.c:688
 #, c-format
 msgid "File must begin with \"/\": %s"
 msgstr ""
 
-#: ../build/files.c:687
+#: ../build/files.c:700
 msgid "Can't mix special %%doc with other forms: %s"
 msgstr ""
 
-#: ../build/files.c:775
+#: ../build/files.c:788
 #, c-format
 msgid "File listed twice: %s"
 msgstr ""
 
-#: ../build/files.c:928
+#: ../build/files.c:940
 #, c-format
 msgid "File doesn't match prefix (%s): %s"
 msgstr ""
 
-#: ../build/files.c:938 ../build/files.c:1053
+#: ../build/files.c:950 ../build/files.c:1073
 #, c-format
 msgid "File not found: %s"
 msgstr ""
 
-#: ../build/files.c:984
+#: ../build/files.c:1001
 #, c-format
 msgid "Bad owner/group: %s\n"
 msgstr ""
 
-#: ../build/files.c:989
+#: ../build/files.c:1007
 #, c-format
-msgid "File %d: %s\n"
+msgid "File %4d: 0%o %s.%s\t %s\n"
 msgstr ""
 
-#: ../build/files.c:1037
+#: ../build/files.c:1057
 #, c-format
 msgid "File needs leading \"/\": %s"
 msgstr ""
 
-#: ../build/files.c:1099
+#: ../build/files.c:1114
 msgid "Could not open %%files file: %s"
 msgstr ""
 
-#: ../build/files.c:1105 ../build/pack.c:448
+#: ../build/files.c:1121 ../build/pack.c:448
 #, c-format
 msgid "line: %s"
 msgstr ""
 
-#: ../build/files.c:1369 ../build/parsePrep.c:40
+#: ../build/files.c:1389 ../build/parsePrep.c:40
 #, c-format
 msgid "Bad owner/group: %s"
 msgstr ""
 
-#: ../build/files.c:1423
+#: ../build/files.c:1443
 #, c-format
 msgid "Couldn't exec %s"
 msgstr ""
 
-#: ../build/files.c:1427
+#: ../build/files.c:1447
 #, c-format
 msgid "Couldn't fork %s"
 msgstr ""
 
-#: ../build/files.c:1477
+#: ../build/files.c:1497
 #, c-format
 msgid "%s failed"
 msgstr ""
 
-#: ../build/files.c:1481
+#: ../build/files.c:1501
 #, c-format
 msgid "failed to write all data to %s"
 msgstr ""
 
-#: ../build/files.c:1515
+#: ../build/files.c:1535
 msgid "Finding provides...\n"
 msgstr ""
 
-#: ../build/files.c:1522
+#: ../build/files.c:1542
 msgid "Failed to find provides"
 msgstr ""
 
-#: ../build/files.c:1541
+#: ../build/files.c:1561
 msgid "Finding requires...\n"
 msgstr ""
 
-#: ../build/files.c:1548
+#: ../build/files.c:1568
 msgid "Failed to find requires"
 msgstr ""
 
-#: ../build/files.c:1582
+#: ../build/files.c:1602
 msgid "Provides:"
 msgstr ""
 
-#: ../build/files.c:1597
+#: ../build/files.c:1617
 msgid "Prereqs:"
 msgstr ""
 
-#: ../build/files.c:1609
+#: ../build/files.c:1629
 msgid "Requires:"
 msgstr ""
 
-#: ../build/files.c:1633
+#: ../build/files.c:1653
 #, c-format
 msgid "Processing files: %s\n"
 msgstr ""