#!/bin/bash VERSION=$(uname -r) function compile_for_5x { cd /usr/src/promethean/kernel sed -i 's/SUBDIRS/M/g' /usr/src/promethean/kernel/Makefile make -C /lib/modules/${VERSION}/build M=$PWD clean cp /usr/src/linux-headers-${VERSION}/Module.symvers /usr/src/promethean/kernel make -C /lib/modules/${VERSION}/build M=$PWD #Control build return sed -i 's/\(Error building driver.*\)/\0\n\t\texit 1/g' b ./b if [ $? -eq 1 ] then #Something went wrong. Last chance: Reinstall headers apt-get remove --purge -y linux-headers-$VERSION [ -d /usr/src/linux-headers-$VERSION/ ] && rm -fr /usr/src/linux-headers-$VERSION apt-get install -y linux-headers-$VERSION ./b fi cd $OLDPWD } function fix_activinspire_pkg { apt-get download activinspire if [ $? -ne 0 ] then exit 1 fi #Rebuild the package without libcurl3 depend mkdir wrk dpkg-deb -R activinspire*.deb wrk sed -i 's/libcurl3,//g' wrk/DEBIAN/control dpkg-deb -b wrk activinspire-lliurex.deb dpkg -i $PWD/activinspire-lliurex.deb } function fix_activtools_pkg { #this pkg needs activaid so install it first apt-get install -y activdriver apt-get install -y activaid apt-get download activtools if [ $? -ne 0 ] then exit 1 fi #Rebuild the package without libssl1.0.0 depend mkdir wrk dpkg-deb -R activtools*.deb wrk sed -i 's/libssl1.0.0,/libssl1.1,/g' wrk/DEBIAN/control dpkg-deb -b wrk activtools-lliurex.deb dpkg -i $PWD/activtools-lliurex.deb mv $PWD/activtools-lliurex.deb /tmp mv $PWD/wrk /tmp } ACTION="$1" case $ACTION in preInstall) dpkg --add-architecture i386 apt-get update #Install needed packages apt-get install -y activinspire-32bitdependsfor64bit-lliurex #Get the linux-headers of current kernel apt-get install -y linux-headers-$VERSION WRKDIR=$(mktemp -d) chmod 777 $WRKDIR cd $WRKDIR fix_activtools_pkg rm -fr $WRKDIR/* fix_activinspire_pkg apt-get install -y -f if [ $? -ne 0 ] then exit 1 fi ;; postInstall) dpkg --compare-versions 5.0 lt $VERSION && compile_for_5x ;; remove) errpkg='' for pkg in promethean-fixboot activinspire activrelay activtools activdriver activaid activinspire-32bitdependsfor64bit-lliurex do apt-get remove -y $pkg TEST=$( dpkg-query -s $pkg 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" == 'installed' ];then errpkg="$errpkg $pkg" fi done if [ ${#errpkg} -gt 0 ] then exit 1 fi ;; esac exit 0