Backport patch to fix Fedora composes writing data into source file:/// URIs

This commit is contained in:
Colin Walters 2016-03-31 14:02:18 -04:00
parent 4301486c90
commit 8240cf91ac
2 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,97 @@
From 63761e51274e7e35f8164896b3c4bac6582e80f1 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Thu, 31 Mar 2016 13:16:42 -0400
Subject: [PATCH] core: Skip over local packages for downloads
Because `hif_source_get_location()` is actually a reference to the
upstream repo, we shouldn't create a cache directory there.
This is just a two line fix, but I changed some things so that we keep
track of the number of local packages, in order to make the "Need to
download" print accurate.
We still need to add them (confusingly) to the `packages_to_download`
because that's also used for the container path which imports them.
Closes: #255
Closes: #256
Approved by: jlebon
---
src/libpriv/rpmostree-core.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/libpriv/rpmostree-core.c b/src/libpriv/rpmostree-core.c
index ae29999..08c3530 100644
--- a/src/libpriv/rpmostree-core.c
+++ b/src/libpriv/rpmostree-core.c
@@ -58,6 +58,7 @@ struct _RpmOstreeInstall {
GPtrArray *packages_requested;
/* Target state */
+ guint n_packages_download_local;
GPtrArray *packages_to_download;
guint64 n_bytes_to_fetch;
@@ -653,6 +654,7 @@ static gboolean
get_packages_to_download (HifContext *hifctx,
OstreeRepo *ostreerepo,
GPtrArray **out_packages,
+ guint *out_n_local,
GError **error)
{
gboolean ret = FALSE;
@@ -660,6 +662,7 @@ get_packages_to_download (HifContext *hifctx,
g_autoptr(GPtrArray) packages = NULL;
g_autoptr(GPtrArray) packages_to_download = NULL;
GPtrArray *sources = hif_context_get_repos (hifctx);
+ guint n_local = 0;
packages = hif_goal_get_packages (hif_context_get_goal (hifctx),
HIF_PACKAGE_INFO_INSTALL,
@@ -721,12 +724,15 @@ get_packages_to_download (HifContext *hifctx,
if (g_file_test (cachepath, G_FILE_TEST_EXISTS))
continue;
}
+ else
+ n_local++;
g_ptr_array_add (packages_to_download, g_object_ref (pkg));
}
ret = TRUE;
*out_packages = g_steal_pointer (&packages_to_download);
+ *out_n_local = n_local;
out:
return ret;
}
@@ -766,11 +772,14 @@ rpmostree_context_prepare_install (RpmOstreeContext *self,
}
printf ("%s", "done\n");
- if (!get_packages_to_download (hifctx, self->ostreerepo, &ret_install->packages_to_download, error))
+ if (!get_packages_to_download (hifctx, self->ostreerepo, &ret_install->packages_to_download,
+ &ret_install->n_packages_download_local,
+ error))
goto out;
rpmostree_print_transaction (hifctx);
- g_print ("\n Need to download %u packages\n", ret_install->packages_to_download->len);
+ g_print ("\n Need to download %u packages\n",
+ ret_install->packages_to_download->len - ret_install->n_packages_download_local);
ret = TRUE;
*out_install = g_steal_pointer (&ret_install);
@@ -957,6 +966,9 @@ source_download_packages (HifRepo *source,
HifPackage *pkg = packages->pdata[i];
struct PkgDownloadState *dlstate;
+ if (pkg_is_local (pkg))
+ continue;
+
if (target_dfd == -1)
{
target_dir = g_build_filename (hif_repo_get_location (source), "/packages/", NULL);
--
1.8.3.1

View File

@ -1,7 +1,7 @@
Summary: Client side upgrade program and server side compose tool
Name: rpm-ostree
Version: 2016.1
Release: 2%{?dist}
Release: 3%{?dist}
#VCS: https://github.com/cgwalters/rpm-ostree
# This tarball is generated via "make -f Makefile.dist-packaging dist-snapshot"
Source0: rpm-ostree-%{version}.tar.xz
@ -9,6 +9,7 @@ Source0: rpm-ostree-%{version}.tar.xz
# Bundled because the library is API/ABI unstable, and we're trying to
# avoid being version locked with PackageKit/dnf right now.
Source1: libhif.tar.gz
Patch0: 0001-core-Skip-over-local-packages-for-downloads.patch
Provides: bundled(libhif) = 0.7.0
License: LGPLv2+
URL: https://github.com/projectatomic/rpm-ostree
@ -145,6 +146,9 @@ python autofiles.py > files.devel \
%files devel -f files.devel
%changelog
* Thu Mar 31 2016 Colin Walters <walters@redhat.com> - 2016.1-3
- Backport patch to fix Fedora composes writing data into source file:/// URIs
* Thu Mar 24 2016 Colin Walters <walters@redhat.com> - 2016.1-2
- New upstream version