#!/bin/sh
# This script should be run before building the package every time a new
# kernel is released.

set -e

BL='fbdev-blacklist.conf'

if [ -e extra/$BL ]; then cd extra; fi

{
printf "# This file blacklists the framebuffer drivers.\n\n"

find /lib/modules/$(uname -r)/kernel/drivers/video -type f | sort | \
while read file; do
  /sbin/modinfo $file | grep -q '^alias: *pci:' \
    && echo blacklist $(basename $file .ko) || true
done
} > $BL.tmp

if diff --unified=0 $BL $BL.tmp; then
  rm $BL.tmp
else
  printf "\n\n\n$BL.tmp has changes!\n\n\n\n"
fi

