Add support for a new macro, %{_docdir}. It can be used to specify
authorPaul Nasrat <pnasrat@redhat.com>
Mon, 16 Apr 2007 12:12:32 +0000 (13:12 +0100)
committerPaul Nasrat <pnasrat@redhat.com>
Mon, 16 Apr 2007 12:12:32 +0000 (13:12 +0100)
the name of the directory for %doc files.
Default is "%{NAME}-%{VERSION}", SUSE uses just "%{NAME}".
rh#125514
Patch from OpenSuSE

build/files.c

index 49188a4..f1d6a19 100644 (file)
@@ -1006,11 +1006,23 @@ static int parseForSimple(/*@unused@*/Spec spec, Package pkg, char * buf,
            res = 1;
        } else {
        /* XXX WATCHOUT: buf is an arg */
-           {   const char *ddir, *n, *v;
-
-               (void) headerNVR(pkg->header, &n, &v, NULL);
-
-               ddir = rpmGetPath("%{_docdir}/", n, "-", v, NULL);
+          {
+               static char *_docdir_fmt= 0;
+               static int oneshot = 0;
+               const char *ddir, *fmt, *errstr;
+               if (!oneshot) {
+                   _docdir_fmt = rpmExpand("%{?_docdir_fmt}", NULL);
+                   if (!_docdir_fmt || !*_docdir_fmt)
+                       _docdir_fmt = "%{NAME}-%{VERSION}";
+                   oneshot = 1;
+               }
+               fmt = headerSprintf(pkg->header, _docdir_fmt, rpmTagTable, rpmHeaderFormats, &errstr);
+               if (!fmt) {
+                   rpmError(RPMERR_BADSPEC, _("illegal _docdir_fmt: %s\n"), errstr);
+                   fl->processingFailed = 1;
+                   res = 1;
+               }
+               ddir = rpmGetPath("%{_docdir}/", fmt, NULL);
                strcpy(buf, ddir);
                ddir = _free(ddir);
            }