From 23434f3408063164c863a7d56c661c41fa2e779f Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Wed, 27 Jan 2016 01:05:21 +0100 Subject: [PATCH] LU-7679 build: strengthen lustre-dkms during on-target build This patch modifies internal scripts to strengthen lustre[-client]-dkms package vs issues ([spl,zfs]-dkms not built, configure errors, ...) that could be encountered during on-target DKMS build step. Signed-off-by: Bruno Faccini Change-Id: I2dc8c91ff5874228dde0bc7995e45a6dcc6973d4 Reviewed-on: http://review.whamcloud.com/18167 Reviewed-by: Dmitry Eremin Tested-by: Jenkins Reviewed-by: Michael MacDonald Tested-by: Maloo Reviewed-by: Oleg Drokin --- autoMakefile.am | 4 ++- lustre-dkms.spec.in | 84 +++++++++++++++++++------------------------ lustre-dkms_post-build.sh | 50 ++++++++++++++++++++++++++ lustre-dkms_pre-build.sh | 79 ++++++++++++++++++++++++++++++++++++++++ lustre/scripts/dkms.mkconf.in | 83 +++++++----------------------------------- 5 files changed, 181 insertions(+), 119 deletions(-) create mode 100755 lustre-dkms_post-build.sh create mode 100755 lustre-dkms_pre-build.sh diff --git a/autoMakefile.am b/autoMakefile.am index 1a44bf2..64d4c4c 100644 --- a/autoMakefile.am +++ b/autoMakefile.am @@ -102,7 +102,9 @@ EXTRA_DIST = @PACKAGE_TARNAME@.spec \ build/Rules.in \ build/gen_filelist.sh \ config.h.in \ - undef.h + undef.h \ + lustre-dkms_pre-build.sh \ + lustre-dkms_post-build.sh rpm-local: @(if test -z "$(RPMBUILD)"; then \ diff --git a/lustre-dkms.spec.in b/lustre-dkms.spec.in index 967d89c..36ce678 100644 --- a/lustre-dkms.spec.in +++ b/lustre-dkms.spec.in @@ -51,58 +51,45 @@ This package contains the dkms Lustre kernel modules. %build cat << EOF > dkms.conf # Embryonic lustre-dkms dkms.conf to allow for on-target accurate and full -# version re-create during first dkms add stage. +# version re-create during first run of Lustre DKMS module build step. PACKAGE_NAME=%{module} PACKAGE_VERSION=%{version} -POST_ADD="lustre-dkms_post-add.sh \$module \$module_version \$kernelver \ +PACKAGE_CONFIG="/etc/sysconfig/lustre" +PRE_BUILD="lustre-dkms_pre-build.sh \$module \$module_version \$kernelver \ + \$kernel_source_dir \$arch \$source_tree \$dkms_tree" +POST_BUILD="lustre-dkms_post-build.sh \$module \$module_version \$kernelver \ \$kernel_source_dir \$arch \$source_tree \$dkms_tree" -# at least one DEST_MODULE_LOCATION[] element, along with an install -# path made of either "extra" or "updates" subdir, are required during -# dkms.conf validity check of "dkms add" step. -DEST_MODULE_LOCATION[${#DEST_MODULE_LOCATION[@]}]="/extra/lnet/" EOF - -cat << EOF > lustre-dkms_post-add.sh -#!/bin/bash -# \$1 : \$module -# \$2 : \$module_version -# \$3 : \$kernelver -# \$4 : \$kernel_source_dir -# \$5 : \$arch -# \$6 : \$source_tree -# \$7 : \$dkms_tree - -if [ \$1 = "lustre-client" ] ; then - SERVER="--disable-server" -else - SPL_VERSION=\$(dkms status -m spl -k \$3/\$5 | awk -F', ' '{print \$2; exit 0}' | sed 's/: added\$//') - ZFS_VERSION=\$(dkms status -m zfs -k \$3/\$5 | awk -F', ' '{print \$2; exit 0}' | sed 's/: added\$//') - - SERVER="--enable-server --disable-ldiskfs --with-linux=\$4 --with-linux-obj=\$4 \\ - --with-spl=\$6/spl-\${SPL_VERSION} \\ - --with-spl-obj=\$7/spl/\${SPL_VERSION}/\$3/\$5 \\ - --with-zfs=\$6/zfs-\${ZFS_VERSION} \\ - --with-zfs-obj=\$7/zfs/\${ZFS_VERSION}/\$3/\$5" -fi - -rpm -qa | grep krb5-devel >/dev/null -if [ \$? == 0 ] ; then - GSS="--enable-gss" -else - GSS="--disable-gss" -fi - -# run a configure pass to clean "--enable-dist" only effect and also to -# ensure local/on-target environment to be taken into account -./configure --enable-modules --disable-iokit --disable-snmp --disable-doc \\ - --disable-utils --disable-tests --disable-maintainer-mode \\ - \$GSS \$SERVER \\ - --disable-manpages --disable-dlc -# re-create dkms.conf based on this -lustre/scripts/dkms.mkconf -n \$1 -v \$2 -f ./dkms.conf +%if %{with servers} +cat << EOF >> dkms.conf +BUILD_DEPENDS[0]="zfs" +EOF +%endif +cat << EOF >> dkms.conf +AUTOINSTALL="yes" +REMAKE_INITRD="no" +MAKE[0]="make" +# just have to set STRIP[0], it will become the new default. +STRIP[0]="\$( + [[ -r \${PACKAGE_CONFIG} ]] \\ + && source \${PACKAGE_CONFIG} \\ + && shopt -q -s extglob \\ + && [[ \${LUSTRE_DKMS_DISABLE_STRIP,,} == @(y|yes) ]] \\ + && echo -n no +)" + +# at least one module's set of BUILT_MODULE_NAME[]/BUILT_MODULE_LOCATION[] +# elements, along with an install path made of either "extra" or "updates" +# subdir in its DEST_MODULE_LOCATION[] element, are required to fake during +# dkms.conf validity checks of "dkms [add,build]" steps. +# Final/full correct BUILT_MODULE_NAME[]/BUILT_MODULE_LOCATION[]/ +# DEST_MODULE_LOCATION[] sets of values for all modules will be fixed during +# on-target post-configure run of dkms.mkconf as part of build step. +# it must be for a module shared by both lustre[-client]-dkms packages. +BUILT_MODULE_NAME[\${#BUILT_MODULE_NAME[@]}]="lustre" +BUILT_MODULE_LOCATION[\${#BUILT_MODULE_LOCATION[@]}]="lustre/llite/" +DEST_MODULE_LOCATION[\${#DEST_MODULE_LOCATION[@]}]="/extra/lustre/" EOF - -chmod 755 lustre-dkms_post-add.sh sed -i 's/BUILDID[[:print:]]*/BUILDID = %{buildid}/' META sed -i 's/PRISTINE[[:print:]]*/PRISTINE = 1/' META @@ -147,6 +134,9 @@ dkms remove -m %{module} -v %{version} --all --rpm_safe_upgrade exit 0 %changelog +* Sat Jan 23 2016 Bruno Faccini + - detect and handle cases where [spl,zfs]-dkms packages are not built + - also handle on-target configure issues * Wed Oct 7 2015 Bruno Faccini - adapted for Lustre Client DKMS creation - allow for on-target reconfig to prevent static deps requires diff --git a/lustre-dkms_post-build.sh b/lustre-dkms_post-build.sh new file mode 100755 index 0000000..bfff1a5 --- /dev/null +++ b/lustre-dkms_post-build.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# $1 : $module +# $2 : $module_version +# $3 : $kernelver +# $4 : $kernel_source_dir +# $5 : $arch +# $6 : $source_tree +# $7 : $dkms_tree +# +# This script ensure that ALL Lustre kernel modules that have been built +# during DKMS build step of lustre[-client]-dkms module will be moved in +# DKMS vault/repository, and this before the build directory content will be +# trashed. +# This is required because dkms.conf file is only sourced at the very +# beginning of the DKMS build step when its content has to be on-target +# customized during pre_build script. This can lead to incomplete list +# of built Lustre kernel modules then to be saved for next DKMS install step. + +# Use this place to also save config.log that has been generated during +# pre_build. +# $7/$1/$2/$3/$5/log repository should have already been created to save +# make.log and $kernel_config +mkdir -p "$7/$1/$2/$3/$5/log" +mv -f "$7/$1/$2/build/config.log" "$7/$1/$2/$3/$5/log/config.log" 2>/dev/null + +# read last dkms.conf version that has just been customized during pre_build +source $6/$1-$2/dkms.conf + +# Make sure all the modules built successfully +for ((count=0; count < ${#BUILT_MODULE_NAME[@]}; count++)); do + # Lustre supported kernels are >= 2.5, so don't need to check for old .o + # module suffix + [[ -e ${BUILT_MODULE_LOCATION[$count]}${BUILT_MODULE_NAME[$count]}.ko ]] && continue + echo "Build of ${BUILT_MODULE_NAME[$count]}.ko failed for: $3 ($5)" \ + "Consult logs in $7/$1/$2/$3/$5/log/ for more information." +done + +# Strip modules ? +for ((count=0; count < ${#BUILT_MODULE_NAME[@]}; count++)); do + [[ ${STRIP[$count]} = '' ]] && STRIP[$count]=${STRIP[0]:-yes} + [[ ${STRIP[$count]} != no ]] && strip -g "$7/$1/$2/build/${BUILT_MODULE_LOCATION[$count]}${BUILT_MODULE_NAME[$count]}.ko" + + # Save a copy of the new module in save area that should have been created in previous build steps + mkdir -p "$7/$1/$2/$3/$5/module" >/dev/null + # if DEST_MODULE_NAME[] is different than BUILD_MODULE_NAME[], need to use it as the module name in save area + # this is not presently the case for none of the Lustre kernel modules. + cp -f "$7/$1/$2/build/${BUILT_MODULE_LOCATION[$count]}${BUILT_MODULE_NAME[$count]}.ko" \ + "$7/$1/$2/$3/$5/module/${BUILT_MODULE_NAME[$count]}.ko" >/dev/null +done + diff --git a/lustre-dkms_pre-build.sh b/lustre-dkms_pre-build.sh new file mode 100755 index 0000000..c7b5a1c --- /dev/null +++ b/lustre-dkms_pre-build.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# $1 : $module +# $2 : $module_version +# $3 : $kernelver +# $4 : $kernel_source_dir +# $5 : $arch +# $6 : $source_tree +# $7 : $dkms_tree + +if [ $1 = "lustre-client" ] ; then + SERVER="--disable-server" + KERNEL_STUFF="" +else + SPL_VERSION=$(dkms status -m spl -k $3 -a $5 | awk -F', ' '{print $2; exit 0}' | grep -v ': added$') + if [ -z $SPL_VERSION ] ; then + echo "spl-dkms package must already be installed and built under DKMS control" + exit 1 + fi + ZFS_VERSION=$(dkms status -m zfs -k $3 -a $5 | awk -F', ' '{print $2; exit 0}' | grep -v ': added$') + if [ -z $ZFS_VERSION ] ; then + echo "zfs-dkms package must already be installed and built under DKMS control" + exit 1 + fi + + SERVER="--enable-server --disable-ldiskfs --with-linux=$4 --with-linux-obj=$4 \ + --with-spl=$6/spl-${SPL_VERSION} \ + --with-spl-obj=$7/spl/${SPL_VERSION}/$3/$5 \ + --with-zfs=$6/zfs-${ZFS_VERSION} \ + --with-zfs-obj=$7/zfs/${ZFS_VERSION}/$3/$5" + + KERNEL_STUFF="--with-linux=$4 --with-linux-obj=$4" +fi + +PACKAGE_CONFIG="/etc/sysconfig/lustre" +DKMS_CONFIG_OPTS=$( + [[ -r ${PACKAGE_CONFIG} ]] \ + && source ${PACKAGE_CONFIG} \ + && shopt -q -s extglob \ + && \ + { + if [[ ${LUSTRE_DKMS_DISABLE_CDEBUG,,} == @(y|yes) ]] + then + echo --disable-libcfs-cdebug + fi + if [[ ${LUSTRE_DKMS_DISABLE_TRACE,,} == @(y|yes) ]] + then + echo --disable-libcfs-trace + fi + if [[ ${LUSTRE_DKMS_DISABLE_ASSERT,,} == @(y|yes) ]] + then + echo --disable-libcfs-assert + fi + } + ) + +rpm -qa | grep krb5-devel >/dev/null +if [ $? == 0 ] ; then + GSS="--enable-gss" +else + GSS="--disable-gss" +fi + +# run a configure pass to clean "--enable-dist" only effect and also to +# ensure local/on-target environment to be taken into account for +# dkms.mkconf script customizations and before next build/MAKE step +./configure --prefix=/usr --enable-modules --disable-iokit --disable-snmp \ + --disable-doc --disable-utils --disable-tests --disable-maintainer-mode \ + $KERNEL_STUFF $GSS $SERVER $DKMS_CONFIG_OPTS \ + --disable-manpages --disable-dlc + +if [ $? != 0 ] ; then + echo "configure error, check $7/$1/$2/build/config.log" + exit 1 +fi + +# now re-create dkms.conf based on configure result, to set accurate Lustre +# modules names that will be built and their future install locations, for +# next DKMS module install step +lustre/scripts/dkms.mkconf -n $1 -v $2 -f $6/$1-$2/dkms.conf diff --git a/lustre/scripts/dkms.mkconf.in b/lustre/scripts/dkms.mkconf.in index c0de823..c209969 100644 --- a/lustre/scripts/dkms.mkconf.in +++ b/lustre/scripts/dkms.mkconf.in @@ -2,96 +2,37 @@ PROG=$0 -pkgcfg=/etc/sysconfig/lustre - -while getopts "n:v:c:f:" opt; do +while getopts "n:v:f:" opt; do case $opt in n) pkgname=$OPTARG ;; v) pkgver=$OPTARG ;; - c) pkgcfg=$OPTARG ;; f) filename=$OPTARG ;; esac done if [ -z "${pkgname}" -o -z "${pkgver}" -o -z "${filename}" ]; then - echo "Usage: $PROG -n -v -c -f " + echo "Usage: $PROG -n -v -f " exit 1 fi rpm -qa | grep krb5-devel >/dev/null if [ $? == 0 ] ; then - GSS="--enable-gss" + GSS="yes" else - GSS="--disable-gss" + GSS="no" fi cat >${filename} <>${filename} <>${filename} <>${filename} <>${filename} <>${filename} <>${filename} <>${filename} <