2022-06-15 11:31:57 +00:00
|
|
|
#!/usr/bin/env atf-sh
|
|
|
|
|
|
|
|
. $(atf_get_srcdir)/test_env.sh
|
|
|
|
init_tests \
|
|
|
|
abuild_help \
|
2022-06-15 11:34:54 +00:00
|
|
|
abuild_invalid_opt \
|
2022-06-15 12:27:04 +00:00
|
|
|
abuild_version \
|
2022-06-15 12:37:55 +00:00
|
|
|
abuild_simple_pkg_without_deps \
|
2022-06-15 15:27:53 +00:00
|
|
|
abuild_build_fail \
|
2022-06-15 16:20:34 +00:00
|
|
|
abuild_invalid_filename \
|
2022-06-15 17:23:36 +00:00
|
|
|
abuild_usr_lib64 \
|
|
|
|
abuild_dbg_subpackage \
|
2022-06-20 09:29:51 +00:00
|
|
|
abuild_SETFATTR_in_dbg \
|
2022-06-20 09:51:44 +00:00
|
|
|
abuild_reproducible \
|
2022-06-20 10:25:23 +00:00
|
|
|
abuild_checksum_generation \
|
2022-06-20 10:37:29 +00:00
|
|
|
abuild_checksum_duplicates \
|
2022-06-20 10:54:11 +00:00
|
|
|
abuild_subpkg_dep_leak \
|
2022-06-20 13:26:22 +00:00
|
|
|
abuild_py_providers_creation \
|
2023-03-20 09:19:12 +00:00
|
|
|
abuild_py_dependency_scan \
|
|
|
|
abuild_py_dependency_scan_conflict \
|
2022-06-20 13:48:46 +00:00
|
|
|
abuild_reject_init_with_improper_shebang \
|
|
|
|
abuild_valid_pkgnames \
|
|
|
|
abuild_invalid_pkgnames \
|
|
|
|
abuild_invalid_subpkgnames \
|
2022-06-20 13:52:57 +00:00
|
|
|
abuild_invalid_subpkg_version \
|
2024-04-01 14:58:22 +00:00
|
|
|
abuild_provide_pkgname \
|
2024-01-11 21:04:32 +00:00
|
|
|
abuild_subpackage_arch \
|
2023-06-03 10:55:12 +00:00
|
|
|
abuild_large_doc_subpackage \
|
|
|
|
abuild_bigdocs \
|
2024-03-28 14:08:24 +00:00
|
|
|
abuild_pkgver_digit_letter_digit \
|
2022-03-19 09:15:06 +00:00
|
|
|
abuild_multiline_license \
|
2024-02-12 11:36:20 +00:00
|
|
|
abuild_license_spdx \
|
2022-08-05 14:00:36 +00:00
|
|
|
abuild_git_ceiling \
|
|
|
|
abuild_package_size_zero \
|
2022-09-23 10:31:56 +00:00
|
|
|
abuild_package_size_nonzero \
|
2024-03-22 19:36:53 +00:00
|
|
|
abuild_keepdirs \
|
2022-12-01 14:46:03 +00:00
|
|
|
abuild_amove \
|
2022-12-01 14:53:43 +00:00
|
|
|
abuild_doc \
|
2022-12-02 15:17:39 +00:00
|
|
|
abuild_dev \
|
2022-08-29 11:47:38 +00:00
|
|
|
abuild_devhelp_warn \
|
|
|
|
abuild_devhelp \
|
2022-12-06 15:59:03 +00:00
|
|
|
abuild_check_maintainer \
|
2023-04-14 06:03:17 +00:00
|
|
|
abuild_cleanoldpkg \
|
2023-04-18 09:56:37 +00:00
|
|
|
abuild_path_with_spaces \
|
|
|
|
abuild_pyc_warn \
|
2022-07-03 12:30:15 +00:00
|
|
|
abuild_pyc \
|
|
|
|
abuild_setcap_binary \
|
2023-06-15 12:37:24 +00:00
|
|
|
abuild_setcap_binary_with_option \
|
2023-06-22 03:33:59 +00:00
|
|
|
abuild_command_provides \
|
|
|
|
abuild_gocache_dir \
|
2023-06-22 04:04:50 +00:00
|
|
|
abuild_cargo_home_dir \
|
2023-10-17 19:48:57 +00:00
|
|
|
abuild_fish_comp_split \
|
|
|
|
abuild_deps
|
2022-06-15 11:31:57 +00:00
|
|
|
|
|
|
|
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
|
2022-06-15 12:27:04 +00:00
|
|
|
export ABUILD_CONF=/dev/null
|
2022-12-06 15:59:03 +00:00
|
|
|
export ABUILD_APK_INDEX_OPTS="--allow-untrusted"
|
2022-06-15 12:27:04 +00:00
|
|
|
export GIT_CONFIG_GLOBAL="$(atf_get_srcdir)/testdata/gitconfig"
|
|
|
|
export REPODEST="$PWD"/packages
|
|
|
|
|
|
|
|
testrepo=$(atf_get_srcdir)/testrepo
|
|
|
|
|
|
|
|
# copy keys
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys() {
|
|
|
|
cp -ra "$(atf_get_srcdir)"/testdata/.abuild "$PWD"
|
|
|
|
}
|
2022-06-15 11:31:57 +00:00
|
|
|
|
|
|
|
abuild_help_body() {
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"usage:" \
|
|
|
|
abuild -h
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_invalid_opt_body() {
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"usage:" \
|
|
|
|
abuild -@
|
|
|
|
}
|
2022-06-15 11:34:54 +00:00
|
|
|
|
|
|
|
abuild_version_body() {
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"abuild [0-9]+\.[0-9]+" \
|
|
|
|
abuild -V
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:27:04 +00:00
|
|
|
abuild_simple_pkg_without_deps_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-15 12:27:04 +00:00
|
|
|
cp -r "$testrepo"/pkg1 .
|
|
|
|
cd pkg1
|
2024-04-11 20:20:41 +00:00
|
|
|
atf_check -s exit:0 -o ignore \
|
2022-06-15 12:27:04 +00:00
|
|
|
-e not-match:"WARNING" \
|
|
|
|
-e not-match:"fatal" \
|
|
|
|
abuild
|
|
|
|
}
|
|
|
|
|
2022-06-15 12:37:55 +00:00
|
|
|
abuild_build_fail_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-15 12:37:55 +00:00
|
|
|
mkdir buildfail
|
|
|
|
cat >buildfail/APKBUILD <<-EOF
|
2022-06-15 15:27:53 +00:00
|
|
|
# Maintainer: Joe User <juser@example.com>
|
2022-06-15 12:37:55 +00:00
|
|
|
pkgname="buildfail"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package that fails to build"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
subpackages="\$pkgname-dev \$pkgname-doc"
|
|
|
|
source=""
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
cd buildfail
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR: buildfail: build failed" \
|
|
|
|
abuild
|
2022-06-15 15:27:53 +00:00
|
|
|
}
|
2022-06-15 12:37:55 +00:00
|
|
|
|
2022-06-15 15:27:53 +00:00
|
|
|
abuild_invalid_filename_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-15 15:27:53 +00:00
|
|
|
mkdir invalid-filename
|
|
|
|
cd invalid-filename
|
|
|
|
cat >APKBUILD <<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="invalid-filename"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package that fails to build"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
touch $'bad\nfile'
|
|
|
|
}
|
|
|
|
check() {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
cp -r * "\$pkgdir"/
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR:.*: Found filenames with newline" \
|
|
|
|
abuild
|
2022-06-15 12:37:55 +00:00
|
|
|
}
|
2022-06-15 15:27:53 +00:00
|
|
|
|
2022-06-15 16:20:34 +00:00
|
|
|
abuild_usr_lib64_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-15 16:20:34 +00:00
|
|
|
mkdir lib64test
|
|
|
|
cd lib64test
|
|
|
|
cat >APKBUILD <<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="lib64test"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
source=""
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
mkdir -p usr/lib64
|
|
|
|
}
|
|
|
|
check() {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
cp -r * "\$pkgdir"/
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR:.*: Packages must not put anything under /usr/lib64" \
|
|
|
|
abuild
|
|
|
|
|
|
|
|
options=lib64 atf_check -s exit:0 \
|
|
|
|
-e match:"Build complete" \
|
|
|
|
abuild
|
|
|
|
}
|
|
|
|
|
2022-06-15 17:23:36 +00:00
|
|
|
abuild_dbg_subpackage_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-15 17:23:36 +00:00
|
|
|
cp -ra "$testrepo" .
|
|
|
|
cd testrepo/dbgpkg
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"hello world" \
|
|
|
|
-e match:"Build complete" \
|
|
|
|
abuild
|
|
|
|
cd ../..
|
|
|
|
|
|
|
|
arch=$(abuild -A)
|
|
|
|
tar -zxf "$REPODEST"/testrepo/$arch/dbgpkg-1.0-r0.apk \
|
|
|
|
|| atf_fail "failed to extract dbgpkg-1.0-r0.apk"
|
|
|
|
if [ -e usr/lib/debug ]; then
|
|
|
|
atf_fail "usr/lib/debug should not exist"
|
|
|
|
fi
|
|
|
|
debuginfo=$(readelf -wk usr/bin/hello | grep '^ Separate debug info file: [^/]*\.debug$')
|
|
|
|
debuginfo_file=${debuginfo#" Separate debug info file: "}
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-e match:"nm: usr/bin/hello: no symbols" \
|
|
|
|
nm usr/bin/hello
|
|
|
|
|
|
|
|
if ! [ usr/bin/hello -ef usr/bin/hello-hard ]; then
|
|
|
|
atf_fail 'hello is not a hardlink of hello-hard'
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -r usr
|
|
|
|
tar -xf "$REPODEST"/testrepo/$arch/dbgpkg-dbg-1.0-r0.apk
|
|
|
|
if [ -e usr/bin ]; then
|
|
|
|
atf_fail "usr/bin should not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
find usr
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"T main" \
|
|
|
|
nm usr/lib/debug/usr/bin/$debuginfo_file
|
|
|
|
|
|
|
|
if [ -e usr/lib/debug/usr/bin/hello-sym.debug ]; then
|
|
|
|
atf_fail "usr/lib/debug/usr/bin/hello-sym.debug should not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e usr/lib/debug/usr/bin/hello.debug ] && [ -e usr/lib/debug/usr/bin/hello-hard.debug ]; then
|
|
|
|
atf_fail "only one of hello.debug and hello-hard.debug should exist"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_SETFATTR_in_dbg_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-15 17:23:36 +00:00
|
|
|
cp -ra "$testrepo"/dbgpkg .
|
|
|
|
cd dbgpkg
|
|
|
|
SETFATTR=true atf_check -s exit:0 \
|
|
|
|
-o match:"hello world" \
|
|
|
|
-e match:"Build complete" \
|
|
|
|
abuild
|
|
|
|
}
|
|
|
|
|
2022-06-20 09:29:51 +00:00
|
|
|
abuild_reproducible_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-20 09:29:51 +00:00
|
|
|
cp -ra "$testrepo" .
|
|
|
|
cd testrepo/pkg1
|
|
|
|
|
|
|
|
# set timestamp of APKBUILD to 1 min older than current time
|
|
|
|
touch -d @$(( $(date -u +%s) - 60)) APKBUILD
|
|
|
|
|
|
|
|
arch=$(abuild -A)
|
|
|
|
pkgs=$(abuild listpkg)
|
|
|
|
|
|
|
|
abuild || atf_fail "first build failed"
|
|
|
|
checksums=$(cd "$REPODEST"/testrepo/$arch && md5sum $pkgs)
|
|
|
|
echo "$checksums"
|
|
|
|
|
|
|
|
rm -r "$REPODEST"/testrepo
|
|
|
|
abuild || atf_fail "rebuild failed"
|
|
|
|
checksums2=$(cd "$REPODEST"/testrepo/$arch && md5sum $pkgs)
|
|
|
|
echo "$checksums2"
|
|
|
|
|
|
|
|
if [ "$checksums" != "$checksums2" ]; then
|
|
|
|
atf_fail "checksums does not match"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-06-20 09:51:44 +00:00
|
|
|
abuild_checksum_generation_body() {
|
|
|
|
mkdir foo
|
|
|
|
cat > foo/APKBUILD <<-EOF
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
source="test.txt"
|
|
|
|
EOF
|
|
|
|
echo "foo" > foo/test.txt
|
|
|
|
cd foo
|
|
|
|
abuild checksum || atf_fail "checksum generation failed"
|
|
|
|
( . ./APKBUILD && echo "$sha512sums" | sed '/^$/d' > sums )
|
|
|
|
cat sums
|
|
|
|
sha512sum -c sums || atf_fail "checksum mismatch"
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:25:23 +00:00
|
|
|
abuild_checksum_duplicates_body() {
|
|
|
|
mkdir -p foo/dir1 foo/dir2
|
|
|
|
cat > foo/APKBUILD <<-EOF
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
source="dir1/testfile dir2/testfile"
|
|
|
|
EOF
|
|
|
|
echo "first" > foo/dir1/testfile
|
|
|
|
echo "second" > foo/dir2/testfile
|
|
|
|
cd foo
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR:.*duplicate found" \
|
|
|
|
abuild checksum
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:37:29 +00:00
|
|
|
abuild_subpkg_dep_leak_body() {
|
|
|
|
mkdir -p testrepo/subpkg-dep-leak
|
|
|
|
cd testrepo/subpkg-dep-leak
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
|
|
|
|
pkgname="subpkg-dep-leak"
|
|
|
|
pkgver=1.0
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package with subpackages and dependencies"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
depends="tar scanelf"
|
|
|
|
license="MIT"
|
|
|
|
subpackages="\$pkgname-subpkg"
|
|
|
|
options="!check"
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
}
|
|
|
|
|
|
|
|
subpkg() {
|
|
|
|
depends="sed"
|
|
|
|
mkdir -p "\$subpkgdir"
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
abuild clean unpack prepare build rootpkg
|
|
|
|
|
|
|
|
grep 'depend = tar' pkg/.control.subpkg-dep-leak/.PKGINFO \
|
|
|
|
|| atf_fail "subpkg-dep-leak should depend on tar"
|
|
|
|
grep 'depend = scanelf' pkg/.control.subpkg-dep-leak/.PKGINFO \
|
|
|
|
|| atf_fail "subpkg-dep-leak should depend on scanelf"
|
|
|
|
! grep 'depend = sed' pkg/.control.subpkg-dep-leak/.PKGINFO \
|
|
|
|
|| atf_fail "subpkg-dep-leak should not depends on sed"
|
|
|
|
|
|
|
|
grep 'depend = sed' pkg/.control.subpkg-dep-leak-subpkg/.PKGINFO \
|
|
|
|
|| atf_fail "subpkg-dep-leak-subpkg should depend on sed"
|
|
|
|
|
|
|
|
! grep 'depend = tar' pkg/.control.subpkg-dep-leak-subpkg/.PKGINFO \
|
|
|
|
|| atf_fail "subpkg-dep-leak-subpkg should not depend on tar"
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:54:11 +00:00
|
|
|
abuild_py_providers_creation_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-20 10:54:11 +00:00
|
|
|
cp -ra "$testrepo" .
|
2023-03-20 09:19:12 +00:00
|
|
|
cd testrepo/py3\ foo\ and\ bar
|
2022-06-20 10:54:11 +00:00
|
|
|
abuild rootpkg || atf_fail "abuild failed"
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"provides = py3.9:foo=1.0.0-r0" \
|
|
|
|
cat pkg/.control.py3-foo-and-bar/.PKGINFO
|
|
|
|
}
|
|
|
|
|
2023-03-20 09:19:12 +00:00
|
|
|
abuild_py_dependency_scan_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo" .
|
|
|
|
cd testrepo/py3\ foo\ and\ bar
|
|
|
|
abuild rootpkg || atf_fail "abuild failed"
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"depend = python3~3.9" \
|
|
|
|
cat pkg/.control.py3-foo-and-bar/.PKGINFO
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_py_dependency_scan_conflict_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo" .
|
|
|
|
cd testrepo/py3-conflicting-python-versions
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"ERROR.*package contains python3 modules for conflicting python3 versions" \
|
|
|
|
abuild rootpkg
|
|
|
|
}
|
|
|
|
|
2022-06-20 13:26:22 +00:00
|
|
|
abuild_reject_init_with_improper_shebang_body() {
|
|
|
|
mkdir invalid-initd
|
|
|
|
cd invalid-initd
|
|
|
|
cat >APKBUILD<<-EOF
|
|
|
|
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
|
|
|
|
pkgname="invalid-initd"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
subpackages=""
|
|
|
|
source="test.initd"
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
cat >test.initd<<-EOF
|
|
|
|
#!/bin/sh
|
|
|
|
command="test"
|
|
|
|
EOF
|
|
|
|
abuild checksum
|
|
|
|
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-o match:"OK" \
|
|
|
|
-e match:"ERROR.*is not an openrc" \
|
|
|
|
abuild unpack
|
|
|
|
}
|
|
|
|
|
2022-06-20 13:48:46 +00:00
|
|
|
abuild_valid_pkgnames_body() {
|
|
|
|
cp -ra "$testrepo"/test-pkgname .
|
|
|
|
cd test-pkgname
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME=foo atf_check -s exit:0 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTSUBNAME=foo atf_check -s exit:0 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
2024-03-22 10:48:28 +00:00
|
|
|
TESTNAME="more_+-2.0-complicated" atf_check -s exit:0 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
2022-06-20 13:48:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
abuild_invalid_pkgnames_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-20 13:48:46 +00:00
|
|
|
cp -ra "$testrepo"/test-pkgname .
|
|
|
|
cd test-pkgname
|
|
|
|
TESTNAME="" atf_check -s exit:1 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME="-foo" atf_check -s exit:1 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME="foo with spaces" atf_check -s exit:1 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
2024-03-22 10:48:28 +00:00
|
|
|
TESTNAME="width@at" atf_check -s exit:1 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME="width=equal" atf_check -s exit:1 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
2022-06-20 13:48:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
abuild_invalid_subpkgnames_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-20 13:48:46 +00:00
|
|
|
cp -ra "$testrepo"/test-pkgname .
|
|
|
|
cd test-pkgname
|
|
|
|
TESTSUBNAME="" atf_check -s exit:1 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTSUBNAME="-foo" atf_check -s exit:1 \
|
|
|
|
-e match:"Checking sanity" \
|
|
|
|
abuild sanitycheck
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_invalid_subpkg_version_body() {
|
2022-06-22 11:23:16 +00:00
|
|
|
init_keys
|
2022-06-20 13:48:46 +00:00
|
|
|
cp -ra "$testrepo"/test-pkgname .
|
|
|
|
cd test-pkgname
|
|
|
|
TESTDEPVER="1.0-0" atf_check -s exit:1 \
|
|
|
|
-e match:"Invalid version" \
|
|
|
|
abuild all
|
|
|
|
}
|
2022-06-20 13:52:57 +00:00
|
|
|
|
2024-04-01 14:58:22 +00:00
|
|
|
abuild_provide_pkgname_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo"/test-pkgname .
|
|
|
|
cd test-pkgname
|
|
|
|
TESTNAME=provided atf_check -s exit:1 \
|
|
|
|
-e match:"provides must not contain" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME=test TESTPROVIDES='test~1' atf_check -s exit:1 \
|
|
|
|
-e match:"provides must not contain" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME=test TESTPROVIDES='test=1' atf_check -s exit:1 \
|
|
|
|
-e match:"provides must not contain" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME=test TESTPROVIDES='test>1' atf_check -s exit:1 \
|
|
|
|
-e match:"provides must not contain" \
|
|
|
|
abuild sanitycheck
|
|
|
|
TESTNAME=test TESTPROVIDES='test<=1' atf_check -s exit:1 \
|
|
|
|
-e match:"provides must not contain" \
|
|
|
|
abuild sanitycheck
|
|
|
|
}
|
|
|
|
|
2024-01-11 21:04:32 +00:00
|
|
|
abuild_subpackage_arch_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo" .
|
|
|
|
cd testrepo/subpackage-arch
|
|
|
|
arch="$(abuild -A)"
|
|
|
|
|
|
|
|
for i in noarch all "$arch"; do
|
|
|
|
TESTSUBARCH="$i" abuild all
|
|
|
|
|
|
|
|
[ -f "$REPODEST/testrepo/$arch/test-pkgname-$i-1.0-r0.apk" ] || \
|
|
|
|
atf_fail "Failed to place $i arch subpackage correctly"
|
|
|
|
rm -rf "$REPODEST/testrepo"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-06-03 10:55:12 +00:00
|
|
|
abuild_large_doc_subpackage_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo"/large-doc-subpkg .
|
|
|
|
cd large-doc-subpkg
|
2024-04-11 20:20:41 +00:00
|
|
|
atf_check -s exit:0 -o ignore \
|
2023-06-03 10:55:12 +00:00
|
|
|
-e match:"-doc subpackage is unusually large" \
|
|
|
|
abuild all
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_bigdocs_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo"/large-doc-subpkg .
|
|
|
|
cd large-doc-subpkg
|
2024-04-11 20:20:41 +00:00
|
|
|
options=bigdocs atf_check -s exit:0 -o ignore \
|
2023-06-03 10:55:12 +00:00
|
|
|
-e not-match:"-doc subpackage is unusually large" \
|
|
|
|
abuild all
|
|
|
|
}
|
|
|
|
|
2024-03-28 14:08:24 +00:00
|
|
|
abuild_pkgver_digit_letter_digit_body() {
|
2023-03-16 12:22:19 +00:00
|
|
|
cp -ra "$testrepo"/test-pkgname .
|
|
|
|
cd test-pkgname
|
2024-03-28 14:08:24 +00:00
|
|
|
TESTPKGVER=1.0p1 atf_check -s exit:1 \
|
|
|
|
-e match:'ERROR.*version' \
|
2024-03-13 10:43:10 +00:00
|
|
|
abuild sanitycheck
|
2023-03-16 12:22:19 +00:00
|
|
|
}
|
|
|
|
|
2022-06-20 13:52:57 +00:00
|
|
|
abuild_multiline_license_body() {
|
|
|
|
cp -ra "$testrepo"/test-licenses .
|
|
|
|
cd test-licenses
|
|
|
|
abuild rootpkg
|
2024-02-12 11:36:20 +00:00
|
|
|
atf_check -o match:'^license = MIT AND \(GPL-3.0-only OR GPL-3.0-or-later AND BSD-Clause-4\)$' \
|
2022-06-20 13:52:57 +00:00
|
|
|
cat pkg/.control.test-licenses/.PKGINFO
|
|
|
|
}
|
2022-03-19 09:15:06 +00:00
|
|
|
|
2024-02-12 11:36:20 +00:00
|
|
|
abuild_license_spdx_body() {
|
|
|
|
cp -ra "$testrepo"/test-licenses .
|
|
|
|
cd test-licenses
|
|
|
|
TESTPKGVER=1.0_p1 atf_check -s exit:0 \
|
|
|
|
-e not-match:'WARNING' \
|
|
|
|
abuild sanitycheck
|
|
|
|
}
|
|
|
|
|
2022-03-19 09:15:06 +00:00
|
|
|
abuild_git_ceiling_body() {
|
|
|
|
init_keys
|
|
|
|
git init
|
|
|
|
mkdir git-pkg
|
|
|
|
cd git-pkg
|
|
|
|
cat >APKBUILD<<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="git-pkg"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
git status
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"not a git repository" \
|
|
|
|
-e match:"ERROR: git-pkg: build failed" \
|
|
|
|
abuild
|
|
|
|
}
|
2022-08-05 14:00:36 +00:00
|
|
|
|
|
|
|
create_fake_du() {
|
|
|
|
mkdir -p bin
|
|
|
|
cat > bin/du <<-EOF
|
|
|
|
#!/bin/sh
|
|
|
|
echo 0
|
|
|
|
EOF
|
|
|
|
chmod +x bin/du
|
|
|
|
PATH="$PWD/bin:$PATH"
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_package_size_zero_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p test-size
|
|
|
|
create_fake_du
|
|
|
|
|
|
|
|
cd test-size
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
|
|
|
|
# test package
|
|
|
|
pkgname="test-size"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package that has no files'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
install="\$pkgname.post-install"
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
cat > test-size.post-install <<-EOF
|
|
|
|
#!/bin/sh
|
|
|
|
echo 1
|
|
|
|
EOF
|
|
|
|
abuild rootpkg
|
|
|
|
# should be set to 1
|
|
|
|
atf_check -o match:'^size = 1$' \
|
|
|
|
cat pkg/.control.test-size/.PKGINFO
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_package_size_nonzero_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p test-size
|
|
|
|
|
|
|
|
cd test-size
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
|
|
|
|
# test package
|
|
|
|
pkgname="test-size"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package that has files'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
printf "%s" "very important data" > "\$pkgdir"/testfile
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
abuild rootpkg
|
|
|
|
# should not be set to 1
|
|
|
|
atf_check -o not-match:'^size = 1$' \
|
|
|
|
cat pkg/.control.test-size/.PKGINFO
|
|
|
|
}
|
2022-09-23 10:31:56 +00:00
|
|
|
|
2024-03-22 19:36:53 +00:00
|
|
|
abuild_keepdirs_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p test-amove
|
|
|
|
|
|
|
|
cd test-amove
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
|
|
|
|
# test package
|
|
|
|
pkgname="test-keepdirs"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package - keepdirs'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
options='keepdirs'
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"/usr/bin
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
abuild rootpkg || atf_fail "abuild rootpkg failed"
|
|
|
|
test -d pkg/test-keepdirs/usr/bin || atf_fail "$i failed"
|
|
|
|
}
|
|
|
|
|
2022-09-23 10:31:56 +00:00
|
|
|
abuild_amove_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p test-amove
|
|
|
|
|
|
|
|
cd test-amove
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
|
|
|
|
# test package
|
|
|
|
pkgname="test-amove"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package - amove'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
subpackages="\$pkgname-file:_file
|
|
|
|
\$pkgname-etc:_etc
|
|
|
|
\$pkgname-bin:_bin
|
|
|
|
\$pkgname-sbin:_sbin
|
2024-04-11 12:22:44 +00:00
|
|
|
\$pkgname-root:_root
|
2022-09-23 10:31:56 +00:00
|
|
|
\$pkgname-var:_var
|
2023-12-12 21:38:22 +00:00
|
|
|
\$pkgname-usr:_usr
|
|
|
|
\$pkgname-space:_space"
|
2022-09-23 10:31:56 +00:00
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"/etc \
|
|
|
|
"\$pkgdir"/bin \
|
|
|
|
"\$pkgdir"/sbin \
|
|
|
|
"\$pkgdir"/var/lib/\$pkgname \
|
|
|
|
"\$pkgdir"/usr/share
|
|
|
|
touch "\$pkgdir"/etc/file \
|
|
|
|
"\$pkgdir"/etc/\$pkgname.conf \
|
|
|
|
"\$pkgdir"/bin/hello \
|
|
|
|
"\$pkgdir"/sbin/shello \
|
2024-04-11 12:22:44 +00:00
|
|
|
"\$pkgdir"/root \
|
2023-12-12 21:38:22 +00:00
|
|
|
"\$pkgdir"/sbin/space' ' \
|
2022-09-23 10:31:56 +00:00
|
|
|
"\$pkgdir"/var/lib/\$pkgname/testfile \
|
|
|
|
"\$pkgdir"/usr/share/a \
|
|
|
|
"\$pkgdir"/usr/share/b
|
2024-04-11 12:22:44 +00:00
|
|
|
ln -s dangling "\$pkgdir"/symlink
|
2022-09-23 10:31:56 +00:00
|
|
|
}
|
|
|
|
_file() {
|
|
|
|
amove etc/file
|
|
|
|
}
|
|
|
|
_etc() {
|
|
|
|
# leading and trailing /
|
2024-04-11 12:22:44 +00:00
|
|
|
amove ///etc/
|
2022-09-23 10:31:56 +00:00
|
|
|
}
|
|
|
|
_bin() {
|
|
|
|
# trailing /
|
2024-04-11 12:22:44 +00:00
|
|
|
amove bin///
|
2022-09-23 10:31:56 +00:00
|
|
|
}
|
|
|
|
_sbin() {
|
2024-04-11 12:22:44 +00:00
|
|
|
# no leading and trailing /
|
2022-09-23 10:31:56 +00:00
|
|
|
amove sbin/shello
|
|
|
|
}
|
2024-04-11 12:22:44 +00:00
|
|
|
_root() {
|
|
|
|
# no /
|
|
|
|
amove root
|
|
|
|
|
|
|
|
# symlink without existing target
|
|
|
|
amove symlink
|
|
|
|
}
|
2022-09-23 10:31:56 +00:00
|
|
|
_var() {
|
|
|
|
# leading /
|
|
|
|
amove /var/lib
|
|
|
|
}
|
|
|
|
_usr() {
|
|
|
|
# glob *
|
|
|
|
amove usr/share/*
|
2024-04-11 20:20:41 +00:00
|
|
|
! amove no-glob-match/*
|
2022-09-23 10:31:56 +00:00
|
|
|
}
|
2023-12-12 21:38:22 +00:00
|
|
|
_space() {
|
|
|
|
# with space
|
|
|
|
amove sbin/space' '
|
|
|
|
}
|
2022-09-23 10:31:56 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
abuild rootpkg || atf_fail "abuild rootpkg failed"
|
|
|
|
for i in \
|
|
|
|
test-amove-file/etc/file \
|
|
|
|
test-amove-etc/etc/test-amove.conf \
|
|
|
|
test-amove-bin/bin/hello \
|
|
|
|
test-amove-sbin/sbin/shello \
|
2024-04-11 12:22:44 +00:00
|
|
|
test-amove-root/root \
|
|
|
|
test-amove-root/symlink \
|
2022-09-23 10:31:56 +00:00
|
|
|
test-amove-var/var/lib/test-amove/testfile \
|
|
|
|
test-amove-usr/usr/share/a \
|
|
|
|
test-amove-usr/usr/share/b \
|
2023-12-12 21:38:22 +00:00
|
|
|
test-amove-space/sbin/space' ' \
|
2022-09-23 10:31:56 +00:00
|
|
|
; do \
|
2024-04-11 12:22:44 +00:00
|
|
|
[ -L pkg/"$i" ] || [ -e pkg/"$i" ] || atf_fail "$i failed"
|
2022-09-23 10:31:56 +00:00
|
|
|
done
|
|
|
|
}
|
2022-12-01 14:46:03 +00:00
|
|
|
|
|
|
|
abuild_doc_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p foo
|
|
|
|
|
|
|
|
cd foo
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
# test package
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package - doc'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
subpackages="\$pkgname-doc"
|
|
|
|
|
|
|
|
build() {
|
|
|
|
touch foo foo.1 readme
|
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
install -Dt "\$pkgdir"/usr/bin foo
|
|
|
|
install -Dt "\$pkgdir"/usr/share/man/man1 foo.1
|
|
|
|
install -Dt "\$pkgdir"/usr/share/doc/foo readme
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
abuild build rootpkg || atf_fail "abuild rootpkg failed"
|
|
|
|
find pkg
|
|
|
|
for i in \
|
|
|
|
foo/usr/bin/foo \
|
|
|
|
foo-doc/usr/share/man/man1/foo.1.gz \
|
|
|
|
foo-doc/usr/share/doc/foo/readme \
|
|
|
|
; do \
|
|
|
|
test -f pkg/$i || atf_fail "$i failed"
|
|
|
|
done
|
|
|
|
}
|
2022-12-01 14:53:43 +00:00
|
|
|
|
|
|
|
abuild_dev_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p foo
|
|
|
|
|
|
|
|
cd foo
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
# test package
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package - dev'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
subpackages="\$pkgname-dev"
|
|
|
|
|
|
|
|
build() {
|
|
|
|
touch foo foo.h libfoo.so.1
|
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
install -Dt "\$pkgdir"/usr/bin foo
|
|
|
|
install -Dt "\$pkgdir"/usr/include foo.h
|
|
|
|
install -Dt "\$pkgdir"/usr/lib libfoo.so.1
|
|
|
|
ln -s libfoo.so.1 "\$pkgdir"/usr/lib/libfoo.so
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
abuild build rootpkg || atf_fail "abuild rootpkg failed"
|
|
|
|
find pkg
|
|
|
|
for i in \
|
|
|
|
foo/usr/bin/foo \
|
|
|
|
foo-dev/usr/include/foo.h \
|
|
|
|
; do \
|
|
|
|
test -f pkg/$i || atf_fail "$i failed"
|
|
|
|
done
|
|
|
|
test -L pkg/foo-dev/usr/lib/libfoo.so || atf_fail "libfoo.so failed"
|
|
|
|
}
|
2022-12-02 15:17:39 +00:00
|
|
|
|
2022-08-29 11:47:38 +00:00
|
|
|
abuild_devhelp_warn_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p foo
|
|
|
|
|
|
|
|
cd foo
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package that has devhelp'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"/usr/share/devhelp/book
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
atf_check -e match:"WARNING:" \
|
|
|
|
abuild rootpkg
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_devhelp_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p foo
|
|
|
|
|
|
|
|
cd foo
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package that has devhelp'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
subpackages="\$pkgname-devhelp"
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"/usr/share/devhelp/book
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
atf_check -e not-match:"WARNING:" \
|
|
|
|
-o match:'->' \
|
|
|
|
abuild rootpkg
|
|
|
|
}
|
|
|
|
|
2022-12-02 15:17:39 +00:00
|
|
|
abuild_check_maintainer_body() {
|
|
|
|
mkdir -p foo && cd foo
|
|
|
|
for m in "Test User 123 <123example.com>" \
|
|
|
|
"foo" \
|
|
|
|
"user@example.com" \
|
|
|
|
" Leading Space <n@example.com>" \
|
|
|
|
"Trailing Space <n@example.com> " \
|
|
|
|
"Foo<u@example.com>" \
|
|
|
|
'"Quotes <u@example.com>"'; do
|
|
|
|
printf "# Maintainer: %s\n%s\n" "$m" "pkgname=foo" > APKBUILD
|
|
|
|
atf_check -s not-exit:0 \
|
|
|
|
-e match:"ERROR:" \
|
|
|
|
abuild check_maintainer
|
|
|
|
done
|
|
|
|
|
|
|
|
for m in "Test User <123@example.com>" "Foo O'Brian <n@example.com>" "Łukasz Something <s@example.com>"; do
|
|
|
|
printf "# Maintainer: %s\n%s\n" "$m" "pkgname=foo" > APKBUILD
|
|
|
|
atf_check abuild check_maintainer
|
|
|
|
done
|
|
|
|
}
|
2022-12-06 15:59:03 +00:00
|
|
|
|
|
|
|
abuild_cleanoldpkg_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir -p main/foo
|
|
|
|
cd main/foo
|
|
|
|
for arch in aarch64 x86_64; do
|
|
|
|
for v in 0.9 1.0 1.1; do
|
|
|
|
cat > APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test User 123 <123@example.com>
|
|
|
|
# test package
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="$v"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc='Dummy test package - dev'
|
|
|
|
url='https://gitlab.alpinelinux.org/alpine/aports'
|
|
|
|
arch='noarch'
|
|
|
|
license='MIT'
|
|
|
|
options='!check'
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"
|
|
|
|
}
|
|
|
|
EOF
|
2023-10-18 06:46:09 +00:00
|
|
|
CARCH=$arch atf_check -e not-empty abuild clean unpack rootpkg
|
2022-12-06 15:59:03 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
CARCH=aarch64 atf_check -e match:"Cleaning" abuild cleanoldpkg
|
|
|
|
|
|
|
|
find "$REPODEST"
|
|
|
|
|
|
|
|
# should keep the current APKBUILD version
|
|
|
|
for arch in aarch64 x86_64; do
|
|
|
|
f="$REPODEST"/main/$arch/foo-1.1-r0.apk
|
|
|
|
if ! test -e "$f"; then
|
|
|
|
atf_fail "$f was deleted"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# should remove old packages of aarch64
|
|
|
|
for i in 0.9 1.0; do
|
|
|
|
f="$REPODEST"/main/aarch64/foo-$i-r0.apk
|
|
|
|
if test -e "$f"; then
|
|
|
|
atf_fail "$f was not deleted"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# should not delete other arches than aarch64
|
|
|
|
for i in 0.9 1.0; do
|
|
|
|
f="$REPODEST"/main/x86_64/foo-$i-r0.apk
|
|
|
|
if ! test -e "$f"; then
|
|
|
|
atf_fail "$f was deleted"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2023-04-14 06:03:17 +00:00
|
|
|
|
|
|
|
abuild_path_with_spaces_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo" .
|
|
|
|
cd testrepo/pkg\ path\ with\ spaces
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"hello world" \
|
|
|
|
-e match:"Build complete" \
|
|
|
|
abuild
|
|
|
|
}
|
2023-04-18 09:56:37 +00:00
|
|
|
|
|
|
|
abuild_pyc_warn_body() {
|
|
|
|
init_keys
|
|
|
|
|
|
|
|
mkdir -p pycachetest
|
|
|
|
cd pycachetest
|
|
|
|
cat >APKBUILD <<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="pycachetest"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
source=""
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"/usr/lib/python3.11/site-packages/test/__pycache__/
|
|
|
|
touch "\$pkgdir"/usr/lib/python3.11/site-packages/test/__pycache__/main.cpython-311.pyc
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
atf_check -e match:"WARNING.*pyc*" abuild rootpkg
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_pyc_body() {
|
|
|
|
init_keys
|
|
|
|
|
|
|
|
mkdir -p foo
|
|
|
|
cd foo
|
|
|
|
cat >APKBUILD <<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
source=""
|
|
|
|
subpackages="\$pkgname-pyc"
|
|
|
|
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"/usr/lib/python3.11/site-packages/test/__pycache__/
|
|
|
|
touch "\$pkgdir"/usr/lib/python3.11/site-packages/test/__pycache__/main.cpython-311.pyc
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
atf_check -o match:"->" -e not-match:"WARNING.*pyc*" abuild rootpkg
|
|
|
|
atf_check -o match:"__pycache__" find pkg/foo-pyc -name '__pycache__'
|
|
|
|
# verify install_if is correct
|
|
|
|
atf_check -o match:"foo=1.0-r0" -o match:"pyc" \
|
|
|
|
grep install_if pkg/.control.foo-pyc/.PKGINFO
|
|
|
|
}
|
2022-07-03 12:30:15 +00:00
|
|
|
|
|
|
|
abuild_setcap_binary_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo"/setcap .
|
|
|
|
cd setcap
|
|
|
|
atf_check -s exit:1 \
|
|
|
|
-e match:"Found binary with extra capabilities" \
|
|
|
|
-e match:"Found setcap binary executable by others" \
|
|
|
|
abuild all
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_setcap_binary_with_option_body() {
|
|
|
|
init_keys
|
|
|
|
cp -ra "$testrepo"/setcap .
|
|
|
|
cd setcap
|
|
|
|
options=setcap atf_check -s exit:0 \
|
|
|
|
-e not-match:"Found binary with extra capabilities" \
|
|
|
|
-e match:"Found setcap binary executable by others" \
|
|
|
|
abuild all
|
|
|
|
}
|
2023-06-15 12:37:24 +00:00
|
|
|
|
|
|
|
abuild_command_provides_body() {
|
|
|
|
init_keys
|
2024-04-17 06:16:19 +00:00
|
|
|
mkdir testprovides
|
|
|
|
cd testprovides
|
|
|
|
cat >APKBUILD<<-EOF
|
|
|
|
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
|
|
|
|
pkgname=testprovides
|
|
|
|
pkgver=1.0
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package that installs a file and directory in path"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
prepare() { mkdir -p "\$builddir"; }
|
|
|
|
build() { true; }
|
|
|
|
check() { true; }
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir/usr/bin"
|
|
|
|
printf "%s\n" '#!/bin/sh' >"\$pkgdir/usr/bin/foo"
|
|
|
|
chmod +x "\$pkgdir/usr/bin/foo"
|
2024-04-17 06:20:10 +00:00
|
|
|
cp -a "\$pkgdir/usr/bin/foo" "\$pkgdir/usr/bin/foo@"
|
2024-04-17 06:16:19 +00:00
|
|
|
mkdir -p "\$pkgdir/usr/bin/dir/"
|
2024-04-06 20:35:13 +00:00
|
|
|
ln -s /bin/not-on-the-host-system-but-in-a-dependency "\$pkgdir/usr/bin/link"
|
2024-04-17 06:16:19 +00:00
|
|
|
}
|
|
|
|
EOF
|
2023-06-15 12:37:24 +00:00
|
|
|
abuild rootpkg
|
|
|
|
|
|
|
|
atf_check \
|
|
|
|
-o match:"provides = cmd:foo=1.0-r0" \
|
2024-04-17 06:20:10 +00:00
|
|
|
-o not-match:"provides = cmd:foo@=1.0-r0" \
|
2024-04-06 20:35:13 +00:00
|
|
|
-o match:"provides = cmd:link=1.0-r0" \
|
2023-06-15 12:37:24 +00:00
|
|
|
-o not-match:"provides = cmd:dir=1.0-r0" \
|
2024-04-17 06:16:19 +00:00
|
|
|
grep '^provides = ' pkg/.control.testprovides/.PKGINFO
|
2023-06-15 12:37:24 +00:00
|
|
|
}
|
2023-06-22 03:33:59 +00:00
|
|
|
|
|
|
|
abuild_gocache_dir_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir gocache-dir
|
|
|
|
cd gocache-dir
|
|
|
|
cat >APKBUILD<<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="gocache-dir"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
echo "dir:\$GOCACHE"
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2023-06-26 08:33:40 +00:00
|
|
|
unset GOCACHE
|
2023-06-22 03:33:59 +00:00
|
|
|
MOVE_CACHES=1 \
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"dir:.*/tmp/go" \
|
|
|
|
abuild prepare build
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_cargo_home_dir_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir cargo-home-dir
|
|
|
|
cd cargo-home-dir
|
|
|
|
cat >APKBUILD<<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="cargo-home-dir"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
build() {
|
|
|
|
echo "dir:\$CARGO_HOME"
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
:
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2023-06-26 08:33:40 +00:00
|
|
|
unset CARGO_HOME
|
2023-06-22 03:33:59 +00:00
|
|
|
MOVE_CACHES=1 \
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:"dir:.*/tmp/cargo" \
|
|
|
|
abuild prepare build
|
|
|
|
}
|
2023-06-22 04:04:50 +00:00
|
|
|
|
|
|
|
abuild_fish_comp_split_body() {
|
|
|
|
init_keys
|
|
|
|
mkdir fish-split-dir
|
|
|
|
cd fish-split-dir
|
|
|
|
cat >APKBUILD<<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="fish-split-dir"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
prepare() {
|
|
|
|
mkdir -p "\$builddir"
|
|
|
|
}
|
|
|
|
package() {
|
|
|
|
mkdir -p "\$pkgdir"/usr/share/fish/completions/
|
|
|
|
mkdir -p "\$pkgdir"/usr/share/fish/vendor_completions.d/
|
|
|
|
echo "comp" > "\$pkgdir"/usr/share/fish/completions/comp.fish
|
|
|
|
echo "comp" > "\$pkgdir"/usr/share/fish/vendor_completions.d/comp.fish
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
# test that there is a warning for the legacy dir existing
|
|
|
|
atf_check -s exit:0 \
|
|
|
|
-e match:"fish completions for programs should be located in /usr/share/fish/vendor_completions.d" \
|
|
|
|
abuild prepare build rootpkg
|
|
|
|
|
|
|
|
# now add the correct subpackage
|
|
|
|
echo 'subpackages="$pkgname-fish-completion"' >> APKBUILD
|
|
|
|
abuild clean prepare build rootpkg
|
|
|
|
|
|
|
|
if ! [ -d pkg/fish-split-dir-fish-completion/usr/share/fish/completions ]; then
|
|
|
|
echo "missing old dir"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if ! [ -d pkg/fish-split-dir-fish-completion/usr/share/fish/vendor_completions.d ]; then
|
|
|
|
echo "missing new dir"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2023-10-17 19:48:57 +00:00
|
|
|
|
|
|
|
create_mock_apk() {
|
|
|
|
mkdir -p bin
|
|
|
|
cat > bin/apk <<-EOF
|
|
|
|
#!/bin/sh
|
|
|
|
if [ "\$1" = "--print-arch" ]; then
|
|
|
|
echo 'aarch64'
|
|
|
|
exit 0
|
|
|
|
fi
|
2024-04-14 00:05:03 +00:00
|
|
|
printf 'apk %s\n' "\$*" >&2
|
2023-10-17 19:48:57 +00:00
|
|
|
EOF
|
|
|
|
chmod +x bin/apk
|
|
|
|
ln -s apk bin/abuild-apk
|
|
|
|
PATH="$PWD/bin:$PATH"
|
|
|
|
}
|
|
|
|
|
|
|
|
abuild_deps_body() {
|
|
|
|
create_mock_apk
|
|
|
|
mkdir testdeps
|
|
|
|
cd testdeps
|
|
|
|
cat >APKBUILD <<-EOF
|
|
|
|
# Maintainer: Joe User <juser@example.com>
|
|
|
|
pkgname="testdeps"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="Dummy test package"
|
|
|
|
url="https://gitlab.alpinelinux.org/alpine/aports"
|
|
|
|
arch="noarch"
|
|
|
|
license="MIT"
|
|
|
|
depends="foo"
|
|
|
|
makedepends="bar"
|
2023-10-17 20:04:07 +00:00
|
|
|
checkdepends="checkdep"
|
2023-10-17 19:48:57 +00:00
|
|
|
makedepends_host="hostdep"
|
|
|
|
makedepends_build="builddep"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# native build. pull in both depends and makedepends
|
|
|
|
# do not install in any --root
|
|
|
|
atf_check \
|
2023-10-17 20:04:07 +00:00
|
|
|
-e match:'Installing for build: foo bar checkdep$' \
|
|
|
|
-e match:'apk add .*--virtual .makedepends-testdeps foo bar checkdep' \
|
2023-10-17 19:48:57 +00:00
|
|
|
-e not-match:'apk add .*--root' \
|
|
|
|
abuild deps
|
|
|
|
|
2023-10-17 20:04:07 +00:00
|
|
|
# dont install checkdep with ABUILD_BOOTSTRAP
|
|
|
|
ABUILD_BOOTSTRAP=1 atf_check \
|
|
|
|
-e not-match:"apk add.*checkdep" \
|
|
|
|
abuild deps
|
|
|
|
|
2023-10-17 19:48:57 +00:00
|
|
|
# crosscompile:
|
|
|
|
# install makedepends_build without --root
|
|
|
|
# install makedepends_host with --root
|
|
|
|
CTARGET='s390x' CHOST='ppc64le' CBUILDROOT="$PWD/root" atf_check \
|
|
|
|
-e match:'Installing for build: builddep' \
|
|
|
|
-e match:'Installing for host: hostdep' \
|
|
|
|
-e match:'apk add .*--virtual .makedepends-testdeps builddep' \
|
|
|
|
-e not-match:'apk add.*--root.*builddep' \
|
|
|
|
-e match:'apk add .*--root.*hostdep' \
|
|
|
|
-e match:'apk add .*--arch s390x.*hostdep' \
|
2023-10-17 20:04:07 +00:00
|
|
|
-e not-match:'apk add.*checkdep' \
|
2023-10-17 19:48:57 +00:00
|
|
|
abuild deps
|
2023-10-17 20:30:00 +00:00
|
|
|
|
|
|
|
# crosscompile, set only CHOST
|
|
|
|
CHOST='armhf' atf_check \
|
|
|
|
-e match:'apk add.*builddep' \
|
|
|
|
-e not-match:'apk add.*--root.*builddep' \
|
|
|
|
-e match:'apk add.*--root.*--arch armhf.*hostdep' \
|
|
|
|
-e not-match:'apk add.*--arch armhf.*builddep' \
|
|
|
|
abuild deps
|
|
|
|
|
2024-04-14 00:05:03 +00:00
|
|
|
# Check shell_escape
|
|
|
|
atf_check \
|
|
|
|
-e match:"apk add .*--repository It's \\\\b'\"\"' \"escaped\"/.*" \
|
|
|
|
abuild -P "It's \b'\"\"' \"escaped\"" deps
|
2023-10-17 19:48:57 +00:00
|
|
|
}
|