Skip to content

Commit 340f2aa

Browse files
committed
Disable downloading filelists by default
Disable filelists from being downloaded by default for Fedora 40. Adds the `DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS` where applicable, which prevents the filelists from being downloaded. For the changes in `rpmostree_context_prepare()`, disabling filelists is conditional on whether a filepath was specified for `rpm-ostree install` (ie. rpm-ostree install /usr/bin/htop). For the changes in refresh_md_transaction_execute(), `rpm-ostree refresh-md` will not download filelists if they were not previously downloaded. If they were previously downloaded, the filelists will be updated. Since there are many functions affected by this change, the option to return to the previous filelist behaviour is also implemented. This is done by adding: [Service] Environment="DOWNLOAD_FILELISTS=true" in a newly created conf file under /etc/systemd/system/rpm-ostreed.service.d For example: /etc/systemd/system/rpm-ostreed.service.d/filelists.conf
1 parent a10cffa commit 340f2aa

File tree

11 files changed

+317
-30
lines changed

11 files changed

+317
-30
lines changed

src/app/rpmostree-compose-builtin-tree.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ install_packages (RpmOstreeTreeComposeContext *self, gboolean *out_unmodified,
397397
}
398398
}
399399

400-
if (!rpmostree_context_prepare (self->corectx, cancellable, error))
400+
if (!rpmostree_context_prepare (self->corectx, TRUE, cancellable, error))
401401
return FALSE;
402402

