From 1dcf9e4a7be72e1b04fcfbdb24c4406e44bb1926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Thu, 5 Apr 2018 10:00:35 +0300 Subject: main/apk-tools: fix index refresh on time zero --- ...2-db-fix-refreshing-index-if-time-is-zero.patch | 34 ++++++++++++++++++++++ main/apk-tools/APKBUILD | 6 ++-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 main/apk-tools/0002-db-fix-refreshing-index-if-time-is-zero.patch (limited to 'main/apk-tools') diff --git a/main/apk-tools/0002-db-fix-refreshing-index-if-time-is-zero.patch b/main/apk-tools/0002-db-fix-refreshing-index-if-time-is-zero.patch new file mode 100644 index 0000000000..263bc71955 --- /dev/null +++ b/main/apk-tools/0002-db-fix-refreshing-index-if-time-is-zero.patch @@ -0,0 +1,34 @@ +From 258519b1cd32e285060fa4758c123b55ebfe3ef3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Thu, 5 Apr 2018 09:57:15 +0300 +Subject: [PATCH] db: fix refreshing index if time is zero + +During netboot on systems without RTC, time() will be near zero, +and the index fill not exist. Thus the plain test of st.st_mtime +against system time failed. Verify that fstatat() succeeds. +--- + src/database.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/database.c b/src/database.c +index 3976d3d..db34ed3 100644 +--- a/src/database.c ++++ b/src/database.c +@@ -634,9 +634,11 @@ int apk_cache_download(struct apk_database *db, struct apk_repository *repo, + r = apk_repo_format_real_url(db, repo, pkg, url, sizeof(url)); + if (r < 0) return r; + +- if (!(apk_force & APK_FORCE_REFRESH)) +- (void) fstatat(db->cache_fd, cacheitem, &st, 0); +- if (autoupdate && now - st.st_mtime <= db->cache_max_age) return -EALREADY; ++ if (autoupdate && !(apk_force & APK_FORCE_REFRESH)) { ++ if (fstatat(db->cache_fd, cacheitem, &st, 0) == 0 && ++ now - st.st_mtime <= db->cache_max_age) ++ return -EALREADY; ++ } + + apk_message("fetch %s", url); + +-- +2.16.3 + diff --git a/main/apk-tools/APKBUILD b/main/apk-tools/APKBUILD index 8ece4f9eef..508c37a0de 100644 --- a/main/apk-tools/APKBUILD +++ b/main/apk-tools/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa pkgname=apk-tools pkgver=2.9.1 -pkgrel=1 +pkgrel=2 pkgdesc="Alpine Package Keeper - package manager for alpine" subpackages="$pkgname-static" depends= @@ -14,6 +14,7 @@ if [ "$CBUILD" = "$CHOST" ]; then fi source="http://dev.alpinelinux.org/archive/$pkgname/$pkgname-$pkgver.tar.xz 0001-solver-allow-names-with-only-one-provider-to-be-auto.patch + 0002-db-fix-refreshing-index-if-time-is-zero.patch " url="https://git.alpinelinux.org/cgit/apk-tools/" @@ -84,4 +85,5 @@ luaapk() { } sha512sums="4ffb8d1716bbb94421b1cc4277beb47d369c429f4c3bf597d08949abb7586d30c4504edf2f775bea3b93614a280c12391b956ca8f914fb0ec27799a4a005a145 apk-tools-2.9.1.tar.xz -5ca2d2f2646032ed8f9f86357e986b054045a80ddb944be6a540566ff7092f38591ec8dfc7ac06b9daededa95e86c0e892ead55f9e8907eb318aed76644f7f97 0001-solver-allow-names-with-only-one-provider-to-be-auto.patch" +5ca2d2f2646032ed8f9f86357e986b054045a80ddb944be6a540566ff7092f38591ec8dfc7ac06b9daededa95e86c0e892ead55f9e8907eb318aed76644f7f97 0001-solver-allow-names-with-only-one-provider-to-be-auto.patch +6852e1dfce1af502ecd5beadcad920fbde0ec3e34b1dcd010ed80d8f9a44816a51430d6e85b4fe713128ca2d3dc859f53570df39dd5b67fee4a5206b0f85aee8 0002-db-fix-refreshing-index-if-time-is-zero.patch" -- cgit v1.2.3