Whamcloud - gitweb
LU-2784 build: Provide RPMs build for Xeon Phi(TM) card
authorDmitry Eremin <dmitry.eremin@intel.com>
Wed, 13 Mar 2013 14:03:02 +0000 (18:03 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 24 May 2013 19:37:28 +0000 (15:37 -0400)
Enhance Lustre build to provide RPMs which can be installed on
Xeon Phi(TM) card automatically. This means the binaries
should be compiled by cross compiler and deployed into Xeon
Phi(TM) infrastructure on host to be automatically installed
on card after boot.

To produce Lustre client RPMs for Xeon Phi(TM) card just
execute the following commands:

export PATH=/usr/linux-k1om-4.7/bin:$PATH

sh ./autogen.sh

./configure --with-linux=/opt/intel/mic/src/card/kernel \
    --disable-server --without-o2ib \
    --host=x86_64-k1om-linux --build=x86_64-pc-linux

make rpms

NOTE: You should have "intel-mic-gpl-<version>.x86_64" package
installed and MIC GPL sources unpacked in /opt/intel/mic/src.

and the following RPMs will be produced:

lustre-client-mic-<version>.x86_64.rpm
lustre-client-mic-debuginfo-<version>.x86_64.rpm
lustre-client-mic-modules-<version>.x86_64.rpm
lustre-client-mic-source-<version>.x86_64.rpm
lustre-client-mic-tests-<version>.x86_64.rpm
lustre-client-mic-<version>.src.rpm

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I8d61133614443e2a6a33f5c1b1b097250b11d749
Reviewed-on: http://review.whamcloud.com/5324
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
autoMakefile.am
build/gen_filelist.sh [new file with mode: 0644]
config/lustre-build-linux.m4
config/lustre-build.m4
lustre.spec.in
lustre/autoconf/lustre-core.m4

index 1cc3b48..9b6dcfd 100644 (file)
@@ -107,6 +107,10 @@ EXTRA_DIST = @PACKAGE_TARNAME@.spec                                        \
        build/Makefile                                                  \
        build/Rules.in
 
        build/Makefile                                                  \
        build/Rules.in
 
+if ARCH_MIC
+EXTRA_DIST += build/gen_filelist.sh
+endif
+
 rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
        CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | \
                sed -re 's/--(en|dis)able-tests//'); \
 rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
        CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | \
                sed -re 's/--(en|dis)able-tests//'); \
@@ -120,6 +124,27 @@ rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
                        RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
                fi; \
        fi; \
                        RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
                fi; \
        fi; \
+       if [ -n "@CROSS_PATH@" ]; then \
+               if [[ "X$(BUILD_SERVER)" = Xtrue ]]; then \
+                       echo -e "\n" \
+                       "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"; \
+                       exit 1; \
+               fi; \
+               CROSS_SUFFIX="-mic"; \
+               RPMARGS="$$RPMARGS --define \"post_script build/gen_filelist.sh\""; \
+               RPMARGS="$$RPMARGS --define \"cross_path @CROSS_PATH@\""; \
+               RPMARGS="$$RPMARGS --define \"rootdir %{cross_path}\""; \
+               RPMARGS="$$RPMARGS --define \"_prefix %{cross_path}/usr\""; \
+               RPMARGS="$$RPMARGS --define \"_mandir %{_prefix}/share/man\""; \
+               RPMARGS="$$RPMARGS --define \"_sysconfdir %{cross_path}/etc\""; \
+               RPMARGS="$$RPMARGS --define \"make_args @CROSS_VARS@\""; \
+               if [ -s @LINUX@/../../.ver.build ]; then \
+                       MPSS_VERSION=$$(sed -ne 's/DRIVERS_\(.*\)-.*/\1/p' @LINUX@/../../.ver.build); \
+                       if [ -n "$$MPSS_VERSION" ]; then \
+                               RPMARGS="$$RPMARGS --define \"cross_requires intel-mic-gpl = 2.1.$$MPSS_VERSION\""; \
+                       fi; \
+               fi; \
+       fi; \
        CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
                sed -re 's/--with-release=[^ ][^ ]*//'); \
        RPMARGS="$$RPMARGS --define \"configure_args $$CONFIGURE_ARGS\""; \
        CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | \
                sed -re 's/--with-release=[^ ][^ ]*//'); \
        RPMARGS="$$RPMARGS --define \"configure_args $$CONFIGURE_ARGS\""; \
