62
62
#include "utils/url-encode.hpp"
63
63
#include "utils/utils.hpp"
64
64
65
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
65
66
#include <map>
67
+ #endif
66
68
#include <set>
67
69
#include <string>
68
70
#include <vector>
@@ -88,7 +90,9 @@ typedef struct
88
90
LrHandle * repo_handle ;
89
91
LrResult * repo_result ;
90
92
LrUrlVars * urlvars ;
93
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
91
94
std ::map < std ::string , std ::string > * config_changes ; // dnf_repo_set_data, dnf_repo_commit
95
+ #endif
92
96
bool unit_test_mode ; /* ugly hack for unit tests */
93
97
} DnfRepoPrivate ;
94
98
@@ -124,8 +128,10 @@ dnf_repo_finalize(GObject *object)
124
128
if (priv -> context != NULL )
125
129
g_object_remove_weak_pointer (G_OBJECT (priv -> context ),
126
130
(void * * ) & priv -> context );
131
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
127
132
if (priv -> config_changes )
128
133
delete priv -> config_changes ;
134
+ #endif
129
135
130
136
G_OBJECT_CLASS (dnf_repo_parent_class )-> finalize (object );
131
137
}
@@ -930,6 +936,7 @@ dnf_repo_conf_from_gkeyfile(DnfRepo *repo, const char *repoId, GKeyFile *gkeyFil
930
936
}
931
937
}
932
938
939
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
933
940
/* Loads repository configuration overrides */
934
941
static void
935
942
dnf_repo_conf_load_overrides (DnfRepo * repo , const char * repoId )
@@ -987,7 +994,7 @@ dnf_repo_conf_load_overrides(DnfRepo *repo, const char *repoId)
987
994
}
988
995
}
989
996
}
990
-
997
+ #endif
991
998
992
999
static void
993
1000
dnf_repo_apply_setopts (libdnf ::ConfigRepo & config , const char * repoId )
@@ -1032,7 +1039,9 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, gboolean reloadFromGKeyFile, GError **e
1032
1039
// Reload repository configuration from keyfile.
1033
1040
if (reloadFromGKeyFile ) {
1034
1041
dnf_repo_conf_from_gkeyfile (repo , repoId , priv -> keyfile );
1042
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
1035
1043
dnf_repo_conf_load_overrides (repo , repoId );
1044
+ #endif
1036
1045
dnf_repo_apply_setopts (* conf , repoId );
1037
1046
}
1038
1047
@@ -1314,7 +1323,9 @@ dnf_repo_setup(DnfRepo *repo, GError **error) try
1314
1323
1315
1324
auto conf = priv -> repo -> getConfig ();
1316
1325
dnf_repo_conf_from_gkeyfile (repo , repoId , priv -> keyfile );
1326
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
1317
1327
dnf_repo_conf_load_overrides (repo , repoId );
1328
+ #endif
1318
1329
dnf_repo_apply_setopts (* conf , repoId );
1319
1330
1320
1331
auto sslverify = conf -> sslverify ().getValue ();
@@ -2109,18 +2120,20 @@ dnf_repo_set_data(DnfRepo *repo,
2109
2120
{
2110
2121
DnfRepoPrivate * priv = GET_PRIVATE (repo );
2111
2122
2123
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
2112
2124
// we note the changes
2113
2125
// dnf_repo_commit writes them to the override configuration file
2114
2126
if (!priv -> config_changes ) {
2115
2127
priv -> config_changes = new std ::map < std ::string , std ::string > ;
2116
2128
}
2117
2129
(* priv -> config_changes )[parameter ] = value ;
2130
+ #endif
2118
2131
2119
2132
g_key_file_set_string (priv -> keyfile , priv -> repo -> getId ().c_str (), parameter , value );
2120
2133
return TRUE;
2121
2134
} CATCH_TO_GERROR (FALSE )
2122
2135
2123
-
2136
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
2124
2137
static std ::string
2125
2138
get_repos_config_override_dir_path (DnfRepo * repo )
2126
2139
{
@@ -2148,6 +2161,7 @@ modify_config(libdnf::ConfigParser & parser, const std::string & section_id, con
2148
2161
parser .setValue (section_id , key_val .first , key_val .second , "");
2149
2162
}
2150
2163
}
2164
+ #endif
2151
2165
2152
2166
/**
2153
2167
* dnf_repo_commit:
@@ -2175,6 +2189,7 @@ dnf_repo_commit(DnfRepo *repo, GError **error) try
2175
2189
return FALSE;
2176
2190
}
2177
2191
2192
+ #ifdef DNF5_CONF_REPOS_OVERRIDE
2178
2193
constexpr const char * REPOS_OVERRIDE_CFG_HEADER =
2179
2194
"# Generated by libdnf.\n# Do not modify this file manually.\n" ;
2180
2195
const std ::string CFG_MANAGER_REPOS_OVERRIDE_FILENAME = "99-config_manager.repo" ;
@@ -2209,8 +2224,16 @@ dnf_repo_commit(DnfRepo *repo, GError **error) try
2209
2224
delete priv -> config_changes ;
2210
2225
priv -> config_changes = nullptr ;
2211
2226
}
2212
-
2213
2227
return TRUE;
2228
+
2229
+ #else
2230
+
2231
+ /* dump updated file to disk */
2232
+ data = g_key_file_to_data (priv -> keyfile , NULL , error );
2233
+ if (data == NULL )
2234
+ return FALSE;
2235
+ return g_file_set_contents (priv -> filename , data , -1 , error );
2236
+ #endif
2214
2237
} CATCH_TO_GERROR (FALSE )
2215
2238
2216
2239
/**
0 commit comments