[libhif] Do not add the source to the sack if it does not exist
Richard Hughes
rhughes at fedoraproject.org
Tue Feb 3 15:57:16 UTC 2015
commit 2d2d403f2e0a772377f0591e143d97e0a6fd0ca7
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Feb 3 15:19:29 2015 +0000
Do not add the source to the sack if it does not exist
...led-local-source-does-not-exist-do-not-ad.patch | 64 ++++++++++++++++++++
libhif.spec | 9 +++-
2 files changed, 72 insertions(+), 1 deletions(-)
---
diff --git a/0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch b/0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch
new file mode 100644
index 0000000..88defd1
--- /dev/null
+++ b/0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch
@@ -0,0 +1,64 @@
+From 43188b72c5b88e0ec427dc0b24acae5f91c72390 Mon Sep 17 00:00:00 2001
+From: Richard Hughes <richard at hughsie.com>
+Date: Tue, 3 Feb 2015 15:15:49 +0000
+Subject: [PATCH] If the enabled local source does not exist do not add it to
+ the sack
+
+You can reproduce the problem setting baseurl=file:///notgoingtoexist in an
+enabled .repo file.
+
+Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1135740
+---
+ libhif/hif-sack.c | 7 +++++++
+ libhif/hif-source.c | 17 ++++++++++++++++-
+ 2 files changed, 23 insertions(+), 1 deletion(-)
+
+diff --git a/libhif/hif-sack.c b/libhif/hif-sack.c
+index 5f86c58..0aab526 100644
+--- a/libhif/hif-sack.c
++++ b/libhif/hif-sack.c
+@@ -93,6 +93,13 @@ hif_sack_add_source (HySack sack,
+ }
+ }
+
++ /* checking disabled the repo */
++ if (hif_source_get_enabled (src) == HIF_SOURCE_ENABLED_NONE) {
++ g_debug ("Skipping %s as repo no longer enabled",
++ hif_source_get_id (src));
++ return hif_state_finished (state, error);
++ }
++
+ /* done */
+ if (!hif_state_done (state, error))
+ return FALSE;
+diff --git a/libhif/hif-source.c b/libhif/hif-source.c
+index b38fcf4..bef2ba3 100644
+--- a/libhif/hif-source.c
++++ b/libhif/hif-source.c
+@@ -960,7 +960,22 @@ hif_source_check (HifSource *source,
+ if (priv->kind == HIF_SOURCE_KIND_MEDIA &&
+ !g_file_test (priv->location, G_FILE_TEST_EXISTS)) {
+ priv->enabled = HIF_SOURCE_ENABLED_NONE;
+- return TRUE;
++ g_set_error (error,
++ HIF_ERROR,
++ HIF_ERROR_SOURCE_NOT_AVAILABLE,
++ "%s was not found", priv->location);
++ return FALSE;
++ }
++
++ /* has the local repo vanished? */
++ if (priv->kind == HIF_SOURCE_KIND_LOCAL &&
++ !g_file_test (priv->location, G_FILE_TEST_EXISTS)) {
++ priv->enabled = HIF_SOURCE_ENABLED_NONE;
++ g_set_error (error,
++ HIF_ERROR,
++ HIF_ERROR_SOURCE_NOT_AVAILABLE,
++ "%s was not found", priv->location);
++ return FALSE;
+ }
+
+ /* Yum metadata */
+--
+2.1.0
+
diff --git a/libhif.spec b/libhif.spec
index ee1d067..2d2ca2a 100644
--- a/libhif.spec
+++ b/libhif.spec
@@ -1,7 +1,7 @@
Summary: Simple package library built on top of hawkey and librepo
Name: libhif
Version: 0.1.8
-Release: 2%{?dist}
+Release: 3%{?dist}
License: LGPLv2+
URL: https://github.com/hughsie/libhif
Source0: http://people.freedesktop.org/~hughsient/releases/libhif-%{version}.tar.xz
@@ -18,6 +18,7 @@ BuildRequires: libsolv-devel
# already upstream
Patch0: 0001-Ensure-the-mirror-list-is-set-before-trying-to-downl.patch
+Patch1: 0001-If-the-enabled-local-source-does-not-exist-do-not-ad.patch
%description
This library provides a simple interface to hawkey and librepo and is currently
@@ -33,6 +34,7 @@ GLib headers and libraries for libhif.
%prep
%setup -q
%patch0 -p1 -b .naughty-librepo
+%patch1 -p1 -b .file-repo-not-exists
%build
%configure \
@@ -65,6 +67,11 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/libhif*.la
%{_datadir}/gir-1.0/*.gir
%changelog
+* Tue Feb 03 2015 Richard Hughes <richard at hughsie.com> 0.1.8-3
+- Do not add the source to the sack if it does not exist, which fixes a crash
+ for repo files with things like baseurl=file:///notgoingtoexist
+- Resolves: #1135740
+
* Tue Feb 03 2015 Richard Hughes <richard at hughsie.com> 0.1.8-2
- Ensure the mirror list is set before trying to download packages
- This works around a librepo behaviour change in the latest update
More information about the scm-commits
mailing list