]> git.pld-linux.org Git - packages/rpm.git/blame - uname-deps.patch
- teach rpm how to read /proc files
[packages/rpm.git] / uname-deps.patch
CommitLineData
f16801b5
JR
1diff --git a/lib/depends.c b/lib/depends.c
2index 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);
2aa7d974 10+ if (strstr(N, "uname(") == N) {
f16801b5 11+ if (tsmem->uname == NULL)
9354bf65 12+ rpmdsUnamePool(rpmtsPool(ts), &(tsmem->uname));
f16801b5
JR
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;
23diff --git a/lib/rpmds.c b/lib/rpmds.c
24index 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 */
2aa7d974 35@@ -1596,3 +1597,60 @@ rpmRC rpmdsParseRichDep(rpmds dep, rpmds *leftds, rpmds *rightds, rpmrichOp *op,
f16801b5
JR
36 return rc;
37 }
38
2aa7d974
JR
39+/**
40+ * Merge a single provides, wrapping N as "NS(N)".
41+ */
42+static int rpmdsNSAdd(rpmstrPool pool, rpmds *dsp, const char * NS,
43+ const char *N, const char *EVR, rpmsenseFlags Flags)
44+{
45+ char *t;
46+ rpmds ds;
47+ int rc;
48+
49+ t = (char *) alloca(strlen(NS)+sizeof("()")+strlen(N));
50+ *t = '\0';
51+ (void) stpcpy( stpcpy( stpcpy( stpcpy(t, NS), "("), N), ")");
52+
53+ ds = rpmdsSinglePool(pool, RPMTAG_PROVIDENAME, t, EVR, Flags);
54+ rc = rpmdsMerge(dsp, ds);
55+ rpmdsFree(ds);
56+ return rc;
57+}
58+
f16801b5
JR
59+int rpmdsUnamePool(rpmstrPool pool, rpmds * dsp)
60+{
61+ int rc = -1;
62+ static const char * NS = "uname";
63+ struct utsname un;
f16801b5
JR
64+
65+ if (uname(&un) < 0)
66+ goto exit;
67+
2aa7d974 68+ rc = rpmdsNSAdd(pool, dsp, NS, "sysname", un.sysname, RPMSENSE_EQUAL);
f16801b5
JR
69+ if (rc < 0)
70+ goto exit;
2aa7d974 71+ rc = rpmdsNSAdd(pool, dsp, NS, "nodename", un.nodename, RPMSENSE_EQUAL);
f16801b5
JR
72+ if (rc < 0)
73+ goto exit;
2aa7d974 74+ rc = rpmdsNSAdd(pool, dsp, NS, "release", un.release, RPMSENSE_EQUAL);
f16801b5
JR
75+ if (rc < 0)
76+ goto exit;
2aa7d974 77+ rc = rpmdsNSAdd(pool, dsp, NS, "machine", un.machine, RPMSENSE_EQUAL);
f16801b5
JR
78+ if (rc < 0)
79+ goto exit;
80+#if defined(__linux__)
2aa7d974 81+ rc = rpmdsNSAdd(pool, dsp, NS, "domainname", un.domainname, RPMSENSE_EQUAL);
f16801b5
JR
82+ if (rc < 0)
83+ goto exit;
84+#endif
85+exit:
86+ /* freeze the pool to save memory, but only if private pool */
87+ if (*dsp && (*dsp)->pool != pool)
88+ rpmstrPoolFreeze((*dsp)->pool, 0);
89+ return (rc < 0) ? -1 : 0;
90+}
91+
92+int rpmdsUname(rpmds * dsp)
93+{
94+ return rpmdsUnamePool(NULL, dsp);
95+}
e10224c5
JR
96diff --git a/lib/rpmds.h b/lib/rpmds.h
97index 90d54aa27..558252c04 100644
98--- a/lib/rpmds.h
99+++ b/lib/rpmds.h
100@@ -412,6 +412,13 @@ int rpmdsNVRMatchesDep(const Header h, const rpmds req, int nopromote);
101 */
102 int rpmdsRpmlib(rpmds * dsp, const void * tblp);
103
104+/**
105+ * Load uname provides into a dependency set.
106+ * @retval *dsp (loaded) dependency set
107+ * @return 0 on success
108+ */
109+int rpmdsUname(rpmds * dsp);
110+
111 /** \ingroup rpmds
112 * Create and load a dependency set.
113 * @param pool shared string pool (or NULL for private pool)
114@@ -468,6 +475,14 @@ rpmds rpmdsSinglePoolTix(rpmstrPool pool, rpmTagVal tagN,
115 */
116 int rpmdsRpmlibPool(rpmstrPool pool, rpmds * dsp, const void * tblp);
117
118+/**
119+ * Load uname provides into a dependency set.
120+ * @param pool shared string pool (or NULL for private pool)
121+ * @retval *dsp (loaded) dependency set
122+ * @return 0 on success
123+ */
124+int rpmdsUnamePool(rpmstrPool pool, rpmds * dsp);
125+
126
127 typedef enum rpmrichOp_e {
128 RPMRICHOP_SINGLE = 1,
f16801b5
JR
129diff --git a/lib/rpmts_internal.h b/lib/rpmts_internal.h
130index e69ef2584..ecdb12f0c 100644
131--- a/lib/rpmts_internal.h
132+++ b/lib/rpmts_internal.h
133@@ -21,6 +21,7 @@ typedef struct tsMembers_s {
134 rpmal addedPackages; /*!< Set of packages being installed. */
135
136 rpmds rpmlib; /*!< rpmlib() dependency set. */
137+ rpmds uname; /*!< uname() dependency set. */
138 rpmte * order; /*!< Packages sorted by dependencies. */
139 int orderCount; /*!< No. of transaction elements. */
140 int orderAlloced; /*!< No. of allocated transaction elements. */
This page took 0.092593 seconds and 4 git commands to generate.