for i in postinst prerm; do
    abinfo "Generating $i ..."
    sed -e \
        "s/%PKGVER%/$__UPSTREAM_VER/g" \
        "$SRCDIR/autobuild/$i.in" > \
        "$SRCDIR/autobuild/$i"
done

abinfo "Unpacking upstream deb package ..."
dpkg-deb -X "$SRCDIR"/zhaoxin-linux-graphics-driver-dri-glvnd-"$__UPSTREAM_VER"_amd64.deb "$SRCDIR"

abinfo "Entering kernel module sources directory"
cd "$SRCDIR"/usr/src/zx-"$__UPSTREAM_VER"

abinfo "Restoring normal permissions for kernel module sources ..."
find -type d -not -perm 755 -exec chmod -v 755 {} ";"
find -type f -not -perm 644 -exec chmod -v 644 {} ";"

abinfo "Patching kernel module sources ..."
ab_apply_patches "$SRCDIR"/autobuild/module-patches/*.patch
