RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Alexey Tourbin
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   05-Jul-2008 03:24:20
  Branch: HEAD                             Handle: 2008070501242000

  Modified files:
    rpm                     CHANGES
    rpm/build               files.c

  Log:
    build/files.c: check if the same files are packaged into a few
    sub-packages

  Summary:
    Revision    Changes     Path
    1.2460      +1  -0      rpm/CHANGES
    1.328       +55 -0      rpm/build/files.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2459 -r1.2460 CHANGES
  --- rpm/CHANGES       4 Jul 2008 22:25:03 -0000       1.2459
  +++ rpm/CHANGES       5 Jul 2008 01:24:20 -0000       1.2460
  @@ -1,5 +1,6 @@
   
   5.1.0 -> 5.2a0:
  +    - at: rpmbuild: check if the same files are packaged into a few 
sub-packages.
       - jbj: rpmwget: add --foodebug options, more wget-style spewage.
       - jbj: rpmdav: capture connection state transitions w wget-style spewage.
       - jbj: rpmdav: add global rpmioHttpConnectTimeoutSecs (unused) for now.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/build/files.c
  ============================================================================
  $ cvs diff -u -r1.327 -r1.328 files.c
  --- rpm/build/files.c 5 Jul 2008 00:06:41 -0000       1.327
  +++ rpm/build/files.c 5 Jul 2008 01:24:20 -0000       1.328
  @@ -2850,6 +2850,60 @@
       return rc;
   }
   
  +/* auxiliary function for checkDuplicateFiles() */
  +/* XXX need to pass Header because fi->h is NULL */
  +static int fiIntersect(rpmfi fi1, rpmfi fi2, Header h1, Header h2)
  +{
  +    int n = 0;
  +    int i1, i2;
  +    const char *fn1, *fn2;
  +    const char *N1 = NULL, *N2 = NULL;
  +
  +    fi1 = rpmfiInit(fi1, 0);
  +    while ((i1 = rpmfiNext(fi1)) >= 0) {
  +     if (S_ISDIR(rpmfiFMode(fi1)))
  +         continue;
  +     fn1 = rpmfiFN(fi1);
  +     fi2 = rpmfiInit(fi2, 0);
  +     while ((i2 = rpmfiNext(fi2)) >= 0) {
  +         if (S_ISDIR(rpmfiFMode(fi2)))
  +             /[EMAIL PROTECTED]@*/ continue;
  +         fn2 = rpmfiFN(fi2);
  +         if (strcmp(fn1, fn2))
  +             /[EMAIL PROTECTED]@*/ continue;
  +         if (!N1) headerNEVRA(h1, &N1, NULL, NULL, NULL, NULL);
  +         if (!N2) headerNEVRA(h2, &N2, NULL, NULL, NULL, NULL);
  +         rpmlog(RPMLOG_WARNING,
  +                _("file %s is packaged into both %s and %s\n"),
  +                fn1, N1, N2);
  +         n++;
  +     }
  +    }
  +    return n;
  +}
  +
  +/**
  + * Check if the same files are packaged into a few sub-packages.
  + * @param spec               spec file control structure
  + * @return           number of duplicate files
  + */
  +static int checkDuplicateFiles(Spec spec)
  +{
  +    int n = 0;
  +    Package pkg1, pkg2;
  +
  +    for (pkg1 = spec->packages; pkg1->next; pkg1 = pkg1->next) {
  +     rpmfi fi1 = rpmfiNew(NULL, pkg1->header, RPMTAG_BASENAMES, 0);
  +     for (pkg2 = pkg1->next; pkg2; pkg2 = pkg2->next) {
  +         rpmfi fi2 = rpmfiNew(NULL, pkg2->header, RPMTAG_BASENAMES, 0);
  +         n += fiIntersect(fi1, fi2, pkg1->header, pkg2->header);
  +         fi2 = rpmfiFree(fi2);
  +     }
  +     fi1 = rpmfiFree(fi1);
  +    }
  +    return n;
  +}
  +
   /[EMAIL PROTECTED]@*/
   rpmRC processBinaryFiles(Spec spec, int installSpecialDoc, int test)
   {
  @@ -2898,6 +2952,7 @@
       if (res == RPMRC_OK) {
        if (checkUnpackagedFiles(spec) > 0)
            res = RPMRC_FAIL;
  +     (void) checkDuplicateFiles(spec);
       }
       
       return res;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to