diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-02-04 10:31:10 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-02-18 16:15:25 +0200 |
commit | 8a133356e688d7edbdf816328103b8623dbf7e51 (patch) | |
tree | 44b71a67ab8aa0ba9936ab282f8ab1b881c497d6 /src | |
parent | 83da34406bd829cfb15ea2d94a01510a8124776e (diff) | |
download | apk-tools-8a133356e688d7edbdf816328103b8623dbf7e51.tar.gz apk-tools-8a133356e688d7edbdf816328103b8623dbf7e51.tar.bz2 apk-tools-8a133356e688d7edbdf816328103b8623dbf7e51.tar.xz apk-tools-8a133356e688d7edbdf816328103b8623dbf7e51.zip |
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.
(cherry picked from commit 45d313c51cbae20bce0789db86ba82ff79c9b202)
Diffstat (limited to 'src')
-rw-r--r-- | src/add.c | 2 | ||||
-rw-r--r-- | src/apk.c | 12 | ||||
-rw-r--r-- | src/apk_defines.h | 2 | ||||
-rw-r--r-- | src/archive.c | 2 | ||||
-rw-r--r-- | src/database.c | 4 | ||||
-rw-r--r-- | src/lua-apk.c | 5 |
6 files changed, 10 insertions, 17 deletions
@@ -87,7 +87,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); @@ -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 b008b51..1a84ea0 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 e04e583..81821dc 100644 --- a/src/archive.c +++ b/src/archive.c @@ -394,7 +394,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 834695a..606c82f 100644 --- a/src/database.c +++ b/src/database.c @@ -625,7 +625,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) @@ -1006,7 +1006,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 2f365b2..73c33e9 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; |