403403
rpmostree_print_transaction (dnfctx);
@@ -1685,7 +1685,7 @@ rpmostree_compose_builtin_extensions (int argc, char **argv, RpmOstreeCommandInv
16851685

16861686
#undef TMP_EXTENSIONS_ROOTFS
16871687

1688-
if (!rpmostree_context_prepare (ctx, cancellable, error))
1688+
if (!rpmostree_context_prepare (ctx, FALSE, cancellable, error))
16891689
return FALSE;
16901690

16911691
if (!glnx_shutil_mkdir_p_at (AT_FDCWD, opt_extensions_output_dir, 0755, cancellable, error))

src/daemon/rpm-ostreed.service

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ TimeoutStartSec=5m
2828
# with the rpm-ostree user.
2929
ExecStart=+rpm-ostree start-daemon
3030
ExecReload=rpm-ostree reload
31+
# disable/enable downloading filelists
32+
Environment="DOWNLOAD_FILELISTS=false"

src/daemon/rpmostree-sysroot-upgrader.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self, GCancellable *cancellable,
953953

954954
if (rpmostree_origin_has_any_packages (self->computed_origin))
955955
{
956-
if (!rpmostree_context_prepare (self->ctx, cancellable, error))
956+
if (!rpmostree_context_prepare (self->ctx, FALSE, cancellable, error))
957957
return FALSE;
958958
self->layering_type = RPMOSTREE_SYSROOT_UPGRADER_LAYERING_RPMMD_REPOS;
959959

@@ -967,7 +967,7 @@ prep_local_assembly (RpmOstreeSysrootUpgrader *self, GCancellable *cancellable,
967967
* See comment in rpmostree_origin_may_require_local_assembly(). */
968968
if (rpmostree_origin_has_modules_enable (self->computed_origin))
969969
{
970-
if (!rpmostree_context_prepare (self->ctx, cancellable, error))
970+
if (!rpmostree_context_prepare (self->ctx, FALSE, cancellable, error))
971971
return FALSE;
972972
}
973973
rpmostree_context_set_is_empty (self->ctx);

src/daemon/rpmostreed-os.cxx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,8 @@ os_handle_modify_yum_repo (RPMOSTreeOS *interface, GDBusMethodInvocation *invoca
911911
}
912912

913913
static DnfContext *
914-
os_create_dnf_context_simple (RPMOSTreeOS *interface, gboolean with_sack, GCancellable *cancellable,
915-
GError **error)
914+
os_create_dnf_context_simple (RPMOSTreeOS *interface, gboolean with_sack, gboolean enable_filelists,
915+
GCancellable *cancellable, GError **error)
916916
{
917917
glnx_unref_object OstreeSysroot *ot_sysroot = NULL;
918918
const gchar *os_name = rpmostree_os_get_name (interface);
@@ -947,14 +947,29 @@ os_create_dnf_context_simple (RPMOSTreeOS *interface, gboolean with_sack, GCance
947947
/* point libdnf to our repos dir */
948948
rpmostree_context_configure_from_deployment (ctx, ot_sysroot, cfg_merge_deployment);
949949

950-
if (with_sack
951-
&& !rpmostree_context_download_metadata (
952-
ctx,
953-
static_cast<DnfContextSetupSackFlags> (DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB
954-
| DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO),
955-
cancellable, error))
956-
return NULL;
950+
auto flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB
951+
| DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS
952+
| DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO);
953+
954+
char *download_filelists = (char *)"false";
955+
if (g_getenv ("DOWNLOAD_FILELISTS"))
956+
{
957+
download_filelists = (char *)(g_getenv ("DOWNLOAD_FILELISTS"));
958+
for (int i = 0; i < strlen (download_filelists); i++)
959+
{
960+
download_filelists[i] = tolower (download_filelists[i]);
961+
}
962+
}
957963

964+
/* check if filelist optimization is disabled */
965+
if (strcmp (download_filelists, "true") == 0 || enable_filelists)
966+
{
967+
flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB
968+
| DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO);
969+
}
970+
971+
if (with_sack && !rpmostree_context_download_metadata (ctx, flags, cancellable, error))
972+
return NULL;
958973
DnfContext *dnfctx = rpmostree_context_get_dnf (ctx);
959974
return static_cast<DnfContext *> (g_object_ref (dnfctx));
960975
}
@@ -968,7 +983,7 @@ os_handle_list_repos (RPMOSTreeOS *interface, GDBusMethodInvocation *invocation)
968983
sd_journal_print (LOG_INFO, "Handling ListRepos for caller %s",
969984
g_dbus_method_invocation_get_sender (invocation));
970985

971-
dnfctx = os_create_dnf_context_simple (interface, FALSE, NULL, &local_error);
986+
dnfctx = os_create_dnf_context_simple (interface, FALSE, FALSE, NULL, &local_error);
972987
if (dnfctx == NULL)
973988
return os_throw_dbus_invocation_error (invocation, &local_error);
974989

@@ -1073,7 +1088,7 @@ os_handle_what_provides (RPMOSTreeOS *interface, GDBusMethodInvocation *invocati
10731088
sd_journal_print (LOG_INFO, "Handling WhatProvides for caller %s",
10741089
g_dbus_method_invocation_get_sender (invocation));
10751090

1076-
dnfctx = os_create_dnf_context_simple (interface, TRUE, cancellable, &local_error);
1091+
dnfctx = os_create_dnf_context_simple (interface, TRUE, FALSE, cancellable, &local_error);
10771092
if (dnfctx == NULL)
10781093
return os_throw_dbus_invocation_error (invocation, &local_error);
10791094

@@ -1112,7 +1127,7 @@ os_handle_get_packages (RPMOSTreeOS *interface, GDBusMethodInvocation *invocatio
11121127
sd_journal_print (LOG_INFO, "Handling GetPackages for caller %s",
11131128
g_dbus_method_invocation_get_sender (invocation));
11141129

1115-
dnfctx = os_create_dnf_context_simple (interface, TRUE, cancellable, &local_error);
1130+
dnfctx = os_create_dnf_context_simple (interface, TRUE, FALSE, cancellable, &local_error);
11161131
if (dnfctx == NULL)
11171132
return os_throw_dbus_invocation_error (invocation, &local_error);
11181133

@@ -1317,7 +1332,7 @@ os_handle_search (RPMOSTreeOS *interface, GDBusMethodInvocation *invocation,
13171332
}
13181333

13191334
g_autoptr (DnfContext) dnfctx
1320-
= os_create_dnf_context_simple (interface, TRUE, cancellable, &local_error);
1335+
= os_create_dnf_context_simple (interface, TRUE, FALSE, cancellable, &local_error);
13211336
if (dnfctx == NULL)
13221337
return os_throw_dbus_invocation_error (invocation, &local_error);
13231338

src/daemon/rpmostreed-transaction-types.cxx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,8 +2279,30 @@ refresh_md_transaction_execute (RpmostreedTransaction *transaction, GCancellable
22792279
rpmostree_context_configure_from_deployment (ctx, sysroot, cfg_merge_deployment);
22802280

22812281
/* don't even bother loading the rpmdb */
2282-
if (!rpmostree_context_download_metadata (ctx, DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB,
2283-
cancellable, error))
2282+
2283+
/* skip filelists if filelists have not been previously downloaded */
2284+
auto flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB
2285+
| DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS);
2286+
2287+
/* update filelists if filelists were previously downloaded or filelist optimization is disabled
2288+
*/
2289+
2290+
char *download_filelists = (char *)"false";
2291+
if (g_getenv ("DOWNLOAD_FILELISTS"))
2292+
{
2293+
download_filelists = (char *)(g_getenv ("DOWNLOAD_FILELISTS"));
2294+
for (int i = 0; i < strlen (download_filelists); i++)
2295+
{
2296+
download_filelists[i] = tolower (download_filelists[i]);
2297+
}
2298+
}
2299+
2300+
if (rpmostree_context_get_filelists_exist (ctx) || strcmp (download_filelists, "true") == 0)
2301+
{
2302+
flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB);
2303+
}
2304+
2305+
if (!rpmostree_context_download_metadata (ctx, flags, cancellable, error))
22842306
return FALSE;
22852307

22862308
return TRUE;

src/libpriv/rpmostree-container.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ rpmostree_container_rebuild (rpmostreecxx::Treefile &treefile, GCancellable *can
5959
if (!rpmostree_context_setup (ctx, "/", "/", cancellable, error))
6060
return FALSE;
6161

62-
if (!rpmostree_context_prepare (ctx, cancellable, error))
62+
if (!rpmostree_context_prepare (ctx, FALSE, cancellable, error))
6363
return FALSE;
6464

6565
if (!rpmostree_context_download (ctx, cancellable, error))
@@ -93,4 +93,4 @@ container_rebuild (rust::Str treefile)
9393
if (!rpmostree_container_rebuild (*tf, NULL, &local_error))
9494
util::throw_gerror (local_error);
9595
}
96-
}
96+
}

src/libpriv/rpmostree-core-private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ struct _RpmOstreeContext
7373

7474
GHashTable *fileoverride_pkgs; /* set of nevras */
7575

76+
gboolean filelists_exist;
77+
7678
std::optional<rust::Box<rpmostreecxx::LockfileConfig> > lockfile;
7779
gboolean lockfile_strict;
7880

src/libpriv/rpmostree-core.cxx

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ rpmostree_context_init (RpmOstreeContext *self)
119119
self->dnf_cache_policy = RPMOSTREE_CONTEXT_DNF_CACHE_DEFAULT;
120120
self->enable_rofiles = TRUE;
121121
self->unprivileged = getuid () != 0;
122+
self->filelists_exist = FALSE;
122123
}
123124

