From e1a05c74cb8ae6ab41ee960343cc64a0a9af95a5 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Wed, 18 Jul 2018 13:28:49 +0300 Subject: prevent automatic repository index update for 'apk del' ref #9063 --- src/apk_database.h | 3 ++- src/database.c | 6 ++++-- src/del.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/apk_database.h b/src/apk_database.h index 19bafcd..2a7cb3b 100644 --- a/src/apk_database.h +++ b/src/apk_database.h @@ -156,7 +156,7 @@ struct apk_database { unsigned int pending_triggers; int performing_self_upgrade : 1; int permanent : 1; - int open_write : 1; + int autoupdate : 1; int open_complete : 1; int compat_newfeatures : 1; int compat_notinstallable : 1; @@ -211,6 +211,7 @@ struct apk_db_file *apk_db_file_query(struct apk_database *db, #define APK_OPENF_NO_SYS_REPOS 0x0100 #define APK_OPENF_NO_INSTALLED_REPO 0x0200 #define APK_OPENF_CACHE_WRITE 0x0400 +#define APK_OPENF_NO_AUTOUPDATE 0x0800 #define APK_OPENF_NO_REPOS (APK_OPENF_NO_SYS_REPOS | \ APK_OPENF_NO_INSTALLED_REPO) diff --git a/src/database.c b/src/database.c index db34ed3..70a1053 100644 --- a/src/database.c +++ b/src/database.c @@ -1519,7 +1519,9 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) r = -1; goto ret_r; } - if (dbopts->open_flags & APK_OPENF_WRITE) db->open_write = 1; + if ((dbopts->open_flags & APK_OPENF_WRITE) && + !(dbopts->open_flags & APK_OPENF_NO_AUTOUPDATE)) + db->autoupdate = 1; if (!dbopts->cache_dir) dbopts->cache_dir = "etc/apk/cache"; apk_db_setup_repositories(db, dbopts->cache_dir); @@ -2266,7 +2268,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t _repository) r = apk_repo_format_real_url(db, repo, NULL, buf, sizeof(buf)); if (r == 0) apk_message("fetch %s", buf); } else { - if (db->open_write) apk_repository_update(db, repo); + if (db->autoupdate) apk_repository_update(db, repo); r = apk_repo_format_cache_index(APK_BLOB_BUF(buf), repo); } } else { diff --git a/src/del.c b/src/del.c index d1a6015..8e149ab 100644 --- a/src/del.c +++ b/src/del.c @@ -161,7 +161,7 @@ static struct apk_applet apk_del = { .name = "del", .help = "Remove PACKAGEs from 'world' and uninstall them", .arguments = "PACKAGE...", - .open_flags = APK_OPENF_WRITE, + .open_flags = APK_OPENF_WRITE | APK_OPENF_NO_AUTOUPDATE, .command_groups = APK_COMMAND_GROUP_INSTALL, .context_size = sizeof(struct del_ctx), .optgroups = { &optgroup_global, &optgroup_commit, &optgroup_applet }, -- cgit v1.2.3-70-g09d2