]> git.pld-linux.org Git - packages/libhif.git/commitdiff
- new, with preliminary rpm5 port auto/th/libhif-0.1.0-1
authorJakub Bogusz <qboosh@pld-linux.org>
Sun, 15 Jun 2014 07:38:47 +0000 (09:38 +0200)
committerJakub Bogusz <qboosh@pld-linux.org>
Sun, 15 Jun 2014 07:38:47 +0000 (09:38 +0200)
libhif-rpm5.patch [new file with mode: 0644]
libhif.spec [new file with mode: 0644]

diff --git a/libhif-rpm5.patch b/libhif-rpm5.patch
new file mode 100644 (file)
index 0000000..095539c
--- /dev/null
@@ -0,0 +1,479 @@
+--- libhif-0.1.0/libhif/hif-context.c.orig     2014-06-04 10:15:54.000000000 +0200
++++ libhif-0.1.0/libhif/hif-context.c  2014-06-15 07:25:26.340531502 +0200
+@@ -31,7 +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>
+@@ -801,13 +802,17 @@ 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);
+       if (g_strcmp0 (value, "i486") == 0 ||
+           g_strcmp0 (value, "i586") == 0 ||
+-          g_strcmp0 (value, "i686") == 0) {
++          g_strcmp0 (value, "i686") == 0 ||
++          g_strcmp0 (value, "athlon") == 0 ||
++          g_strcmp0 (value, "pentium2") == 0 ||
++          g_strcmp0 (value, "pentium3") == 0 ||
++          g_strcmp0 (value, "pentium4") == 0) {
+               value = "i386";
+       } else if (g_strcmp0 (value, "armv7l") == 0 ||
+                  g_strcmp0 (value, "armv6l") == 0 ||
+--- 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.0/libhif/hif-transaction.c.orig 2014-06-10 12:06:55.000000000 +0200
++++ libhif-0.1.0/libhif/hif-transaction.c      2014-06-15 08:04:22.977149465 +0200
+@@ -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;
+       GPtrArray               *sources;
+@@ -96,8 +96,7 @@ hif_transaction_finalize (GObject *objec
+       g_ptr_array_unref (priv->pkgs_to_download);
+       g_object_unref (priv->context);
+       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);
+@@ -121,7 +120,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);
+ }
+@@ -371,7 +369,7 @@ hif_transaction_check_untrusted (HifTran
+               }
+               /* check file */
+-              ret = hif_keyring_check_untrusted_file (priv->keyring,
++              ret = hif_keyring_check_untrusted_file (
+                                                       filename,
+                                                       error);
+               if (!ret)
+@@ -439,15 +437,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;
+ }
+@@ -735,7 +724,6 @@ hif_transaction_ts_progress_cb (const vo
+               /* don't do anything */
+               break;
+-      case RPMCALLBACK_INST_STOP:
+       case RPMCALLBACK_UNINST_STOP:
+               /* phase complete */
+@@ -749,8 +737,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:
+@@ -1292,15 +1278,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 */
diff --git a/libhif.spec b/libhif.spec
new file mode 100644 (file)
index 0000000..543f36a
--- /dev/null
@@ -0,0 +1,119 @@
+Summary:       Simple package library built on top of hawkey and librepo
+Summary(pl.UTF-8):     Prosta biblioteka obsługi pakietów oparta na bibliotekach hawkey i librepo
+Name:          libhif
+Version:       0.1.0
+Release:       1
+License:       LGPL v2.1+
+Group:         Libraries
+Source0:       http://people.freedesktop.org/~hughsient/releases/%{name}-%{version}.tar.xz
+# Source0-md5: 50d2fcc5cd61d93af70168a4a4ea1e1b
+Patch0:                %{name}-rpm5.patch
+URL:           https://github.com/hughsie/libhif
+BuildRequires: glib2-devel >= 1:2.36.0
+BuildRequires: gobject-introspection-devel >= 0.9.8
+BuildRequires: gtk-doc >= 1.9
+BuildRequires: hawkey-devel >= 0.4.6
+BuildRequires: librepo-devel >= 0.1.5
+BuildRequires: libsolv-devel
+BuildRequires: pkgconfig
+BuildRequires: rpm-devel >= 5
+BuildRequires: tar >= 1:1.22
+BuildRequires: xz
+Requires:      glib2 >= 1:2.36.0
+Requires:      hawkey >= 0.4.6
+Requires:      librepo >= 0.1.5
+BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+This library provides a simple interface to hawkey and librepo and is
+currently used by PackageKit and rpm-ostree.
+
+%description -l pl.UTF-8
+Ta biblioteka udostępnia prosty interfejs do bibliotek hawkey i
+librepo, jest obecnie używana przez pakiety PackageKit i rpm-ostree.
+
+%package devel
+Summary:       Header files for libhif library
+Summary(pl.UTF-8):     Pliki nagłówkowe biblioteki libhif
+Group:         Development/Libraries
+Requires:      %{name} = %{version}-%{release}
+Requires:      glib2-devel >= 1:2.36.0
+Requires:      hawkey-devel >= 0.4.6
+Requires:      librepo-devel >= 0.1.5
+Requires:      rpm-devel >= 5
+
+%description devel
+Header files for libhif library.
+
+%description devel -l pl.UTF-8
+Pliki nagłówkowe biblioteki libhif.
+
+%package static
+Summary:       Static libhif library
+Summary(pl.UTF-8):     Statyczna biblioteka libhif
+Group:         Development/Libraries
+Requires:      %{name}-devel = %{version}-%{release}
+
+%description static
+Static libhif library.
+
+%description static -l pl.UTF-8
+Statyczna biblioteka libhif.
+
+%package apidocs
+Summary:       libhif API documentation
+Summary(pl.UTF-8):     Dokumentacja API biblioteki libhif
+Group:         Documentation
+
+%description apidocs
+API documentation for libhif library.
+
+%description apidocs -l pl.UTF-8
+Dokumentacja API biblioteki libhif.
+
+%prep
+%setup -q
+%patch0 -p1
+
+%build
+%configure \
+       --disable-silent-rules \
+       --with-html-dir=%{_gtkdocdir}
+%{__make}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%{__make} install \
+       DESTDIR=$RPM_BUILD_ROOT
+
+# obsoleted by pkg-config
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/libhif.la
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post  -p /sbin/ldconfig
+%postun        -p /sbin/ldconfig
+
+%files
+%defattr(644,root,root,755)
+%doc AUTHORS MAINTAINERS NEWS README.md
+%attr(755,root,root) %{_libdir}/libhif.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libhif.so.1
+%{_libdir}/girepository-1.0/Hif-1.0.typelib
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libhif.so
+%{_datadir}/gir-1.0/Hif-1.0.gir
+%{_includedir}/libhif
+%{_pkgconfigdir}/libhif.pc
+
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libhif.a
+
+%files apidocs
+%defattr(644,root,root,755)
+%{_gtkdocdir}/libhif
This page took 0.11246 seconds and 4 git commands to generate.