RPM Community Forums

Mailing List Message of <rpm-cvs>

[CVS] RPM: rpm/ CHANGES rpm/lib/ rpminstall.c rpm/ macros.in

From: Jeff Johnson <jbj@rpm5.org>
Date: Sun 03 Feb 2008 - 21:12:33 CET
Message-Id: <20080203201233.745F0348458@rpm5.org>
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
  Module: rpm                              Date:   03-Feb-2008 21:12:33
  Branch: HEAD                             Handle: 2008020320123201

  Modified files:
    rpm                     CHANGES macros.in
    rpm/lib                 rpminstall.c

  Log:
    - jbj: add rpmcliWalkFirst() to search (possibly multiple) dirs.

  Summary:
    Revision    Changes     Path
    1.2128      +1  -0      rpm/CHANGES
    1.196       +71 -7      rpm/lib/rpminstall.c
    1.231       +4  -3      rpm/macros.in
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2127 -r1.2128 CHANGES
  --- rpm/CHANGES	3 Feb 2008 16:05:24 -0000	1.2127
  +++ rpm/CHANGES	3 Feb 2008 20:12:32 -0000	1.2128
  @@ -1,4 +1,5 @@
   5.0.0 -> 5.1a1:
  +    - jbj: add rpmcliWalkFirst() to search (possibly multiple) dirs.
       - rse: add _rpmgi_pattern_{glob,regex} macros for "+N" arg-to-path rewrite.
       - jbj: functional "+N-V-R.A" path-to-repository expansions with -i/-U.
       - jbj: mire.c: add STANDALONE test exerciser.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpminstall.c
  ============================================================================
  $ cvs diff -u -r1.195 -r1.196 rpminstall.c
  --- rpm/lib/rpminstall.c	3 Feb 2008 16:05:24 -0000	1.195
  +++ rpm/lib/rpminstall.c	3 Feb 2008 20:12:33 -0000	1.196
  @@ -332,14 +332,71 @@
       return 0;
   }
   
  +static const char * rpmcliWalkFirst(ARGV_t av, miRE mire)
  +{
  +    /* XXX use global ftsOpts? */
  +    int _ftsOpts = (FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOSTAT);
  +    FTS * ftsp = Fts_open((char *const *)av, _ftsOpts, NULL);
  +    FTSENT * fts;
  +    const char * fn = NULL;
  +    int xx;
  +
  +    if (ftsp != NULL)
  +    while((fts = Fts_read(ftsp)) != NULL) {
  +	switch (fts->fts_info) {
  +	/* No-op conditions. */
  +	case FTS_D:		/* preorder directory */
  +	case FTS_DP:		/* postorder directory */
  +	case FTS_DOT:		/* dot or dot-dot */
  +	    continue;
  +	    /*@notreached@*/ break;
  +	case FTS_F:		/* regular file */
  +	    if (mireRegexec(mire, fts->fts_accpath))
  +		continue;
  +	    break;
  +	/* Error conditions. */
  +	case FTS_NS:		/* stat(2) failed */
  +	case FTS_DNR:		/* unreadable directory */
  +	case FTS_ERR:		/* error; errno is set */
  +	case FTS_DC:		/* directory that causes cycles */
  +	case FTS_DEFAULT:	/* none of the above */
  +	case FTS_INIT:		/* initialized only */
  +	case FTS_NSOK:		/* no stat(2) requested */
  +	case FTS_SL:		/* symbolic link */
  +	case FTS_SLNONE:	/* symbolic link without target */
  +	case FTS_W:		/* whiteout object */
  +	default:
  +	    goto exit;
  +	    /*@notreached@*/ break;
  +	}
  +
  +	/* Stop on first file that matches. */
  +	fn = xstrdup(fts->fts_accpath);
  +	break;
  +    }
  +
  +exit:
  +    xx = Fts_close(ftsp);
  +    return fn;
  +}
  +
   static const char * rpmcliInstallElementPath(rpmts ts, const char * arg)
   {
  +#ifdef GLOB_ONLY
       /* XXX note the added "-*.rpm" to force globbing on '-' boundaries. */
       const char * fn = rpmGetPath(
   	"%{?_rpmgi_pattern_glob:%{_rpmgi_pattern_glob ", arg, "}}"
   	"%{!?_rpmgi_pattern_glob:", arg, "-*-*.*.rpm}",
   	NULL
       );
  +#else
  +    /* Create a glob pattern to match repository directories. */
  +    const char * fn = rpmGetPath(
  +	"%{?_rpmgi_pattern_glob}"
  +	"%{!?_rpmgi_pattern_glob:.}", "/",
  +	NULL
  +    );
  +#endif
       const char * mirePattern = rpmExpand(
           "%{?_rpmgi_pattern_regex:%{_rpmgi_pattern_regex ", arg, "}}"
           "%{!?_rpmgi_pattern_regex:", arg, "-[^-]+-[^-]+\\.[^.]+\\.rpm$}",
  @@ -349,19 +406,26 @@
       ARGV_t av = NULL;
       int ac = 0;
       int xx = mireRegcomp(mire, mirePattern);
  -    int i;
   
  -    /* Get list of candidate package paths. */
  +    /* Get explicit list of candidate repository directories. */
       xx = rpmGlob(fn, &ac, &av);
       fn = _free(fn);
   
       /* Filter out glibc <-> glibc-common confusions. */
  -    for (i = 0; i < ac; i++) {
  -	if (mireRegexec(mire, av[i]))
  -	    continue;
  -	fn = xstrdup(av[0]);
  -	break;
  +#ifdef	GLOB_ONLY
  +    {	int i;
  +	for (i = 0; i < ac; i++) {
  +	    if (mireRegexec(mire, av[i]))
  +		continue;
  +	    /* Stop on first file that matches. */
  +	    fn = xstrdup(av[0]);
  +	    break;
  +	}
       }
  +#else
  +    /* Walk (possibly multi-root'd) directories, until 1st match is found. */
  +    fn = rpmcliWalkFirst(av, mire);
  +#endif
   
       av = argvFree(av);
       mire = mireFree(mire);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/macros.in
  ============================================================================
  $ cvs diff -u -r1.230 -r1.231 macros.in
  --- rpm/macros.in	3 Feb 2008 16:05:24 -0000	1.230
  +++ rpm/macros.in	3 Feb 2008 20:12:32 -0000	1.231
  @@ -1,7 +1,7 @@
   #/*! \page config_macros Default configuration: @USRLIBRPM@/macros
   # \verbatim
   #
  -# $Id: macros.in,v 1.230 2008/02/03 16:05:24 jbj Exp $
  +# $Id: macros.in,v 1.231 2008/02/03 20:12:32 jbj Exp $
   #
   # This is a global RPM configuration file. All changes made here will
   # be lost when the rpm package is upgraded. Any per-system configuration
  @@ -981,8 +981,9 @@
   
   #
   # Pattern matching for installation via "+N-V-R.A" CLI arguments
  -%_rpmgi_pattern_glob()    %{_rpmdir}/%1-*-*.*.rpm
  -%_rpmgi_pattern_regex()   ^.+/%1-[^-]+-[^-]+\\.[^.]+\\.rpm$
  +#%_rpmgi_pattern_glob()	%{_rpmdir}/%1-*-*.*.rpm
  +%_rpmgi_pattern_glob	%{_rpmdir}/*/
  +%_rpmgi_pattern_regex()	^.+/%1-[^-]+-[^-]+\\.[^.]+\\.rpm$
   
   #==============================================================================
   # ---- Run-time probe dependency macros.
  @@ .
Received on Sun Feb 3 21:12:33 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.