From ae8ce645421962402b046cd2a34c27aa3c38609a Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 21 Feb 2015 16:52:27 +0100 Subject: [PATCH] Restore pkg file timestamps while unpacking as regular user. Requested by @dominikh. --- NEWS | 3 +++ include/xbps_api_impl.h | 10 +++++----- tests/xbps/xbps-create/basic_test.sh | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index eb28c263..5ad83a61 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ xbps-0.44 (???): + * libxbps: file timestamps stored in binary packages are now restored while + unpacking as regular user. + * xbps-pkgdb(8): this now uses the code from libxbps to check the target file of symlinks. This fixes some false positives with symlinks. diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index b177bf8a..a9fb07cd 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2010-2014 Juan Romero Pardines. + * Copyright (c) 2010-2015 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,10 +46,10 @@ #include "compat.h" #define EXTRACT_FLAGS ARCHIVE_EXTRACT_SECURE_NODOTDOT | \ - ARCHIVE_EXTRACT_SECURE_SYMLINKS -#define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | \ - ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK | \ - EXTRACT_FLAGS + ARCHIVE_EXTRACT_SECURE_SYMLINKS | \ + ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | \ + ARCHIVE_EXTRACT_UNLINK +#define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | EXTRACT_FLAGS #ifndef __UNCONST #define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) diff --git a/tests/xbps/xbps-create/basic_test.sh b/tests/xbps/xbps-create/basic_test.sh index 34600889..6c7512a8 100644 --- a/tests/xbps/xbps-create/basic_test.sh +++ b/tests/xbps/xbps-create/basic_test.sh @@ -86,8 +86,33 @@ symlink_relative_target_cwd_body() { atf_check_equal $rv 0 } +atf_test_case restore_mtime + +restore_mtime_head() { + atf_set "descr" "xbps-create(8): restore file mtime as user" +} + +restore_mtime_body() { + mkdir -p repo pkg_A/usr/include/gsm + touch -f pkg_A/usr/include/gsm/gsm.h + + cd repo + xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A + atf_check_equal $? 0 + cd .. + xbps-rindex -d -a repo/*.xbps + atf_check_equal $? 0 + xbps-install -r root --repository=repo -yvd foo + + expected=$(stat --printf='%Y' pkg_A/usr/include/gsm/gsm.h) + result=$(stat --printf='%Y' root/usr/include/gsm/gsm.h) + + atf_check_equal "$expected" "$result" +} + atf_init_test_cases() { atf_add_test_case hardlinks_size atf_add_test_case symlink_relative_target atf_add_test_case symlink_relative_target_cwd + atf_add_test_case restore_mtime }