xbps-create(8): fix #64 "incorrect installed-size with hardlinks"
This commit is contained in:
parent
04bde70969
commit
039a155918
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
|||||||
xbps-0.42 (???):
|
xbps-0.42 (???):
|
||||||
|
|
||||||
|
* xbps-create(8): fixed issue #64 "xbps-create(8) incorrect installed-size with hardlinks".
|
||||||
|
https://github.com/voidlinux/xbps/issues/64
|
||||||
|
|
||||||
* Added a new configuration keyword "bestmatching", which expects "true" or "false"
|
* Added a new configuration keyword "bestmatching", which expects "true" or "false"
|
||||||
and disabled by default. If enabled the pkg with the greatest version available
|
and disabled by default. If enabled the pkg with the greatest version available
|
||||||
in all registered repositories will be choosen, rather than the first package
|
in all registered repositories will be choosen, rather than the first package
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
struct xentry {
|
struct xentry {
|
||||||
TAILQ_ENTRY(xentry) entries;
|
TAILQ_ENTRY(xentry) entries;
|
||||||
char *file, *type, *target, *hash;
|
char *file, *type, *target, *hash;
|
||||||
|
ino_t inode;
|
||||||
};
|
};
|
||||||
|
|
||||||
static TAILQ_HEAD(xentry_head, xentry) xentry_list =
|
static TAILQ_HEAD(xentry_head, xentry) xentry_list =
|
||||||
@ -315,8 +316,24 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u
|
|||||||
assert(xe->target);
|
assert(xe->target);
|
||||||
free(buf);
|
free(buf);
|
||||||
} else if (type == FTW_F) {
|
} else if (type == FTW_F) {
|
||||||
|
struct xentry *xep;
|
||||||
|
bool hlink = false;
|
||||||
|
/*
|
||||||
|
* Regular files. First find out if it's a hardlink:
|
||||||
|
* - st_nlink > 1
|
||||||
|
* and then search for a stored file matching its inode.
|
||||||
|
*/
|
||||||
|
TAILQ_FOREACH(xep, &xentry_list, entries) {
|
||||||
|
if (sb->st_nlink > 1 && xep->inode == sb->st_ino) {
|
||||||
|
/* matched */
|
||||||
|
hlink = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hlink)
|
||||||
|
instsize += sb->st_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Regular files.
|
|
||||||
* Find out if it's a configuration file or not
|
* Find out if it's a configuration file or not
|
||||||
* and calculate sha256 hash.
|
* and calculate sha256 hash.
|
||||||
*/
|
*/
|
||||||
@ -329,8 +346,7 @@ ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _u
|
|||||||
if ((xe->hash = xbps_file_hash(fpath)) == NULL)
|
if ((xe->hash = xbps_file_hash(fpath)) == NULL)
|
||||||
die("failed to process hash for %s:", fpath);
|
die("failed to process hash for %s:", fpath);
|
||||||
|
|
||||||
if (sb->st_nlink <= 1)
|
xe->inode = sb->st_ino;
|
||||||
instsize += sb->st_size;
|
|
||||||
|
|
||||||
} else if (type == FTW_D || type == FTW_DP) {
|
} else if (type == FTW_D || type == FTW_DP) {
|
||||||
/* directory */
|
/* directory */
|
||||||
|
@ -3,7 +3,8 @@ syntax("kyuafile", 1)
|
|||||||
test_suite("xbps")
|
test_suite("xbps")
|
||||||
|
|
||||||
include('libxbps/Kyuafile')
|
include('libxbps/Kyuafile')
|
||||||
|
include('xbps-checkvers/Kyuafile')
|
||||||
|
include('xbps-create/Kyuafile')
|
||||||
include('xbps-install/Kyuafile')
|
include('xbps-install/Kyuafile')
|
||||||
include('xbps-query/Kyuafile')
|
include('xbps-query/Kyuafile')
|
||||||
include('xbps-rindex/Kyuafile')
|
include('xbps-rindex/Kyuafile')
|
||||||
include('xbps-checkvers/Kyuafile')
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-include ../../config.mk
|
-include ../../config.mk
|
||||||
|
|
||||||
SUBDIRS = common libxbps xbps-install xbps-query xbps-rindex xbps-checkvers
|
SUBDIRS = common libxbps xbps-checkvers xbps-create xbps-install xbps-query xbps-rindex
|
||||||
|
|
||||||
include ../../mk/subdir.mk
|
include ../../mk/subdir.mk
|
||||||
|
4
tests/xbps/xbps-create/Kyuafile
Normal file
4
tests/xbps/xbps-create/Kyuafile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
syntax("kyuafile", 1)
|
||||||
|
|
||||||
|
test_suite("xbps-create")
|
||||||
|
atf_test_program{name="basic_test"}
|
8
tests/xbps/xbps-create/Makefile
Normal file
8
tests/xbps/xbps-create/Makefile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
TOPDIR = ../../..
|
||||||
|
-include $(TOPDIR)/config.mk
|
||||||
|
|
||||||
|
TESTSHELL = basic_test
|
||||||
|
TESTSSUBDIR = xbps/xbps-create
|
||||||
|
EXTRA_FILES = Kyuafile
|
||||||
|
|
||||||
|
include $(TOPDIR)/mk/test.mk
|
35
tests/xbps/xbps-create/basic_test.sh
Normal file
35
tests/xbps/xbps-create/basic_test.sh
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#! /usr/bin/env atf-sh
|
||||||
|
# Test that xbps-create(8) works as expected.
|
||||||
|
|
||||||
|
atf_test_case hardlinks_size
|
||||||
|
|
||||||
|
hardlinks_size_head() {
|
||||||
|
atf_set "descr" "xbps-create(8): installed-size behaviour with hardlinks"
|
||||||
|
}
|
||||||
|
|
||||||
|
hardlinks_size_body() {
|
||||||
|
mkdir -p repo pkg_A
|
||||||
|
echo 123456789 > pkg_A/file00
|
||||||
|
ln pkg_A/file00 pkg_A/file01
|
||||||
|
ln pkg_A/file00 pkg_A/file02
|
||||||
|
ln pkg_A/file00 pkg_A/file03
|
||||||
|
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
|
||||||
|
result="$(xbps-query -r root -C empty.conf --repository=$PWD/repo -p installed_size foo)"
|
||||||
|
expected="10B"
|
||||||
|
rv=0
|
||||||
|
if [ "$result" != "$expected" ]; then
|
||||||
|
echo "result: $result"
|
||||||
|
echo "expected: $expected"
|
||||||
|
rv=1
|
||||||
|
fi
|
||||||
|
atf_check_equal $rv 0
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_init_test_cases() {
|
||||||
|
atf_add_test_case hardlinks_size
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user