main/devicepkg-dev: install deviceinfo under /usr/share/deviceinfo (MR 4283)

In the process, add some tests and do some renaming on the existing ones, and
remove the workaround for #2228, will be solved appropriately in a follow-up
commit.

Fixes #1836
This commit is contained in:
Pablo Correa Gómez 2023-06-07 19:10:24 +02:00 committed by Oliver Smith
parent fe40948947
commit 1d748a93dd
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 30 additions and 20 deletions

View file

@ -1,5 +1,5 @@
pkgname=devicepkg-dev
pkgver=0.15.3
pkgver=0.16.0
pkgrel=0
pkgdesc="Provides default device package functions"
url="https://postmarketos.org"
@ -25,21 +25,33 @@ check() {
# Execute the script to create the subpackage deviceinfo
sh devicepkg_subpackage_kernel.sh \
$testdir linux-test linux-test-kernel-downstream
$testdir device-test device-test-kernel-downstream
sh devicepkg_subpackage_kernel.sh \
$testdir linux-test linux-test-kernel-mainline
$testdir device-test device-test-kernel-mainline
# Compare the result with the expected files
if ! cmp -s "$srcdir/expected-deviceinfo-downstream" \
"$testdir/pkg/linux-test-kernel-downstream/etc/deviceinfo"; then
"$testdir/pkg/device-test-kernel-downstream/usr/share/deviceinfo/device-test-kernel-downstream"
then
echo "ERROR: unexpected result with downstream deviceinfo"
exit 1
fi
if ! cmp -s "$srcdir/expected-deviceinfo-mainline" \
"$testdir/pkg/linux-test-kernel-mainline/etc/deviceinfo"; then
"$testdir/pkg/device-test-kernel-mainline/usr/share/deviceinfo/device-test-kernel-mainline"
then
echo "ERROR: unexpected result with mainline deviceinfo"
exit 1
fi
# Check that the link is a link, and that it points to the right place
if [ "$(readlink $testdir/pkg/device-test-kernel-mainline/usr/share/deviceinfo/deviceinfo)" != "device-test-kernel-mainline" ];
then
echo "ERROR: mainline deviceinfo link not pointing to correct location"
fi
if ! cmp -s "$testdir/pkg/device-test-kernel-mainline/usr/share/deviceinfo/deviceinfo" \
"$srcdir/expected-deviceinfo-mainline";
then
echo "ERROR: mainline deviceinfo contains incorrect data"
fi
# Cleanup
rm -r "$testdir"
@ -62,10 +74,10 @@ package() {
sha512sums="
d69930dd790b00fb39760a37d95a10899f0d167e10e2804feb05d9ce04f94185dc32d36edc90214aba2ea2aa09bf18f7dab93f1d2eff23f67beb2cc83be30e7c compiler-gcc.h
54b369ff87e017114edae03986dec79742280c55a156a98ea8c6a1c740632e904e51c01810e7dac99add0d9d06c0fcebb040fed595348f180233b3ec810443ba devicepkg_build.sh
33e3ce8fde0989ec3e367055199625de7c131c4b1f8a72cefc13bfde96604ff440afe2519d357827a3fe43c90b34736cf455b6f886a25f1217464457d8e94905 devicepkg_package.sh
5b83255dabd2019ea07a589d185bee5dad6760e28ab02de3480a0adfd1cf20d0c2e0b4a978e56757899ef683819091cee99d168a48e24a3f604b725e1ba26849 devicepkg_package.sh
f81e74e45ae8e55686ae459f550e229e7398daeafa72bd023c2d8c3a0d50e60bf53d5bbdfec931e9fbabe1cd71de57b2192805aaef091ab90bc7203cbaf66ba6 downstreamkernel_prepare.sh
107242a3da38a574c46cb779e0c75afbeef4cfe659e1b85971973ac55843df06f70f53a5985ca623d4123f05f2984f5dace4a53a3509ecefd7dfdc3c8b705cfe downstreamkernel_package.sh
6e64a78dcb768fe7d40e9eeef6147084567168a3f3238b836bd518adb48c9d2bfeb6e96a4bde0d47cc4a69d8dba680631612aff4f6393a44b3bd9d4bf5ac9608 devicepkg_subpackage_kernel.sh
ece2e6352c61c5764b2502d05b388880f53f2cded3056aed003c9cf5245328627c0b0fb08a3102e7064acdcba8715b8d5bf4c07a7b87e9f635b87e2450e75fc0 devicepkg_subpackage_kernel.sh
9bb7f2a0930f397a713e9f4b6d5b83a426d9a2a3f692dcc42ac30717bf26ead869d8823a38f3ad388af12b2b9a02e8ec4d4418e9c2062389ed06d2b891a49ff3 deviceinfo
136247a16ec91dc0c7241eeddb28c2196ae3b29946a9bc7e9566f848491ef1c53b12d05bf2dbc1cc352986712fd76f25c1510bcc8f301af540a2f01c33b299e1 expected-deviceinfo-downstream
8cdbf149e1bdfaf4d4a246a208732836956fd81a3aa01ef968e4c2e2cca4027f71cfc38e22debade83ddfca4e05267983c1c8a9c1aa9461a8cf493ef7e893097 expected-deviceinfo-mainline

View file

@ -19,7 +19,8 @@ if [ ! -f "$srcdir/deviceinfo" ]; then
fi
install -Dm644 "$srcdir/deviceinfo" \
"$pkgdir/etc/deviceinfo"
"$pkgdir/usr/share/deviceinfo/$pkgname"
ln -s "$pkgname" "$pkgdir/usr/share/deviceinfo/deviceinfo"
install -Dm644 "$srcdir/machine-info" \
"$pkgdir/etc/machine-info"
@ -52,8 +53,3 @@ if [ -f "$srcdir/modprobe.conf" ]; then
install -Dm644 "$srcdir/modprobe.conf" \
"$pkgdir/etc/modprobe.d/$pkgname.conf"
fi
# Workaround for https://gitlab.com/postmarketOS/pmaports/-/issues/2228
touch "$pkgname"-trigger
install -Dm644 "$pkgname"-trigger \
"$pkgdir"/usr/share/mkinitfs-triggers/"$pkgname"

View file

@ -13,12 +13,14 @@ srcdir="$startdir/src"
pkgdir="$startdir/pkg/$pkgname"
subpkgdir="$startdir/pkg/$subpkgname"
if [ -e "$pkgdir/etc/deviceinfo" ]; then
rm -v "$pkgdir/etc/deviceinfo"
if [ -e "$pkgdir/usr/share/deviceinfo/$pkgname" ]; then
rm -v "$pkgdir/usr/share/deviceinfo/$pkgname"
fi
deviceinfo="$subpkgdir/usr/share/deviceinfo/$subpkgname"
install -Dm644 "$srcdir/deviceinfo" \
"$subpkgdir/etc/deviceinfo"
"$deviceinfo"
ln -s "$subpkgname" "$subpkgdir/usr/share/deviceinfo/deviceinfo"
# Get the kernel type ("downstream", "mainline")
kernel=$(echo "$subpkgname" | sed -n "s/.*-kernel-\(.*\)/\1/p" | tr - _)
@ -38,17 +40,17 @@ fi
# Iterate over deviceinfo variables that have the kernel type as suffix
# var looks like: deviceinfo_kernel_cmdline, ...
grep -E "(.+)_$kernel=.*" "$subpkgdir/etc/deviceinfo" | \
grep -E "(.+)_$kernel=.*" "$deviceinfo" | \
sed "s/\(.\+\)_$kernel=.*/\1/g" | while IFS= read -r var
do
if grep -Eq "$var=.*" "$subpkgdir/etc/deviceinfo"; then
if grep -Eq "$var=.*" "$deviceinfo"; then
echo "ERROR: variable '$var' should contain a kernel subpackage suffix"
exit 1
fi
# Remove the kernel suffix from the variable
sed -i "s/$var\_$kernel/$var/g" "$subpkgdir/etc/deviceinfo"
sed -i "s/$var\_$kernel/$var/g" "$deviceinfo"
# Remove the variables with other kernel suffixes
sed -i "/$var\_.*=.*/d" "$subpkgdir/etc/deviceinfo"
sed -i "/$var\_.*=.*/d" "$deviceinfo"
done