abuild: Fix building with spaces in path

This commit is contained in:
Marian Buschsieweke 2023-04-14 06:03:17 +00:00 committed by Natanael Copa
parent b7c4da8f53
commit 10b4e8e8bd
4 changed files with 58 additions and 7 deletions

View File

@ -1004,7 +1004,7 @@ check_license() {
}
check_secfixes_comment() {
local c=$(sed -E -n -e '/^# secfixes:/,/(^[^#]|^$)/p' $APKBUILD | grep '^#')
local c=$(sed -E -n -e '/^# secfixes:/,/(^[^#]|^$)/p' "$APKBUILD" | grep '^#')
local invalid=$(echo "$c" \
| grep -v -E '(^# secfixes:|^# +- [A-Z0-9-]+|^# [0-9]+.*:$|^#$)')
if [ -z "$invalid" ]; then
@ -1706,7 +1706,7 @@ create_apks() {
if ! options_has "!tracedeps"; then
for file in "$pkgbasedir"/.control.*/.PKGINFO; do
dir="${file%/.PKGINFO}"
name="$(pkginfo_val pkgname $file)"
name="$(pkginfo_val pkgname "$file")"
datadir="$pkgbasedir"/$name
subpkgname=$name
scan_shared_objects "$name" "$dir" "$datadir"
@ -1719,13 +1719,13 @@ create_apks() {
for file in "$pkgbasedir"/.control.*/.PKGINFO; do
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 name=$(pkginfo_val pkgname "$file")
local ver=$(pkginfo_val pkgver "$file")
local size=$(pkginfo_val size "$file" | human_size)
local apk=$name-$ver.apk
local datadir="$pkgbasedir"/$name
local subpkgname=$name
local subpkgarch=$(pkginfo_val arch $file)
local subpkgarch=$(pkginfo_val arch "$file")
trace_apk_deps "$name" "$dir" "$subpkgarch" || return 1
msg "Package size: ${size}"

View File

@ -30,7 +30,8 @@ init_tests \
abuild_doc \
abuild_dev \
abuild_check_maintainer \
abuild_cleanoldpkg
abuild_cleanoldpkg \
abuild_path_with_spaces
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
export ABUILD_CONF=/dev/null
@ -763,3 +764,13 @@ abuild_cleanoldpkg_body() {
fi
done
}
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
}

View File

@ -0,0 +1,35 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
# test package
pkgname="pkg-path-with-spaces"
pkgver="1.0"
pkgrel=0
pkgdesc="Dummy test package to test building with spaces in path"
url="https://gitlab.alpinelinux.org/alpine/aports"
arch="all"
license="MIT"
source="hello.c"
builddir="$srcdir/$pkgname-1.0"
prepare() {
mkdir -p "$builddir"
cp "$srcdir"/*.c "$builddir"
}
build() {
${CC:-gcc} -o hello hello.c
}
check() {
./hello
}
package() {
install -D -m755 hello "$pkgdir"/usr/bin/hello
ln "$pkgdir"/usr/bin/hello "$pkgdir"/usr/bin/hello-hard
ln -s "$pkgdir"/usr/bin/hello "$pkgdir"/usr/bin/hello-sym
}
sha512sums="
e80c0d471f7ec07708795b86127f0f7c968c49031f1e57cae200b5fbf2606e55fc4d56efb05a85c6f54dfe33e87d6789154cf15aee72ba0d216f08fb57926503 hello.c
"

View File

@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("hello world\n");
return 0;
}