aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2020-02-04 10:31:10 +0200
committerTimo Teräs <timo.teras@iki.fi>2020-02-04 10:31:10 +0200
commit45d313c51cbae20bce0789db86ba82ff79c9b202 (patch)
treed144b6462d34c1ceeaf26fbc87902d515e346e0b
parent8fc403c582a725b667d0211f9ccd8a217d25c2fc (diff)
downloadaports-45d313c51cbae20bce0789db86ba82ff79c9b202.tar.bz2
aports-45d313c51cbae20bce0789db86ba82ff79c9b202.tar.xz
remove apk_time() as it is causing problems with shared objects
Instead, to make sure test mode produces same output, redefine time() for the test mode binary. Reverts parts of 0b82bcc53e60.
-rw-r--r--src/add.c2
-rw-r--r--src/apk.c12
-rw-r--r--src/apk_defines.h2
-rw-r--r--src/archive.c2
-rw-r--r--src/database.c4
-rw-r--r--src/lua-apk.c5
6 files changed, 10 insertions, 17 deletions
diff --git a/src/add.c b/src/add.c
index 0292995e34..4ca1dc534d 100644
--- a/src/add.c
+++ b/src/add.c
@@ -81,7 +81,7 @@ static struct apk_package *create_virtual_package(struct apk_database *db, struc
struct apk_package *virtpkg;
struct tm tm;
EVP_MD_CTX *mdctx;
- time_t now = apk_time();
+ time_t now = time(NULL);
pid_t pid = getpid();
gmtime_r(&now, &tm);
diff --git a/src/apk.c b/src/apk.c
index 2b4a41d8e9..68050cdf42 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -47,14 +47,14 @@ static struct apk_string_array *test_repos;
char **apk_argv;
-time_t apk_time(void)
-{
#ifdef TEST_MODE
- return 1559567666;
-#else
- return time(NULL);
-#endif
+time_t time(time_t *tloc)
+{
+ const time_t val = 1559567666;
+ if (tloc) *tloc = val;
+ return val;
}
+#endif
static void version(void)
{
diff --git a/src/apk_defines.h b/src/apk_defines.h
index b008b51837..1a84ea004c 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -122,8 +122,6 @@ extern char **apk_argv;
#define APK_MAX_TAGS 16 /* see solver; unsigned short */
#define APK_CACHE_CSUM_BYTES 4
-time_t apk_time(void);
-
static inline size_t apk_calc_installed_size(size_t size)
{
const size_t bsize = 4 * 1024;
diff --git a/src/archive.c b/src/archive.c
index 24676b12c1..226bc2364b 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -293,7 +293,7 @@ int apk_tar_write_entry(struct apk_ostream *os, const struct apk_file_info *ae,
PUT_OCTAL(buf.uid, ae->uid);
PUT_OCTAL(buf.gid, ae->gid);
PUT_OCTAL(buf.mode, ae->mode & 07777);
- PUT_OCTAL(buf.mtime, ae->mtime ?: apk_time());
+ PUT_OCTAL(buf.mtime, ae->mtime ?: time(NULL));
/* Checksum */
strcpy(buf.magic, "ustar ");
diff --git a/src/database.c b/src/database.c
index 3f1904f8db..f358ad1674 100644
--- a/src/database.c
+++ b/src/database.c
@@ -624,7 +624,7 @@ int apk_cache_download(struct apk_database *db, struct apk_repository *repo,
char tmpcacheitem[128], *cacheitem = &tmpcacheitem[tmpprefix.len];
apk_blob_t b = APK_BLOB_BUF(tmpcacheitem);
int r, fd;
- time_t now = apk_time();
+ time_t now = time(NULL);
apk_blob_push_blob(&b, tmpprefix);
if (pkg != NULL)
@@ -1008,7 +1008,7 @@ static int apk_db_scriptdb_write(struct apk_database *db, struct apk_ostream *os
char filename[256];
apk_blob_t bfn;
int r, i;
- time_t now = apk_time();
+ time_t now = time(NULL);
list_for_each_entry(ipkg, &db->installed.packages, installed_pkgs_list) {
pkg = ipkg->pkg;
diff --git a/src/lua-apk.c b/src/lua-apk.c
index 2f365b224b..73c33e9993 100644
--- a/src/lua-apk.c
+++ b/src/lua-apk.c
@@ -46,11 +46,6 @@ static int typerror (lua_State *L, int narg, const char *tname) {
return luaL_argerror(L, narg, msg);
}
-time_t apk_time(void)
-{
- return time(NULL);
-}
-
static apk_blob_t check_blob(lua_State *L, int index)
{
apk_blob_t blob;