#!/bin/sh

post_install() {
  set -e

  cd /lib/firmware
  [ -e .vendorfw.manifest ] || return 0
 
  printf '==> Removing obsolete vendor firmware from /lib/firmware...\n'
  awk '{ print $2 }' < .vendorfw.manifest | xargs rm -f
  rmdir asmedia brcm 2>/dev/null || true
  # Stop update-vendor-firmware from putting it back this boot
  if [ ! -e vendor/.vendorfw.manifest ]; then
    mkdir -p vendor
    mount -t tmpfs vendorfw vendor
    mv .vendorfw.manifest vendor/
  fi
}

post_upgrade() {
  post_install
}
