debian: Generate postinst devices list automatically at gbp import phase

Alternatively provide a script to keep the post-inst script updated
This commit is contained in:
Marco Trevisan (Treviño)
2021-01-21 19:06:56 +01:00
parent b97f10d63d
commit 4c4b444f21
6 changed files with 67 additions and 18 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/bin/bash
set -e
srcdir="${GBP_SOURCES_DIR:-.}"
debpath="$(dirname "$0")"
autosuspend_file="$srcdir/data/autosuspend.hwdb"
commands_lines=()
while IFS= read -r line; do
if [[ $line =~ ^usb:v([A-Fa-f0-9]{4})p([A-Fa-f0-9]{4}) ]]; then
vendor="$(echo "${BASH_REMATCH[1]}" | tr '[:upper:]' '[:lower:]')"
product="$(echo "${BASH_REMATCH[2]}" | tr '[:upper:]' '[:lower:]')"
commands_lines+=("\tudevadm trigger --action=add --attr-match=idVendor=$vendor --attr-match=idProduct=$product")
fi
done < "$autosuspend_file"
export UDEVADM_TRIGGERS=$( IFS=$'\n'; echo -e "${commands_lines[*]}" )
for i in $debpath/libfprint-*.post*.in; do
out="${i%.in}"
envsubst < "$i" > "$out"
if [ -n "$GBP_BRANCH" ]; then
if ! git diff-index --quiet HEAD -- "$out"; then
git add "$out"
dch "${out#$srcdir}: Devices triggers updated"
git add debian/changelog
debcommit
fi
fi
done