Set non-zero size if there are any files in the package

If there are only empty files in the pkgdir, on some filesystems
(discovered on btrfs), du might return 0 for the sum size of the files.
But apk-tools considers packages with size = 0 to be virtual and skips
extraction of any files contained.

To work around that (until it is resolved in apk-tools 3), settings the
size to 1 when it is zero AND some files are present should work fine.
This commit is contained in:
Wolf 2021-04-09 00:47:35 +02:00 committed by Natanael Copa
parent 5f15ae8360
commit 29557a4a54

View File

@ -1061,6 +1061,13 @@ prepare_metafiles() {
esac
local size=$(du -sk | awk '{print $1 * 1024}')
# If package contains only empty files, the size might be 0. But due to
# apk-tools 2 considering packages with size = 0 virtual, nothing is
# extracted. That will be solved in apk-tools 3. As a workaround we can
# set the size to 1 if any files are present.
if [ "$size" -eq 0 ] && [ -n "$(find . ! -name .)" ]; then
size=1
fi
if [ "$arch" != "$apkbuild_arch" ]; then
local msg="Split function set arch=\"$arch\" for $name, use subpackages=pkg:split:arch format instead"