2017-12-14 21:17:18 +00:00
|
|
|
#!/bin/sh
|
|
|
|
startdir=$1
|
|
|
|
pkgname=$2
|
|
|
|
|
|
|
|
if [ -z "$startdir" ] || [ -z "$pkgname" ]; then
|
|
|
|
echo "ERROR: missing argument!"
|
2018-10-15 19:54:15 +00:00
|
|
|
echo "Please call $0 with \$startdir \$pkgname as arguments."
|
2017-12-14 21:17:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
srcdir="$startdir/src"
|
|
|
|
|
|
|
|
if [ ! -f "$srcdir/deviceinfo" ]; then
|
|
|
|
echo "NOTE: $0 is intended to be used inside of the build() function"
|
|
|
|
echo "of a device package's APKBUILD only."
|
|
|
|
echo "ERROR: deviceinfo file missing!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# shellcheck disable=SC1090,SC1091
|
|
|
|
. "$srcdir/deviceinfo"
|
|
|
|
|
2020-01-20 15:30:01 +00:00
|
|
|
# Create splash screens
|
|
|
|
generate_splash_screens()
|
|
|
|
{
|
|
|
|
splash_config="/etc/postmarketos/splash.ini"
|
|
|
|
splash_width=${deviceinfo_screen_width:-720}
|
|
|
|
splash_height=${deviceinfo_screen_height:-1280}
|
|
|
|
|
|
|
|
# Overwrite $@ to easily iterate over the splash screens. Format:
|
|
|
|
# $1: splash_name
|
|
|
|
# $2: text
|
|
|
|
# $3: arguments
|
|
|
|
set -- "splash-loading" "Loading..." "--center" \
|
|
|
|
"splash-noboot" "boot partition not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
|
|
|
"splash-noinitramfsextra" "initramfs-extra not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
|
|
|
"splash-norootfs" "rootfs not found\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
2021-04-11 16:52:25 +00:00
|
|
|
"splash-resizefs" "Loading...\\nResizing file system during initial boot" "--center" \
|
2020-01-20 15:30:01 +00:00
|
|
|
"splash-mounterror" "unable to mount root partition\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
|
|
|
"splash-debug-shell" "WARNING\\ndebug-shell is active\\nhttps://postmarketos.org/debug-shell" "--center" \
|
2021-12-16 21:04:27 +00:00
|
|
|
"splash-charging-error" "CHARGING MODE\\nerror starting charging-sdl\\nhttps://postmarketos.org/troubleshooting" "--center" \
|
|
|
|
"splash-netboot-waiting" "Waiting for netboot...\\nhttps://postmarketos.org/netboot" "--center" \
|
|
|
|
"splash-netboot-error" "failed to initialize netboot\\nhttps://postmarketos.org/netboot" "--center"
|
2020-01-20 15:30:01 +00:00
|
|
|
|
|
|
|
# Loop through the splash screens definitions
|
|
|
|
while [ $# -gt 2 ]
|
|
|
|
do
|
|
|
|
splash_name=$1
|
|
|
|
splash_text=$2
|
|
|
|
splash_args=$3
|
|
|
|
|
2020-01-20 15:45:17 +00:00
|
|
|
# shellcheck disable=SC2154
|
|
|
|
if [ "${deviceinfo_framebuffer_landscape}" = "true" ]; then
|
2020-01-20 15:30:01 +00:00
|
|
|
splash_args="${splash_args} --landscape"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
pmos-make-splash --text="${splash_text}" $splash_args --config "${splash_config}" \
|
|
|
|
"$splash_width" "$splash_height" "$srcdir/${splash_name}.ppm"
|
|
|
|
gzip "$srcdir/${splash_name}.ppm"
|
|
|
|
|
|
|
|
shift 3 # move to the next 3 arguments
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-02-11 10:20:31 +00:00
|
|
|
# Convert an input calibration matrix from pixel coordinates to 0-1 coordinates
|
|
|
|
# and echo it for libinput.
|
|
|
|
# Parameters:
|
|
|
|
# $1: x multiplier for x coordinate
|
|
|
|
# $2: y multiplier for x coordinate
|
|
|
|
# $3: pixel offset for x coordinate
|
|
|
|
# $4: x multiplier for y coordinate
|
|
|
|
# $5: y multiplier for y coordinate
|
|
|
|
# $6: pixel offset for y coordinate
|
|
|
|
echo_libinput_calibration()
|
|
|
|
{
|
|
|
|
# Check if we have got the required number of parameters.
|
|
|
|
if [ $# -ne 6 ]; then
|
|
|
|
echo "WARNING: There must be exactly 6 (or 0) values for the touchscreen calibration." >&2
|
|
|
|
echo "WARNING: No calibration matrix for x11/libinput will be generated." >&2
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if we have got a screen width and screen height.
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
if [ -z "$deviceinfo_screen_width" ] || [ -z "$deviceinfo_screen_height" ]; then
|
|
|
|
echo "WARNING: Screen width and height are required to generate a calibration matrix for x11/libinput." >&2
|
|
|
|
echo "WARNING: No calibration matrix for x11/libinput will be generated." >&2
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Perform the actual conversion: divide both offsets by width/height.
|
|
|
|
# As the "dc" command from "bc" is incompatible to the one provided by busybox,
|
|
|
|
# this calls busybox explicitly.
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
x_offset=$(busybox dc "$3" "$deviceinfo_screen_width" / p)
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
y_offset=$(busybox dc "$6" "$deviceinfo_screen_height" / p)
|
|
|
|
# Check if we have got results from dc. If there was an error, dc should have
|
|
|
|
# printed an error message that hopefully gives the user a hint why it failed.
|
|
|
|
if [ -z "$x_offset" ] || [ -z "$y_offset" ]; then
|
|
|
|
echo "WARNING: Calculating the offsets for the calibration matrix for x11/libinput failed." >&2
|
|
|
|
echo "No calibration matrix for x11/libinput will be generated." >&2
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "ENV{LIBINPUT_CALIBRATION_MATRIX}=\"$1 $2 $x_offset $4 $5 $y_offset\", \\"
|
|
|
|
}
|
|
|
|
|
2020-05-15 17:41:48 +00:00
|
|
|
# Generate the contents for /etc/machine-info
|
|
|
|
generate_machine_info()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
echo "PRETTY_HOSTNAME=\"$deviceinfo_name\""
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
echo "CHASSIS=\"${deviceinfo_chassis}\""
|
|
|
|
} > "$srcdir/machine-info"
|
|
|
|
}
|
|
|
|
|
2020-01-20 15:30:01 +00:00
|
|
|
generate_splash_screens
|
|
|
|
|
2020-05-15 17:41:48 +00:00
|
|
|
generate_machine_info
|
|
|
|
|
2017-12-14 21:17:18 +00:00
|
|
|
# shellcheck disable=SC2154
|
2019-09-26 19:43:34 +00:00
|
|
|
if [ -n "$deviceinfo_dev_touchscreen" ]; then
|
2017-12-14 21:17:18 +00:00
|
|
|
# Create touchscreen udev rule
|
|
|
|
{
|
|
|
|
echo "SUBSYSTEM==\"input\", ENV{DEVNAME}==\"$deviceinfo_dev_touchscreen\", \\"
|
|
|
|
# shellcheck disable=SC2154
|
2019-09-26 19:43:34 +00:00
|
|
|
if [ -n "$deviceinfo_dev_touchscreen_calibration" ]; then
|
2017-12-14 21:17:18 +00:00
|
|
|
echo "ENV{WL_CALIBRATION}=\"$deviceinfo_dev_touchscreen_calibration\", \\"
|
2018-02-11 10:20:31 +00:00
|
|
|
|
|
|
|
# The following intentionally expands the touchscreen calibration into the
|
|
|
|
# 6 values that should be there.
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
echo_libinput_calibration $deviceinfo_dev_touchscreen_calibration
|
2017-12-14 21:17:18 +00:00
|
|
|
fi
|
|
|
|
echo "ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_TOUCHSCREEN}=\"1\""
|
|
|
|
} > "$srcdir/90-$pkgname.rules"
|
|
|
|
fi
|