124125
static void
@@ -428,6 +429,18 @@ rpmostree_context_get_dnf (RpmOstreeContext *self)
428429
return self->dnfctx;
429430
}
430431

432+
gboolean
433+
rpmostree_context_get_filelists_exist (RpmOstreeContext *self)
434+
{
435+
return self->filelists_exist;
436+
}
437+
438+
void
439+
rpmostree_context_set_filelists_exist (RpmOstreeContext *self, gboolean filelists_exist)
440+
{
441+
self->filelists_exist = filelists_exist;
442+
}
443+
431444
/* Add rpmmd repo information, since it's very useful for determining
432445
* state. See also:
433446
*
@@ -1055,7 +1068,6 @@ rpmostree_context_download_metadata (RpmOstreeContext *self, DnfContextSetupSack
10551068
dnf_repo_get_id (repo), !updated ? " (cached)" : "", repo_ts_str,
10561069
dnf_repo_get_n_solvables (repo));
10571070
}
1058-
10591071
return TRUE;
10601072
}
10611073

@@ -1724,7 +1736,8 @@ find_locked_packages (RpmOstreeContext *self, GPtrArray **out_pkgs, GError **err
17241736

17251737
/* Check for/download new rpm-md, then depsolve */
17261738
gboolean
1727-
rpmostree_context_prepare (RpmOstreeContext *self, GCancellable *cancellable, GError **error)
1739+
rpmostree_context_prepare (RpmOstreeContext *self, gboolean enable_filelists,
1740+
GCancellable *cancellable, GError **error)
17281741
{
17291742
g_assert (!self->empty);
17301743

@@ -1759,10 +1772,43 @@ rpmostree_context_prepare (RpmOstreeContext *self, GCancellable *cancellable, GE
17591772
/* setup sack if not yet set up */
17601773
if (dnf_context_get_sack (dnfctx) == NULL)
17611774
{
1775+
auto flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO
1776+
| DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS);
1777+
1778+
char *download_filelists = (char *)"false";
1779+
if (g_getenv ("DOWNLOAD_FILELISTS"))
1780+
{
1781+
download_filelists = (char *)(g_getenv ("DOWNLOAD_FILELISTS"));
1782+
for (int i = 0; i < strlen (download_filelists); i++)
1783+
{
1784+
download_filelists[i] = tolower (download_filelists[i]);
1785+
}
1786+
}
1787+
1788+
/* check if filelist optimization is disabled */
1789+
if (strcmp (download_filelists, "true") == 0 || enable_filelists)
1790+
{
1791+
flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO);
1792+
}
1793+
else
1794+
{
1795+
auto pkg = "";
1796+
for (auto &pkg_str : packages)
1797+
{
1798+
pkg = std::string (pkg_str).c_str ();
1799+
char *query = strchr ((char *)pkg, '/');
1800+
if (query)
1801+
{
1802+
flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO);
1803+
rpmostree_context_set_filelists_exist (self, TRUE);
1804+
break;
1805+
}
1806+
}
1807+
}
1808+
17621809
/* default to loading updateinfo in this path; this allows the sack to be used later
17631810
* on for advisories -- it's always downloaded anyway */
1764-
if (!rpmostree_context_download_metadata (self, DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO,
1765-
cancellable, error))
1811+
if (!rpmostree_context_download_metadata (self, flags, cancellable, error))
17661812
return FALSE;
17671813
journal_rpmmd_info (self);
17681814
}
@@ -2295,8 +2341,26 @@ rpmostree_find_and_download_packages (const char *const *packages, const char *s
22952341
g_autofree char *reposdir = g_build_filename (repo_root ?: source_root, "etc/yum.repos.d", NULL);
22962342
dnf_context_set_repo_dir (ctx->dnfctx, reposdir);
22972343

2298-
if (!rpmostree_context_download_metadata (ctx, DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB,
2299-
cancellable, error))
2344+
auto flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB
2345+
| DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS);
2346+
2347+
char *download_filelists = (char *)"false";
2348+
if (g_getenv ("DOWNLOAD_FILELISTS"))
2349+
{
2350+
download_filelists = (char *)(g_getenv ("DOWNLOAD_FILELISTS"));
2351+
for (int i = 0; i < strlen (download_filelists); i++)
2352+
{
2353+
download_filelists[i] = tolower (download_filelists[i]);
2354+
}
2355+
}
2356+
2357+
/* check if filelist optimization is disabled */
2358+
if (strcmp (download_filelists, "true") == 0)
2359+
{
2360+
flags = (DnfContextSetupSackFlags)(DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_RPMDB);
2361+
}
2362+
2363+
if (!rpmostree_context_download_metadata (ctx, flags, cancellable, error))
23002364
return glnx_prefix_error (error, "Downloading metadata");
23012365

