2019-11-07 11:01:18 +00:00
|
|
|
setup() {
|
2020-10-29 12:04:27 +00:00
|
|
|
export ABUILD="$PWD/../abuild"
|
|
|
|
export ABUILD_SHAREDIR="$PWD/.."
|
2021-01-07 14:21:03 +00:00
|
|
|
export ABUILD_CONF=/dev/null
|
2021-04-20 09:37:13 +00:00
|
|
|
tmpdir="$BATS_TMPDIR"/abuild
|
|
|
|
export REPODEST="$tmpdir"/packages
|
|
|
|
mkdir -p $tmpdir
|
2021-04-28 08:48:54 +00:00
|
|
|
export CLEANUP="srcdir bldroot pkgdir deps"
|
2019-11-07 11:01:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 13:42:27 +00:00
|
|
|
teardown() {
|
2021-04-20 09:37:13 +00:00
|
|
|
rm -rf "$tmpdir"
|
2020-10-29 13:42:27 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 08:59:38 +00:00
|
|
|
@test "abuild: help text" {
|
2019-11-07 11:01:18 +00:00
|
|
|
$ABUILD -h
|
|
|
|
}
|
|
|
|
|
2020-07-08 08:59:38 +00:00
|
|
|
@test "abuild: version string" {
|
2019-11-07 11:01:18 +00:00
|
|
|
$ABUILD -V
|
|
|
|
}
|
2020-10-29 12:04:27 +00:00
|
|
|
|
|
|
|
@test "abuild: build simple package without deps" {
|
|
|
|
cd testrepo/pkg1
|
|
|
|
$ABUILD
|
|
|
|
}
|
2020-10-29 12:32:28 +00:00
|
|
|
|
|
|
|
@test "abuild: build failure" {
|
|
|
|
cd testrepo/buildfail
|
2021-04-28 08:48:54 +00:00
|
|
|
run ERROR_CLEANUP="$CLEANUP" $ABUILD all
|
2021-02-04 13:34:47 +00:00
|
|
|
[ $status -ne 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "abuild: test check for invalid file names" {
|
|
|
|
cd testrepo/invalid-filename
|
2021-04-28 08:48:54 +00:00
|
|
|
run ERROR_CLEANUP="$CLEANUP" $ABUILD all
|
2021-02-04 13:34:47 +00:00
|
|
|
echo "$output"
|
2020-10-29 12:32:28 +00:00
|
|
|
[ $status -ne 0 ]
|
|
|
|
}
|
|
|
|
|
2020-10-29 13:49:24 +00:00
|
|
|
@test "abuild: test check for /usr/lib64" {
|
|
|
|
cd testrepo/lib64test
|
2021-02-04 13:34:47 +00:00
|
|
|
run $ABUILD all
|
2020-10-29 13:49:24 +00:00
|
|
|
[ $status -ne 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "abuild: test options=lib64" {
|
|
|
|
cd testrepo/lib64test
|
|
|
|
options=lib64 $ABUILD
|
|
|
|
$ABUILD cleanpkg
|
|
|
|
}
|
2020-10-29 14:44:52 +00:00
|
|
|
|
2021-04-28 08:44:28 +00:00
|
|
|
@test "abuild: test -dbg subpackage" {
|
|
|
|
cd testrepo/dbgpkg
|
|
|
|
$ABUILD
|
|
|
|
}
|
|
|
|
|
2021-04-28 08:57:26 +00:00
|
|
|
@test "abuild: test SETFATTR in -dbg subpackage" {
|
|
|
|
cd testrepo/dbgpkg
|
|
|
|
ERROR_CLEANUP="$CLEANUP" SETFATTR=true $ABUILD
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "abuild: test SETFATTR failure in -dbg subpackage" {
|
|
|
|
cd testrepo/dbgpkg
|
|
|
|
run ERROR_CLEANUP="$CLEANUP" SETFATTR=false $ABUILD
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
}
|
|
|
|
|
2020-10-29 14:44:52 +00:00
|
|
|
@test "abuild: verify that packages are reproducible built" {
|
|
|
|
cd testrepo/pkg1
|
|
|
|
arch=$($ABUILD -A)
|
|
|
|
pkgs=$($ABUILD listpkg)
|
2020-10-29 15:02:23 +00:00
|
|
|
|
|
|
|
$ABUILD
|
|
|
|
checksums=$(cd "$REPODEST"/testrepo/$arch && md5sum $pkgs)
|
2020-10-29 14:44:52 +00:00
|
|
|
echo "$checksums"
|
2020-10-29 15:02:23 +00:00
|
|
|
|
2020-10-29 14:44:52 +00:00
|
|
|
$ABUILD cleanpkg all
|
|
|
|
checksums2=$(cd "$REPODEST"/testrepo/$arch && md5sum $pkgs)
|
|
|
|
echo "$checksums2"
|
|
|
|
|
2020-10-29 15:02:23 +00:00
|
|
|
[ "$checksums" = "$checksums2" ]
|
2020-10-29 14:44:52 +00:00
|
|
|
}
|
2021-02-04 13:34:47 +00:00
|
|
|
|
2021-04-20 09:37:13 +00:00
|
|
|
@test "abuild: test checksum generation" {
|
|
|
|
mkdir -p "$tmpdir"/foo
|
|
|
|
cat >> "$tmpdir"/foo/APKBUILD <<-EOF
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
source="test.txt"
|
|
|
|
EOF
|
|
|
|
echo "foo" > "$tmpdir"/foo/test.txt
|
|
|
|
cd "$tmpdir"/foo
|
2021-04-28 10:58:20 +00:00
|
|
|
$ABUILD checksum
|
2021-04-20 14:34:41 +00:00
|
|
|
. ./APKBUILD && echo "$sha512sums" > sums
|
2021-04-20 09:37:13 +00:00
|
|
|
cat sums
|
|
|
|
sha512sum -c sums
|
|
|
|
}
|
|
|
|
|
2021-04-28 11:02:28 +00:00
|
|
|
@test "abuild: test duplicates in checksum generation" {
|
|
|
|
mkdir -p "$tmpdir"/foo "$tmpdir"/foo/dir1 "$tmpdir"/foo/dir2
|
|
|
|
cat >> "$tmpdir"/foo/APKBUILD <<-EOF
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
source="dir1/testfile dir2/testfile"
|
|
|
|
EOF
|
|
|
|
echo "first" > "$tmpdir"/foo/dir1/testfile
|
|
|
|
echo "second" > "$tmpdir"/foo/dir2/testfile
|
|
|
|
cd "$tmpdir"/foo
|
|
|
|
run $ABUILD checksum
|
|
|
|
[ $status -ne 0 ]
|
|
|
|
}
|
|
|
|
|
2021-04-29 09:45:59 +00:00
|
|
|
@test "abuild: test that -dbg should be first" {
|
|
|
|
mkdir -p "$tmpdir"/foo
|
|
|
|
cat >> "$tmpdir"/foo/APKBUILD <<-EOF
|
|
|
|
# Maintainer: Test user <user@example.com>
|
|
|
|
pkgname="foo"
|
|
|
|
pkgver="1.0"
|
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="dummy package for test"
|
|
|
|
url="https://alpinelinux.org"
|
|
|
|
license="MIT"
|
|
|
|
subpackages="\$pkgname-dev \$pkgname-dbg"
|
|
|
|
package() { :; }
|
|
|
|
EOF
|
|
|
|
cd "$tmpdir"/foo
|
|
|
|
run $ABUILD sanitycheck
|
|
|
|
[[ $output[1] == *WARNING*dbg* ]]
|
|
|
|
}
|