From 21ca3cc147d129f04fa0c5ec3db5958caf03cdb8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 13:34:15 -0700 Subject: [PATCH] compat: use a generic install mechanism for bin/get-compat-kernels The script bin/get-compat-kernels used to behave differently depending on the Linux distribution used. Remove this junk given that even on Debian based systems there are "conflicts" being run into when installing all the kernel headers: a higher version of libc is being asked for newer kernels. Dump this stuff and instead use the same mechanism to install the kernel headers for all Linux distributions. This uses ar and tar. If ar is not available warn the user that binutils is required. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 66 ++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index f6a7ef48aa0c..9fa23eb88c0f 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -143,43 +143,32 @@ function get_ubuntu_kernels() { fi done - LSB_RED_ID=$(/usr/bin/lsb_release -i -s) - case $LSB_RED_ID in - "Ubuntu") - # Install with dpkg - sudo dpkg -i *.deb - ;; - *) - # For every other distribution around - - # Create a temporary directory first - TEMP_DIR=`mktemp -d` - - for deb in $(ls linux-*.deb); do - DIR_NAME=$(echo $deb | awk -F"_" '{print $1}') - if [[ ! -d /usr/src/$DIR_NAME ]]; then - echo "Extracting $deb..." - ar p $deb data.tar.gz | sudo tar xz --exclude=usr/share -C $TEMP_DIR - fi - done - - # Move the extracted folders into the system - if [[ -d $TEMP_DIR/lib/modules ]]; then - mv $TEMP_DIR/lib/modules/* /lib/modules - fi - if [[ -d $TEMP_DIR/usr/src ]]; then - # Because of a bug in make < 3.82, mixed implicit and normal - # rules do not cause harm. Since the bug is fixed in the new make - # we have to adjust older kernel's Makefiles to fix the bug. - sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null - - mv $TEMP_DIR/usr/src/* /usr/src + # Create a temporary directory first + TEMP_DIR=`mktemp -d` + + for deb in $(ls linux-*.deb); do + DIR_NAME=$(echo $deb | awk -F"_" '{print $1}') + if [[ ! -d /usr/src/$DIR_NAME ]]; then + echo "Extracting $deb..." + ar p $deb data.tar.gz | sudo tar xz --exclude=usr/share -C $TEMP_DIR fi + done - # Remove the temporary directory - rm -rf $TEMP_DIR - ;; - esac + # Move the extracted folders into the system + if [[ -d $TEMP_DIR/lib/modules ]]; then + mv $TEMP_DIR/lib/modules/* /lib/modules + fi + if [[ -d $TEMP_DIR/usr/src ]]; then + # Because of a bug in make < 3.82, mixed implicit and normal + # rules do not cause harm. Since the bug is fixed in the new make + # we have to adjust older kernel's Makefiles to fix the bug. + sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null + + mv $TEMP_DIR/usr/src/* /usr/src + fi + + # Remove the temporary directory + rm -rf $TEMP_DIR } function usage() { @@ -204,6 +193,13 @@ if [[ $# -eq 1 && $1 = "-i" ]]; then INSTALL_IMAGES="y" fi +which ar 2>&1 > /dev/null +if [[ $? -ne 0 ]]; then + echo -e "${GREEN}ar${NORMAL} is not avilable, typically this is available through a package called binutils" + echo -e "Install binutils and run this script again..." + exit 1 +fi + echo -e "This will download ${YELLOW}21${NORMAL} kernel headers to allow you to" echo -e "cross compile any module over these kernels with ${GREEN}ckmake${NORMAL}." echo -e "The download payload is about ${YELLOW}~220 ${CYAN}MiB${NORMAL}, once uncompressed" -- 2.30.2