23022366
g_autoptr (GPtrArray) pkgs = g_ptr_array_new_with_free_func (g_object_unref);

src/libpriv/rpmostree-core.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ gboolean rpmostree_context_download_metadata (RpmOstreeContext *context,
134134
GCancellable *cancellable, GError **error);
135135

136136
/* This API allocates an install context, use with one of the later ones */
137-
gboolean rpmostree_context_prepare (RpmOstreeContext *self, GCancellable *cancellable,
138-
GError **error);
137+
gboolean rpmostree_context_prepare (RpmOstreeContext *self, gboolean enable_filelists,
138+
GCancellable *cancellable, GError **error);
139139

140140
GPtrArray *rpmostree_context_get_packages (RpmOstreeContext *self);
141141

@@ -166,6 +166,10 @@ gboolean rpmostree_context_import (RpmOstreeContext *self, GCancellable *cancell
166166
gboolean rpmostree_context_force_relabel (RpmOstreeContext *self, GCancellable *cancellable,
167167
GError **error);
168168

169+
gboolean rpmostree_context_get_filelists_exist (RpmOstreeContext *);
170+
171+
void rpmostree_context_set_filelists_exist (RpmOstreeContext *, gboolean filelists_exist);
172+
169173
typedef enum
170174
{
171175
RPMOSTREE_ASSEMBLE_TYPE_SERVER_BASE,

tests/common/libtest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,5 +537,5 @@ rpmostree_busctl_call_os() {
537537
stateroot=$(rpm-ostree status --booted --json | jq -r '.deployments[0].osname')
538538
ospath=/org/projectatomic/rpmostree1/${stateroot//-/_}
539539
busctl call org.projectatomic.rpmostree1 $ospath \
540-
org.projectatomic.rpmostree1.OS "$@"
540+
org.projectatomic.rpmostree1.OS "$@" --timeout=240s
541541
}

0 commit comments

Comments
 (0)