~alpine/devel

Why does apk fail to install packages with 0 size? v1 PROPOSED

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

 1 files changed, 7 insertions(+), 0 deletions(-)
Hi,

On Wed, 7 Apr 2021 18:08:25 -0600 (MDT)
Ariadne Conill <ariadne@dereferenced.org> wrote:
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.alpinelinux.org/~alpine/devel/patches/3487/mbox | git am -3
Learn more about email & git

[PATCH] Set non-zero size if there are any files in the package Export this patch

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.
---
 abuild.in | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/abuild.in b/abuild.in
index ebeb919..5a66866 100644
--- a/abuild.in
+++ b/abuild.in
@@ -1052,6 +1052,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"
-- 
2.31.0