]> git.pld-linux.org Git - packages/rpm.git/blob - uname-deps.patch
4863617994a16cd39b397350cad36cd2dfeaffbc
[packages/rpm.git] / uname-deps.patch
1 diff --git a/lib/depends.c b/lib/depends.c
2 index 28a4a784d..1d8ce1f8a 100644
3 --- a/lib/depends.c
4 +++ b/lib/depends.c
5 @@ -690,6 +690,17 @@ retry:
6         goto unsatisfied;
7      }
8  
9 +    char * N = rpmdsN(dep);
10 +    if (strstr(N, "uname") == N) {
11 +       if (tsmem->uname == NULL)
12 +           rpmdsUnamePool(rpmtsPool(ts), &(tsmem->uname));
13 +       
14 +       if (tsmem->uname != NULL && rpmdsSearch(tsmem->uname, dep) >= 0) {
15 +           rpmdsNotify(dep, "(uname provides)", rc);
16 +           goto exit;
17 +       }
18 +    }
19 +
20      /* Dont look at pre-requisites of already installed packages */
21      if (!adding && isTransientReq(dsflags))
22         goto exit;
23 diff --git a/lib/rpmds.c b/lib/rpmds.c
24 index f7ee76392..754969e39 100644
25 --- a/lib/rpmds.c
26 +++ b/lib/rpmds.c
27 @@ -2,6 +2,7 @@
28   * \file lib/rpmds.c
29   */
30  #include "system.h"
31 +#include <sys/utsname.h>
32  
33  #include <rpm/rpmtypes.h>
34  #include <rpm/rpmlib.h>                /* rpmvercmp */
35 @@ -1596,3 +1597,51 @@ rpmRC rpmdsParseRichDep(rpmds dep, rpmds *leftds, rpmds *rightds, rpmrichOp *op,
36      return rc;
37  }
38  
39 +int rpmdsUnamePool(rpmstrPool pool, rpmds * dsp)
40 +{
41 +    int rc = -1;
42 +    static const char * NS = "uname";
43 +    struct utsname un;
44 +    rpmds ds;
45 +
46 +    if (uname(&un) < 0)
47 +       goto exit;
48 +
49 +    ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME, "uname(sysname)", un.sysname, RPMSENSE_EQUAL);
50 +    rc = rpmdsMerge(dsp, ds);
51 +    rpmdsFree(ds);
52 +    if (rc < 0)
53 +       goto exit;
54 +    ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME, "uname(nodename)", un.nodename, RPMSENSE_EQUAL);
55 +    rc = rpmdsMerge(dsp, ds);
56 +    rpmdsFree(ds);
57 +    if (rc < 0)
58 +       goto exit;
59 +    ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME, "uname(release)", un.release, RPMSENSE_EQUAL);
60 +    rc = rpmdsMerge(dsp, ds);
61 +    rpmdsFree(ds);
62 +    if (rc < 0)
63 +       goto exit;
64 +    ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME, "uname(machine)", un.machine, RPMSENSE_EQUAL);
65 +    rc = rpmdsMerge(dsp, ds);
66 +    rpmdsFree(ds);
67 +    if (rc < 0)
68 +       goto exit;
69 +#if defined(__linux__)
70 +    ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME, "uname(domainname)", un.domainname, RPMSENSE_EQUAL);
71 +    rc = rpmdsMerge(dsp, ds);
72 +    rpmdsFree(ds);
73 +    if (rc < 0)
74 +       goto exit;
75 +#endif
76 +exit:
77 +    /* freeze the pool to save memory, but only if private pool */
78 +    if (*dsp && (*dsp)->pool != pool)
79 +       rpmstrPoolFreeze((*dsp)->pool, 0);
80 +    return (rc < 0) ? -1 : 0;
81 +}
82 +
83 +int rpmdsUname(rpmds * dsp)
84 +{
85 +    return rpmdsUnamePool(NULL, dsp);
86 +}
87 diff --git a/lib/rpmds.h b/lib/rpmds.h
88 index 90d54aa27..558252c04 100644
89 --- a/lib/rpmds.h
90 +++ b/lib/rpmds.h
91 @@ -412,6 +412,13 @@ int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
92   */
93  int rpmdsRpmlib(rpmds * dsp, const void * tblp);
94  
95 +/**
96 + * Load uname provides into a dependency set.
97 + * @retval *dsp                (loaded) dependency set
98 + * @return             0 on success
99 + */
100 +int rpmdsUname(rpmds * dsp);
101 +
102  /** \ingroup rpmds
103   * Create and load a dependency set.
104   * @param pool         shared string pool (or NULL for private pool)
105 @@ -468,6 +475,14 @@ rpmds rpmdsSinglePoolTix(rpmstrPool pool, rpmTagVal tagN,
106   */
107  int rpmdsRpmlibPool(rpmstrPool pool, rpmds * dsp, const void * tblp);
108  
109 +/**
110 + * Load uname provides into a dependency set.
111 + * @param pool         shared string pool (or NULL for private pool)
112 + * @retval *dsp                (loaded) dependency set
113 + * @return             0 on success
114 + */
115 +int rpmdsUnamePool(rpmstrPool pool, rpmds * dsp);
116 +
117  
118  typedef enum rpmrichOp_e {
119      RPMRICHOP_SINGLE  = 1,
120 diff --git a/lib/rpmts_internal.h b/lib/rpmts_internal.h
121 index e69ef2584..ecdb12f0c 100644
122 --- a/lib/rpmts_internal.h
123 +++ b/lib/rpmts_internal.h
124 @@ -21,6 +21,7 @@ typedef struct tsMembers_s {
125      rpmal addedPackages;       /*!< Set of packages being installed. */
126  
127      rpmds rpmlib;              /*!< rpmlib() dependency set. */
128 +    rpmds uname;               /*!< uname() dependency set. */
129      rpmte * order;             /*!< Packages sorted by dependencies. */
130      int orderCount;            /*!< No. of transaction elements. */
131      int orderAlloced;          /*!< No. of allocated transaction elements. */
This page took 0.039758 seconds and 2 git commands to generate.