-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibhif-rpm5.patch
516 lines (472 loc) · 14.1 KB
/
libhif-rpm5.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
--- libhif-0.2.0/libhif/hif-context.c.orig 2015-03-20 21:24:51.000000000 +0100
+++ libhif-0.2.0/libhif/hif-context.c 2015-04-11 17:13:34.053370041 +0200
@@ -31,8 +31,8 @@
#include "config.h"
-#include <rpm/rpmlib.h>
#include <rpm/rpmmacro.h>
+#include <rpm/rpmrc.h>
#include <hawkey/query.h>
#include <hawkey/packagelist.h>
@@ -1240,7 +1240,7 @@ hif_context_setup (HifContext *context,
"alphaev68", "alphaev7", "alphapca56", NULL } },
{ "arm", { "armv5tejl", "armv5tel", "armv6l", "armv7l", NULL } },
{ "armhfp", { "armv7hl", "armv7hnl", NULL } },
- { "i386", { "i386", "athlon", "geode", "i386",
+ { "i386", { "i386", "athlon", "geode", "pentium2", "pentium3", "pentium4",
"i486", "i586", "i686", NULL } },
{ "ia64", { "ia64", NULL } },
{ "noarch", { "noarch", NULL } },
@@ -1317,9 +1317,9 @@ hif_context_setup (HifContext *context,
}
/* get info from RPM */
- rpmGetOsInfo (&value, NULL);
+ value = rpmExpand ("%{_target_os}", NULL);
priv->os_info = g_strdup (value);
- rpmGetArchInfo (&value, NULL);
+ value = rpmExpand ("%{_target_cpu}", NULL);
priv->arch_info = g_strdup (value);
/* find the base architecture */
--- libhif-0.1.0/libhif/hif-keyring.c.orig 2014-06-04 10:15:54.000000000 +0200
+++ libhif-0.1.0/libhif/hif-keyring.c 2014-06-15 07:51:30.257165572 +0200
@@ -35,7 +35,9 @@
#include <stdlib.h>
#include <glib.h>
-#include <rpm/rpmlib.h>
+#include "rpmorg-compat.h"
+#include <rpm/rpmcli.h>
+#include <rpm/rpmio.h>
#include <rpm/rpmts.h>
#include "hif-cleanup.h"
@@ -55,7 +57,7 @@
* Since: 0.1.0
**/
gboolean
-hif_keyring_add_public_key (rpmKeyring keyring,
+hif_keyring_add_public_key (const rpmts ts,
const gchar *filename,
GError **error)
{
@@ -63,10 +65,7 @@ hif_keyring_add_public_key (rpmKeyring k
gint rc;
gsize len;
pgpArmor armor;
- pgpDig dig = NULL;
- rpmPubkey pubkey = NULL;
uint8_t *pkt = NULL;
- _cleanup_free_ gchar *data = NULL;
/* ignore symlinks and directories */
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR))
@@ -74,13 +73,8 @@ hif_keyring_add_public_key (rpmKeyring k
if (g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
goto out;
- /* get data */
- ret = g_file_get_contents (filename, &data, &len, error);
- if (!ret)
- goto out;
-
/* rip off the ASCII armor and parse it */
- armor = pgpParsePkts (data, &pkt, &len);
+ armor = pgpReadPkts (filename, &pkt, &len);
if (armor < 0) {
ret = FALSE;
g_set_error (error,
@@ -103,7 +97,7 @@ hif_keyring_add_public_key (rpmKeyring k
}
/* test each one */
- pubkey = rpmPubkeyNew (pkt, len);
+/* pubkey = rpmPubkeyNew (pkt, len);
if (pubkey == NULL) {
ret = FALSE;
g_set_error (error,
@@ -112,19 +106,19 @@ hif_keyring_add_public_key (rpmKeyring k
"failed to parse public key for %s",
filename);
goto out;
- }
+ } */
/* does the key exist in the keyring */
- dig = rpmPubkeyDig (pubkey);
+/* dig = rpmPubkeyDig (pubkey);
rc = rpmKeyringLookup (keyring, dig);
if (rc == RPMRC_OK) {
ret = TRUE;
g_debug ("%s is already present", filename);
goto out;
- }
+ } */
/* add to rpmdb automatically, without a prompt */
- rc = rpmKeyringAddKey (keyring, pubkey);
+ rc = rpmcliImportPubkey (ts, pkt, len);
if (rc == 1) {
ret = TRUE;
g_debug ("%s is already added", filename);
@@ -146,10 +140,6 @@ hif_keyring_add_public_key (rpmKeyring k
out:
if (pkt != NULL)
free (pkt); /* yes, free() */
- if (pubkey != NULL)
- rpmPubkeyFree (pubkey);
- if (dig != NULL)
- pgpFreeDig (dig);
return ret;
}
@@ -165,7 +155,7 @@ out:
* Since: 0.1.0
**/
gboolean
-hif_keyring_add_public_keys (rpmKeyring keyring, GError **error)
+hif_keyring_add_public_keys (rpmts ts, GError **error)
{
const gchar *gpg_dir = "/etc/pki/rpm-gpg";
gboolean ret = TRUE;
@@ -182,7 +172,7 @@ hif_keyring_add_public_keys (rpmKeyring
if (filename == NULL)
break;
path_tmp = g_build_filename (gpg_dir, filename, NULL);
- ret = hif_keyring_add_public_key (keyring, path_tmp, error);
+ ret = hif_keyring_add_public_key (ts, path_tmp, error);
} while (ret);
return TRUE;
}
@@ -191,7 +181,7 @@ hif_keyring_add_public_keys (rpmKeyring
* hif_keyring_check_untrusted_file:
*/
gboolean
-hif_keyring_check_untrusted_file (rpmKeyring keyring,
+hif_keyring_check_untrusted_file (
const gchar *filename,
GError **error)
{
@@ -242,10 +232,10 @@ hif_keyring_check_untrusted_file (rpmKey
}
/* convert and upscale */
- headerConvert (hdr, HEADERCONV_RETROFIT_V3);
+/* headerConvert (hdr, HEADERCONV_RETROFIT_V3); */
/* get RSA key */
- td = rpmtdNew ();
+ td = malloc (sizeof (*td));
rc = headerGet (hdr,
RPMTAG_RSAHEADER,
td,
@@ -269,7 +259,7 @@ hif_keyring_check_untrusted_file (rpmKey
}
/* make it into a digest */
- dig = pgpNewDig ();
+ dig = rpmtsDig (ts);
rc = pgpPrtPkts (td->data, td->count, dig, 0);
if (rc != 0) {
g_set_error (error,
@@ -281,7 +271,7 @@ hif_keyring_check_untrusted_file (rpmKey
}
/* does the key exist in the keyring */
- rc = rpmKeyringLookup (keyring, dig);
+ rc = rpmtsFindPubkey (ts, dig);
if (rc != RPMRC_OK) {
g_set_error_literal (error,
HIF_ERROR,
@@ -295,18 +285,18 @@ hif_keyring_check_untrusted_file (rpmKey
ret = TRUE;
out:
if (dig != NULL)
- pgpFreeDig (dig);
+ dig = pgpDigFree (dig);
if (td != NULL) {
rpmtdFreeData (td);
- rpmtdFree (td);
+ free (td);
}
if (ts != NULL)
- rpmtsFree (ts);
+ ts = rpmtsFree (ts);
if (hdr != NULL)
- headerFree (hdr);
+ hdr = headerFree (hdr);
if (fd != NULL)
Fclose (fd);
if (header != NULL)
- headerFree (header);
+ header = headerFree (header);
return ret;
}
--- libhif-0.1.0/libhif/hif-keyring.h.orig 2014-03-28 17:30:12.000000000 +0100
+++ libhif-0.1.0/libhif/hif-keyring.h 2014-06-15 07:27:41.550528685 +0200
@@ -28,14 +28,14 @@
#include <glib.h>
-#include <rpm/rpmkeyring.h>
+#include <rpm/rpmts.h>
-gboolean hif_keyring_add_public_key (rpmKeyring keyring,
+gboolean hif_keyring_add_public_key (const rpmts ts,
const gchar *filename,
GError **error);
-gboolean hif_keyring_add_public_keys (rpmKeyring keyring,
+gboolean hif_keyring_add_public_keys (rpmts ts,
GError **error);
-gboolean hif_keyring_check_untrusted_file (rpmKeyring keyring,
+gboolean hif_keyring_check_untrusted_file (
const gchar *filename,
GError **error);
--- libhif-0.1.8/libhif/hif-transaction.c.orig 2015-01-19 16:15:50.000000000 +0100
+++ libhif-0.1.8/libhif/hif-transaction.c 2015-01-29 17:46:08.063875003 +0100
@@ -30,7 +30,8 @@
#include "config.h"
-#include <rpm/rpmlib.h>
+#include "rpmorg-compat.h"
+#include <rpm/rpmio.h>
#include <rpm/rpmts.h>
#include <rpm/rpmlog.h>
@@ -61,7 +62,6 @@ typedef struct _HifTransactionPrivate Hi
struct _HifTransactionPrivate
{
HifDb *db;
- rpmKeyring keyring;
rpmts ts;
HifContext *context; /* weak reference */
GPtrArray *sources;
@@ -95,8 +95,7 @@ hif_transaction_finalize (GObject *objec
g_ptr_array_unref (priv->pkgs_to_download);
g_timer_destroy (priv->timer);
- rpmKeyringFree (priv->keyring);
- rpmtsFree (priv->ts);
+ priv->ts = rpmtsFree (priv->ts);
if (priv->db != NULL)
g_object_unref (priv->db);
@@ -120,7 +119,6 @@ hif_transaction_init (HifTransaction *tr
{
HifTransactionPrivate *priv = GET_PRIVATE (transaction);
priv->ts = rpmtsCreate ();
- priv->keyring = rpmtsGetKeyring (priv->ts, 1);
priv->timer = g_timer_new ();
priv->pkgs_to_download = g_ptr_array_new_with_free_func ((GDestroyNotify) hy_package_free);
}
@@ -381,7 +379,7 @@ hif_transaction_check_untrusted (HifTran
}
/* check file */
- if (!hif_keyring_check_untrusted_file (priv->keyring, fn, &error_local)) {
+ if (!hif_keyring_check_untrusted_file (fn, &error_local)) {
/* probably an i/o error */
if (!g_error_matches (error_local,
@@ -472,15 +470,6 @@ hif_transaction_rpmcb_type_to_string (co
case RPMCALLBACK_SCRIPT_ERROR:
type = "script-error";
break;
- case RPMCALLBACK_SCRIPT_START:
- type = "script-start";
- break;
- case RPMCALLBACK_SCRIPT_STOP:
- type = "script-stop";
- break;
- case RPMCALLBACK_INST_STOP:
- type = "install-stop";
- break;
}
return type;
}
@@ -779,7 +768,6 @@ hif_transaction_ts_progress_cb (const vo
/* don't do anything */
break;
- case RPMCALLBACK_INST_STOP:
case RPMCALLBACK_UNINST_STOP:
/* phase complete */
@@ -793,8 +781,6 @@ hif_transaction_ts_progress_cb (const vo
case RPMCALLBACK_UNPACK_ERROR:
case RPMCALLBACK_CPIO_ERROR:
case RPMCALLBACK_SCRIPT_ERROR:
- case RPMCALLBACK_SCRIPT_START:
- case RPMCALLBACK_SCRIPT_STOP:
case RPMCALLBACK_UNKNOWN:
case RPMCALLBACK_REPACKAGE_PROGRESS:
case RPMCALLBACK_REPACKAGE_START:
@@ -1203,7 +1189,7 @@ hif_transaction_commit (HifTransaction *
goto out;
/* import all GPG keys */
- ret = hif_keyring_add_public_keys (priv->keyring, error);
+ ret = hif_keyring_add_public_keys (priv->ts, error);
if (!ret)
goto out;
@@ -1221,15 +1207,7 @@ hif_transaction_commit (HifTransaction *
/* setup the transaction */
tmp = hif_context_get_install_root (priv->context);
- rc = rpmtsSetRootDir (priv->ts, tmp);
- if (rc < 0) {
- ret = FALSE;
- g_set_error_literal (error,
- HIF_ERROR,
- HIF_ERROR_INTERNAL_ERROR,
- "failed to set root");
- goto out;
- }
+ rpmtsSetRootDir (priv->ts, tmp);
rpmtsSetNotifyCallback (priv->ts,
hif_transaction_ts_progress_cb,
transaction);
--- libhif-0.1.0/libhif/hif-rpmts.c.orig 2014-06-04 10:15:54.000000000 +0200
+++ libhif-0.1.0/libhif/hif-rpmts.c 2014-06-15 08:10:12.430475514 +0200
@@ -35,9 +35,12 @@
#endif
#include <glib.h>
-#include <rpm/rpmlib.h>
+#define _RPMLOG_INTERNAL
+#include <rpm/rpm46compat.h>
+#include <rpm/pkgio.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmdb.h>
+#include <rpm/rpmio.h>
#include "hif-cleanup.h"
#include "hif-rpmts.h"
@@ -230,10 +233,17 @@ hif_rpmts_get_problem_str (rpmProblem pr
diskspace,
generic_str);
break;
- case RPMPROB_OBSOLETES:
- str = g_strdup_printf ("package %s is obsoleted by %s",
- pkg_nevr,
- pkg_nevr_alt);
+ case RPMPROB_RDONLY:
+ str = g_strdup_printf ("tried to install package on read-only filesystem");
+ break;
+ case RPMPROB_BADPRETRANS:
+ str = g_strdup_printf ("bad %%pretrans?"); // unimplemented acc. to rpmps.h
+ break;
+ case RPMPROB_BADPLATFORM:
+ str = g_strdup_printf ("package %s is for a different platform", pkg_nevr);
+ break;
+ case RPMPROB_NOREPACKAGE:
+ str = g_strdup_printf ("re-packaged package %s is missing", pkg_nevr);
break;
}
return str;
@@ -297,7 +307,7 @@ hif_rpmts_look_for_problems (rpmts ts, G
HIF_ERROR_INTERNAL_ERROR,
"Error running transaction and no problems were reported!");
out:
- rpmpsFree (probs);
+ probs = rpmpsFree (probs);
return ret;
}
@@ -310,11 +320,11 @@ hif_rpmts_log_handler_cb (rpmlogRec rec,
GString **string = (GString **) data;
/* only log errors */
- if (rpmlogRecPriority (rec) != RPMLOG_ERR)
+ if (rec->pri != RPMLOG_ERR)
return RPMLOG_DEFAULT;
/* do not log internal BDB errors */
- if (g_strstr_len (rpmlogRecMessage (rec), -1, "BDB") != NULL)
+ if (g_strstr_len (rec->message, -1, "BDB") != NULL)
return 0;
/* create string if required */
@@ -324,7 +334,7 @@ hif_rpmts_log_handler_cb (rpmlogRec rec,
/* if text already exists, join them */
if ((*string)->len > 0)
g_string_append (*string, ": ");
- g_string_append (*string, rpmlogRecMessage (rec));
+ g_string_append (*string, rec->message);
/* remove the trailing /n which rpm does */
if ((*string)->len > 0)
@@ -373,7 +383,7 @@ hif_rpmts_find_package (rpmts ts, HyPack
}
/* success */
- headerLink (hdr);
+ hdr = headerLink (hdr);
out:
rpmlogSetCallback (NULL, NULL);
if (iter != NULL)
@@ -419,6 +429,6 @@ hif_rpmts_add_remove_pkg (rpmts ts, HyPa
}
out:
if (hdr != NULL)
- headerFree (hdr);
+ hdr = headerFree (hdr);
return ret;
}
--- libhif-0.1.0/libhif/rpmorg-compat.h.orig 1970-01-01 01:00:00.000000000 +0100
+++ libhif-0.1.0/libhif/rpmorg-compat.h 2014-06-15 07:52:06.750498144 +0200
@@ -0,0 +1,64 @@
+#ifndef RPMORG_COMPAT_H
+#define RPMORG_COMPAT_H
+
+#include <rpm/rpm46compat.h>
+
+#define _RPMVSF_NOSIGNATURES (RPMVSF_NODSAHEADER | RPMVSF_NORSAHEADER | RPMVSF_NODSA | RPMVSF_NORSA)
+#define _RPMVSF_NODIGESTS (RPMVSF_NOSHA1HEADER | RPMVSF_NOMD5HEADER | RPMVSF_NOSHA1 | RPMVSF_NOMD5)
+
+static inline const char * headerGetString(Header h, int32_t tag)
+{
+ const char *res = NULL;
+ struct rpmtd_s td;
+
+ if (headerGet(h, tag, &td, HEADERGET_MINMEM)) {
+ if (rpmtdCount(&td) == 1) {
+ res = rpmtdGetString(&td);
+ }
+ rpmtdFreeData(&td);
+ }
+ return res;
+}
+
+static inline uint64_t rpmtdGetNumber(rpmtd td)
+{
+ uint64_t val = 0;
+ int ix;
+ assert(td != NULL);
+ ix = (td->ix >= 0 ? td->ix : 0);
+
+ switch (td->type) {
+ case RPM_INT64_TYPE:
+ val = *((uint64_t *) td->data + ix);
+ break;
+ case RPM_INT32_TYPE:
+ val = *((uint32_t *) td->data + ix);
+ break;
+ case RPM_INT16_TYPE:
+ val = *((uint16_t *) td->data + ix);
+ break;
+ case RPM_INT8_TYPE:
+ case RPM_CHAR_TYPE:
+ val = *((uint8_t *) td->data + ix);
+ break;
+ default:
+ break;
+ }
+ return val;
+}
+
+static inline uint64_t headerGetNumber(Header h, int32_t tag)
+{
+ uint64_t res = 0;
+ struct rpmtd_s td;
+
+ if (headerGet(h, tag, &td, HEADERGET_EXT)) {
+ if (rpmtdCount(&td) == 1) {
+ res = rpmtdGetNumber(&td);
+ }
+ rpmtdFreeData(&td);
+ }
+ return res;
+}
+
+#endif /* RPMORG_COMPAT_H */
--- libhif-0.2.0/libhif/hif-source.c.orig 2015-04-08 20:57:23.000000000 +0200
+++ libhif-0.2.0/libhif/hif-source.c 2015-04-11 18:00:35.709977897 +0200
@@ -44,6 +44,7 @@
#include <glib/gstdio.h>
#include <hawkey/util.h>
#include <librepo/librepo.h>
+#include <rpm/rpmio.h>
#include <rpm/rpmts.h>
#include "hif-cleanup.h"
@@ -1171,15 +1172,12 @@ hif_source_add_public_key (HifSource *so
{
HifSourcePrivate *priv = GET_PRIVATE (source);
gboolean ret;
- rpmKeyring keyring;
rpmts ts;
/* then import to rpmdb */
ts = rpmtsCreate ();
- keyring = rpmtsGetKeyring (ts, 1);
- ret = hif_keyring_add_public_key (keyring, priv->pubkey_tmp, error);
- rpmKeyringFree (keyring);
- rpmtsFree (ts);
+ ret = hif_keyring_add_public_key (ts, priv->pubkey_tmp, error);
+ ts = rpmtsFree (ts);
return ret;
}