summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-11-15 13:35:59 +0200
committerTimo Teräs <timo.teras@iki.fi>2021-12-14 20:58:02 +0200
commit74f67ab81c646b9c1fb1136776cf05a949de2526 (patch)
tree690373e31faacc5d0a56dc40f49c4fbb9c44a137 /src/database.c
parent5eb7f989c0d901d9f10c03dee184abda1eaaf130 (diff)
downloadapk-tools-74f67ab81c646b9c1fb1136776cf05a949de2526.tar.gz
apk-tools-74f67ab81c646b9c1fb1136776cf05a949de2526.tar.bz2
apk-tools-74f67ab81c646b9c1fb1136776cf05a949de2526.tar.xz
apk-tools-74f67ab81c646b9c1fb1136776cf05a949de2526.zip
fix fetching of depdencies only packages
Remove the APK_REPOSITORY_CACHED bit from dependencies only packages (that is, installed_size == 0). For fetch, the problem is that apk_db_select_repo() would return the cache repository, but the package would not be there. Update also the locations needed to handle these packages correctly without the cached repository bit being set.
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/database.c b/src/database.c
index f059412..d0f064d 100644
--- a/src/database.c
+++ b/src/database.c
@@ -523,10 +523,8 @@ struct apk_package *apk_db_pkg_add(struct apk_database *db, struct apk_package *
if (!pkg->license) pkg->license = &apk_atom_null;
- /* Set as "cached" if installing from specified file, and
- * for virtual packages */
- if (pkg->filename != NULL || pkg->installed_size == 0)
- pkg->repos |= BIT(APK_REPOSITORY_CACHED);
+ // Set as "cached" if installing from specified file
+ if (pkg->filename) pkg->repos |= BIT(APK_REPOSITORY_CACHED);
idb = apk_hash_get(&db->available.packages, APK_BLOB_CSUM(pkg->csum));
if (idb == NULL) {
@@ -1220,8 +1218,7 @@ static int apk_db_index_write_nr_cache(struct apk_database *db)
struct apk_ostream *os;
int r;
- if (!apk_db_cache_active(db))
- return 0;
+ if (!apk_db_cache_active(db)) return 0;
/* Write list of installed non-repository packages to
* cached index file */
@@ -1234,16 +1231,14 @@ static int apk_db_index_write_nr_cache(struct apk_database *db)
ctx.os = os;
list_for_each_entry(ipkg, &db->installed.packages, installed_pkgs_list) {
struct apk_package *pkg = ipkg->pkg;
- if (pkg->repos != BIT(APK_REPOSITORY_CACHED))
- continue;
- r = write_index_entry(pkg, &ctx);
- if (r != 0)
- return r;
+ if ((pkg->repos == BIT(APK_REPOSITORY_CACHED) ||
+ (pkg->repos == 0 && !pkg->installed_size))) {
+ r = write_index_entry(pkg, &ctx);
+ if (r != 0) return r;
+ }
}
r = apk_ostream_close(os);
- if (r < 0)
- return r;
-
+ if (r < 0) return r;
return ctx.count;
}