-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract a shared internal rpmostree-hif.[ch]
As we start to do more package things, extract common helper functions around HifContext * that by default operates on the system root. Some of these bits should go in libhif, but the immediate plan is to iterate here, then push downwards later.
- Loading branch information
Showing
7 changed files
with
137 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- | ||
* | ||
* Copyright (C) 2014 Colin Walters <walters@verbum.org> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; either version 2 of the licence or (at | ||
* your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General | ||
* Public License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#include <glib-unix.h> | ||
#include <rpm/rpmsq.h> | ||
#include <gio/gunixoutputstream.h> | ||
|
||
#include "rpmostree-hif.h" | ||
#include "rpmostree-cleanup.h" | ||
|
||
HifContext * | ||
_rpmostree_libhif_get_default (void) | ||
{ | ||
HifContext *hifctx; | ||
|
||
/* We can be control-c'd at any time */ | ||
#if BUILDOPT_HAVE_RPMSQ_SET_INTERRUPT_SAFETY | ||
rpmsqSetInterruptSafety (FALSE); | ||
#endif | ||
|
||
hifctx = hif_context_new (); | ||
|
||
hif_context_set_http_proxy (hifctx, g_getenv ("http_proxy")); | ||
|
||
hif_context_set_repo_dir (hifctx, "/etc/yum.repos.d"); | ||
hif_context_set_cache_dir (hifctx, "/var/cache/rpm-ostree/metadata"); | ||
hif_context_set_solv_dir (hifctx, "/var/cache/rpm-ostree/solv"); | ||
hif_context_set_lock_dir (hifctx, "/run/rpm-ostree/lock"); | ||
|
||
hif_context_set_check_disk_space (hifctx, FALSE); | ||
hif_context_set_check_transaction (hifctx, FALSE); | ||
|
||
return hifctx; | ||
} | ||
|
||
gboolean | ||
_rpmostree_libhif_setup (HifContext *context, | ||
GCancellable *cancellable, | ||
GError **error) | ||
{ | ||
if (!hif_context_setup (context, cancellable, error)) | ||
return FALSE; | ||
|
||
/* Forcibly override rpm/librepo SIGINT handlers. We always operate | ||
* in a fully idempotent/atomic mode, and can be killed at any time. | ||
*/ | ||
signal (SIGINT, SIG_DFL); | ||
signal (SIGTERM, SIG_DFL); | ||
|
||
return TRUE; | ||
} | ||
|
||
void | ||
_rpmostree_libhif_repos_disable_all (HifContext *context) | ||
{ | ||
GPtrArray *sources; | ||
guint i; | ||
|
||
sources = hif_context_get_sources (context); | ||
for (i = 0; i < sources->len; i++) | ||
{ | ||
HifSource *src = sources->pdata[i]; | ||
|
||
hif_source_set_enabled (src, HIF_SOURCE_ENABLED_NONE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- | ||
* | ||
* Copyright (C) 2015 Colin Walters <walters@verbum.org> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published | ||
* by the Free Software Foundation; either version 2 of the licence or (at | ||
* your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General | ||
* Public License along with this library; if not, write to the | ||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <gio/gio.h> | ||
#include <libhif.h> | ||
#include <libhif/hif-utils.h> | ||
|
||
HifContext *_rpmostree_libhif_get_default (void); | ||
|
||
gboolean _rpmostree_libhif_setup (HifContext *context, | ||
GCancellable *cancellable, | ||
GError **error); | ||
|
||
void _rpmostree_libhif_repos_disable_all (HifContext *context); |