core: allow no enabled repos for local pkgs

This is a valid case when layering local RPMs. Otherwise (e.g. if
specific non-local packages are requested), give the nicer error rather
than letting libdnf throw something less useful.

Closes: #780

Closes: #781
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2017-05-19 09:44:57 -04:00 committed by Atomic Bot
parent 2ada15aff3
commit 174510fc5d
3 changed files with 24 additions and 6 deletions

View File

@ -568,7 +568,6 @@ rpmostree_context_setup (RpmOstreeContext *self,
GCancellable *cancellable,
GError **error)
{
GPtrArray *repos = NULL;
g_autofree char **enabled_repos = NULL;
g_autofree char **instlangs = NULL;
@ -615,15 +614,22 @@ rpmostree_context_setup (RpmOstreeContext *self,
if (!dnf_context_setup (self->hifctx, cancellable, error))
return FALSE;
/* NB: missing repo --> let hif figure it out for itself */
/* NB: missing "repos" --> let hif figure it out for itself */
if (g_variant_dict_lookup (self->spec->dict, "repos", "^a&s", &enabled_repos))
if (!context_repos_enable_only (self, (const char *const*)enabled_repos, error))
return FALSE;
repos = dnf_context_get_repos (self->hifctx);
GPtrArray *repos = dnf_context_get_repos (self->hifctx);
if (repos->len == 0)
return glnx_throw (error, "No enabled repositories");
{
/* To be nice, let's only make this fatal if "packages" is empty (e.g. if
* we're only installing local RPMs. Missing deps will cause the regular
* 'not found' error from libdnf. */
g_autofree char **pkgs = NULL;
if (g_variant_dict_lookup (self->spec->dict, "packages", "^a&s", &pkgs) &&
g_strv_length (pkgs) > 0)
return glnx_throw (error, "No enabled repositories");
}
require_enabled_repos (repos);
{ gboolean docs;

View File

@ -28,6 +28,7 @@ vm_send_test_repo
vm_assert_layered_pkg foo absent
vm_cmd ostree refs $(vm_get_deployment_info 0 checksum) --create vmcheck_tmp/without_foo
vm_rpmostree install /tmp/vmcheck/repo/packages/x86_64/foo-1.0-1.x86_64.rpm
echo "ok install foo locally"
@ -65,3 +66,10 @@ if vm_rpmostree install /tmp/vmcheck/repo/packages/x86_64/foo-1.0-1.x86_64.rpm;
assert_not_reached "didn't error out when trying to install same pkg"
fi
echo "ok error on layering same pkg in base"
# check that installing local RPMs without any repos available works
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/without_foo
vm_rpmostree upgrade
vm_cmd rm -rf /etc/yum.repos.d/
vm_rpmostree install /tmp/vmcheck/repo/packages/x86_64/foo-1.0-1.x86_64.rpm
echo "ok layer local foo without repos"

View File

@ -55,7 +55,7 @@ if ! vm_cmd test -f /etc/yum.repos.d/.vmcheck; then
vm_cmd rm /etc/yum.repos.d.tmp -rf
vm_cmd mkdir /etc/yum.repos.d.tmp
vm_cmd touch /etc/yum.repos.d.tmp/.vmcheck
vm_cmd mv /etc/yum.repos.d{.tmp,}
vm_cmd cp -r /etc/yum.repos.d{.tmp,}
else
echo "Keeping existing vmcheck /etc/yum.repos.d"
fi
@ -152,6 +152,10 @@ for tf in $(find . -name 'test-*.sh' | sort); do
# make sure to clean up any pending & rollback deployments
vm_rpmostree cleanup -b -p -r || :
# and put back our tmp repo
vm_cmd rm /etc/yum.repos.d -rf
vm_cmd cp -r /etc/yum.repos.d{.tmp,}
done