@@ -127,7 +152,7 @@ rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
                RPMARGS="$$RPMARGS --define \"build_lustre_tests 0\""; \
        fi; \
        if [[ "X$(BUILD_SERVER)" = Xfalse ]]; then \
                RPMARGS="$$RPMARGS --define \"build_lustre_tests 0\""; \
        fi; \
        if [[ "X$(BUILD_SERVER)" = Xfalse ]]; then \
-               RPMARGS="$$RPMARGS --define \"lustre_name lustre-client\""; \
+               RPMARGS="$$RPMARGS --define \"lustre_name lustre-client$$CROSS_SUFFIX\""; \
        fi; \
        if [[ "X$(BUILD_OSD_LDISKFS)" = Xtrue ]]; then \
                RPMARGS="$$RPMARGS --define \"build_lustre_osd_ldiskfs 1\""; \
        fi; \
        if [[ "X$(BUILD_OSD_LDISKFS)" = Xtrue ]]; then \
                RPMARGS="$$RPMARGS --define \"build_lustre_osd_ldiskfs 1\""; \
diff --git a/build/gen_filelist.sh b/build/gen_filelist.sh
new file mode 100644 (file)
index 0000000..b5e5a5c
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# Run this script after a package install and pre uninstall
+usage()
+{
+       echo "Usage: $0 <root_dir> <create|remove>"
+       exit 1
+}
+
+if [ $# -ne 2 ]; then usage; fi
+if [ !  -d $1 ]; then usage; fi
+
+NAME=$(basename "$0" .sh)
+ROOT_DIR="$1"
+FILELIST="$(dirname $ROOT_DIR)/$NAME.filelist"
+case "$2" in
+create)
+       EXCLUDE="\(share\|include\|src\)"
+
+       # Create filelist for Intel(R) Xeon Phi(TM) infrastructure
+       for i in $(rpm -ql $NAME | grep $ROOT_DIR | grep -v $EXCLUDE); do
+               find $ROOT_DIR -path $i -type f -printf "file /%P $(basename $ROOT_DIR)/%P %#m 0 0\n"
+               dir=$(dirname $i)
+               while [ "$dir" != "$ROOT_DIR" ]; do
+                       echo "dir $dir 0755 0 0" | sed -e "s#$ROOT_DIR##"
+                       dir=$(dirname $dir)
+               done
+               # Link scripts for autorun after boot (NOT READY YET)
+               #if [ -n "$(echo $i | grep '/init.d/')" ]; then
+               #       echo "slink /etc/rc3.d/S31$(basename $i) ../init.d/$(basename $i) 0755 0 0"
+               #fi
+       done | sort -u > $FILELIST
+
+       mkdir -p /etc/sysconfig/mic/conf.d
+       echo "Overlay $(dirname $ROOT_DIR) $FILELIST" > /etc/sysconfig/mic/conf.d/$NAME.conf
+       ;;
+remove)
+       rm -f $FILELIST
+       rm -f /etc/sysconfig/mic/conf.d/$NAME.conf
+       ;;
+*)
+       usage
+       ;;
+esac
+exit 0
index b08ae65..59609da 100644 (file)
@@ -70,7 +70,7 @@ fi
 AC_MSG_RESULT([$LINUXRELEASE])
 AC_SUBST(LINUXRELEASE)
 
 AC_MSG_RESULT([$LINUXRELEASE])
 AC_SUBST(LINUXRELEASE)
 
-moduledir='/lib/modules/'$LINUXRELEASE/updates/kernel
+moduledir='$(CROSS_PATH)/lib/modules/$(LINUXRELEASE)/updates/kernel'
 AC_SUBST(moduledir)
 
 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
 AC_SUBST(moduledir)
 
 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
