+# we are using the fact that this is a sourced sh script to take over and
+# handle updating ourselves. config is static and does not need changes.
+
+version=$version-mod
+verbose=0
+
+# replicate existing script
+everbose() {
+ if [ "$verbose" = "0" ]; then
+ return
+ fi
+
+ echo $*
+}
+
+ewarn() {
+ echo "WARNING:" $@ >&2
+}
+
+eerror() {
+ echo "ERROR:" $@ >&2
+ return 1
+}
+
+usage() {
+ echo "usage: $0 [-v|--verbose] [--warn-only]"
+}
+
+# NOTE: no-op for most options
+while [ $# -gt 0 ]; do
+ opt="$1"
+ shift
+ case "$opt" in
+ -v|--verbose)
+ verbose=1
+ ;;
+ --warn-only)
+ warn_only=1
+ ;;
+ --)
+ break
+ ;;
+ -*)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+src=/usr/share/syslinux/efi64
+boot=/boot/EFI/Boot
+everbose "Installing binaries from $src to $boot"
+cp $src/*.c32 $src/ldlinux.e64 $boot
+cp $src/syslinux.efi $boot/bootx64.efi
+
+ids=/usr/share/hwdata/pci.ids
+bootids=hdt/pci.ids
+apkargs="-q --no-progress"
+if ! apk info -e hwids-pci >/dev/null; then
+ everbose "Installing hwids-pci"
+ if apk $apkargs add hwids-pci; then
+ undo_hwids=1
+ else
+ ewarn $(cat <<EOF
+ Unable to install hwids-pci! If update-extlinux is
+ being called from syslinux hook during
+ installation/upgrade, you will need to run
+ update-extlinux after the apk database is unlocked.
+ Alternatively, install hwids-pci manually before
+ upgrading boot-related packages.
+EOF
+)
+ fi
+else
+ everbose "Upgrading hwids-pci"
+ if ! apk $apkargs upgrade hwids-pci; then
+ ewarn "Upgrade failed for hwids-pci, pci.ids may be out of date"
+ fi
+fi
+if [ ! -r "$ids" ]; then
+ ewarn "Cannot read $ids, can't update $boot/$bootids"
+else
+ everbose "Installing $ids to $boot/$bootids"
+ cp $ids $boot/$bootids
+fi
+if [ -n "$undo_hwids" ]; then
+ everbose "Deleting hwids-pci"
+ apk $apkargs del hwids-pci
+fi
+
+# exit from parent script
+exit 0