2018-10-15 19:54:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
startdir=$1
|
|
|
|
pkgname=$2
|
|
|
|
subpkgname=$3
|
|
|
|
|
|
|
|
if [ -z "$startdir" ] || [ -z "$pkgname" ] || [ -z "$subpkgname" ]; then
|
|
|
|
echo "ERROR: missing argument!"
|
|
|
|
echo "Please call $0 with \$startdir \$pkgname \$subpkgname as arguments."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
srcdir="$startdir/src"
|
|
|
|
pkgdir="$startdir/pkg/$pkgname"
|
|
|
|
subpkgdir="$startdir/pkg/$subpkgname"
|
|
|
|
|
2023-06-07 17:10:24 +00:00
|
|
|
if [ -e "$pkgdir/usr/share/deviceinfo/$pkgname" ]; then
|
|
|
|
rm -v "$pkgdir/usr/share/deviceinfo/$pkgname"
|
2018-10-15 19:54:15 +00:00
|
|
|
fi
|
|
|
|
|
2023-06-07 17:10:24 +00:00
|
|
|
deviceinfo="$subpkgdir/usr/share/deviceinfo/$subpkgname"
|
2018-10-15 19:54:15 +00:00
|
|
|
install -Dm644 "$srcdir/deviceinfo" \
|
2023-06-07 17:10:24 +00:00
|
|
|
"$deviceinfo"
|
|
|
|
ln -s "$subpkgname" "$subpkgdir/usr/share/deviceinfo/deviceinfo"
|
2018-10-15 19:54:15 +00:00
|
|
|
|
|
|
|
# Get the kernel type ("downstream", "mainline")
|
2020-01-18 10:43:16 +00:00
|
|
|
kernel=$(echo "$subpkgname" | sed -n "s/.*-kernel-\(.*\)/\1/p" | tr - _)
|
2018-10-15 19:54:15 +00:00
|
|
|
|
2023-06-27 16:55:53 +00:00
|
|
|
# All the installation paths for the modules conflict with those from
|
|
|
|
# devicepkg_package. It is not supported to have both a modules and
|
|
|
|
# a modules.$kernel file, it should instead be more than one modules.$kernel
|
|
|
|
# files, with different $kernel values. The conflict between the package and
|
|
|
|
# the subpackage aims to prevent the unsupported situation to slip through.
|
2023-07-28 11:11:54 +00:00
|
|
|
if [ -f "$srcdir/modules-initfs.$kernel" ]; then
|
|
|
|
install -Dm644 "$srcdir/modules-initfs.$kernel" \
|
2023-06-09 18:55:52 +00:00
|
|
|
"$subpkgdir/usr/share/mkinitfs/modules/00-$pkgname.modules"
|
2023-06-27 16:55:53 +00:00
|
|
|
mkdir -p "$subpkgdir/usr/share/mkinitfs/files"
|
|
|
|
echo "/usr/share/mkinitfs/modules/00-$pkgname.modules:/lib/modules/initramfs.load" \
|
|
|
|
> "$subpkgdir/usr/share/mkinitfs/files/00-$pkgname-modules.files"
|
2023-06-09 18:55:52 +00:00
|
|
|
fi
|
|
|
|
|
2018-10-15 19:54:15 +00:00
|
|
|
# Iterate over deviceinfo variables that have the kernel type as suffix
|
|
|
|
# var looks like: deviceinfo_kernel_cmdline, ...
|
2023-06-07 17:10:24 +00:00
|
|
|
grep -E "(.+)_$kernel=.*" "$deviceinfo" | \
|
2018-10-15 19:54:15 +00:00
|
|
|
sed "s/\(.\+\)_$kernel=.*/\1/g" | while IFS= read -r var
|
|
|
|
do
|
2023-06-07 17:10:24 +00:00
|
|
|
if grep -Eq "$var=.*" "$deviceinfo"; then
|
2018-10-15 19:54:15 +00:00
|
|
|
echo "ERROR: variable '$var' should contain a kernel subpackage suffix"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove the kernel suffix from the variable
|
2023-06-07 17:10:24 +00:00
|
|
|
sed -i "s/$var\_$kernel/$var/g" "$deviceinfo"
|
2018-10-15 19:54:15 +00:00
|
|
|
|
|
|
|
# Remove the variables with other kernel suffixes
|
2023-06-07 17:10:24 +00:00
|
|
|
sed -i "/$var\_.*=.*/d" "$deviceinfo"
|
2018-10-15 19:54:15 +00:00
|
|
|
done
|