openafs/kernel-source.build-modules.sh
Christof Hanke 8e6465d313 Accepting request 874301 from home:mgerstner:branches:filesystems
- kernel-source.build-modules.sh: choose safe CWD while executing the build to
  prevent files being created in unsafe locations. Use new SUSE naming
  convention and rely on /etc/os-release, since /etc/SuSE-release no longer
  exists.

OBS-URL: https://build.opensuse.org/request/show/874301
OBS-URL: https://build.opensuse.org/package/show/filesystems/openafs?expand=0&rev=74
2021-02-22 14:22:09 +00:00

65 lines
1.8 KiB
Bash

#!/bin/bash
if [ $# != 1 ]; then
echo building a openafs-kernel module for the running kernel
echo Need one of: build build_debug install
exit 1
fi
rootdir=`cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd`
if [ -z "$rootdir" ]; then
echo "failed to determine the dirname of this script"
exit 1
fi
cd "$rootdir"
LOGFILE=libafs_tree/build.log
kernel_flavour=`uname -r | awk -F- '{print $NF}'`
kernel_version=`uname -r | sed "s/-$kernel_flavour//"`
arch=`uname -m`
suse_flavour=`cat /etc/os-release | grep PRETTY_NAME | awk -F '=' '{print $2}'`
suse_version=`cat /etc/os-release | grep VERSION_ID | awk -F '=' '{print $2}'`
echo This SUSE is version $suse_version of flavour $suse_flavour
echo you are running the kernel \"$kernel_version\" of flavour \"$kernel_flavour\" on \"$arch\"
echo all output is saved into $LOGFILE
if [ $1 == "build_debug" ]; then
DEBUG_OPT="--enable-debug-kernel"
fi
if [ $1 == "build" -o $1 == "build_debug" ]; then
cd libafs_tree
echo calling configure...
./configure --with-linux-kernel-headers=/usr/src/linux/ --with-linux-kernel-build=/usr/src/linux-obj/$arch/$kernel_flavour $DEBUG_OPT > build.log 2>&1
if [ $? != 0 ]; then
echo configure failed! See $LOGFILE for details
exit $?
fi
echo calling make
make >> build.log 2>&1
if [ $? != 0 ]; then
echo make failed! See $LOGFILE for details
exit $?
fi
echo
echo build sucessfull!
echo Now run $0 install to install the kernel-modules
exit 0
fi
if [ $1 == "install" ]; then
module_files="afspag.ko libafs.ko"
build_dir=libafs_tree/src/libafs/MODLOAD-$kernel_version-$kernel_flavour-MP/
install_dir=/lib/modules/$kernel_version-$kernel_flavour
echo installing kernel-modules into
for mod in $module_files; do
cp -v $build_dir/$mod $install_dir/$mod
done
/sbin/depmod -a
fi