@@ -294,6 +294,7 @@ AC_DEFUN([LB_LINUX_SYMVERFILE],
 AC_DEFUN([LB_LINUX_CROSS],
        [AC_MSG_CHECKING([for cross compilation])
 CROSS_VARS=
 AC_DEFUN([LB_LINUX_CROSS],
        [AC_MSG_CHECKING([for cross compilation])
 CROSS_VARS=
+CROSS_PATH=
 case $target_vendor in
        # The K1OM architecture is an extension of the x86 architecture.
        # So, the $target_arch is x86_64.
 case $target_vendor in
        # The K1OM architecture is an extension of the x86 architecture.
        # So, the $target_arch is x86_64.
@@ -304,7 +305,11 @@ case $target_vendor in
                        AC_MSG_ERROR([Cross compiler not found in PATH.])
                fi
                CROSS_VARS="ARCH=$target_vendor CROSS_COMPILE=x86_64-$target_vendor-linux-"
                        AC_MSG_ERROR([Cross compiler not found in PATH.])
                fi
                CROSS_VARS="ARCH=$target_vendor CROSS_COMPILE=x86_64-$target_vendor-linux-"
+               CROSS_PATH=${CROSS_PATH:=/opt/intel/mic/lustre/device-k1om}
                CCAS=$CC
                CCAS=$CC
+               # need to produce special section for debuginfo extraction
+               LDFLAGS="${LDFLAGS} -Wl,--build-id"
+               EXTRA_KLDFLAGS="${EXTRA_KLDFLAGS} -Wl,--build-id"
                if test x$enable_server = xyes ; then
                        AC_MSG_WARN([Disabling server (not supported for x86_64-$target_vendor-linux).])
                        enable_server='no'
                if test x$enable_server = xyes ; then
                        AC_MSG_WARN([Disabling server (not supported for x86_64-$target_vendor-linux).])
                        enable_server='no'
@@ -315,6 +320,7 @@ case $target_vendor in
                ;;
 esac
 AC_SUBST(CROSS_VARS)
                ;;
 esac
 AC_SUBST(CROSS_VARS)
+AC_SUBST(CROSS_PATH)
 ])
 
 # these are like AC_TRY_COMPILE, but try to build modules against the
 ])
 
 # these are like AC_TRY_COMPILE, but try to build modules against the
index bdc0737..d068937 100644 (file)
@@ -468,11 +468,11 @@ AC_DEFUN([LB_PATH_DEFAULTS],
 [# directories for binaries
 AC_PREFIX_DEFAULT([/usr])
 
 [# directories for binaries
 AC_PREFIX_DEFAULT([/usr])
 
-sysconfdir='/etc'
+sysconfdir='$(CROSS_PATH)/etc'
 AC_SUBST(sysconfdir)
 
 # Directories for documentation and demos.
 AC_SUBST(sysconfdir)
 
 # Directories for documentation and demos.
-docdir='${datadir}/doc/$(PACKAGE)'
+docdir='$(datadir)/doc/$(PACKAGE)'
 AC_SUBST(docdir)
 
 LIBCFS_PATH_DEFAULTS
 AC_SUBST(docdir)
 
 LIBCFS_PATH_DEFAULTS
@@ -539,6 +539,7 @@ AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
 AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
 AM_CONDITIONAL(ARCH_x86, test x$target_cpu = "xx86_64" -o x$target_cpu = "xi686")
 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
 AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
 AM_CONDITIONAL(ARCH_x86, test x$target_cpu = "xx86_64" -o x$target_cpu = "xi686")
+AM_CONDITIONAL(ARCH_MIC, test x$target_cpu = "xx86_64" -a x$target_vendor = "xk1om")
 
 # Sanity check for PCLMULQDQ instruction availability
 # PCLMULQDQ instruction is a new instruction available beginning with
 
 # Sanity check for PCLMULQDQ instruction availability
 # PCLMULQDQ instruction is a new instruction available beginning with
index 98086b8..89d556b 100644 (file)
@@ -43,7 +43,7 @@
 # response from them
 #%%global _use_internal_dependency_generator 0
 
 # response from them
 #%%global _use_internal_dependency_generator 0
 
-%define is_client %(bash -c "if [[ %{lustre_name} = *-client ]]; then echo -n '1'; else echo -n '0'; fi")
+%define is_client %(bash -c "if [[ %{lustre_name} = *-client* ]]; then echo -n '1'; else echo -n '0'; fi")
 # for those uses that don't want the -smp/-bigsmp (or the .arch) on the end
 # of %kversion
 %define krequires %(bash -c "echo %{kversion} | sed -e 's/\.x86_64$//' -e 's/\.i[3456]86$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
 # for those uses that don't want the -smp/-bigsmp (or the .arch) on the end
 # of %kversion
 %define krequires %(bash -c "echo %{kversion} | sed -e 's/\.x86_64$//' -e 's/\.i[3456]86$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
 %define build_lustre_osd_zfs 0
 %endif
 
 %define build_lustre_osd_zfs 0
 %endif
 
+%if %{defined cross_path} && %{defined post_script}
+%define rpm_post_base %(echo $(dirname %{cross_path})/%{lustre_name})
+%endif
+
 Summary: Lustre File System
 Name: %{lustre_name}
 Version: %{version}
 Summary: Lustre File System
 Name: %{lustre_name}
 Version: %{version}
@@ -81,6 +85,9 @@ Userspace tools and files for the Lustre file system.
 
 %package modules
 Summary: Kernel Lustre modules for Linux %{kversion}
 
 %package modules
 Summary: Kernel Lustre modules for Linux %{kversion}
+%if %{defined cross_requires}
+Requires: %{cross_requires}
+%else
 # for SLES11, we need nothing here
 # for SLES10, we need (where %{flavor} is, i.e. smp):
 %if %sles10
 # for SLES11, we need nothing here
 # for SLES10, we need (where %{flavor} is, i.e. smp):
 %if %sles10
@@ -92,6 +99,7 @@ Requires: kernel-%{flavor}
 Requires: kernel = %{krequires}
 %endif
 %endif
 Requires: kernel = %{krequires}
 %endif
 %endif
+%endif
 Group: Development/Kernel
 
 %description modules
 Group: Development/Kernel
 
 %description modules
@@ -224,62 +232,58 @@ fi
 
 # we need to eval "configure" because $CONFIGURE_ARGS could have a quoted
 # string in it which we don't want word splitted by the shell
 
 # we need to eval "configure" because $CONFIGURE_ARGS could have a quoted
 # string in it which we don't want word splitted by the shell
-%define eval_configure %(echo '%configure' | sed -e 's#\./configure#eval ./configure#')
+# also remove (build|host|target) options because they will be specified
+# inside $CONFIGURE_ARGS
+%define eval_configure %(echo '%configure' | sed -e 's#\./configure#eval ./configure#' -e 's/--\\(build\\|host\\|target\\)=[^ ][^ ]* //g')
 
 %eval_configure \
        %{?kdir: --with-linux=%kdir} %{?kobjdir: --with-linux-obj=%kobjdir} \
        $CONFIGURE_ARGS
 
 %eval_configure \
        %{?kdir: --with-linux=%kdir} %{?kobjdir: --with-linux-obj=%kobjdir} \
        $CONFIGURE_ARGS
-make -j $RPM_BUILD_NCPUS -s
+make -j $RPM_BUILD_NCPUS -s %{?make_args}
 
 %install
 make install DESTDIR=$RPM_BUILD_ROOT
 # hack to avoid changing the libsysio code for "make install"
 rm -f $RPM_BUILD_ROOT%{_libdir}/libsysio.a
 # Remove ldiskfs module(s) - they are packaged by the ldiskfs .spec.
 
 %install
 make install DESTDIR=$RPM_BUILD_ROOT
 # hack to avoid changing the libsysio code for "make install"
 rm -f $RPM_BUILD_ROOT%{_libdir}/libsysio.a
 # Remove ldiskfs module(s) - they are packaged by the ldiskfs .spec.
-rm -rf $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates/kernel/fs/lustre-ldiskfs
+rm -rf $RPM_BUILD_ROOT%{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre-ldiskfs
 
 # hack to include the llog_test module in lustre-tests
 llog_base=$RPM_BUILD_DIR/lustre-%{version}/lustre/obdclass/llog_test
 if [ -e ${llog_base}.ko ]; then
 
 # hack to include the llog_test module in lustre-tests
 llog_base=$RPM_BUILD_DIR/lustre-%{version}/lustre/obdclass/llog_test
 if [ -e ${llog_base}.ko ]; then
-  cp ${llog_base}.ko $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates/kernel/fs/lustre
+  cp ${llog_base}.ko $RPM_BUILD_ROOT%{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre
 elif [ -e ${llog_base}.o ]; then
 elif [ -e ${llog_base}.o ]; then
-  cp ${llog_base}.o $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates/kernel/fs/lustre
+  cp ${llog_base}.o $RPM_BUILD_ROOT%{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre
 fi
 
 # The .ha_v2 extension identifies the heartbeat resource agent as using
 # legacy syntax. Install a compatibility symlink to avoid conflicts when
 # newer-style agents are added.
 fi
 
 # The .ha_v2 extension identifies the heartbeat resource agent as using
 # legacy syntax. Install a compatibility symlink to avoid conflicts when
 # newer-style agents are added.
-ln -s Lustre.ha_v2 $RPM_BUILD_ROOT/etc/ha.d/resource.d/Lustre
+ln -s Lustre.ha_v2 $RPM_BUILD_ROOT%{_sysconfdir}/ha.d/resource.d/Lustre
 
 # Create the pristine source directory.
 cd $RPM_BUILD_DIR/lustre-%{version}
 
 # Create the pristine source directory.
 cd $RPM_BUILD_DIR/lustre-%{version}
-mkdir -p $RPM_BUILD_ROOT/usr/src
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/src
 rm -f lustre-source
 rm -f lustre-source
-ln -s $RPM_BUILD_ROOT/usr/src lustre-source
+ln -s $RPM_BUILD_ROOT%{_prefix}/src lustre-source
 make distdir distdir=lustre-source/lustre-%{version}
 chmod -R go-w lustre-source/lustre-%{version}
 # fc18 needs 'x' permission for library files
 find $RPM_BUILD_ROOT -name '*.so' | xargs chmod +x
 
 cat >lustre.files <<EOF
 make distdir distdir=lustre-source/lustre-%{version}
 chmod -R go-w lustre-source/lustre-%{version}
 # fc18 needs 'x' permission for library files
 find $RPM_BUILD_ROOT -name '*.so' | xargs chmod +x
 
 cat >lustre.files <<EOF
-%attr(-, root, root) /sbin/mount.lustre
-%attr(-, root, root) /usr/sbin/*
-%attr(-, root, root) /usr/bin/*
-
-%attr(-, root, root) /usr/share/lustre
-
+%attr(-, root, root) %{?rootdir}/sbin/mount.lustre
+%attr(-, root, root) %{_sbindir}/*
+%attr(-, root, root) %{_bindir}/*
 %attr(-, root, root) %{_libdir}/libptlctl.a
 %attr(-, root, root) %{_libdir}/liblustreapi.a
 %attr(-, root, root) %{_libdir}/liblustreapi.so
 %attr(-, root, root) %{_libdir}/libptlctl.a
 %attr(-, root, root) %{_libdir}/liblustreapi.a
 %attr(-, root, root) %{_libdir}/liblustreapi.so
-%attr(-, root, root) /usr/include/lustre
-%attr(-, root, root) /usr/include/libcfs
-
 %attr(-, root, root) %{_mandir}/man?/*
 %attr(-, root, root) %{_mandir}/man?/*
-
+%attr(-, root, root) %{_datadir}/lustre
+%attr(-, root, root) %{_includedir}/lustre
+%attr(-, root, root) %{_includedir}/libcfs
 %attr(-, root, root) %{_libexecdir}/lustre/lc_common
 %attr(-, root, root) %{_libexecdir}/lustre/lc_common
-
 %attr(-, root, root) %{_sysconfdir}/udev/rules.d/99-lustre.rules
 %attr(-, root, root) %{_sysconfdir}/udev/rules.d/99-lustre.rules
-
 %attr(-, root, root) %{_sysconfdir}/init.d/lnet
 %attr(-, root, root) %{_sysconfdir}/init.d/lustre
 %attr(-, root, root) %config(noreplace) %{_sysconfdir}/ldev.conf
 %attr(-, root, root) %{_sysconfdir}/init.d/lnet
 %attr(-, root, root) %{_sysconfdir}/init.d/lustre
 %attr(-, root, root) %config(noreplace) %{_sysconfdir}/ldev.conf
@@ -309,39 +313,63 @@ fi
 
 # Have universal lustre headers
 if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/lustre/lustre_idl.h ] ; then
 
 # Have universal lustre headers
 if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/lustre/lustre_idl.h ] ; then
-  echo '%attr(-, root, root) /usr/include/linux/lustre_user.h' >>lustre.files
+  echo '%attr(-, root, root) %{_includedir}/linux/lustre_user.h' >>lustre.files
 else
 else
-  echo '%attr(-, root, root) /usr/include/linux/lustre_idl.h' >>lustre.files
+  echo '%attr(-, root, root) %{_includedir}/linux/lustre_idl.h' >>lustre.files
 fi
 
 if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/linux/lustre_types.h ] ; then
 fi
 
 if [ -f $RPM_BUILD_DIR/lustre-%{version}/lustre/include/linux/lustre_types.h ] ; then
-  echo '%attr(-, root, root) /usr/include/linux/lustre_types.h' >>lustre.files
+  echo '%attr(-, root, root) %{_includedir}/linux/lustre_types.h' >>lustre.files
 fi
 
 %if %{build_lustre_tests}
 echo '%attr(-, root, root) %{_libdir}/lustre/tests/*' >lustre-tests.files
 fi
 
 %if %{build_lustre_tests}
 echo '%attr(-, root, root) %{_libdir}/lustre/tests/*' >lustre-tests.files
-echo '%attr(-, root, root) /lib/modules/%{kversion}/updates/kernel/fs/lustre/llog_test.*' >>lustre-tests.files
+echo '%attr(-, root, root) %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/llog_test.*' >>lustre-tests.files
 if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/liblustre/tests ] ; then
   echo '%attr(-, root, root) %{_libdir}/lustre/liblustre/tests/*' >>lustre-tests.files
 fi
 %endif
 
 if [ -d $RPM_BUILD_ROOT%{_libdir}/lustre/liblustre/tests ] ; then
   echo '%attr(-, root, root) %{_libdir}/lustre/liblustre/tests/*' >>lustre-tests.files
 fi
 %endif
 
+%if %{defined cross_path}
+%if %{defined rpm_post_base}
+POST_SCRIPT=$RPM_BUILD_DIR/lustre-%{version}/%{post_script}
+if [ -f $POST_SCRIPT ]; then
+       cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}.sh
+       echo '%attr(0555, root, root) %{rpm_post_base}.sh' >>lustre.files
+       cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-modules.sh
+%if %{build_lustre_osd_ldiskfs}
+       cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-osd-ldiskfs.sh
+%endif
+%if %{build_lustre_osd_zfs}
+       cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-osd-zfs.sh
+%endif
+%if %{build_lustre_tests}
+       cp -f $POST_SCRIPT $RPM_BUILD_ROOT/%{rpm_post_base}-tests.sh
+       echo '%attr(0555, root, root) %{rpm_post_base}-tests.sh' >>lustre-tests.files
+%endif
+fi
+%endif
+%else
 # mark modules executable for find-debuginfo.sh
 # mark modules executable for find-debuginfo.sh
-find $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates -name "*.ko" -type f | \
+find $RPM_BUILD_ROOT%{?rootdir}/lib/modules/%{kversion}/updates -name "*.ko" -type f | \
        xargs --no-run-if-empty chmod u+x
        xargs --no-run-if-empty chmod u+x
+%endif
 
 %files -f lustre.files
 
 %files modules
 
 %files -f lustre.files
 
 %files modules
-%attr(-, root, root) /lib/modules/%{kversion}/updates/*
+%attr(-, root, root) %{?rootdir}/lib/modules/%{kversion}/updates/*
 %if %{build_lustre_tests}
 %if %{build_lustre_tests}
-%exclude /lib/modules/%{kversion}/updates/kernel/fs/lustre/llog_test.ko
+%exclude %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/llog_test.ko
 %endif
 %if %{build_lustre_osd_ldiskfs}
 %endif
 %if %{build_lustre_osd_ldiskfs}
-%exclude /lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_ldiskfs.ko
+%exclude %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_ldiskfs.ko
 %endif
 %if %{build_lustre_osd_zfs}
 %endif
 %if %{build_lustre_osd_zfs}
-%exclude /lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_zfs.ko
+%exclude %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_zfs.ko
+%endif
+%if %{defined rpm_post_base}
+%attr(0555, root, root) %{rpm_post_base}-modules.sh
 %endif
 %attr(-, root, root) %doc COPYING
 %attr(-, root, root) %doc ChangeLog-lustre
 %endif
 %attr(-, root, root) %doc COPYING
 %attr(-, root, root) %doc ChangeLog-lustre
@@ -349,16 +377,22 @@ find $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates -name "*.ko" -type f | \
 
 %if %{build_lustre_osd_ldiskfs}
 %files osd-ldiskfs
 
 %if %{build_lustre_osd_ldiskfs}
 %files osd-ldiskfs
-%attr(-, root, root) /lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_ldiskfs.ko
+%attr(-, root, root) %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_ldiskfs.ko
+%if %{defined rpm_post_base}
+%attr(0555, root, root) %{rpm_post_base}-osd-ldiskfs.sh
+%endif
 %endif
 
 %if %{build_lustre_osd_zfs}
 %files osd-zfs
 %endif
 
 %if %{build_lustre_osd_zfs}
 %files osd-zfs
-%attr(-, root, root) /lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_zfs.ko
+%attr(-, root, root) %{?rootdir}/lib/modules/%{kversion}/updates/kernel/fs/lustre/osd_zfs.ko
+%if %{defined rpm_post_base}
+%attr(0555, root, root) %{rpm_post_base}-osd-zfs.sh
+%endif
 %endif
 
 %files source
 %endif
 
 %files source
-%attr(-, root, root) /usr/src/lustre-%{version}
+%attr(-, root, root) %{_prefix}/src/lustre-%{version}
 
 # uncomment these lines to enable deps packages
 # %files deps-sles
 
 # uncomment these lines to enable deps packages
 # %files deps-sles
@@ -368,7 +402,24 @@ find $RPM_BUILD_ROOT/lib/modules/%{kversion}/updates -name "*.ko" -type f | \
 %files tests -f lustre-tests.files
 %endif
 
 %files tests -f lustre-tests.files
 %endif
 
+%if %{defined rpm_post_base}
+%post
+if [ -x %{rpm_post_base}.sh ]; then
+       %{rpm_post_base}.sh %{cross_path} create
+fi
+
+%preun
+if [ -x %{rpm_post_base}.sh ]; then
+       %{rpm_post_base}.sh %{cross_path} remove
+fi
+%endif
+
 %post modules
 %post modules
+%if %{defined rpm_post_base}
+if [ -x %{rpm_post_base}-modules.sh ]; then
+       %{rpm_post_base}-modules.sh %{cross_path} create
+fi
+%else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
@@ -402,9 +453,15 @@ if sysctl kernel.unsupported >/dev/null 2>&1 &&
 
      into /etc/modprobe.d/unsupported_modules"
 fi
 
      into /etc/modprobe.d/unsupported_modules"
 fi
+%endif
 
 %if %{build_lustre_osd_ldiskfs}
 %post osd-ldiskfs
 
 %if %{build_lustre_osd_ldiskfs}
 %post osd-ldiskfs
+%if %{defined rpm_post_base}
+if [ -x %{rpm_post_base}-osd-ldiskfs.sh ]; then
+       %{rpm_post_base}-osd-ldiskfs.sh %{cross_path} create
+fi
+%else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
@@ -439,9 +496,15 @@ if sysctl kernel.unsupported >/dev/null 2>&1 &&
      into /etc/modprobe.d/unsupported_modules"
 fi
 %endif
      into /etc/modprobe.d/unsupported_modules"
 fi
 %endif
+%endif
 
 %if %{build_lustre_osd_zfs}
 %post osd-zfs
 
 %if %{build_lustre_osd_zfs}
 %post osd-zfs
+%if %{defined rpm_post_base}
+if [ -x %{rpm_post_base}-osd-zfs.sh ]; then
+       %{rpm_post_base}-osd-zfs.sh %{cross_path} create
+fi
+%else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
@@ -476,23 +539,43 @@ if sysctl kernel.unsupported >/dev/null 2>&1 &&
      into /etc/modprobe.d/unsupported_modules"
 fi
 %endif
      into /etc/modprobe.d/unsupported_modules"
 fi
 %endif
+%endif
 
 %preun modules
 
 %preun modules
+%if %{defined rpm_post_base}
+if [ -x %{rpm_post_base}-modules.sh ]; then
+       %{rpm_post_base}-modules.sh %{cross_path} remove
+fi
+%else
 MODULES_RPM_NAME=$(rpm -q %{name}-modules | grep "%{version}-%{release}")
 rpm -ql $MODULES_RPM_NAME | grep '\.ko$' > /var/run/%{name}-modules || true
 MODULES_RPM_NAME=$(rpm -q %{name}-modules | grep "%{version}-%{release}")
 rpm -ql $MODULES_RPM_NAME | grep '\.ko$' > /var/run/%{name}-modules || true
+%endif
 
 %if %{build_lustre_osd_ldiskfs}
 %preun osd-ldiskfs
 
 %if %{build_lustre_osd_ldiskfs}
 %preun osd-ldiskfs
+%if %{defined rpm_post_base}
+if [ -x %{rpm_post_base}-osd-ldiskfs.sh ]; then
+       %{rpm_post_base}-osd-ldiskfs.sh %{cross_path} remove
+fi
+%else
 OSD_LDISKFS_RPM_NAME=$(rpm -q %{name}-osd-ldiskfs | grep "%{version}-%{release}")
 rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-ldiskfs || true
 %endif
 OSD_LDISKFS_RPM_NAME=$(rpm -q %{name}-osd-ldiskfs | grep "%{version}-%{release}")
 rpm -ql $OSD_LDISKFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-ldiskfs || true
 %endif
+%endif
 
 %if %{build_lustre_osd_zfs}
 %preun osd-zfs
 
 %if %{build_lustre_osd_zfs}
 %preun osd-zfs
+%if %{defined rpm_post_base}
+if [ -x %{rpm_post_base}-osd-zfs.sh ]; then
+       %{rpm_post_base}-osd-zfs.sh %{cross_path} remove
+fi
+%else
 OSD_ZFS_RPM_NAME=$(rpm -q %{name}-osd-zfs | grep "%{version}-%{release}")
 rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-zfs || true
 %endif
 OSD_ZFS_RPM_NAME=$(rpm -q %{name}-osd-zfs | grep "%{version}-%{release}")
 rpm -ql $OSD_ZFS_RPM_NAME | grep '\.ko$' > /var/run/%{name}-osd-zfs || true
 %endif
+%endif
 
 
+%if %{undefined cross_path}
 %postun modules
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 %postun modules
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
@@ -556,9 +639,20 @@ if [ -x /sbin/weak-modules ]; then
 fi
 rm /var/run/%{name}-osd-zfs
 %endif
 fi
 rm /var/run/%{name}-osd-zfs
 %endif
+%endif
 
 %if %{build_lustre_tests}
 %post tests
 
 %if %{build_lustre_tests}
 %post tests
+%if %{defined rpm_post_base}
+if [ -x %{rpm_post_base}-tests.sh ]; then
+       %{rpm_post_base}-tests.sh %{cross_path} create
+fi
+
+%preun tests
+if [ -x %{rpm_post_base}-tests.sh ]; then
+       %{rpm_post_base}-tests.sh %{cross_path} remove
+fi
+%else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
 if [ -f /boot/System.map-%{kversion} ]; then
        depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
 else
@@ -572,6 +666,7 @@ else
        depmod -ae %{kversion} || exit 0
 fi
 %endif
        depmod -ae %{kversion} || exit 0
 fi
 %endif
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %clean
 rm -rf $RPM_BUILD_ROOT
index 7ac2b22..8f92859 100644 (file)
@@ -20,7 +20,7 @@ LUSTRE="$PWD/lustre"
 AC_SUBST(LUSTRE)
 
 # mount.lustre
 AC_SUBST(LUSTRE)
 
 # mount.lustre
-rootsbindir='/sbin'
+rootsbindir='$(CROSS_PATH)/sbin'
 AC_SUBST(rootsbindir)
 
 demodir='$(docdir)/demo'
 AC_SUBST(rootsbindir)
 
 demodir='$(docdir)/demo'