- updated to 0.8.15
[packages/PackageKit.git] / PackageKit-hawkey-rpm5.patch
1 --- PackageKit-0.8.15/backends/hawkey/hif-keyring.c.orig        2013-12-05 14:36:16.000000000 +0100
2 +++ PackageKit-0.8.15/backends/hawkey/hif-keyring.c     2014-01-19 17:21:44.407060059 +0100
3 @@ -27,8 +27,12 @@
4  
5  #include <stdlib.h>
6  #include <glib.h>
7 -#include <rpm/rpmlib.h>
8 +#include "rpmorg-compat.h"
9 +#include <rpm/rpmcli.h>
10 +#include <rpm/rpmio.h>
11 +#include <rpm/rpmps.h>
12  #include <rpm/rpmts.h>
13 +#include <rpm/rpmpgp.h>
14  
15  #include "hif-keyring.h"
16  #include "hif-utils.h"
17 @@ -37,17 +41,14 @@
18   * hif_keyring_add_public_key:
19   **/
20  gboolean
21 -hif_keyring_add_public_key (rpmKeyring keyring,
22 +hif_keyring_add_public_key (const rpmts ts,
23                             const gchar *filename,
24                             GError **error)
25  {
26         gboolean ret = TRUE;
27 -       gchar *data = NULL;
28         gint rc;
29         gsize len;
30         pgpArmor armor;
31 -       pgpDig dig = NULL;
32 -       rpmPubkey pubkey = NULL;
33         uint8_t *pkt = NULL;
34  
35         /* ignore symlinks and directories */
36 @@ -56,13 +57,8 @@ hif_keyring_add_public_key (rpmKeyring k
37         if (g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
38                 goto out;
39  
40 -       /* get data */
41 -       ret = g_file_get_contents (filename, &data, &len, error);
42 -       if (!ret)
43 -               goto out;
44 -
45         /* rip off the ASCII armor and parse it */
46 -       armor = pgpParsePkts (data, &pkt, &len);
47 +       armor = pgpReadPkts (filename, &pkt, &len);
48         if (armor < 0) {
49                 ret = FALSE;
50                 g_set_error (error,
51 @@ -85,7 +81,7 @@ hif_keyring_add_public_key (rpmKeyring k
52         }
53  
54         /* test each one */
55 -       pubkey = rpmPubkeyNew (pkt, len);
56 +/*     pubkey = rpmPubkeyNew (pkt, len);
57         if (pubkey == NULL) {
58                 ret = FALSE;
59                 g_set_error (error,
60 @@ -94,19 +90,19 @@ hif_keyring_add_public_key (rpmKeyring k
61                              "failed to parse public key for %s",
62                              filename);
63                 goto out;
64 -       }
65 +       } */
66  
67         /* does the key exist in the keyring */
68 -       dig = rpmPubkeyDig (pubkey);
69 +/*     dig = rpmPubkeyDig (pubkey);
70         rc = rpmKeyringLookup (keyring, dig);
71         if (rc == RPMRC_OK) {
72                 ret = TRUE;
73                 g_debug ("%s is already present", filename);
74                 goto out;
75 -       }
76 +       } */
77  
78         /* add to rpmdb automatically, without a prompt */
79 -       rc = rpmKeyringAddKey (keyring, pubkey);
80 +       rc = rpmcliImportPubkey (ts, pkt, len);
81         if (rc == 1) {
82                 ret = TRUE;
83                 g_debug ("%s is already added", filename);
84 @@ -128,11 +124,6 @@ hif_keyring_add_public_key (rpmKeyring k
85  out:
86         if (pkt != NULL)
87                 free (pkt); /* yes, free() */
88 -       if (pubkey != NULL)
89 -               rpmPubkeyFree (pubkey);
90 -       if (dig != NULL)
91 -               pgpFreeDig (dig);
92 -       g_free (data);
93         return ret;
94  }
95  
96 @@ -140,7 +131,7 @@ out:
97   * hif_keyring_add_public_keys:
98   **/
99  gboolean
100 -hif_keyring_add_public_keys (rpmKeyring keyring, GError **error)
101 +hif_keyring_add_public_keys (rpmts ts, GError **error)
102  {
103         const gchar *filename;
104         const gchar *gpg_dir = "/etc/pki/rpm-gpg";
105 @@ -159,7 +150,7 @@ hif_keyring_add_public_keys (rpmKeyring
106                 if (filename == NULL)
107                         break;
108                 path_tmp = g_build_filename (gpg_dir, filename, NULL);
109 -               ret = hif_keyring_add_public_key (keyring, path_tmp, error);
110 +               ret = hif_keyring_add_public_key (ts, path_tmp, error);
111                 g_free (path_tmp);
112         } while (ret);
113  out:
114 @@ -172,8 +163,7 @@ out:
115   * hif_keyring_check_untrusted_file:
116   */
117  gboolean
118 -hif_keyring_check_untrusted_file (rpmKeyring keyring,
119 -                                 const gchar *filename,
120 +hif_keyring_check_untrusted_file (const gchar *filename,
121                                   GError **error)
122  {
123         FD_t fd = NULL;
124 @@ -216,10 +206,10 @@ hif_keyring_check_untrusted_file (rpmKey
125         }
126  
127         /* convert and upscale */
128 -       headerConvert (hdr, HEADERCONV_RETROFIT_V3);
129 +       /* headerConvert (hdr, HEADERCONV_RETROFIT_V3); */
130  
131         /* get RSA key */
132 -       td = rpmtdNew ();
133 +       td = malloc (sizeof (*td) );
134         rc = headerGet (hdr,
135                         RPMTAG_RSAHEADER,
136                         td,
137 @@ -243,7 +233,7 @@ hif_keyring_check_untrusted_file (rpmKey
138         }
139  
140         /* make it into a digest */
141 -       dig = pgpNewDig ();
142 +       dig = rpmtsDig (ts);
143         rc = pgpPrtPkts (td->data, td->count, dig, 0);
144         if (rc != 0) {
145                 g_set_error (error,
146 @@ -255,7 +245,7 @@ hif_keyring_check_untrusted_file (rpmKey
147         }
148  
149         /* does the key exist in the keyring */
150 -       rc = rpmKeyringLookup (keyring, dig);
151 +       rc = rpmtsFindPubkey (ts, dig);
152         if (rc != RPMRC_OK) {
153                 g_set_error_literal (error,
154                                      HIF_ERROR,
155 @@ -269,18 +259,18 @@ hif_keyring_check_untrusted_file (rpmKey
156         ret = TRUE;
157  out:
158         if (dig != NULL)
159 -               pgpFreeDig (dig);
160 +               dig = pgpDigFree (dig);
161         if (td != NULL) {
162                 rpmtdFreeData (td);
163 -               rpmtdFree (td);
164 +               free (td);
165         }
166         if (ts != NULL)
167 -               rpmtsFree (ts);
168 +               ts = rpmtsFree (ts);
169         if (hdr != NULL)
170 -               headerFree (hdr);
171 +               hdr = headerFree (hdr);
172         if (fd != NULL)
173                 Fclose (fd);
174         if (header != NULL)
175 -               headerFree (header);
176 +               header = headerFree (header);
177         return ret;
178  }
179 --- PackageKit-0.8.15/backends/hawkey/hif-keyring.h.orig        2013-12-05 14:36:16.000000000 +0100
180 +++ PackageKit-0.8.15/backends/hawkey/hif-keyring.h     2014-01-19 16:52:38.130466677 +0100
181 @@ -24,14 +24,14 @@
182  
183  #include <glib.h>
184  
185 -#include <rpm/rpmkeyring.h>
186 +#include <rpm/rpmts.h>
187  
188 -gboolean        hif_keyring_add_public_key     (rpmKeyring              keyring,
189 +gboolean        hif_keyring_add_public_key     (const rpmts             ts,
190                                                  const gchar            *filename,
191                                                  GError                 **error);
192 -gboolean        hif_keyring_add_public_keys    (rpmKeyring              keyring,
193 +gboolean        hif_keyring_add_public_keys    (rpmts                   ts,
194                                                  GError                 **error);
195 -gboolean        hif_keyring_check_untrusted_file (rpmKeyring            keyring,
196 +gboolean        hif_keyring_check_untrusted_file (
197                                                  const gchar            *filename,
198                                                  GError                 **error);
199  
200 --- PackageKit-0.8.15/backends/hawkey/hif-rpmts.c.orig  2013-12-12 16:08:37.000000000 +0100
201 +++ PackageKit-0.8.15/backends/hawkey/hif-rpmts.c       2014-01-19 17:35:21.507025769 +0100
202 @@ -26,9 +26,11 @@
203  #endif
204  
205  #include <glib.h>
206 -#include <rpm/rpmlib.h>
207 +#include <rpm/rpm46compat.h>
208 +#include <rpm/pkgio.h>
209  #include <rpm/rpmlog.h>
210  #include <rpm/rpmdb.h>
211 +#include <rpm/rpmio.h>
212  
213  #include "hif-rpmts.h"
214  #include "hif-utils.h"
215 @@ -212,10 +214,17 @@ hif_rpmts_get_problem_str (rpmProblem pr
216                                        diskspace,
217                                        generic_str);
218                 break;
219 -       case RPMPROB_OBSOLETES:
220 -               str = g_strdup_printf ("package %s is obsoleted by %s",
221 -                                      pkg_nevr,
222 -                                      pkg_nevr_alt);
223 +       case RPMPROB_RDONLY:
224 +               str = g_strdup_printf ("tried to install package on read-only filesystem");
225 +               break;
226 +       case RPMPROB_BADPRETRANS:
227 +               str = g_strdup_printf ("bad %%pretrans?"); // unimplemented acc. to rpmps.h
228 +               break;
229 +       case RPMPROB_BADPLATFORM:
230 +               str = g_strdup_printf ("package %s is for a different platform", pkg_nevr);
231 +               break;
232 +       case RPMPROB_NOREPACKAGE:
233 +               str = g_strdup_printf ("re-packaged package %s is missing", pkg_nevr);
234                 break;
235         }
236         return str;
237 @@ -273,7 +282,7 @@ hif_rpmts_look_for_problems (rpmts ts, G
238  out:
239         if (string != NULL)
240                 g_string_free (string, TRUE);
241 -       rpmpsFree (probs);
242 +       probs = rpmpsFree (probs);
243         return ret;
244  }
245  
246 @@ -349,7 +358,7 @@ hif_rpmts_find_package (rpmts ts, HyPack
247         }
248  
249         /* success */
250 -       headerLink (hdr);
251 +       hdr = headerLink (hdr);
252  out:
253         rpmlogSetCallback (NULL, NULL);
254         if (rpm_error != NULL)
255 @@ -388,6 +397,6 @@ hif_rpmts_add_remove_pkg (rpmts ts, HyPa
256         }
257  out:
258         if (hdr != NULL)
259 -               headerFree (hdr);
260 +               hdr = headerFree (hdr);
261         return ret;
262  }
263 --- PackageKit-0.8.15/backends/hawkey/hif-state.c.orig  2013-12-12 16:07:44.000000000 +0100
264 +++ PackageKit-0.8.15/backends/hawkey/hif-state.c       2014-01-19 17:36:10.177023726 +0100
265 @@ -28,7 +28,6 @@
266  #include <glib.h>
267  #include <glib-unix.h>
268  #include <signal.h>
269 -#include <rpm/rpmsq.h>
270  
271  #include "hif-utils.h"
272  #include "hif-state.h"
273 --- PackageKit-0.8.15/backends/hawkey/pk-backend-hawkey.c.orig  2013-12-17 15:20:05.000000000 +0100
274 +++ PackageKit-0.8.15/backends/hawkey/pk-backend-hawkey.c       2014-01-19 19:40:01.683378522 +0100
275 @@ -39,12 +39,14 @@
276  #include <hawkey/version.h>
277  #include <hawkey/util.h>
278  #include <librepo/librepo.h>
279 -#include <rpm/rpmlib.h>
280 +#include "rpmorg-compat.h"
281  #include <rpm/rpmdb.h>
282 +#include <rpm/rpmio.h>
283  #include <rpm/rpmlog.h>
284 +#include <rpm/rpmmacro.h>
285  #include <rpm/rpmps.h>
286 +#include <rpm/rpmrc.h>
287  #include <rpm/rpmts.h>
288 -#include <rpm/rpmkeyring.h>
289  
290  #include "hif-db.h"
291  #include "hif-goal.h"
292 @@ -77,7 +79,6 @@ typedef struct {
293         HifDb           *db;
294         HifState        *state;
295         rpmts            ts;
296 -       rpmKeyring       keyring;
297         GPtrArray       *packages_to_download;
298         PkBitfield       transaction_flags;
299         HyGoal           goal;
300 @@ -286,29 +287,32 @@ pk_backend_initialize (PkBackend *backen
301                                "info");
302  
303         /* get info from RPM */
304 -       rpmGetOsInfo (&value, NULL);
305 +       value = rpmExpand ("%{_target_os}", NULL);
306         g_key_file_set_string (priv->config,
307                                HIF_CONFIG_GROUP_NAME,
308                                "Hawkey::OsInfo", value);
309 -       rpmGetArchInfo (&value, NULL);
310 +       value = rpmExpand ("%{_target_cpu}", NULL);
311         g_key_file_set_string (priv->config,
312                                HIF_CONFIG_GROUP_NAME,
313                                "Hawkey::ArchInfo", value);
314 -       rpmGetArchInfo (&value, NULL);
315         priv->native_arches = g_new0 (gchar *, 3);
316         priv->native_arches[0] = g_strdup (value);
317         priv->native_arches[1] = g_strdup ("noarch");
318 -       if (g_strcmp0 (value, "i486") == 0 ||
319 -           g_strcmp0 (value, "i586") == 0 ||
320 -           g_strcmp0 (value, "i686") == 0) {
321 +       if (strcmp (value, "i486") == 0 ||
322 +           strcmp (value, "i586") == 0 ||
323 +           strcmp (value, "i686") == 0 ||
324 +           strcmp (value, "athlon") == 0 ||
325 +           strcmp (value, "pentium2") == 0 ||
326 +           strcmp (value, "pentium3") == 0 ||
327 +           strcmp (value, "pentium4") == 0) {
328                 value = "i386";
329 -       } else if (g_strcmp0 (value, "armv7l") == 0 ||
330 -                  g_strcmp0 (value, "armv6l") == 0 ||
331 -                  g_strcmp0 (value, "armv5tejl") == 0 ||
332 -                  g_strcmp0 (value, "armv5tel") == 0) {
333 +       } else if (strcmp (value, "armv7l") == 0 ||
334 +                  strcmp (value, "armv6l") == 0 ||
335 +                  strcmp (value, "armv5tejl") == 0 ||
336 +                  strcmp (value, "armv5tel") == 0) {
337                 value = "arm";
338 -       } else if (g_strcmp0 (value, "armv7hnl") == 0 ||
339 -                g_strcmp0 (value, "armv7hl") == 0) {
340 +       } else if (strcmp (value, "armv7hnl") == 0 ||
341 +                strcmp (value, "armv7hl") == 0) {
342                 value = "armhfp";
343         }
344         g_key_file_set_string (priv->config,
345 @@ -476,7 +480,6 @@ pk_backend_start_job (PkBackend *backend
346  
347         /* setup RPM */
348         job_data->ts = rpmtsCreate ();
349 -       job_data->keyring = rpmtsGetKeyring (job_data->ts, 1);
350  
351         /* HifState */
352         job_data->packages_to_download =
353 @@ -546,8 +549,7 @@ pk_backend_stop_job (PkBackend *backend,
354         g_ptr_array_unref (job_data->packages_to_download);
355         if (job_data->goal != NULL)
356                 hy_goal_free (job_data->goal);
357 -       rpmtsFree (job_data->ts);
358 -       rpmKeyringFree (job_data->keyring);
359 +       job_data->ts = rpmtsFree (job_data->ts);
360         g_object_unref (job_data->db);
361         g_free (job_data);
362         pk_backend_job_set_user_data (job, NULL);
363 @@ -1911,7 +1913,7 @@ out:
364   * pk_backend_transaction_check_untrusted:
365   */
366  static gboolean
367 -pk_backend_transaction_check_untrusted (rpmKeyring keyring,
368 +pk_backend_transaction_check_untrusted (
369                                         GPtrArray *sources,
370                                         HyGoal goal,
371                                         GError **error)
372 @@ -1957,7 +1959,7 @@ pk_backend_transaction_check_untrusted (
373                 }
374  
375                 /* check file */
376 -               ret = hif_keyring_check_untrusted_file (keyring,
377 +               ret = hif_keyring_check_untrusted_file (
378                                                         filename,
379                                                         error);
380                 if (!ret)
381 @@ -2045,15 +2047,6 @@ hif_commit_rpmcb_type_to_string (const r
382         case RPMCALLBACK_SCRIPT_ERROR:
383                 type = "script-error";
384                 break;
385 -       case RPMCALLBACK_SCRIPT_START:
386 -               type = "script-start";
387 -               break;
388 -       case RPMCALLBACK_SCRIPT_STOP:
389 -               type = "script-stop";
390 -               break;
391 -       case RPMCALLBACK_INST_STOP:
392 -               type = "install-stop";
393 -               break;
394         }
395         return type;
396  }
397 @@ -2329,7 +2322,6 @@ hif_commit_ts_progress_cb (const void *a
398                 /* don't do anything */
399                 break;
400  
401 -       case RPMCALLBACK_INST_STOP:
402         case RPMCALLBACK_UNINST_STOP:
403  
404                 /* phase complete */
405 @@ -2344,8 +2336,6 @@ hif_commit_ts_progress_cb (const void *a
406         case RPMCALLBACK_UNPACK_ERROR:
407         case RPMCALLBACK_CPIO_ERROR:
408         case RPMCALLBACK_SCRIPT_ERROR:
409 -       case RPMCALLBACK_SCRIPT_START:
410 -       case RPMCALLBACK_SCRIPT_STOP:
411         case RPMCALLBACK_UNKNOWN:
412         case RPMCALLBACK_REPACKAGE_PROGRESS:
413         case RPMCALLBACK_REPACKAGE_START:
414 @@ -2738,14 +2728,14 @@ pk_backend_transaction_commit (PkBackend
415                 goto out;
416  
417         /* import all GPG keys */
418 -       ret = hif_keyring_add_public_keys (job_data->keyring, error);
419 +       ret = hif_keyring_add_public_keys (job_data->ts, error);
420         if (!ret)
421                 goto out;
422  
423         /* find any packages without valid GPG signatures */
424         if (pk_bitfield_contain (job_data->transaction_flags,
425                                  PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED)) {
426 -               ret = pk_backend_transaction_check_untrusted (job_data->keyring,
427 +               ret = pk_backend_transaction_check_untrusted (
428                                                               job_data->enabled_sources,
429                                                               job_data->goal,
430                                                               error);
431 @@ -2765,15 +2755,7 @@ pk_backend_transaction_commit (PkBackend
432         /* setup the transaction */
433         commit = g_new0 (HifTransactionCommit, 1);
434         commit->timer = g_timer_new ();
435 -       rc = rpmtsSetRootDir (job_data->ts, "/");
436 -       if (rc < 0) {
437 -               ret = FALSE;
438 -               g_set_error_literal (error,
439 -                                    HIF_ERROR,
440 -                                    PK_ERROR_ENUM_INTERNAL_ERROR,
441 -                                    "failed to set root");
442 -               goto out;
443 -       }
444 +       rpmtsSetRootDir (job_data->ts, "/");
445         rpmtsSetNotifyCallback (job_data->ts,
446                                 hif_commit_ts_progress_cb,
447                                 commit);
448 --- PackageKit-0.8.15/backends/hawkey/rpmorg-compat.h.orig      1970-01-01 01:00:00.000000000 +0100
449 +++ PackageKit-0.8.15/backends/hawkey/rpmorg-compat.h   2014-01-19 19:40:00.416711909 +0100
450 @@ -0,0 +1,64 @@
451 +#ifndef RPMORG_COMPAT_H
452 +#define RPMORG_COMPAT_H
453 +
454 +#include <rpm/rpm46compat.h>
455 +
456 +#define _RPMVSF_NOSIGNATURES (RPMVSF_NODSAHEADER | RPMVSF_NORSAHEADER | RPMVSF_NODSA | RPMVSF_NORSA)
457 +#define        _RPMVSF_NODIGESTS (RPMVSF_NOSHA1HEADER | RPMVSF_NOMD5HEADER | RPMVSF_NOSHA1 | RPMVSF_NOMD5)
458 +
459 +static inline const char * headerGetString(Header h, int32_t tag)
460 +{
461 +    const char *res = NULL;
462 +    struct rpmtd_s td;
463 +
464 +    if (headerGet(h, tag, &td, HEADERGET_MINMEM)) {
465 +       if (rpmtdCount(&td) == 1) {
466 +           res = rpmtdGetString(&td);
467 +       }
468 +       rpmtdFreeData(&td);
469 +    }
470 +    return res;
471 +}
472 +
473 +static inline uint64_t rpmtdGetNumber(rpmtd td)
474 +{
475 +    uint64_t val = 0;
476 +    int ix;
477 +    assert(td != NULL);
478 +    ix = (td->ix >= 0 ? td->ix : 0);
479 +
480 +    switch (td->type) {
481 +    case RPM_INT64_TYPE:
482 +       val = *((uint64_t *) td->data + ix);
483 +       break;
484 +    case RPM_INT32_TYPE:
485 +       val = *((uint32_t *) td->data + ix);
486 +       break;
487 +    case RPM_INT16_TYPE:
488 +       val = *((uint16_t *) td->data + ix);
489 +       break;
490 +    case RPM_INT8_TYPE:
491 +    case RPM_CHAR_TYPE:
492 +       val = *((uint8_t *) td->data + ix);
493 +       break;
494 +    default:
495 +       break;
496 +    }
497 +    return val;
498 +}
499 +
500 +static inline uint64_t headerGetNumber(Header h, int32_t tag)
501 +{
502 +    uint64_t res = 0;
503 +    struct rpmtd_s td;
504 +
505 +    if (headerGet(h, tag, &td, HEADERGET_EXT)) {
506 +       if (rpmtdCount(&td) == 1) {
507 +           res = rpmtdGetNumber(&td);
508 +       }
509 +       rpmtdFreeData(&td);
510 +    }
511 +    return res;
512 +}
513 +
514 +#endif /* RPMORG_COMPAT_H */
This page took 0.389116 seconds and 3 git commands to generate.