abuild: Warn if -doc subpackage exceeds a certain threshold

In the warning, suggest splitting the -doc subpackage into additional
smaller packages (which are not pulled in by the `docs` meta package).

Fixes https://gitlab.alpinelinux.org/alpine/tsc/-/issues/16
This commit is contained in:
Sören Tempel 2023-06-03 10:55:12 +00:00 committed by alice
parent a787a9c9c1
commit e2ab6219d3
4 changed files with 68 additions and 2 deletions

View File

@ -215,6 +215,11 @@ file.
packages containing firmware, and should typically never
be needed.
*bigdocs*
Specifies that this packages intentionally has a large -doc subpackage.
Thereby suppressing a warning to be emitted if the -doc subpackage
exceeds a certain package size threshold (currently 2 MiB).
*charset.alias*
Specifies that the package ships a _/usr/lib/charset.alias_
file and that it should be installed on the user's

View File

@ -32,6 +32,7 @@ fi
: ${SETFATTR:="setfattr"}
apk_opt_wait="--wait 30"
doc_threshold=$((2 * 1024 * 1024)) # 2 MiB
umask 022
@ -1764,14 +1765,19 @@ create_apks() {
local dir="${file%/.PKGINFO}"
local name=$(pkginfo_val pkgname "$file")
local ver=$(pkginfo_val pkgver "$file")
local size=$(pkginfo_val size "$file" | human_size)
local size=$(pkginfo_val size "$file")
local apk=$name-$ver.apk
local datadir="$pkgbasedir"/$name
local subpkgname=$name
local subpkgarch=$(pkginfo_val arch "$file")
# See https://gitlab.alpinelinux.org/alpine/tsc/-/issues/16
if ! options_has "bigdocs" && is_doc_pkg "$name" && [ "$size" -gt "$doc_threshold" ]; then
warning "The -doc subpackage is unusually large, consider splitting it"
fi
trace_apk_deps "$name" "$dir" "$subpkgarch" || return 1
msg "Package size: ${size}"
msg "Package size: $(echo "$size" | human_size)"
msg "Compressing data..."
(
cd "$datadir"

View File

@ -23,6 +23,8 @@ init_tests \
abuild_invalid_pkgnames \
abuild_invalid_subpkgnames \
abuild_invalid_subpkg_version \
abuild_large_doc_subpackage \
abuild_bigdocs \
abuild_warn_pkgver_patch_version \
abuild_multiline_license \
abuild_git_ceiling \
@ -441,6 +443,24 @@ abuild_invalid_subpkg_version_body() {
abuild all
}
abuild_large_doc_subpackage_body() {
init_keys
cp -ra "$testrepo"/large-doc-subpkg .
cd large-doc-subpkg
atf_check -s exit:0 \
-e match:"-doc subpackage is unusually large" \
abuild all
}
abuild_bigdocs_body() {
init_keys
cp -ra "$testrepo"/large-doc-subpkg .
cd large-doc-subpkg
options=bigdocs atf_check -s exit:0 \
-e not-match:"-doc subpackage is unusually large" \
abuild all
}
abuild_warn_pkgver_patch_version_body() {
cp -ra "$testrepo"/test-pkgname .
cd test-pkgname

View File

@ -0,0 +1,35 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="large-doc-subpkg"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package to check if large doc subpackages cause a warning to be emitted"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="noarch"
license="MIT"
subpackages="$pkgname-doc"
source=""
prepare() {
mkdir -p "$builddir"
}
build() {
true
}
check() {
true
}
package() {
mkdir -p "$pkgdir/usr/bin"
cat >"$pkgdir/usr/bin/foo" <<EOF
#!/bin/sh
EOF
mkdir -p "$pkgdir/usr/share/doc/$pkgname"
dd bs=1024 count=$((3 * 1024)) if=/dev/random \
of="$pkgdir/usr/share/doc/$pkgname/large-file"
}