From ddd86436f4e3643c04b797f858dab95d5f2e4de9 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 25 Dec 2015 15:00:15 +0000 Subject: fish --- scripts/backport_firmware_install.sh | 21 ++++++++++ scripts/blacklist.sh | 35 ++++++++++++++++ scripts/check_depmod.sh | 78 ++++++++++++++++++++++++++++++++++++ scripts/compress_modules.sh | 21 ++++++++++ scripts/update-initramfs.sh | 62 ++++++++++++++++++++++++++++ 5 files changed, 217 insertions(+) create mode 100755 scripts/backport_firmware_install.sh create mode 100755 scripts/blacklist.sh create mode 100755 scripts/check_depmod.sh create mode 100755 scripts/compress_modules.sh create mode 100755 scripts/update-initramfs.sh (limited to 'scripts') diff --git a/scripts/backport_firmware_install.sh b/scripts/backport_firmware_install.sh new file mode 100755 index 0000000..e4b9fb0 --- /dev/null +++ b/scripts/backport_firmware_install.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ -f /usr/bin/lsb_release ]; then + LSB_RED_ID=$(/usr/bin/lsb_release -i -s) +else + LSB_RED_ID="Unknown" +fi + +case $LSB_RED_ID in +"Ubuntu") + mkdir -p /lib/udev/ /lib/udev/rules.d/ + cp udev/ubuntu/compat_firmware.sh /lib/udev/ + cp udev/50-compat_firmware.rules /lib/udev/rules.d/ + ;; +*) + mkdir -p /lib/udev/ /lib/udev/rules.d/ + cp udev/compat_firmware.sh /lib/udev/ + cp udev/50-compat_firmware.rules /lib/udev/rules.d/ + ;; +esac + diff --git a/scripts/blacklist.sh b/scripts/blacklist.sh new file mode 100755 index 0000000..f941c4a --- /dev/null +++ b/scripts/blacklist.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +BLACKLIST_CONF="/etc/modprobe.d/backports.conf" +BLACKLIST_MAP=".blacklist.map" + +MODULE_DIR=$1 +MODULE_UPDATES=$2 + +if [[ ! -d $MODULE_DIR ]]; then + exit +fi + +if [[ ! -d $MODULE_UPDATES ]]; then + exit +fi + +mkdir -p $(dirname $BLACKLIST_CONF) +rm -f $BLACKLIST_CONF + +echo "# To be used when using backported drivers" > $BLACKLIST_CONF + +for i in $(grep -v ^# $BLACKLIST_MAP | awk '{print $2}'); do + MODULE="${i}.ko" + MODULE_UPDATE="$(grep -v ^# $BLACKLIST_MAP | grep $i | awk '{print $1}' | head -1).ko" + + COUNT=$(find $MODULE_DIR -type f -name ${MODULE} -or -name ${MODULE}.gz | wc -l) + COUNT_REPLACE=$(find $MODULE_UPDATES -type f -name ${MODULE_UPDATE} -or -name ${MODULE_UPDATE}.gz | wc -l) + + if [ $COUNT -ne 0 ]; then + if [ $COUNT_REPLACE -ne 0 ]; then + echo "Blacklisting $MODULE ..." + echo blacklist $i >> $BLACKLIST_CONF + fi + fi +done diff --git a/scripts/check_depmod.sh b/scripts/check_depmod.sh new file mode 100755 index 0000000..6123894 --- /dev/null +++ b/scripts/check_depmod.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Copyright 2009-2013 Luis R. Rodriguez +# +# Ensures your distribution likes to prefer updates/ over the kernel/ +# search updates built-in + +# Seems Mandriva has an $DEPMOD_DIR but it doesn't have any files, +# so lets deal with those distributions. +DEPMOD_CONF="/etc/depmod.conf" +DEPMOD_CONF_TMP="$DEPMOD_CONF.backports.old" +DEPMOD_DIR="/etc/depmod.d/" +BACKPORT_DEPMOD_FILE="backports.conf" +GREP_REGEX_UPDATES="^[[:space:]]*search.*[[:space:]]updates\([[:space:]]\|$\)" +GREP_REGEX_SEARCH="^[[:space:]]*search[[:space:]].\+$" +DEPMOD_CMD="depmod" + +function add_compat_depmod_conf { + echo "NOTE: Your distribution lacks an $DEPMOD_DIR directory with " + echo "updates/ directory being prioritized for modules, we're adding " + echo "one for you." + mkdir -p $DEPMOD_DIR + FIRST_FILE=$(ls $DEPMOD_DIR|head -1) + [ -n "$FIRST_FILE" ] && while [[ $FIRST_FILE < $BACKPORT_DEPMOD_FILE ]]; do + BACKPORT_DEPMOD_FILE="0$BACKPORT_DEPMOD_FILE" + done + echo "search updates" > $DEPMOD_DIR/$BACKPORT_DEPMOD_FILE +} + +function add_global_depmod_conf { + echo "NOTE: Your distribution lacks updates/ directory being" + echo "prioritized for modules, we're adding it to $DEPMOD_CONF." + rm -f $DEPMOD_CONF_TMP + [ -f $DEPMOD_CONF ] && cp -f $DEPMOD_CONF $DEPMOD_CONF_TMP + echo "search updates" > $DEPMOD_CONF + [ -f $DEPMOD_CONF_TMP ] && cat $DEPMOD_CONF_TMP >> $DEPMOD_CONF +} + +function depmod_updates_ok { + echo "depmod will prefer updates/ over kernel/ -- OK!" +} + +function add_depmod_conf { + if [ -f "$DEPMOD_CONF" ]; then + add_global_depmod_conf + else + DEPMOD_VERSION=$($DEPMOD_CMD --version | cut -d" " -f2 | sed "s/\.//") + if [[ $DEPMOD_VERSION -gt 36 ]]; then + add_compat_depmod_conf + else + add_global_depmod_conf + fi + fi +} + +GREP_FILES="" +[ -f $DEPMOD_CONF ] && GREP_FILES="$DEPMOD_CONF" +if [ -d $DEPMOD_DIR ]; then + DEPMOD_FILE_COUNT=$(ls $DEPMOD_DIR | wc -l) + [[ $DEPMOD_FILE_COUNT -gt 0 ]] && GREP_FILES="$GREP_FILES $DEPMOD_DIR/*" +fi + +if [ -n "$GREP_FILES" ]; then + grep -q "$GREP_REGEX_SEARCH" $GREP_FILES + if [[ $? -eq 0 ]]; then + grep -q "$GREP_REGEX_UPDATES" $GREP_FILES + if [[ $? -eq 0 ]]; then + depmod_updates_ok + else + add_depmod_conf + fi + else + depmod_updates_ok + fi +else + depmod_updates_ok +fi + +exit 0 diff --git a/scripts/compress_modules.sh b/scripts/compress_modules.sh new file mode 100755 index 0000000..bbf264f --- /dev/null +++ b/scripts/compress_modules.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +function mod_filename() +{ + which modinfo > /dev/null 2>&1 + if [[ $? -eq 0 ]]; then + MOD_QUERY="modinfo -F filename" + else + MOD_QUERY="modprobe -l" + fi + mod_path="$($MOD_QUERY $1 | tail -1)" + echo $(basename "$mod_path") +} + +if test "$(mod_filename mac80211)" = "mac80211.ko.gz" ; then + for driver in $(find "$1" -type f -name *.ko); do + gzip -9 $driver + done +fi diff --git a/scripts/update-initramfs.sh b/scripts/update-initramfs.sh new file mode 100755 index 0000000..e0d7702 --- /dev/null +++ b/scripts/update-initramfs.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# Copyright 2009-2013 Luis R. Rodriguez +# +# Since we provide ssb, ethernet modules and most importantly +# DRM drivers, people may want to update the initramfs image +# of their distribution. This can also help people who may +# want to wireless-boot their systems. + +KLIB="$1" +ver=$(echo $KLIB | awk -F "/lib/modules/" '{print $2}' | awk -F"/" '{print $1}') +dir=/boot/ + +LSB_RED_ID=$(/usr/bin/lsb_release -i -s &> /dev/null) + +if [[ -z $LSB_RED_ID && -f "/etc/os-release" ]]; then + # Let's try with os-release. Fedora doesn't have + # lsb_release anymore. + LSB_RED_ID=$(sed -n '/^NAME/ s/^NAME=\(.*\)$/\1/p' /etc/os-release) +fi + +case $LSB_RED_ID in +"Ubuntu") + echo "Updating ${LSB_RED_ID}'s initramfs for $ver under $dir ..." + mkinitramfs -o $dir/initrd.img-$ver $ver + echo "Will now run update-grub to ensure grub will find the new initramfs ..." + update-grub + ;; +"Debian") + echo "Updating ${LSB_RED_ID}'s initramfs for $ver under $dir ..." + mkinitramfs -o $dir/initrd.img-$ver $ver + echo "Will now run update-grub to ensure grub will find the new initramfs ..." + update-grub + ;; +"Fedora") + # This adds a -compat-drivers suffixed initramfs with a new grub2 + # entry to not override distribution's default stuff. + INITRAMFS=${dir}initramfs-$ver-compat-drivers.img + KERNEL=${dir}vmlinuz-$ver + GRUB_TITLE="Fedora ($ver) with compat-drivers" + + echo "Updating ${LSB_RED_ID}'s initramfs for $ver under $dir ..." + mkinitrd --force $INITRAMFS $ver + + # If a previous compat-drivers entry for the same kernel exists + # do not add it again. + grep -q "${GRUB_TITLE}" /etc/grub2.cfg &> /dev/null + if [[ "$?" == "1" ]]; then + echo "Will now run grubby to add a new kernel entry ..." + # Add a new kernel entry + grubby --grub2 --copy-default --add-kernel="$KERNEL" --initrd="$INITRAMFS" --title="$GRUB_TITLE" + fi + ;; +*) + echo "Note:" + echo "You may or may not need to update your initramfs, you should if" + echo "any of the modules installed are part of your initramfs. To add" + echo "support for your distribution to do this automatically send a" + echo "patch against \"$(basename $0)\". If your distribution does not" + echo "require this send a patch with the '/usr/bin/lsb_release -i -s'" + echo "($LSB_RED_ID) tag for your distribution to avoid this warning." + ;; +esac -- cgit v1.2.3