]> git.pld-linux.org Git - packages/zif.git/blame - zif-rpm5.patch
- updated to 0.2.3
[packages/zif.git] / zif-rpm5.patch
CommitLineData
8a9884f2
JB
1--- zif-0.2.3/libzif/zif-package-local.c.orig 2011-09-05 12:56:28.000000000 +0200
2+++ zif-0.2.3/libzif/zif-package-local.c 2013-11-17 20:25:11.580739617 +0100
3@@ -31,7 +31,7 @@
4 #endif
5
6 #include <glib.h>
7-#include <rpm/rpmlib.h>
8+#include "rpmorg-compat.h"
9 #include <rpm/rpmdb.h>
10 #include <rpm/rpmts.h>
11
12@@ -70,7 +70,7 @@ zif_get_header_string (Header header, rp
13 ZifString *data = NULL;
14 rpmtd td;
15
16- td = rpmtdNew ();
17+ td = malloc (sizeof (rpmtd));
18 retval = headerGet (header, tag, td, HEADERGET_MINMEM);
19
20 if (retval != 1)
21@@ -78,7 +78,7 @@ zif_get_header_string (Header header, rp
22 data = zif_string_new (rpmtdGetString (td));
23 out:
24 rpmtdFreeData (td);
25- rpmtdFree (td);
26+ free (td);
27 return data;
28 }
29
30@@ -90,24 +90,25 @@ zif_get_header_key_id (Header header, rp
31 {
32 gint retval;
33 char *format;
34+ const char * errstr = "(unkown error)";
35 gchar *data = NULL;
36 rpmtd td;
37
38- td = rpmtdNew ();
39+ td = malloc (sizeof (rpmtd));
40 retval = headerGet (header, tag, td, HEADERGET_MINMEM);
41 if (retval != 1)
42 goto out;
43
44 /* format the signature as a text id */
45- format = rpmtdFormat (td, RPMTD_FORMAT_PGPSIG, NULL);
46+ format = headerSprintf(header, "%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|", NULL, rpmHeaderFormats, &errstr);
47 if (format != NULL) {
48 /* copy this, so we can free with g_free() */
49 data = g_strdup (format);
50- free (format);
51+ format = _free (format);
52 }
53 out:
54 rpmtdFreeData (td);
55- rpmtdFree (td);
56+ free (td);
57 return data;
58 }
59
60@@ -122,7 +123,7 @@ zif_get_header_u32 (Header header, rpmTa
61 guint data = 0;
62 rpmtd td;
63
64- td = rpmtdNew ();
65+ td = malloc (sizeof (rpmtd));
66 retval = headerGet (header, RPMTAG_SIZE, td, HEADERGET_MINMEM);
67 if (retval != 1)
68 goto out;
69@@ -131,7 +132,7 @@ zif_get_header_u32 (Header header, rpmTa
70 data = *data_p;
71 out:
72 rpmtdFreeData (td);
73- rpmtdFree (td);
74+ free (td);
75 return data;
76 }
77
78@@ -147,7 +148,7 @@ zif_get_header_uint32_index (Header head
79 rpmtd td;
80 guint i;
81
82- td = rpmtdNew ();
83+ td = malloc (sizeof (rpmtd));
84 retval = headerGet (header, tag, td, HEADERGET_MINMEM);
85 if (retval != 1)
86 goto out;
87@@ -157,7 +158,7 @@ zif_get_header_uint32_index (Header head
88 g_ptr_array_add (array, GUINT_TO_POINTER (*(data+i)));
89 out:
90 rpmtdFreeData (td);
91- rpmtdFree (td);
92+ free (td);
93 return array;
94 }
95
96@@ -172,7 +173,7 @@ zif_get_header_string_array (Header head
97 GPtrArray *array = NULL;
98 rpmtd td;
99
100- td = rpmtdNew ();
101+ td = malloc (sizeof (rpmtd));
102 retval = headerGet (header, tag, td, HEADERGET_DEFAULT);
103 if (retval != 1)
104 goto out;
105@@ -184,7 +185,7 @@ zif_get_header_string_array (Header head
106 }
107 out:
108 rpmtdFreeData (td);
109- rpmtdFree (td);
110+ free (td);
111 return array;
112 }
113
114@@ -713,7 +714,7 @@ zif_package_local_set_from_filename (Zif
115 }
116
117 /* convert and upscale */
118- headerConvert (hdr, HEADERCONV_RETROFIT_V3);
119+ /* headerConvert (hdr, HEADERCONV_RETROFIT_V3); */
120
121 /* set from header */
122 ret = zif_package_local_set_from_header (pkg,
123--- zif-0.2.3/libzif/zif-package-local.h.orig 2011-01-27 12:40:48.000000000 +0100
124+++ zif-0.2.3/libzif/zif-package-local.h 2013-10-01 20:56:40.255196845 +0200
125@@ -27,7 +27,7 @@
126 #define __ZIF_PACKAGE_LOCAL_H
127
128 #include <glib-object.h>
129-#include <rpm/rpmlib.h>
130+#include <rpm/rpm46compat.h>
131 #include <rpm/rpmdb.h>
132
133 #include "zif-package.h"
134--- zif-0.2.3/libzif/rpmorg-compat.h.orig 1970-01-01 01:00:00.000000000 +0100
135+++ zif-0.2.3/libzif/rpmorg-compat.h 2013-11-17 20:47:24.434017016 +0100
136@@ -0,0 +1,64 @@
137+#ifndef RPMORG_COMPAT_H
138+#define RPMORG_COMPAT_H
139+
140+#include <rpm/rpm46compat.h>
141+
142+#define _RPMVSF_NOSIGNATURES (RPMVSF_NODSAHEADER | RPMVSF_NORSAHEADER | RPMVSF_NODSA | RPMVSF_NORSA)
143+#define _RPMVSF_NODIGESTS (RPMVSF_NOSHA1HEADER | RPMVSF_NOMD5HEADER | RPMVSF_NOSHA1 | RPMVSF_NOMD5)
144+
145+static inline const char * headerGetString(Header h, int32_t tag)
146+{
147+ const char *res = NULL;
148+ struct rpmtd_s td;
149+
150+ if (headerGet(h, tag, &td, HEADERGET_MINMEM)) {
151+ if (rpmtdCount(&td) == 1) {
152+ res = rpmtdGetString(&td);
153+ }
154+ rpmtdFreeData(&td);
155+ }
156+ return res;
157+}
158+
159+static inline uint64_t rpmtdGetNumber(rpmtd td)
160+{
161+ uint64_t val = 0;
162+ int ix;
163+ assert(td != NULL);
164+ ix = (td->ix >= 0 ? td->ix : 0);
165+
166+ switch (td->type) {
167+ case RPM_INT64_TYPE:
168+ val = *((uint64_t *) td->data + ix);
169+ break;
170+ case RPM_INT32_TYPE:
171+ val = *((uint32_t *) td->data + ix);
172+ break;
173+ case RPM_INT16_TYPE:
174+ val = *((uint16_t *) td->data + ix);
175+ break;
176+ case RPM_INT8_TYPE:
177+ case RPM_CHAR_TYPE:
178+ val = *((uint8_t *) td->data + ix);
179+ break;
180+ default:
181+ break;
182+ }
183+ return val;
184+}
185+
186+static inline uint64_t headerGetNumber(Header h, int32_t tag)
187+{
188+ uint64_t res = 0;
189+ struct rpmtd_s td;
190+
191+ if (headerGet(h, tag, &td, HEADERGET_EXT)) {
192+ if (rpmtdCount(&td) == 1) {
193+ res = rpmtdGetNumber(&td);
194+ }
195+ rpmtdFreeData(&td);
196+ }
197+ return res;
198+}
199+
200+#endif /* RPMORG_COMPAT_H */
201--- zif-0.2.3/libzif/zif-store-local.c.orig 2011-09-05 12:53:07.000000000 +0200
202+++ zif-0.2.3/libzif/zif-store-local.c 2013-11-17 20:36:08.047378734 +0100
203@@ -34,7 +34,7 @@
204 #include <string.h>
205
206 #include <glib.h>
207-#include <rpm/rpmlib.h>
208+#include "rpmorg-compat.h"
209 #include <rpm/rpmdb.h>
210 #include <rpm/rpmts.h>
211 #include <fcntl.h>
212@@ -244,16 +244,7 @@ zif_store_local_load (ZifStore *store, Z
213
214 /* get list */
215 ts = rpmtsCreate ();
216- rc = rpmtsSetRootDir (ts, local->priv->prefix);
217- if (rc < 0) {
218- ret = FALSE;
219- g_set_error (error,
220- ZIF_STORE_ERROR,
221- ZIF_STORE_ERROR_FAILED,
222- "failed to set root (%s)",
223- local->priv->prefix);
224- goto out;
225- }
226+ rpmtsSetRootDir (ts, local->priv->prefix);
227 g_debug ("using rpmdb at %s", local->priv->prefix);
228 mi = rpmtsInitIterator (ts, RPMDBI_PACKAGES, NULL, 0);
229 if (mi == NULL)
230--- zif-0.2.3/libzif/zif-transaction.c.orig 2011-09-05 12:53:07.000000000 +0200
231+++ zif-0.2.3/libzif/zif-transaction.c 2013-11-19 19:24:28.350307447 +0100
232@@ -51,12 +51,12 @@
233 #include <glib/gstdio.h>
234 #include <fcntl.h>
235
236+#include "rpmorg-compat.h"
237 #include <rpm/rpmdb.h>
238-#include <rpm/rpmlib.h>
239 #include <rpm/rpmlog.h>
240 #include <rpm/rpmps.h>
241 #include <rpm/rpmts.h>
242-#include <rpm/rpmkeyring.h>
243+#include <rpm/rpmpgp.h>
244
245 #include "zif-array.h"
246 #include "zif-config.h"
247@@ -3052,15 +3052,12 @@ out:
248 * zif_transaction_add_public_key_to_rpmdb:
249 **/
250 static gboolean
251-zif_transaction_add_public_key_to_rpmdb (rpmKeyring keyring, const gchar *filename, GError **error)
252+zif_transaction_add_public_key_to_rpmdb (const rpmts ts, const gchar *filename, GError **error)
253 {
254 gboolean ret = TRUE;
255- gchar *data = NULL;
256 gint rc;
257 gsize len;
258 pgpArmor armor;
259- pgpDig dig = NULL;
260- rpmPubkey pubkey = NULL;
261 uint8_t *pkt = NULL;
262
263 /* ignore symlinks and directories */
264@@ -3070,12 +3067,8 @@ zif_transaction_add_public_key_to_rpmdb
265 goto out;
266
267 /* get data */
268- ret = g_file_get_contents (filename, &data, &len, error);
269- if (!ret)
270- goto out;
271-
272 /* rip off the ASCII armor and parse it */
273- armor = pgpParsePkts (data, &pkt, &len);
274+ armor = pgpReadPkts (filename, &pkt, &len);
275 if (armor < 0) {
276 ret = FALSE;
277 g_set_error (error,
278@@ -3098,7 +3091,7 @@ zif_transaction_add_public_key_to_rpmdb
279 }
280
281 /* test each one */
282- pubkey = rpmPubkeyNew (pkt, len);
283+/* pubkey = rpmPubkeyNew (pkt, len);
284 if (pubkey == NULL) {
285 ret = FALSE;
286 g_set_error (error,
287@@ -3107,19 +3100,19 @@ zif_transaction_add_public_key_to_rpmdb
288 "failed to parse public key for %s",
289 filename);
290 goto out;
291- }
292+ }*/
293
294 /* does the key exist in the keyring */
295- dig = rpmPubkeyDig (pubkey);
296+/* dig = rpmPubkeyDig (pubkey);
297 rc = rpmKeyringLookup (keyring, dig);
298 if (rc == RPMRC_OK) {
299 ret = TRUE;
300 g_debug ("%s is already present", filename);
301 goto out;
302- }
303+ }*/
304
305 /* add to rpmdb automatically, without a prompt */
306- rc = rpmKeyringAddKey (keyring, pubkey);
307+ rc = rpmcliImportPubkey(ts, pkt, len);
308 if (rc != 0) {
309 ret = FALSE;
310 g_set_error (error,
311@@ -3137,11 +3130,10 @@ zif_transaction_add_public_key_to_rpmdb
312 out:
313 if (pkt != NULL)
314 free (pkt); /* yes, free() */
315- if (pubkey != NULL)
316+/* if (pubkey != NULL)
317 rpmPubkeyFree (pubkey);
318 if (dig != NULL)
319- pgpFreeDig (dig);
320- g_free (data);
321+ pgpFreeDig (dig); */
322 return ret;
323 }
324
325@@ -3149,7 +3141,7 @@ out:
326 * zif_transaction_add_public_keys_to_rpmdb:
327 **/
328 static gboolean
329-zif_transaction_add_public_keys_to_rpmdb (rpmKeyring keyring, GError **error)
330+zif_transaction_add_public_keys_to_rpmdb (rpmts ts, GError **error)
331 {
332 GDir *dir;
333 const gchar *filename;
334@@ -3168,7 +3160,7 @@ zif_transaction_add_public_keys_to_rpmdb
335 if (filename == NULL)
336 break;
337 path_tmp = g_build_filename (gpg_dir, filename, NULL);
338- ret = zif_transaction_add_public_key_to_rpmdb (keyring,
339+ ret = zif_transaction_add_public_key_to_rpmdb (ts,
340 path_tmp,
341 error);
342 g_free (path_tmp);
343@@ -3184,7 +3176,7 @@ out:
344 **/
345 static gboolean
346 zif_transaction_prepare_ensure_trusted (ZifTransaction *transaction,
347- rpmKeyring keyring,
348+ rpmts ts,
349 ZifPackage *package,
350 GError **error)
351 {
352@@ -3226,7 +3218,7 @@ zif_transaction_prepare_ensure_trusted (
353 zif_package_set_compare_mode (package_tmp, compare_mode);
354
355 /* get RSA key */
356- td = rpmtdNew ();
357+ td = malloc (sizeof (rpmtd));
358 h = zif_package_local_get_header (ZIF_PACKAGE_LOCAL (package_tmp));
359 rc = headerGet (h,
360 RPMTAG_RSAHEADER,
361@@ -3248,7 +3240,7 @@ zif_transaction_prepare_ensure_trusted (
362 }
363
364 /* make it into a digest */
365- dig = pgpNewDig ();
366+ dig = rpmtsDig(ts);
367 rc = pgpPrtPkts (td->data, td->count, dig, 0);
368 if (rc != 0) {
369 g_set_error (error,
370@@ -3260,7 +3252,7 @@ zif_transaction_prepare_ensure_trusted (
371 }
372
373 /* does the key exist in the keyring */
374- rc = rpmKeyringLookup (keyring, dig);
375+ rc = rpmtsFindPubkey(ts, dig);
376 if (rc == RPMRC_FAIL) {
377 g_set_error_literal (error,
378 ZIF_TRANSACTION_ERROR,
379@@ -3275,12 +3267,12 @@ zif_transaction_prepare_ensure_trusted (
380
381 /* only do this once, even if it fails */
382 transaction->priv->auto_added_pubkeys = TRUE;
383- ret = zif_transaction_add_public_keys_to_rpmdb (keyring, error);
384+ ret = zif_transaction_add_public_keys_to_rpmdb (ts, error);
385 if (!ret)
386 goto out;
387
388 /* try again, as we might have the key now */
389- rc = rpmKeyringLookup (keyring, dig);
390+ rc = rpmtsFindPubkey(ts, dig);
391 }
392
393 /* set trusted */
394@@ -3297,10 +3289,10 @@ out:
395 if (package_tmp != NULL)
396 g_object_unref (package_tmp);
397 if (dig != NULL)
398- pgpFreeDig (dig);
399+ dig = pgpDigFree (dig);
400 if (td != NULL) {
401 rpmtdFreeData (td);
402- rpmtdFree (td);
403+ free (td);
404 }
405 return ret;
406 }
407@@ -3327,7 +3319,6 @@ zif_transaction_prepare (ZifTransaction
408 GError *error_local = NULL;
409 GPtrArray *download = NULL;
410 guint i;
411- rpmKeyring keyring = NULL;
412 ZifPackage *package;
413 ZifPackage *package_tmp;
414 ZifState *state_local;
415@@ -3476,7 +3467,6 @@ skip:
416 "gpgcheck", NULL);
417 localpkg_gpgcheck = zif_config_get_boolean (priv->config,
418 "localpkg_gpgcheck", NULL);
419- keyring = rpmtsGetKeyring (transaction->priv->ts, 1);
420 for (i=0; i<priv->install->len; i++) {
421 package_tmp = g_ptr_array_index (priv->install, i);
422
423@@ -3492,7 +3482,7 @@ skip:
424
425 /* do the check */
426 ret = zif_transaction_prepare_ensure_trusted (transaction,
427- keyring,
428+ transaction->priv->ts,
429 package_tmp,
430 error);
431 if (!ret)
432@@ -3509,8 +3499,6 @@ skip_self_check:
433 /* success */
434 priv->state = ZIF_TRANSACTION_STATE_PREPARED;
435 out:
436- if (keyring != NULL)
437- rpmKeyringFree (keyring);
438 if (download != NULL)
439 g_ptr_array_unref (download);
440 return ret;
441@@ -4267,6 +4255,18 @@ zif_transaction_get_problem_str (rpmProb
442 pkg_nevr_alt);
443 break;
444 #endif
445+ case RPMPROB_RDONLY:
446+ str = g_strdup_printf ("tried to install package on read-only filesystem");
447+ break;
448+ case RPMPROB_BADPRETRANS:
449+ str = g_strdup_printf ("bad %%pretrans?"); // unimplemented acc. to rpmps.h
450+ break;
451+ case RPMPROB_BADPLATFORM:
452+ str = g_strdup_printf ("package %s is for a different platform", pkg_nevr);
453+ break;
454+ case RPMPROB_NOREPACKAGE:
455+ str = g_strdup_printf ("re-packaged package %s is missing", pkg_nevr);
456+ break;
457 }
458 return str;
459 }
460@@ -4323,10 +4323,13 @@ zif_transaction_look_for_problems (ZifTr
461 out:
462 if (string != NULL)
463 g_string_free (string, TRUE);
464- rpmpsFree (probs);
465+ probs = rpmpsFree (probs);
466 return ret;
467 }
468
469+/* available in rpmts.h only if _RPMTS_INTERNAL */
470+void rpmtsSetScriptFd(rpmts ts, /*@null@*/ FD_t scriptFd);
471+
472 /**
473 * zif_transaction_commit:
474 * @transaction: A #ZifTransaction
475@@ -4409,16 +4412,7 @@ zif_transaction_commit (ZifTransaction *
476 commit->transaction = transaction;
477 commit->timer = g_timer_new ();
478 prefix = zif_store_local_get_prefix (ZIF_STORE_LOCAL (priv->store_local));
479- rc = rpmtsSetRootDir (transaction->priv->ts, prefix);
480- if (rc < 0) {
481- ret = FALSE;
482- g_set_error (error,
483- ZIF_TRANSACTION_ERROR,
484- ZIF_TRANSACTION_ERROR_FAILED,
485- "failed to set root (%s)",
486- prefix);
487- goto out;
488- }
489+ rpmtsSetRootDir (transaction->priv->ts, prefix);
490 rpmtsSetNotifyCallback (transaction->priv->ts,
491 zif_transaction_ts_progress_cb,
492 commit);
493@@ -4757,7 +4751,7 @@ zif_transaction_finalize (GObject *objec
494 transaction = ZIF_TRANSACTION (object);
495
496 if (transaction->priv->ts != NULL)
497- rpmtsFree (transaction->priv->ts);
498+ transaction->priv->ts = rpmtsFree (transaction->priv->ts);
499 g_object_unref (transaction->priv->db);
500 g_object_unref (transaction->priv->config);
501 g_ptr_array_unref (transaction->priv->install);
502--- zif-0.2.3/libzif/zif-utils.c.orig 2011-06-29 10:46:17.000000000 +0200
503+++ zif-0.2.3/libzif/zif-utils.c 2013-11-19 19:47:55.886915045 +0100
504@@ -30,8 +30,10 @@
505 # include <config.h>
506 #endif
507
508+#include <string.h>
509 #include <glib.h>
510-#include <rpm/rpmlib.h>
511+#include <rpm/rpmevr.h>
512+#include <rpm/rpmrc.h>
513 #include <rpm/rpmdb.h>
514 #include <archive.h>
515 #include <archive_entry.h>
516--- zif-0.2.3/libzif/zif-config.c.orig 2011-09-05 12:53:07.000000000 +0200
517+++ zif-0.2.3/libzif/zif-config.c 2013-11-19 20:23:49.663491326 +0100
518@@ -41,7 +41,7 @@
519 #include <string.h>
520
521 #include <glib.h>
522-#include <rpm/rpmlib.h>
523+#include <rpm/rpm46compat.h>
524
525 #include "zif-config.h"
526 #include "zif-utils.h"
527@@ -876,7 +876,7 @@ zif_config_class_init (ZifConfigClass *k
528 static void
529 zif_config_init (ZifConfig *config)
530 {
531- const gchar *value;
532+ const char *value;
533
534 config->priv = ZIF_CONFIG_GET_PRIVATE (config);
535 config->priv->file_override = g_key_file_new ();
536@@ -893,15 +893,14 @@ zif_config_init (ZifConfig *config)
537 G_CALLBACK (zif_config_file_monitor_cb), config);
538
539 /* get info from RPM */
540- rpmGetOsInfo (&value, NULL);
541+ value = rpmExpand ("%{_target_os}", NULL);
542 zif_config_set_default (config, "osinfo", value);
543- rpmGetArchInfo (&value, NULL);
544+ value = rpmExpand ("%{_target_cpu}", NULL);
545 zif_config_set_default (config, "archinfo", value);
546- rpmGetArchInfo (&value, NULL);
547- if (g_strcmp0 (value, "i486") == 0 ||
548- g_strcmp0 (value, "i586") == 0 ||
549- g_strcmp0 (value, "i686") == 0)
550- value = "i386";
551+ if (strcmp (value, "i486") == 0 ||
552+ strcmp (value, "i586") == 0 ||
553+ strcmp (value, "i686") == 0)
554+ value= "i386";
555 zif_config_set_default (config, "basearch", value);
556 }
557
558--- zif-0.2.3/examples/Makefile.am.orig 2011-06-25 18:29:24.000000000 +0200
559+++ zif-0.2.3/examples/Makefile.am 2013-11-19 21:08:44.966711548 +0100
560@@ -1,5 +1,6 @@
561 INCLUDES = \
562 $(GLIB_CFLAGS) \
563+ $(RPM_CFLAGS) \
564 -DBINDIR=\"$(bindir)\" \
565 -DDATADIR=\"$(datadir)\" \
566 -DPREFIX=\""$(prefix)"\" \
567--- zif-0.2.3/tools/Makefile.am.orig 2011-06-25 18:29:24.000000000 +0200
568+++ zif-0.2.3/tools/Makefile.am 2013-11-19 21:34:56.059978950 +0100
569@@ -1,5 +1,6 @@
570 INCLUDES = \
571 $(GLIB_CFLAGS) \
572+ $(RPM_CFLAGS) \
573 $(SQLITE_CFLAGS) \
574 -DBINDIR=\"$(bindir)\" \
575 -DDATADIR=\"$(datadir)\" \
This page took 0.136039 seconds and 4 git commands to generate.