From 25c93758d6b1136d268fe3fcc1c4979c17463c0b Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" Date: Tue, 26 Mar 2013 09:31:22 -0700 Subject: [PATCH] LU-1199 build: Clean out the build directory Clean up the build directory. Move in the direction of reserving "build/" for the special-purpose Makefile that lives there. Eventually we could rewrite the autoconf tests to eliminate that Makfile, and the build directory could disappear altogether (after finding homes for anything else that is left). The autoconf m4 file move into a top level "config" directory. Most other things that have moved are put in the new "contrib" top-level directory. For instance, "contrib/lbuild" contains all of the lbuild-related files, and "contrib/git-hooks" contains the git hooks for lustre developers. Most of the moved files were unchanged, however the lbuild scripts needed some tweaking to deal with the new location. Because of the way that Intel's build farm and git hooks expect to find certain files in fixed locations I have had to leave a few symlinks in place that point to the new locations. Change-Id: I04dc529d4f4060b892e1e4eaa8613bbc3337c414 Signed-off-by: Christopher J. Morrone Reviewed-on: http://review.whamcloud.com/5035 Reviewed-by: Brian J. Murrell Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- .gitignore | 5 - autoMakefile.am | 15 +- autogen.sh | 4 +- build/Makefile | 7 - build/autoMakefile.am | 2 - build/autoconf/.gitignore | 1 - build/commit-msg | 293 +-- build/lbuild | 2080 +------------------- build/prepare-commit-msg | 35 +- config/.gitignore | 6 + {build/autoconf => config}/Makefile.am | 0 {build/autoconf => config}/lustre-build-darwin.m4 | 0 {build/autoconf => config}/lustre-build-ldiskfs.m4 | 0 {build/autoconf => config}/lustre-build-linux.m4 | 0 {build/autoconf => config}/lustre-build-zfs.m4 | 0 {build/autoconf => config}/lustre-build.m4 | 4 + configure.ac | 3 + contrib/.gitignore | 1 + contrib/Makefile.am | 2 + contrib/README | 8 + contrib/git-hooks/commit-msg | 292 +++ contrib/git-hooks/prepare-commit-msg | 34 + {build => contrib/git-hooks/tests}/commit.badcid | 0 {build => contrib/git-hooks/tests}/commit.bademail | 0 {build => contrib/git-hooks/tests}/commit.badname | 0 {build => contrib/git-hooks/tests}/commit.badsign | 0 {build => contrib/git-hooks/tests}/commit.dupcid | 0 {build => contrib/git-hooks/tests}/commit.nobody | 0 {build => contrib/git-hooks/tests}/commit.nocmp | 0 {build => contrib/git-hooks/tests}/commit.nojira | 0 {build => contrib/git-hooks/tests}/commit.nosign | 0 {build => contrib/git-hooks/tests}/commit.nosum | 0 {build => contrib/git-hooks/tests}/commit.ok_bugid | 0 {build => contrib/git-hooks/tests}/commit.ok_chmod | 0 {build => contrib/git-hooks/tests}/commit.ok_cid | 0 .../git-hooks/tests}/commit.ok_deleted | 0 {build => contrib/git-hooks/tests}/commit.ok_diff | 0 .../git-hooks/tests}/commit.ok_diffinside | 0 .../git-hooks/tests}/commit.ok_dupsign | 0 .../git-hooks/tests}/commit.ok_innocuous | 0 {build => contrib/git-hooks/tests}/commit.ok_nocid | 0 .../git-hooks/tests}/commit.ok_params | 0 .../git-hooks/tests}/commit.ok_signoff | 0 .../git-hooks/tests}/test-commit-msg.sh | 2 +- contrib/lbuild/Makefile.am | 5 + {build => contrib/lbuild}/exit_traps.sh | 0 {build => contrib/lbuild}/find_linux_rpms | 0 {build => contrib/lbuild}/funcs.sh | 0 contrib/lbuild/lbuild | 2059 +++++++++++++++++++ {build => contrib/lbuild}/lbuild-fc | 2 +- {build => contrib/lbuild}/lbuild-fc11 | 2 +- {build => contrib/lbuild}/lbuild-fc12 | 2 +- {build => contrib/lbuild}/lbuild-fc15 | 2 +- {build => contrib/lbuild}/lbuild-oel5 | 2 +- {build => contrib/lbuild}/lbuild-rhel | 0 {build => contrib/lbuild}/lbuild-rhel5 | 2 +- {build => contrib/lbuild}/lbuild-rhel6 | 2 +- {build => contrib/lbuild}/lbuild-sles | 0 {build => contrib/lbuild}/lbuild-sles10 | 2 +- {build => contrib/lbuild}/lbuild-sles11 | 2 +- {build => contrib}/nn-final-symbol-list.txt | 0 {build => contrib/patches}/mptlinux.spec.patch | 0 .../patches/ofed/01-play-nice-with-RHEL5.ed | 0 {build => contrib}/quiltrc | 0 {build => contrib}/rdac_spec | 0 contrib/scripts/Makefile.am | 1 + {build => contrib/scripts}/checkpatch.pl | 0 {build => contrib/scripts}/checkstack.pl | 0 {build => contrib/scripts}/clearpatches.sh | 0 {build => contrib/scripts}/confirmpatches.sh | 0 {build => contrib/scripts}/libcfs_cleanup.sed | 0 {build => contrib/scripts}/nn-check.py | 0 {build => contrib/scripts}/update_oldconfig | 0 {build => contrib/scripts}/updatecw.sh | 0 74 files changed, 2434 insertions(+), 2443 deletions(-) delete mode 100644 build/autoconf/.gitignore mode change 100755 => 120000 build/commit-msg mode change 100755 => 120000 build/lbuild mode change 100755 => 120000 build/prepare-commit-msg create mode 100644 config/.gitignore rename {build/autoconf => config}/Makefile.am (100%) rename {build/autoconf => config}/lustre-build-darwin.m4 (100%) rename {build/autoconf => config}/lustre-build-ldiskfs.m4 (100%) rename {build/autoconf => config}/lustre-build-linux.m4 (100%) rename {build/autoconf => config}/lustre-build-zfs.m4 (100%) rename {build/autoconf => config}/lustre-build.m4 (99%) create mode 100644 contrib/.gitignore create mode 100644 contrib/Makefile.am create mode 100644 contrib/README create mode 100755 contrib/git-hooks/commit-msg create mode 100755 contrib/git-hooks/prepare-commit-msg rename {build => contrib/git-hooks/tests}/commit.badcid (100%) rename {build => contrib/git-hooks/tests}/commit.bademail (100%) rename {build => contrib/git-hooks/tests}/commit.badname (100%) rename {build => contrib/git-hooks/tests}/commit.badsign (100%) rename {build => contrib/git-hooks/tests}/commit.dupcid (100%) rename {build => contrib/git-hooks/tests}/commit.nobody (100%) rename {build => contrib/git-hooks/tests}/commit.nocmp (100%) rename {build => contrib/git-hooks/tests}/commit.nojira (100%) rename {build => contrib/git-hooks/tests}/commit.nosign (100%) rename {build => contrib/git-hooks/tests}/commit.nosum (100%) rename {build => contrib/git-hooks/tests}/commit.ok_bugid (100%) rename {build => contrib/git-hooks/tests}/commit.ok_chmod (100%) rename {build => contrib/git-hooks/tests}/commit.ok_cid (100%) rename {build => contrib/git-hooks/tests}/commit.ok_deleted (100%) rename {build => contrib/git-hooks/tests}/commit.ok_diff (100%) rename {build => contrib/git-hooks/tests}/commit.ok_diffinside (100%) rename {build => contrib/git-hooks/tests}/commit.ok_dupsign (100%) rename {build => contrib/git-hooks/tests}/commit.ok_innocuous (100%) rename {build => contrib/git-hooks/tests}/commit.ok_nocid (100%) rename {build => contrib/git-hooks/tests}/commit.ok_params (100%) rename {build => contrib/git-hooks/tests}/commit.ok_signoff (100%) rename {build => contrib/git-hooks/tests}/test-commit-msg.sh (93%) create mode 100644 contrib/lbuild/Makefile.am rename {build => contrib/lbuild}/exit_traps.sh (100%) rename {build => contrib/lbuild}/find_linux_rpms (100%) rename {build => contrib/lbuild}/funcs.sh (100%) create mode 100755 contrib/lbuild/lbuild rename {build => contrib/lbuild}/lbuild-fc (93%) rename {build => contrib/lbuild}/lbuild-fc11 (94%) rename {build => contrib/lbuild}/lbuild-fc12 (92%) rename {build => contrib/lbuild}/lbuild-fc15 (84%) rename {build => contrib/lbuild}/lbuild-oel5 (89%) rename {build => contrib/lbuild}/lbuild-rhel (100%) rename {build => contrib/lbuild}/lbuild-rhel5 (99%) rename {build => contrib/lbuild}/lbuild-rhel6 (98%) rename {build => contrib/lbuild}/lbuild-sles (100%) rename {build => contrib/lbuild}/lbuild-sles10 (99%) rename {build => contrib/lbuild}/lbuild-sles11 (99%) rename {build => contrib}/nn-final-symbol-list.txt (100%) rename {build => contrib/patches}/mptlinux.spec.patch (100%) rename {build => contrib}/patches/ofed/01-play-nice-with-RHEL5.ed (100%) rename {build => contrib}/quiltrc (100%) rename {build => contrib}/rdac_spec (100%) create mode 100644 contrib/scripts/Makefile.am rename {build => contrib/scripts}/checkpatch.pl (100%) rename {build => contrib/scripts}/checkstack.pl (100%) rename {build => contrib/scripts}/clearpatches.sh (100%) rename {build => contrib/scripts}/confirmpatches.sh (100%) rename {build => contrib/scripts}/libcfs_cleanup.sed (100%) rename {build => contrib/scripts}/nn-check.py (100%) rename {build => contrib/scripts}/update_oldconfig (100%) rename {build => contrib/scripts}/updatecw.sh (100%) diff --git a/.gitignore b/.gitignore index 83ff49a..ebcc0b5 100644 --- a/.gitignore +++ b/.gitignore @@ -57,16 +57,11 @@ TAGS /COMMIT_EDITMSG.* /compile /config.cache -/config.guess /config.h /config.h.in -/config.sub -/depcomp /INSTALL -/install-sh /lustre.spec /lustre*.tar.gz -/missing /mkinstalldirs /Module.markers /Module.symvers diff --git a/autoMakefile.am b/autoMakefile.am index 8a259bc..79bcd65 100644 --- a/autoMakefile.am +++ b/autoMakefile.am @@ -1,5 +1,5 @@ SUBDIRS := @LDISKFS_SUBDIR@ @SPL_SUBDIR@ @ZFS_SUBDIR@ . @LIBSYSIO_SUBDIR@ @SNMP_SUBDIR@ @LUSTREIOKIT_SUBDIR@ @LIBCFS_SUBDIR@ lnet lustre -DIST_SUBDIRS := @LDISKFS_DIST_SUBDIR@ @SNMP_DIST_SUBDIR@ libsysio lustre-iokit @LIBCFS_SUBDIR@ lnet lustre +DIST_SUBDIRS := @LDISKFS_DIST_SUBDIR@ @SNMP_DIST_SUBDIR@ libsysio lustre-iokit @LIBCFS_SUBDIR@ lnet lustre config contrib SOURCES_SUBDIRS := @LIBCFS_SUBDIR@ lnet lustre RPM_SUBDIRS := @LDISKFS_SUBDIR@ @LUSTREIOKIT_SUBDIR@ MODULE_SYMVERS_DEPS = module-symvers @@ -104,15 +104,8 @@ dist-hook: module-dist-hook EXTRA_DIST = @PACKAGE_TARNAME@.spec \ - build/Makefile build/lbuild* \ - build/Rules.in \ - build/update_oldconfig \ - build/autoconf/lustre-build-linux.m4 \ - build/autoconf/lustre-build-darwin.m4 \ - build/autoconf/lustre-build-ldiskfs.m4 \ - build/autoconf/lustre-build.m4 build/rdac_spec \ - build/mptlinux.spec.patch build/patches \ - build/funcs.sh build/find_linux_rpms build/exit_traps.sh + build/Makefile \ + build/Rules.in rpms-real: @PACKAGE_TARNAME@.spec dist Makefile CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | \ @@ -253,7 +246,7 @@ CSTKO=/tmp/checkstack.orig checkstack: [ -f ${CSTK} -a ! -s ${CSTKO} ] && mv -f ${CSTK} ${CSTKO} || true { for MOD in $$(find . -name "*.ko"); do \ - objdump -d $$MOD | perl build/checkstack.pl; \ + objdump -d $$MOD | perl contrib/scripts/checkstack.pl; \ done } | grep -v " bug " | sort -nr | uniq > ${CSTK} [ -f ${CSTKO} ] && ! diff -u ${CSTKO} ${CSTK} || head -30 ${CSTK} diff --git a/autogen.sh b/autogen.sh index 3a40a5e..5bd10be 100644 --- a/autogen.sh +++ b/autogen.sh @@ -8,7 +8,7 @@ for HOOK in commit-msg prepare-commit-msg; do done echo "Checking for a complete tree..." -REQUIRED_DIRS="build libcfs lnet lustre" +REQUIRED_DIRS="libcfs lnet lustre" OPTIONAL_DIRS="snmp portals" CONFIGURE_DIRS="libsysio lustre-iokit ldiskfs" @@ -43,7 +43,7 @@ run_cmd() echo } -run_cmd "aclocal $ACLOCAL_FLAGS" +run_cmd "aclocal -I $PWD/config $ACLOCAL_FLAGS" run_cmd "autoheader" run_cmd "automake -a -c" run_cmd autoconf diff --git a/build/Makefile b/build/Makefile index da0cda4..d00981f 100644 --- a/build/Makefile +++ b/build/Makefile @@ -46,10 +46,3 @@ endif # PATCHLEVEL echoarch: echo $(ARCH) >$(ARCHFILE) - -TESTS := $(wildcard commit.*) -check-commit: - SHELL="$(SHELL)" $(SHELL) test-commit-msg.sh $(TESTS) - -check: check-commit -.PHONY: check-commit diff --git a/build/autoMakefile.am b/build/autoMakefile.am index a858868..5863e26 100644 --- a/build/autoMakefile.am +++ b/build/autoMakefile.am @@ -3,5 +3,3 @@ MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ # Override the default distclean, which removes Makefile distclean: distclean-recursive @true - -SUBDIRS = autoconf diff --git a/build/autoconf/.gitignore b/build/autoconf/.gitignore deleted file mode 100644 index 10a7e8d..0000000 --- a/build/autoconf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/Makefile.in diff --git a/build/commit-msg b/build/commit-msg deleted file mode 100755 index e0803ea..0000000 --- a/build/commit-msg +++ /dev/null @@ -1,292 +0,0 @@ -#!/bin/bash -# -# A hook script to check the commit log message to ensure that it has -# a well-formed commit summary and body, a valid Signed-off-by: line, -# and a Gerrit Change-Id: line (added automatically if missing). -# -# Called by git-commit with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# Should be installed as .git/hooks/commit-msg. -# - -init() { - set -a - readonly ORIGINAL="$1" - readonly REVISED="$(mktemp "$ORIGINAL.XXXXXX")" - readonly SAVE="$(basename $ORIGINAL).$(date +%Y%m%d.%H%M%S)" - readonly SIGNOFF="Signed-off-by:" - readonly CHANGEID="Change-Id:" - readonly TESTPARAMS="Test-Parameters:" - readonly INNOCUOUS=$(echo \ - Acked-by \ - Tested-by \ - Reported-by \ - Reviewed-by \ - CC \ - | tr ' ' '|') - readonly WIDTH_SUM=62 - readonly WIDTH_REG=70 - readonly JIRA_FMT_A="^[A-Z]\{2,5\}-[0-9]\{1,5\} [-a-z0-9]\{2,11\}: " - readonly JIRA_FMT_B="^[A-Z]\{2,5\}-[0-9]\{1,5\} " - - # Identify a name followed by an email address. - # - readonly EMAILPAT=$'[ \t]*[^<> ]* [^<>]* <[^@ \t>]+@[a-zA-Z0-9.-]+\.[a-z]+>' - - HAS_ERROR=false - HAS_SUMMARY=false - HAS_LAST_BLANK=false - HAS_BODY=false - HAS_SIGNOFF=false - HAS_CHANGEID=false - - IS_WRAPPING_UP=false - - LINE="" - NUM=0 - set +a -} - -# die: commit-msg fatal error: script error or empty input message -# All output redirected to stderr. -# -die() { - echo "commit-msg fatal error: $*" - test -f "$REVISED" && rm -f "$REVISED" - exit 1 -} 1>&2 - -# Called when doing the final "wrap up" clause because we've found -# one of the tagged lines that belongs in the final section. -# -function ck_wrapup() { - $IS_WRAPPING_UP && return - - $HAS_LAST_BLANK || error "blank line must preceed signoff section" - $HAS_SUMMARY || error "missing commit summary line." - $HAS_BODY || error "missing commit description." - - HAS_LAST_BLANK=false - IS_WRAPPING_UP=true -} - -function do_signoff() { - ck_wrapup - # Signed-off-by: First Last - local txt=$(echo "${LINE#*: }" | grep -E "${EMAILPAT}") - if (( ${#txt} == 0 )); then - error "$SIGNOFF line requires name and email address" - else - HAS_SIGNOFF=true # require at least one - fi -} - -function do_changeid() { - ck_wrapup - $HAS_CHANGEID && error "multiple $CHANGEID lines are not allowed" - - # Change-Id: I1234567890123456789012345678901234567890 - # capital "I" plus 40 hex digits - # - local txt=$(echo "$LINE" | grep "^$CHANGEID I[0-9a-fA-F]\{40\}\$") - (( ${#txt} > 0 )) || - error "has invalid $CHANGEID line for Gerrit tracking" - - HAS_CHANGEID=true -} - -# All "innocuous" lines specify a person and email address -# -function do_innocuous() { - ck_wrapup - local txt=$(echo "${LINE#*: }" | grep -E "${EMAILPAT}") - (( ${#txt} == 0 )) && error "invalid name and address" -} - -function do_default_line() { - $IS_WRAPPING_UP && { - error "invalid signoff section line" - return - } - if (( NUM == 1 )); then - HAS_JIRA_COMPONENT=$(echo "$LINE" | grep "$JIRA_FMT_A") - - if (( ${#HAS_JIRA_COMPONENT} == 0 )); then - HAS_JIRA=$(echo "$LINE" | grep "$JIRA_FMT_B") - if (( ${#HAS_JIRA} > 0 )); then - error "has no component in summary." - else - error "missing JIRA ticket number." - fi - elif (( ${#LINE} > WIDTH_SUM )); then - error "summary longer than $WIDTH_SUM columns." - else - HAS_SUMMARY=true - fi - - elif (( ${#LINE} > WIDTH_REG )); then - error "has line longer than $WIDTH_REG columns." - elif ! $HAS_BODY && ! $HAS_LAST_BLANK; then - error "has no blank line after summary." - else - HAS_BODY=true - fi - HAS_LAST_BLANK=false -} - -# Add a new unique Change-Id -# -new_changeid() { - local NEWID=$({ - git var GIT_AUTHOR_IDENT - git var GIT_COMMITTER_IDENT - git write-tree - git rev-parse HEAD 2>/dev/null - grep -v "^$SIGNOFF" "$ORIGINAL" | git stripspace -s - } | git hash-object --stdin) - (( ${#NEWID} > 0 )) || - die "git hash-object failed for $CHANGEID:" - - echo "$CHANGEID I$NEWID" -} - -# A commit message error was encountered. -# All output redirected to stderr. -# -error() { - (( ${#LINE} > 0 )) && echo "line $NUM: $LINE" - echo "error: commit message $*" | fmt - HAS_ERROR=true -} 1>&2 - -usage() { - exec 1>&2 - cat <<- EOF - - See http://wiki.whamcloud.com/display/PUB/Commit+Comments - for full details. An example valid commit comment is: - - LU-nnn component: short description of change under 64 columns - - The "component:" should be a lower-case single-word subsystem of the - Lustre code that best encompasses the change being made. Examples of - components include modules like: llite, lov, lmv, osc, mdc, ldlm, lnet, - ptlrpc, mds, oss, osd, ldiskfs, libcfs, socklnd, o2iblnd; functional - subsystems like: recovery, quota, grant; and auxilliary areas like: - build, tests, docs. This list is not exhaustive, but is a guideline. - - The commit comment should contain a detailed explanation of the change - being made. This can be as long as you'd like. Please give details - of what problem was solved (including error messages or problems that - were seen), a good high-level description of how it was solved, and - which parts of the code were changed (including important functions - that were changed, if this is useful to understand the patch, and - for easier searching). Wrap lines at/under $WIDTH_REG columns. - - Finish the comment with a blank line and a blank-line-free - sign off section: - - $SIGNOFF Your Real Name - $CHANGEID Ixxxx(added automatically if missing)xxxx - - The "$CHANGEID" line should only be there when updating a previous - commit/submission. Copy the one from the original commit. - - The "sign off section" may also include several other tag lines: - $(for T in $(tr '|' ' ' <<< "$INNOCUOUS"); do \ - echo " $T: Some Person "; \ - done) - $TESTPARAMS optional additional test parameters - {Organization}-bug-id: associated external change identifier - EOF - - mv "$ORIGINAL" "$SAVE" && - echo "$0: saved original commit comment to $SAVE" 1>&2 -} - -init ${1+"$@"} -exec 3< "$ORIGINAL" 4> "$REVISED" || exit 1 - -while IFS= read -u3 LINE; do - ((NUM += 1)) - case "$LINE" in - $SIGNOFF* ) do_signoff ;; - $CHANGEID* ) do_changeid ;; - $TESTPARAMS* ) ck_wrapup ;; - - "") - HAS_LAST_BLANK=true - $IS_WRAPPING_UP && continue - ;; - - \#*) - continue ## ignore and suppress comments - ;; - - "diff --git a/"* ) - # Beginning of uncommented diffstat from "commit -v". If - # there are diff and index lines, skip the rest of the input: - # diff --git a/build/commit-msg b/build/commit-msg - # index 80a3442..acb4c50 100755 - # deleted file mode 100644 - # old mode 100644 - # If a "diff --git" line is not followed by one of these - # lines, do the default line processing on both lines. - # - IFS= read -u3 INDEX || break - ((NUM += 1)) - case "$INDEX" in - "index "[0-9a-fA-F]*) break ;; - "deleted file mode "*) break ;; - "old mode "*) break ;; - "new file mode "*) break ;; - esac - LINE=${LINE}$'\n'${INDEX} - do_default_line - ;; - - *) - if [[ "$LINE" =~ ^($INNOCUOUS): ]]; then - do_innocuous - elif [[ "$LINE" =~ ^[A-Za-z0-9_-]+-bug-id: ]]; then - ck_wrapup - else - # Allow arbitrary external bug identifiers for tracking. - # I can't seem to find a pattern for the "case" that - # checks for "*-bug-id", so this is checked here. - do_default_line - fi - ;; - esac - - echo "$LINE" >&4 -done - -(( NUM <= 0 )) && die "empty commit message" - -unset LINE -$HAS_SIGNOFF || error "missing valid $SIGNOFF: line." - -if $HAS_ERROR; then - exec 3<&- 4>&- - usage - rm "$REVISED" - exit 1 -fi - -$HAS_CHANGEID || new_changeid >&4 -exec 3<&- 4>&- - -mv "$REVISED" "$ORIGINAL" - -## Local Variables: -## Mode: shell-script -## sh-basic-offset: 8 -## sh-indent-after-do: 8 -## sh-indentation: 8 -## sh-indent-for-case-label: 0 -## sh-indent-for-case-alt: 8 -## End: diff --git a/build/commit-msg b/build/commit-msg new file mode 120000 index 0000000..37bc6b0 --- /dev/null +++ b/build/commit-msg @@ -0,0 +1 @@ +../contrib/git-hooks/commit-msg \ No newline at end of file diff --git a/build/lbuild b/build/lbuild deleted file mode 100755 index faf56bc..0000000 --- a/build/lbuild +++ /dev/null @@ -1,2079 +0,0 @@ -#!/bin/bash - -# vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4: - -# this is an alternative FD for stdout, to be used especially when we are -# taking stdout from a function as it's return value. i.e. foo=$(bar) -# this is a workaround until a version of bash where we can put xtrace -# on a specific FD -exec 3>&1; STDOUT=3 - -#set -x -xtrace="+x" -if [[ $SHELLOPTS = *xtrace* ]]; then - xtrace="-x" -fi -shopt -s extdebug - -# include the exit_traps library -. ${0%/lbuild}/exit_traps.sh -. ${0%/lbuild}/funcs.sh - -# our children should die when we do -push_exit_trap "kill -INT -$$ || true" kill_children - -# increment this if you have made a change that should force a new kernel -# to build built -#BUILD_GEN=1 -#BUILD_GEN=2 # bz19952: remove -lustre tag from kernel RPM names -#BUILD_GEN=3 # bz19975: enable the building of src.rpms by default -#BUILD_GEN=4 # bz22281: use the git hash in the kernel extra version -BUILD_GEN=5 # TT-107: don't cache the BUILD dir - -TOPDIR=$PWD - -# CVSROOT is inherited from the environment -KERNELDIR= -LINUX= -LUSTRE= -RELEASE=false -# XXX - some recent hacking has pretty much neutered this option. -# search through this file (and lbuild.old_school -- but that will -# be going away soon) for "-bb" and see how many places -# simply don't account for this option -DO_SRC=true -DOWNLOAD=true -TAG= -CANONICAL_TARGET= -TARGET= -TARGET_ARCH="$(uname -m)" -# change default behavior to only build for the current arch -TARGET_ARCHS="$TARGET_ARCH" -TARGET_ARCHS_ALL="$TARGET_ARCH" -[ "$TARGET_ARCH" = "i686" ] && TARGET_ARCHS_ALL="i686 i586 i386" -CONFIGURE_FLAGS= -EXTERNAL_PATCHES= -EXTRA_VERSION= -STAGEDIR= -TMPDIR=${TMPDIR:-"/var/tmp"} -TIMESTAMP= -# this is a dir to try reuse old kernel RPMs in (although, it seems to be -# unused in any real manner -REUSERPM= -# this is the dir that should be used to store reuse products -REUSEBUILD= -# should cached products be used or force rebuilding? -USE_BUILD_CACHE=true -# what does this do exactly? does it imply no kernel build? -NORPM=false -IOKITRPM=true -LDISKFSRPM=true -OSDLDISKFSRPM=true -OSDZFSRPM=false -SKIPLDISKFSRPM="v1_4_* b1_4" -SMPTYPES="smp bigsmp default ''" -PATCHLESS=false -XEN=false -LINUXOBJ= -DISTRO= -KERNELTREE= -# default to not adding -lustre- into the kernel RPM package names -KERNEL_LUSTRE_NAMING=false -# default not use kabi check. -USE_KABI=false - -# patchless build -KERNELRPMSBASE= -RPMSMPTYPE= - -# from target file -SERIES= -BASE_ARCHS= -BIGMEM_ARCHS= -BOOT_ARCHS= -JENSEN_ARCHS= -SMP_ARCHS= -BIGSMP_ARCHS= -PSERIES64_ARCHS= -UP_ARCHS= - -# not in the target file any more -CONFIG= - -# build the lustre-tests rpm? -LUSTRE_TESTS=true - -DATE=$(date) - -USE_DATESTAMP=1 -RPMBUILD= - -OLD_SCHOOL=false - -export CC=${CC:-gcc} - -# Readlink is not present on some older distributions: emulate it. -readlink() { - local path=$1 ll - - if [ -L "$path" ]; then - ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" && - echo "${ll/* -> }" - else - return 1 - fi -} - -usage() { - cat <] - - -d CVSROOT - Specifies the CVS Root to use when pulling files from CVS. The - environment variable \$CVSROOT is used if this option is not - present. - - --external-patches=EXTERNAL_PATCHES - Directory similar to lustre/lustre/kernel_patches/ that lbuild should - look for seres and config files in before looking in the lustre - tree. - - --extraversion=EXTRAVERSION - Text to use for the rpm release and kernel extraversion. - - --timestamp=TIMESTAMP - Date of building lustre in format YYYYMMDDhhmmss - - --reuserpm=DIR - Try to reuse old kernel RPMs from DIR - - --reusebuild=DIR - Try to reuse old kernel builds from DIR - - --kernelrpm=DIR - Path to distro kernel RPM collection - - --ccache - Use ccache - - --norpm - Do not build RPMs (compile only mode) - - --patchless - Build lustre client only - - --distro=DISTRO - Which distro using. Autodetect by default - - --kerneldir=KERNELDIR - Directory containing Linux source tarballs referenced by target - files. - - --kerneltree=KERNELTREE - Directory containing dirs with Linux source tarballs referenced by target - files. Dir names in format kernel version ('2.6.9', etc.) - - --linux=LINUX --with-linux=LINUX - Directory of Linux kernel sources. When this option is used, only - Lustre modules and userspace are built. - - --lustre=LUSTRE - Path to an existing lustre source tarball to use instead of - pulling from CVS. - - --nodownload - Do not try to download a kernel from downloads.lustre.org - - --nosrc - Do not build a .src.rpm, a full kernel patch, or a patched kernel - tarball. - - --ldiskfs - Do ldiskfs RPM. Now true by default - - --noiokit - Do not build lustre-iokit RPM. Now true by default - - --publish - Unused. - - --release - Specifies that the files generated do not include timestamps, and - that this is an official release. - - --src - Build a .src.rpm, a full kernel patch, and a patched kernel tarball. - - --stage=DIR - Directory used to stage packages for release. RPMs will be placed - more or less in DIR/-, and the tarball will be - placed in DIR. - - --tag=TAG - A CVS branch/tag name to build from when pulling from CVS. - - --target=TARGET - The name of the target to build. The available targets are listed - below. - - --target-archs=TARGET_ARCHS - A (space delimited) list of architectures to build. By default, - all of the archs supported by the TARGET will be built, in - addition to a .src.rpm. This option can limit those, for machines - that can only build certain archs or if you only want a certain - arch built (for testing, or a one-off kernel). - - Also note that by using a non-"base" arch (eg, i386) only kernels - will be built - there will be no lustre-lite-utils package. - - --disable-datestamp - Prevents the datestamp flag (-D) from being passed to cvs for - checkouts. This is a workaround for a problem encountered when - using lbuild with tinderbox. - - --xen - Builds a Xen domX kernel. - - --set-value - Set's a variable to a given value. - -EOF - -# list_targets - - fatal "$1" "$2" -} - -# canonicalize a relative path to a file -canon_filepath() { - local PATH="$1" - - if [ ! -f "$PATH" ]; then - return 1 - fi - - local FILE=${PATH##*/} - local DIR=${PATH%/*} - - echo $(canon_path "$DIR")/$FILE - return 0 -} - -# canonicalize a relative path to a dir -canon_path() { - local PATH="$1" - - if [ ! -d "$PATH" ]; then - return 1 - fi - - pushd "$PATH" >/dev/null || return 1 - local CANONPATH=$PWD - popd >/dev/null - - echo "$CANONPATH" - return 0 -} - -check_options() { - - if [ "$LUSTRE" ]; then - [ -r "$LUSTRE" ] || \ - usage 1 "Could not find Lustre source tarball '$LUSTRE'." - else - [ "$CVSROOT" ] || \ - usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre." - [ "$TAG" ] || \ - usage 1 "A branch/tag name must be specified with --tag when not building from a tarball." - fi - - [ -z "$DISTRO" ] && DISTRO=$(autodetect_distro) - - if [ -z "$LINUX" ]; then - [ "$KERNELDIR" -o "$KERNELTREE" ] || \ - usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree." - - [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \ - usage 1 "$KERNELDIR and $KERNELTREE are not a directory." - - if ! $RELEASE; then - [ "$TAG" ] || \ - usage 1 "When building a snapshot, a tag name must be used." - fi - - [ "$TARGET" ] || TARGET=$(autodetect_target "$DISTRO") -# TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target" -# [ -r "$TARGET_FILE" ] || \ -# usage 1 "Target '$TARGET' was not found." - fi - - case $TARGET in - 2.6-rhel6) - CANONICAL_TARGET="rhel6" - ;; - 2.6-rhel5) - CANONICAL_TARGET="rhel5" - ;; - 2.6-rhel4) - CANONICAL_TARGET="rhel-2.6" - ;; - 2.6-suse) - CANONICAL_TARGET="sles-2.6" - ;; - 2.6-sles10) - CANONICAL_TARGET="sles10-2.6" - ;; - 2.6-sles11 | 3.0-sles11) - CANONICAL_TARGET="sles11" - ;; - 2.6-oel5) - CANONICAL_TARGET="oel5" - ;; - hp_pnnl-2.4) - CANONICAL_TARGET="hp-pnnl-2.4" - ;; - 2.6-vanilla \ - | suse-2.4.21-2 \ - | rh-2.4 \ - | rhel-2.4 \ - | sles-2.4 \ - | 2.6-patchless) - CANONICAL_TARGET="$TARGET" - ;; - esac - - local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g) - [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S") - local timestamplength="${#TIMESTAMP}" - if [ $timestamplength -eq 12 ]; then - TIMESTAMP="${TIMESTAMP}00" - elif [ $timestamplength -ne 14 ]; then - TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S") - fi - - RPMBUILD=$(which rpmbuild 2>/dev/null | head -1) - if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then - RPMBUILD=$(which rpm 2>/dev/null | head -1) - if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then - usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)." - fi - fi - - if [ -n "$CCACHE" ]; then - which "$DISTCC" &>/dev/null && export DISTCC RPM_BUILD_NCPUS - - if which "$CCACHE" &>/dev/null; then - local ccache=$(which "$CCACHE") - local bindir="$TOPDIR/bin" - - if [ ! -d $bindir ]; then - mkdir -p $bindir || fatal 1 "error trying to create $bindir" - else - rm ${bindir}/* > /dev/null 2>&1 || true - fi - ln -s "$ccache" ${bindir}/ccache - ln -s "$ccache" ${bindir}/cc - ln -s "$ccache" ${bindir}/$CC - export PATH=$bindir:$PATH - export CCACHE && export CC="ccache $CC" - # zero the cache so we can see how effective we are being with it - echo -n "ccache " - ccache -z - - # get some ccache stats when we are done - push_exit_trap '[ -n "$CCACHE" ] && ccache -s' "ccache_summary" - # should remove the ccache trap if lbuild is interrupted - trap 'echo "Received an INT TERM or HUP signal, terminating."; delete_exit_trap "ccache_summary"; exit 1' INT TERM HUP - fi - fi - - return 0 - -} - -# compare two versions $1 and $2. if $1 < $2, return 0 otherwise return 1. -compare_version () { - [[ $1 == $2 ]] && return 1 - local IFS=. - local i val1=($1) val2=($2) - - # padding zero to val1 if it needs - for ((i=${#val1[@]}; i<${#val2[@]}; i++)); do - val1[i]=0 - done - for ((i=0; i<${#val1[@]}; i++)); do - [[ -z ${val2[i]} ]] && return 1 - - if [[ ${val1[i]} < ${val2[i]} ]]; then - return 0 - elif [[ ${val1[i]} > ${val2[i]} ]]; then - return 1 - fi - done -} - -uniqify() { - - echo $(echo "$*" | xargs -n 1 | sort -u) - -} - -fetch_url() { - local url="$1" - local target="$2" - - local rc=0 - if which wget >/dev/null 2>&1; then - if ! wget -nv "$url" -O "$target"; then - rc=${PIPESTATUS[0]} - fi - elif which curl >/dev/null 2>&1; then - if ! curl -L -s -o "$target" "$url"; then - rc=${PIPESTATUS[0]} - fi - else - fatal 1 "Could not find either wget or curl to fetch URLs." - fi - - return $rc - -} - -download_srpm() { - local target=$1 - local srpm=$2 - local force="${3:-false}" - - if $force || [ ! -r "$KERNELDIR/$srpm" ] || - [ ! -s "$KERNELDIR/$srpm" ]; then - if $DOWNLOAD; then - local location="http://downloads.lustre.org/public/kernels/$target/old" - # get the location from a distro specific method if it exists - if type -p kernel_srpm_location; then - location=$(kernel_srpm_location) - fi - echo "Downloading $location/$srpm..." - if ! fetch_url "$location/$srpm" "$KERNELDIR/$srpm" 2>&1 || - [ ! -s "$KERNELDIR/$srpm" ]; then - rm -f $KERNELDIR/$srpm - # punt to a distro specific method if it exists - if ! type -p download_srpm-$DISTRO; then - fatal 1 "Could not download target $target's kernel SRPM $srpm from $location." - else - if ! download_srpm-$DISTRO "$target" "$srpm" "$force"; then - fatal 1 "Could not download target $target's kernel SRPM $srpm using download_srpm-$DISTRO." - fi - fi - fi - else - fatal 1 "$srpm not found in directory $KERNELDIR." - fi - fi - -} - -download_file() { - local from="$1" - local to="$2" - local force="$3" - - local file=${from##*/} - - if [ -d $to ]; then - to="$to/$file" - fi - - local semaphore="$to-downloading" - - is_downloading() { - if [ ! -f $semaphore ]; then - return 1 - fi - - # make sure the download has not been aborted - local now=$(date +%s) - local file_mtime=$(stat -c %Y "$to") - local staleness=$((now - file_mtime)) - # let's assume an active download will write at least once a minute - if [ $staleness -gt 60 ]; then - return 1 - fi - - return 0 - } - - is_downloaded() { - # if the semaphore file exists, the file is either still downloading - # or a download was aborted and we cannot trust the target file - if [ -f $semaphore ]; then - return 1 - fi - - if ! is_downloading && [ -r "$to" ] && [ -s "$to" ]; then - return 0 - fi - - return 1 - } - - if $force || ! is_downloaded; then - if is_downloading; then - echo "Somebody else is downloading $from..." - while is_downloading; do - echo "Waiting for $to to finish downloading" - sleep 60 - done - if is_downloaded; then - return 0 - else - echo "The download we were waiting for seems to have been aborted" - fi - - fi - - if $DOWNLOAD; then - echo "Downloading $from..." - # flag others so they don't try to download also - push_exit_trap "rm -f $to $semaphore" "download" - touch $semaphore - if ! fetch_url "$from" "$to" || [ ! -s "$to" ]; then - # the trap will remove the files via the fatal below - fatal 1 "Could not download ${to##*/} from ${from%/*}/." - fi - rm -f $semaphore - delete_exit_trap "download" - else - fatal 1 "${to##*/} not found in directory ${to%/*}." - fi - fi - - return 0 - -} - -download_ofed() { - local force="${1:-false}" - - if [ -z "$OFED_VERSION" -o "$OFED_VERSION" = "inkernel" ]; then - return 0 - fi - - local OFED_BASE_VERSION=$OFED_VERSION - if [[ $OFED_VERSION = *.*.*.* ]]; then - OFED_BASE_VERSION=${OFED_VERSION%.*} - fi - - local location="http://www.openfabrics.org/downloads/OFED/ofed-${OFED_BASE_VERSION}/" - - if [[ $OFED_VERSION = *-rc[0-9] ]]; then - local Mmv - Mmv=${OFED_VERSION%%-*} - location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}/" - fi - - if [[ $OFED_VERSION = daily-* ]]; then - local Mmv daily - OFED_VERSION=${OFED_VERSION/daily-/} - Mmv=${OFED_VERSION%%-*} - daily=${OFED_VERSION##$Mmv-} - location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}-daily/" - # find the filename for the version for the date specified - OFED_VERSION=$(curl -s "$location" | sed -nre "/${daily}-/s/.*href=\"OFED-(${Mmv//./\\.}-${daily}-[0-9]{4,4}).tgz.*$/\1/p" | tail -1) - if [ -z "$OFED_VERSION" ]; then - fatal 1 "Could not determine the filename of the OFED snapshot for ${daily}" - fi - fi - - local file="OFED-${OFED_VERSION}.tgz" - download_file "$location/$file" "$KERNELTREE" "$force" - -} - -load_target() { - - EXTRA_VERSION_save="$EXTRA_VERSION" - for patchesdir in "$EXTERNAL_PATCHES" \ - "$TOPDIR/lustre/lustre/kernel_patches"; do - TARGET_FILE="$patchesdir/targets/$TARGET.target" - [ -r "$TARGET_FILE" ] && break - done - [ -r "$TARGET_FILE" ] || fatal 1 "Target $TARGET was not found." - - echo "Loading target config file $TARGET.target..." - - # if the caller specified an OFED_VERSION it should override whatever - # the target file specifies - local env_OFED_VERSION="$OFED_VERSION" - - . "$TARGET_FILE" - - if [ -n "$env_OFED_VERSION" ]; then - OFED_VERSION="$env_OFED_VERSION" - fi - - # doesn't make any sense to build OFED for xen domX's - if $XEN; then - OFED_VERSION="" - fi - - # XXX - set_rpm_smp_type is an ugly undeterministic hack. it needs to - # go away and the target just specify the $RPMSMPTYPE - [ -z "$RPMSMPTYPE" ] && set_rpm_smp_type - - # CC might have been overwriten in TARGET_FILE - if [[ $CC != ccache\ * ]] && which "$CCACHE" &>/dev/null; then - export CCACHE && export CC="ccache $CC" - fi - - if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then - KERNELDIR="$KERNELTREE/${lnxmaj}" - [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR" - fi - - # verify the series is available - if [ "$SERIES" ]; then - for series in $SERIES; do - for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do - [ -r "$patchesdir/series/$series" ] && continue 2 - done - fatal 1 "Target $TARGET's series $SERIES could not be found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n\t$TOPDIR/lustre/lustre/kernel_patches/series." - done - fi - - # set the location of the .config file - local XENPOSTFIX="" - if $XEN; then - XENPOSTFIX="-xen" - fi - - if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then - CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH${RPMSMPTYPE:+-}${RPMSMPTYPE}.config" - fi - - local lnxrelnew=${lnxrel//-/_} - - # remember the EXTRA_VERSION before we diddle it here - # XXX - we really should not diddle with any values read in from the - # target file. if we want to modify a value, we should create - # a new variable. - PRISTINE_EXTRA_VERSION=$EXTRA_VERSION - - if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then - fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/." - fi - - if [ "$EXTRA_VERSION_save" ]; then - EXTRA_VERSION="$EXTRA_VERSION_save" - elif ! $RELEASE; then - # if there is no patch series, then this is not a lustre specific - # kernel. don't make it look like one - if $PATCHLESS || [ -n "$SERIES" ]; then - EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/") -# EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}" - if ! $PATCHLESS && [ -n "$BUILDID" ]; then - EXTRA_VERSION="${EXTRA_VERSION}.${BUILDID}" - fi - fi - fi - # EXTRA_VERSION=${EXTRA_VERSION//-/_} - - ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS" - - BUILD_ARCHS= - for arch in $(uniqify "$ALL_ARCHS"); do - if [ -z "$TARGET_ARCHS" ] || - [[ \ $TARGET_ARCHS\ = *\ $arch\ * ]]; then - BUILD_ARCHS="$BUILD_ARCHS $arch" - fi - done - [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build." - echo "Building for: $BUILD_ARCHS" -} - -tarflags() { - local file="$1" - - case "$file" in - '') - fatal 1 "tarflags(): File name argument missing." - ;; - *.tar.gz | *.tgz) - echo 'zxf' - ;; - *.tar.bz2) - echo 'jxf' - ;; - *.tar) - echo 'xf' - ;; - *) - fatal 1 "tarflags(): Unrecognized tar extension in file: $1" - ;; - esac - -} - -untar() { - local tarfile="$1" - shift - local extractfile="$@" - - echo "Untarring ${tarfile##*/}..." - tar $(tarflags "$tarfile") "$tarfile" $extractfile - -} - -unpack_ofed() { - - if ! untar "$KERNELTREE/OFED-${OFED_VERSION}.tgz"; then - return 1 - fi - [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED - -} - -unpack_lustre() { - - if [ -z "$LUSTRE" ]; then - local DATESTAMP="" - - if [ -n "$USE_DATESTAMP" ]; then - DATESTAMP="-D '$DATE'" - fi - - local DIRNAME="lustre-$TAG-$TIMESTAMP" - - cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \ - fatal 1 "There was an error checking out toplevel Lustre from CVS." - pushd "$DIRNAME" > /dev/null - ./lustrecvs "$TAG" || \ - fatal 1 "There was an error checking out Lustre/Portals/Build from CVS." - echo "Creating lustre tarball..." - sh autogen.sh || fatal 1 "There was an error running autogen.sh." - ./configure --enable-dist || \ - fatal 1 "There was an error running ./configure to create makefiles." - make dist || fatal 1 "There was an error running 'make dist'." - LUSTRE=$PWD/lustre-*.tar.gz - popd > /dev/null - fi - - untar "$LUSTRE" || fatal 1 "Error unpacking Lustre tarball" - [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre - -} - -do_patch_linux() { - - local do_patch=${1:-true} - - FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch" - [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH" - $do_patch && pushd linux >/dev/null - for series in $SERIES; do - echo -n "Applying series $series:" - for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do - [ -r "$patchesdir/series/$series" ] || continue - SERIES_FILE="$patchesdir/series/$series" - for patch in $(<"$SERIES_FILE"); do - echo -n " $patch" - PATCH_FILE="$patchesdir/patches/$patch" - [ -r "$PATCH_FILE" ] || \ - fatal 1 "Patch $patch does not exist in Lustre tree." - cat "$PATCH_FILE" >> "$FULL_PATCH" || { - rm -f $FULL_PATCH - fatal 1 "Error adding patch $patch to full patch." - } - if $do_patch; then - patch -s -p1 < "$PATCH_FILE" 2>&1 || { - rm -f $FULL_PATCH - fatal 1 "Error applying patch $patch." - } - fi - done - break - done - echo - done - $do_patch && popd >/dev/null - echo "Full patch has been saved in ${FULL_PATCH##*/}." - -} - -build_iokit() { - local rpmbuildopt="$1" - - pushd lustre-iokit > /dev/null || return 255 - - if ! ./configure; then - echo "failed to configure in lustre-iokit" - popd >/dev/null # pushd lustre-iokit - return 255 - fi - - if ! make dist; then - echo "failed to make dist in lustre-iokit" - popd >/dev/null # pushd lustre-iokit - return 255 - fi - - if ! $RPMBUILD $rpmbuildopt lustre-iokit*.tar.gz \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - popd >/dev/null # pushd lustre-iokit - return 255 - fi - - if $DO_SRC && ! $RPMBUILD -ts lustre-iokit*.tar.gz \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - popd >/dev/null # pushd lustre-iokit - return 255 - fi - popd >/dev/null # pushd lustre-iokit -} - -build_lustre() { - local linux="$1" - local linuxobj="$2" - - cp "$LUSTRE" SOURCES - - pushd lustre >/dev/null - - echo "Building Lustre RPMs for: $BUILD_ARCHS..." - local targets arch - for arch in $BUILD_ARCHS; do - targets="--target $arch $targets" - done - - local confoptions="" - - if $PATCHLESS; then - confoptions="$confoptions --disable-server" - fi - - local rpmbuildopt='-tb' - if $NORPM; then - rpmbuildopt='-tc' - echo NORPM mode. Only compiling. - fi - - # If server we now build the spl and zfs modules against the lustre kernel. - # These are required prior to the building of lustre server. Client does - # not require spl/zfs. Use !PATCHLESS to indicate server which follows the - # line above so is at least consistant. - if [ $PATCHLESS == false ] && [ "x$ZFSNOTSUPPORTED" == "x" ]; then - if ! build_spl_zfs; then - popd >/dev/null # pushd lustre - return 255 - fi - fi - - ( $(skeep_ldiskfs_rpm $TAG) ) || { - - pushd ldiskfs > /dev/null || return 255 - - if ! ./configure --enable-dist; then - echo "failed to configure in ldiskfs" - popd >/dev/null # pushd ldiskfs - popd >/dev/null # pushd lustre - return 255 - fi - - if ! make dist 2>&1; then - popd >/dev/null # pushd ldiskfs - popd >/dev/null # pushd lustre - return 255 - fi - - #cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES || \ - # fatal 1 "Could not copy lustre-ldiskfs*.tar.gz to $TOPDIR/SOURCES" - - if ! $RPMBUILD $targets $rpmbuildopt lustre-ldiskfs*.tar.gz \ - --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ - --define "kdir $linux" \ - ${linuxobj:+--define "kobjdir $linuxobj"} \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - popd >/dev/null # pushd ldiskfs - popd >/dev/null # pushd lustre - return 255 - fi - - if $DO_SRC; then - if ! $RPMBUILD -ts lustre-ldiskfs*.tar.gz \ - --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ - --define "kdir $linux" \ - ${linuxobj:+--define "kobjdir $linuxobj"} \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - popd >/dev/null # pushd ldiskfs - popd >/dev/null # pushd lustre - return 255 - fi - fi - popd >/dev/null # pushd ldiskfs - - # tell lustre where ldiskfs is - # XXX - pointing to the RPM BUILD dir is a hack. we need to flesh - # out the ldiskfs RPM build so that it builds a - # lustre-ldiskfs-devel RPM and install that and point lustre - # to that instead - confoptions="$confoptions --with-ldiskfs=$(ls -d $TOPDIR/BUILD/lustre-ldiskfs-*)" - } - - if $IOKITRPM; then - if ! build_iokit $rpmbuildopt; then - echo "failed to build lustre-iokit" - popd >/dev/null # pushd lustre - return 255 - fi - fi - - # convert the $PATCHLESS boolean to an empty/not-empty boolean - # as silly as this seems, it makes the syntax of the rpmbuild command - # simpler and not need an eval to deal with the quotes in the quotes - local is_patchless="" - if $PATCHLESS; then - is_patchless="yes" - fi - - # ditto for the lustre-tests boolean - local lustre_tests="" - if ! $LUSTRE_TESTS; then - lustre_tests="no" - fi - - local osd_zfs="" - if $OSDZFSRPM; then - osd_zfs="yes" - fi - - local osd_ldiskfs="" - if $OSDLDISKFSRPM; then - osd_ldiskfs="yes" - fi - - $RPMBUILD $targets $rpmbuildopt "$LUSTRE" \ - ${is_patchless:+--define "lustre_name lustre-client"} \ - ${lustre_tests:+--define "build_lustre_tests 0"} \ - ${osd_zfs:+--define "build_lustre_osd_zfs 1"} \ - ${osd_ldiskfs:+--define "build_lustre_osd_ldiskfs 1"} \ - ${FIND_REQUIRES:+--define "__find_requires $FIND_REQUIRES"} \ - --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ - --define "kdir $linux" \ - ${linuxobj:+--define "kobjdir $linuxobj"} \ - --define "_tmppath $TMPDIR" \ - --define "_topdir $TOPDIR" 2>&1 || \ - fatal 1 "Error building rpms for $BUILD_ARCHS." - - if $DO_SRC; then - if ! $RPMBUILD -ts "$LUSTRE" \ - ${is_patchless:+--define "lustre_name lustre-client"} \ - ${lustre_tests:+--define "build_lustre_tests 0"} \ - ${FIND_REQUIRES:+--define "__find_requires $FIND_REQUIRES"} \ - --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ - --define "kdir $linux" \ - ${linuxobj:+--define "kobjdir $linuxobj"} \ - --define "_tmppath $TMPDIR" \ - --define "_topdir $TOPDIR" 2>&1; then - popd - return 255 - fi - fi - popd >/dev/null - -} - -### -# build_spl_zfs -# -# Fetch spl/zfs from the git repo and prepare for lustre build -# -# return 0 if successful, else 255 -build_spl_zfs() { - # make sure the RPM build environment is set up - create_rpmbuild_dirs - - # The spl/zfs spec files expect RPM_BUILD_ROOT to point to the root of the - # destination for the rpms - export RPM_BUILD_ROOT=$TOPDIR - - # The files expect a kver to be set to the kernel version . - kver=$(cat ${LINUX}/include/config/kernel.release) - - # build and install the spl and zfs (and -devel) RPMs for lustre to use - local pkg - for pkg in spl zfs; do - - local rpmmod spldir - - [ "$pkg" == "zfs" ] && spldir="$(ls -d $TOPDIR/usr/src/spl-*/*)" - rpmmod=$pkg-modules - - # need to fetch the repo in order to build it. - # default to github but allow override - git clone ${SPLZFSGITREPO:-"https://github.com/zfsonlinux"}/$pkg.git $pkg 2>&1 - - pushd $pkg || return 255 - - # XXX - _having_ to give a package a kernel just to have it configure - # enough to do a "make dist" is truely bogus! - if ! ./configure --with-linux=${LINUX} \ - ${spldir:+--with-spl="${spldir}"} 2>&1 || - ! make dist 2>&1; then - popd - return 255 - fi - popd - - # XXX - dirty hack time. ~sigh~ - # because the spl tarball contains two .spec files, we cannot - # simply rebuild the tarball - ln $pkg/$pkg-*.tar.gz $TOPDIR/SOURCES || - error "failed to link $pkg/$pkg-*.tar.gz into $TOPDIR/SOURCES" - - # First build the userspace tools RPMs - if ! $RPMBUILD $targets -bb $pkg/$pkg.spec \ - --nodeps -v \ - --define "configure_args ${CONFIGURE_FLAGS}" \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - return 255 - fi - - if $DO_SRC; then - if ! $RPMBUILD -bs $pkg/$pkg.spec \ - --nodeps -v \ - --define "configure_args ${CONFIGURE_FLAGS}" \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - return 255 - fi - fi - - # Now the kernel module RPMs - # Need to provide pointers to the lustre kernel source, objects, usr/src - if ! $RPMBUILD $targets -bb $pkg/$rpmmod.spec \ - --nodeps -v \ - --define "require_kdir ${linux}" \ - ${linuxobj:+--define "require_kobj ${linuxobj}"} \ - ${spldir:+--define "require_spldir ${spldir}"} \ - --define "configure_args ${CONFIGURE_FLAGS}" \ - --define "_usrsrc $TOPDIR/usr/src" \ - --define "kver $kver" \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - return 255 - fi - - if $DO_SRC; then - if ! $RPMBUILD -bs $pkg/$rpmmod.spec \ - --nodeps -v \ - --define "require_kdir ${linux}" \ - ${linuxobj:+--define "require_kobj ${linuxobj}"} \ - ${spldir:+--define "require_spldir ${spldir}"} \ - --define "configure_args ${CONFIGURE_FLAGS}" \ - --define "_usrsrc $TOPDIR/usr/src" \ - --define "kver $kver" \ - --define "_tmppath /var/tmp" \ - --define "_topdir $TOPDIR" 2>&1; then - return 255 - fi - fi - - # We have built the rpms for the package. No we need to extract the - # contained files so we can build further things against them - local rpm=$(ls $TOPDIR/RPMS/*/$rpmmod-devel-*.rpm) - - # cpio only extract to pwd so we need to go there. - pushd $TOPDIR - rpm2cpio < $rpm | cpio -id - popd - - CONFIGURE_FLAGS="--with-$pkg=$(ls -d $TOPDIR/usr/src/$pkg-*/*) ${CONFIGURE_FLAGS}" - done - - OSDZFSRPM=true - - return 0 -} - -stage() { - - [ "$STAGEDIR" ] || return 0 - - for arch in $BUILD_ARCHS; do - rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}" - echo "${0##*/}: Copying RPMs into ${rpmdir}" - mkdir -p "${rpmdir}" - cp -v RPMS/${arch}/*.rpm "${rpmdir}" - if [ -d RPMS/noarch ]; then - cp -v RPMS/noarch/*.rpm "${rpmdir}" - fi - done - - cp -v "$LUSTRE" "$STAGEDIR" - -} - -#check if we need to build separate ldiskfs RPM -skeep_ldiskfs_rpm() { - local tag="$1" - - local skip=false - - if ! $LDISKFSRPM; then - skip=true - elif $PATCHLESS; then - skip=true - else - for skiptag in $SKIPLDISKFSRPM; do - [[ $tag == $skiptag ]] && skip=true && break - done - fi - - echo $skip - -} - -set_rpm_smp_type() { - - local infact_arch="${TARGET_ARCH}" - - RPMSMPTYPE="" - [ "$infact_arch" == "i586" ] && infact_arch="i686" - - local smp_type - for smp_type in $SMP_ARCHS; do - [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break - done - - for smp_type in $BIGSMP_ARCHS; do - [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break - done - - for smp_type in $PPC64_ARCHS; do - [ $infact_arch == $smp_type ] && RPMSMPTYPE=ppc64 && break - done - - for smp_type in $DEFAULT_ARCHS; do - [ $infact_arch == $smp_type ] && RPMSMPTYPE=default && break - done - -} - -# This function takes a linux source pool and digs out the linux release -# from it -find_linux_release() { - local SRCDIR="$1" - - local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h - if [ -s $SRCDIR/include/linux/utsrelease.h ]; then - LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h - fi - - sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER - -} - -# unpack kernel(/source/devel) RPM -# -# This function and it's setting of $LINUX and $LINUXOBJ is a total hack that -# needs to completely refactored. It completely ingores that $BUILD_ARCHS may -# contain a list of arches for which rpmbuild commands (including the one for -# lustre itself) -unpack_linux_devel_rpm() { - local kernelrpm="${1}" - - [ -f "$kernelrpm" ] || return 255 - [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused || return 255 - - pushd $TOPDIR/reused &>/dev/null || return 255 - - if ! rpm2cpio < "$kernelrpm" | cpio -id > /dev/null 2>&1; then - return 255 - fi - - # call a distro specific hook, if available - if type -p unpack_linux_devel_rpm-$DISTRO; then - if ! unpack_linux_devel_rpm-$DISTRO "$kernelrpm"; then - return 255 - fi - fi - - popd &>/dev/null - - find_linux_devel_paths $TOPDIR/reused - - return 0 - -} - -build_kernel_ib() { - local linux="$1" - local kib_prefix="$2" - local kib_rpm="$3" - - # build kernel-ib{,-devel}/compat-rdma{,-devel} - local K_SRC="K_SRC" - # ofed 1.3 had a bug in the rpm spec - if [ "$OFED_VERSION" = "1.3" ]; then - K_SRC="KSRC" - fi - - local OFED_CORE="--with-core-mod --with-ipoib-mod --with-sdp-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod" - local OFED_HARDWARE="--with-mthca-mod --with-mlx4-mod --with-mlx4_en-mod --with-cxgb3-mod --with-nes-mod" - - if compare_version $OFED_VERSION 3.0; then - OFED_CORE="$OFED_CORE --with-madeye-mod --with-rds-mod" - else - OFED_HARDWARE="$OFED_HARDWARE --with-cxgb4-mod" - fi - - # some I/B drivers are architecture dependent and kernel-ib's configure - # does not figure it out for us ~sigh~ - case "$TARGET_ARCH" in - ppc64) - OFED_HARDWARE="$OFED_HARDWARE --with-ehca-mod" - ;; - esac - # we're no longer shipping the OFED iSCSI target - #OFED_ISCSI="--with-srp-mod --with-srp-target-mod" - OFED_ISCSI="--with-srp-mod" - ## ISER module has no backport support as of OFED 1.5 (i.e. only builds on - ##kernels >= 2.6.30) - #if [[ $OFED_VERSION = 1.[0-4]* ]]; then - # OFED_ISCSI="$OFED_ISCSI --with-iser-mod" - #fi - - # assume we are just rebuilding the SRPM - local BUILD_TYPE=${BUILD_TYPE:-"--rebuild"} - local SOURCE="${TOPDIR}/OFED/SRPMS/${kib_prefix}-*.src.rpm" - - # but switch to building from the SPEC if we need to apply patches - if ls ${TOPDIR}/lustre/build/patches/ofed/* >/dev/null; then - BUILD_TYPE="-bb" - rpm --define "_topdir ${TOPDIR}" -ivh $SOURCE - SOURCE="${TOPDIR}/SPECS/${kib_prefix}.spec" - local file ed_fragment1 ed_fragment2 n=1 - for file in $(ls ${TOPDIR}/lustre/build/patches/ofed/*.patch); do - ed_fragment1="$ed_fragment1 -Patch$n: ${file%%*/}" - ed_fragment2="$ed_fragment2 -%patch$n -p0" - cp $file ${TOPDIR}/SOURCES - let n=$n+1 - done - for file in $(ls ${TOPDIR}/lustre/build/patches/ofed/*.ed); do - ed_fragment3="$ed_fragment3 -$(cat $file)" - let n=$n+1 - done - - if [ $n -gt 1 ]; then - ed $SOURCE <&1; then - fatal 1 "Error building ${kib_rpm}" - fi - -} - -store_for_reuse() { - local articles="$1" - local module="$2" - local location="$3" - local signature="$4" - local use_links="$5" - - local linkflag="" - if $use_links; then - linkflag="l" - fi - - local default_iface=$(/sbin/ip route get 192.1.1.1 | sed -ne 's/.* dev \(.*\) * src .*/\1/p') - if [ -z "$default_iface" ]; then - fatal 1 "Failed to determine the default route interface" - fi - local unique_id=$(/sbin/ip addr show dev $default_iface | sed -ne '/ inet /s/ *inet \(.*\)\/.*/\1/p' | head -1) - if [ -z "$unique_id" ]; then - fatal 1 "Failed to determine a unique id from interface $default_interface" - fi - - local finallocation="$location"/"$signature"/"$module" - location="$location"/"$signature-${unique_id}"/"$module" - mkdir -p "$location" - # the cleanup script removes any directory that doesn't have a - # .lastused, so let's try to prevent that as soon as we can - # this solution still slightly racy with the cleanup script - # but the race is a lot tighter now - touch -t 197001010000 "$location/.lastused" - ## use eval/echo here to make sure shell expansions are performed - #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then - local article - for article in $(eval echo $articles); do - if ! cp -a${linkflag} "$article" "$location"; then - error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()" - # rename the cache location so that it's not cached - # product, but is around for analysis - mv "$location"{,-bad-$(date +%s)} || - error "failed to clean up a failed cache attempt" \ - "in \"$location\" -- manual cleanup will be" \ - "necessary" - return 1 - fi - done - - # flag the cache as complete (i.e. in case lbuild was previously - # interrupted while caching) - touch "$location/.lastused" - - # put the temporary location into the final location - # (last one wins) - mkdir -p "${finallocation%/*}" - mv "$location" "$finallocation" - rmdir "${location%/*}" - return 0 - -} - -reuse() { - local module="$1" - local dest="$2" - local use_links="${3:-false}" - local signature="$4" - - if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then - if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then - # the .lastused flag is populated at the end of the caching to - # signal that the caching was completed. if that flag is not - # there, then the cache is invalid (and should be removed in fact) - mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} || - fatal 1 "failed to clean up a bad cache in location $REUSEBUILD/$signature/$module\" -- manual cleanup will be necessary" - return 1 - fi - - # so that we know how stale this entry is - touch $REUSEBUILD/$signature/$module/.lastused - - if $use_links; then - if ls $REUSEBUILD/$signature/$module/* >/dev/null 2>&1; then - cp -al $REUSEBUILD/$signature/$module/* $dest/ - fi - else - # copying is pretty heavy - # cp -a $REUSEBUILD/$signature/$module/* $dest/ - # do some creative symlinking instead - local dir - for dir in BUILD SRPMS SPECS; do - if ls $REUSEBUILD/$signature/$module/$dir/* >/dev/null 2>&1; then - ln -s $REUSEBUILD/$signature/$module/$dir/* $dest/$dir - fi - done - # sources have to be copied by file because we need SOURCES to - # be a dir we can write into -# could overrun ls's arg list here - #ls $REUSEBUILD/$signature/$module/SOURCES/* | - find $REUSEBUILD/$signature/$module/SOURCES/ -type f | - xargs ln -t $dest/SOURCES -s - - # same for RPMS/* dirs -# could overrun ls's arg list here - #ls $REUSEBUILD/$signature/$module/RPMS/$TARGET_ARCH/* | - local dir - for dir in $REUSEBUILD/$signature/$module/RPMS/*; do - mkdir -p $dest/RPMS/${dir##*/} - find $dir -type f | - xargs ln -t $dest/RPMS/${dir##*/} -s - done - fi - return 0 - else - return 1 - fi -} - -basearch() { - local arch="$1" - - if [[ $arch = i[3456]86 ]]; then - echo "i386" - else - echo "$arch" - fi - -} - -build_kernel_with_srpm() { - local outfd=$1 - - if [ -z "$outfd" ] || [ $outfd = 1 ]; then - fatal 1 "You must supply a file descriptor to ${FUNCNAME[0]} and it cannot be 1" - fi - - # need to generate the patch for this target - do_patch_linux false >&${outfd} # sets global $FULL_PATCH (yeah, yuck) - - # get an md5sum of the kernel patch + config for reuse check - # XXX really, there needs to be a signature and a CONFIG_FILE per arch - # in BUILD_ARCHS - local release_str - if $RELEASE; then - local release_str="RELEASE=$RELEASE\n" - fi - - if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then - local REUSE_SIGNATURE=$({ echo -en $release_str; - echo $BUILD_GEN; - cat $CONFIG_FILE $TARGET_FILE $FULL_PATCH; } | - md5sum | cut -d" " -f1) - # see if we can link to the reuse pool - # XXX - hrm. i'm not convinced this doesn't belong in the reuse - # "library" - local CAN_LINK_FOR_REUSE=false - touch $REUSEBUILD/$$ - if cp -al $REUSEBUILD/$$ $TOPDIR/ 2>/dev/null; then - CAN_LINK_FOR_REUSE=true - fi - rm $REUSEBUILD/$$ - fi - - # the extra version string to use for the kernel (which might be a reused - # kernel, remember) - local kernel_extra_version="" - if ! $USE_BUILD_CACHE || ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \ - "$REUSE_SIGNATURE"; then - # nothing cached, build from scratch - if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then - echo "Downloading kernel SRPM" >&${outfd} - download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&${outfd} - fi - - if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \ - --define "_topdir $TOPDIR" >&${outfd} 2>&1; then - # should we clean this up or leave it for analysis? - #rm -rf $RPMTOPDIR - fatal 1 "Error installing kernel SRPM." - fi - - # put the Lustre kernel patch into the RPM build tree - cp $FULL_PATCH $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch - prepare_and_build_srpm >&${outfd} || - fatal 1 "failed to prepare_and_build_srpm" - - if [ -z "$REUSE_SIGNATURE" ]; then - echo "No reuse signature was caculated so not storing the built kernel" >&${outfd} - else - # store the resulting kernel RPM build tree for future use - echo "Storing the built kernel for future reuse" >&${outfd} - if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,SRPMS,RPMS}" \ - "kernel" "$REUSEBUILD" "$REUSE_SIGNATURE" \ - "$CAN_LINK_FOR_REUSE"; then - error "Failed to store kernel RPMS for reuse" - echo "unknown" >&${outfd} - return 1 - fi - fi - fi # build reuse - - # figure out the EXTRA_VERSION of the kernel we built or are re-using - local KERNEL_RPM - if ! KERNEL_RPM=$(find_rpm "$TOPDIR/RPMS/$TARGET_ARCH/" provides "^kernel ="); then - fatal 1 "Failed to find a kernel RPM in $TOPDIR/RPMS/$TARGET_ARCH/" - fi - kernel_extra_version=$(rpm -q --queryformat "%{RELEASE}" -p $TOPDIR/RPMS/$TARGET_ARCH/$KERNEL_RPM) - - # should now have the following RPMs - # $TOPDIR/RPMS/$arch/kernel-lustre-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm - # $TOPDIR/RPMS/$arch/kernel-lustre-devel-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm - # $TOPDIR/RPMS/$arch/kernel-lustre-headers-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm - # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-common-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm - # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm - - echo $kernel_extra_version - return 0 - -} - -# build OFED -# globals used: -# TOPDIR -# REUSEBUILD, USE_BUILD_CACHE -# CONFIGURE_FLAGS - -build_ofed() { - local linux="$1" - local ofed_version="$2" - local kib_prefix - local kib_rpm - - # if an ofed version is given, then it means use OFED proper, - # not any vendor specific "inkernel" version - if [ -z "$ofed_version" ]; then - return 0 - fi - - if [ "$ofed_version" = "inkernel" ]; then - # see if there is a distro specific override for this and use - # that if it exists - # XXX we need to better integrate a distro specific override with - # the rest of this function so that all of the reuse cache - # stuff is leveraged given that 80% of this function is reuse - if type -p build_ofed-${DISTRO}; then - local ofed_location - ofed_location=$(build_ofed-${DISTRO} ${STDOUT}) - local rc=${PIPESTATUS[0]} - CONFIGURE_FLAGS="--with-o2ib=${ofed_location} ${CONFIGURE_FLAGS}" - return $rc - else - return 0 - fi - elif compare_version $OFED_VERSION 3.0; then - kib_prefix="ofa_kernel" - kib_rpm="kernel-ib" - else - kib_prefix="compat-rdma" - kib_rpm="compat-rdma" - fi - - # build kernel-ib/compat-rdma - if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then - local REUSE_SIGNATURE=$({ echo "$ofed_version"; - echo "$(find_linux_release ${linux})"; - cat "${linux}/include/linux/autoconf.h"; } | - md5sum | cut -d" " -f1) - # see if we can link to the reuse pool - # XXX - hrm. i'm not convinced this doesn't belong in the reuse - # "library" - local CAN_LINK_FOR_REUSE=false - touch $REUSEBUILD/$$ - if cp -al $REUSEBUILD/$$ $TOPDIR/; then - CAN_LINK_FOR_REUSE=true - fi - rm $REUSEBUILD/$$ - fi - - if ! $USE_BUILD_CACHE || ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \ - "$REUSE_SIGNATURE"; then - if [ -n "$REUSE_SIGNATURE" ]; then - # stash away the existing built articles for a moment - mkdir bak - mv {BUILD,{S,}RPMS,S{OURCE,PEC}S} bak - function mv_back { - pushd bak - find . | cpio -pudlm .. - popd - rm -rf bak - } - create_rpmbuild_dirs - fi - # build it - build_kernel_ib "${linux}" "${kib_prefix}" "${kib_rpm}" - - if [ -z "$REUSE_SIGNATURE" ]; then - echo "No reuse signature was caculated so not storing the built ofed" - else - # store the resulting RPM build tree for future use - echo "Storing the built ofed for future reuse" - if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \ - "ofed" "$REUSEBUILD" "$REUSE_SIGNATURE" \ - "$CAN_LINK_FOR_REUSE"; then - error "Failed to store OFED RPMS for reuse" - mv_back - return 1 - fi - # put the stuff we stashed away back - mv_back - fi - fi - - pushd "$TOPDIR" >/dev/null - rm -rf ${kib_rpm}-devel - mkdir ${kib_rpm}-devel - cd ${kib_rpm}-devel - # the actual ofed RPMs don't have the -rc$n or -$date string appened that - # might be present on the file - local linuxrelease=$(find_linux_release "$linux") - ofed_version=$(echo $ofed_version | - sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//') - local rpm=$(ls $TOPDIR/RPMS/*/${kib_rpm}-devel-${ofed_version}-${linuxrelease//-/_}.*.rpm) - if ! rpm2cpio < $rpm | cpio -id; then - fatal 1 "could not unpack the ${kib_rpm}-devel rpm." - fi - CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/${kib_prefix} ${CONFIGURE_FLAGS}" - popd >/dev/null - -} - -build_with_srpm() { - - if ! $PATCHLESS; then - local kernel_extra_version - if ! kernel_extra_version=$(build_kernel_with_srpm ${STDOUT}); then - fatal 1 "Failed to build the kernel from it's SRPM" - fi - - for arch in $BUILD_ARCHS; do - local kernel_devel_rpm - if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name $KERNEL_LUSTRE_NAMING) ="); then - fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/" - fi - - # install the -devel RPM in preparation for modules builds - if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \ - "$TOPDIR/RPMS/$arch/$kernel_devel_rpm"; then - fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm" - fi - done - else - # need to find and unpack the vendor's own kernel-devel for patchless - # client build - local kernelrpm - if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE"); then - fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}" - fi - if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then - fatal 1 "Could not find the Linux tree in $kernelrpm" - fi - fi - - # ~sigh~ have to make copies of and modify some of the rpm - # infrastructure files so that find-requires can find our unpacked - # kernel-devel artifacts - cp $RPM_HELPERS_DIR/{symset-table,find-requires{,.ksyms}} . - FIND_REQUIRES="$(pwd)/find-requires" - chmod 755 {symset-table,find-requires{,.ksyms}} - local tmp="$(pwd)" - tmp="${tmp//\//\\/}" - ed find-requires < 0; j-- )); do - newarg=${BASH_ARGV[$j + $p - 1]} - args="${args:+${args} }'${newarg}'" - done - let p+=${BASH_ARGC[$n - 1]} - fi - echo " ${funcname} ${args:+${args} }at ${sourcefile}:${lineno}" - done - - echo - echo "BEGIN BACKTRACE" - - #echo ${BASH_LINENO[*]} - #echo ${BASH_SOURCE[*]} - #echo ${FUNCNAME[*]} - local i=$((${#FUNCNAME[@]} - 1)) - while [ $i -ge 0 ]; do - local lineno=${BASH_LINENO[$i]} - if [ $i = 0 ]; then - let lineno-=11 - fi - local SOURCELINE="${BASH_SOURCE[$i + 1]}:${lineno}" - # Can't figure out how to get function args from other frames... - local FUNCTION="${FUNCNAME[$i]}()" - echo "$SOURCELINE:$FUNCTION" - i=$((i - 1)) - done - - echo "END BACKTRACE" - - echo $BACKTRACE - -} - -seen_list=$(new_list) -trap 'set +x; -echo "An unexpected error has occurred at ${BASH_SOURCE[0]##*/}:$((LINENO-1)). -Unfortunately the above line number in the message may or may not be correct, -but details have been send to the lbuild maintainer. Attempting to continue."; (echo "Untrapped error" -echo -# have we seen this one -echo "checking seen list for ${BASH_SOURCE[0]}:${BASH_LINENO[0]}" - -if is_list_member "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}"; then - echo "seen this one already" -else - seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}") -fi -backtrace -echo -echo "Environment:" -set -) | mail -s "Untrapped error at ${BASH_SOURCE[0]##*/}:$((LINENO-15)) on $HOSTNAME" brian@whamcloud.com >&2; set $xtrace' ERR -set -E - -[ -r ~/.lbuildrc ] && . ~/.lbuildrc - -options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,ofed-version:,publish,release,set-value:,src,stage:,tag:,target:,target-archs:,with-linux:,xen -- "$@") - -if [ $? != 0 ]; then - usage 1 -fi - -eval set -- "$options" - -while [ "$1" ]; do - case "$1" in - '') - usage 1 - ;; - --ccache) - CCACHE='ccache' - shift - ;; - -d) - CVSROOT=$2 - shift 2 - ;; - -D) - DATE=$2 - shift 2 - ;; - --external-patches) - EXTERNAL_PATCHES=$2 - shift 2 - ;; - --extraversion) - EXTRA_VERSION=$2 - shift 2 - ;; - --help | -h) - usage 0 - ;; - --kerneldir) - KERNELDIR=$2 - shift 2 - ;; - --kerneltree) - if ! KERNELTREE=$(canon_path "$2"); then - fatal 1 "Could not determine the canonical location of $2" - fi - shift 2 - ;; - --linux | --with-linux) - if ! LINUX=$(canon_path "$2"); then - fatal 1 "Could not determine the canonical location of $2" - fi - shift 2 - ;; - --distro) - DISTRO=$2 - shift 2 - ;; - --reuserpm) - REUSERPM=$2 - shift 2 - ;; - --reusebuild) - if ! REUSEBUILD=$(canon_path "$2"); then - fatal 1 "Could not determine the canonical location of $2" - fi - shift 2 - ;; - --norpm) - NORPM=true - shift - ;; - --ldiskfs) - LDISKFSRPM=true - shift - ;; - --noiokit) - IOKITRPM=false - shift - ;; - --patchless) - PATCHLESS=true - shift - ;; - --kernelrpm) - if ! KERNELRPMSBASE=$(canon_path "$2"); then - fatal 1 "Could not determine the canonical location of $2" - fi - shift 2 - ;; - --timestamp) - TIMESTAMP=$2 - shift 2 - ;; - --lustre) - if ! LUSTRE=$(canon_filepath "$2"); then - fatal 1 "Could not determine the canonical location of $2" - fi - shift 2 - ;; - --nodownload) - DOWNLOAD=false - shift 1 - ;; - --nosrc) - DO_SRC=false - shift 1 - ;; - --ofed-version) - OFED_VERSION="$2" - shift 2 - ;; - --publish) - shift - ;; - --release) - RELEASE=true - shift - ;; - --src) - DO_SRC=true - shift 1 - ;; - --stage) - STAGEDIR=$2 - shift 2 - ;; - --tag) - TAG=$2 - shift 2 - ;; - --target) - TARGET=$2 - shift 2 - ;; - --target-archs) - TARGET_ARCHS=$2 - shift 2 - ;; - --disable-datestamp) - USE_DATESTAMP= - shift - ;; - --xen) - XEN=true - shift - ;; - --set-value) - eval $2 - shift 2 - ;; - --) - shift - # there are actually some lustre configure flags that we need to - # handle ourselves (but we still give them to configure) - if [[ \ $@\ == *\ --disable-tests\ * ]]; then - LUSTRE_TESTS=false - fi - CONFIGURE_FLAGS=$@ - CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests" - break - ;; - *) - usage 1 "Unrecognized option: $1" - ;; - esac -done - -check_options - -unpack_lustre - -# XXX - should we _always_ get the buildid from the META file? what are the -# other (i.e. non-lustre-tarball use cases of lbuild)? -BUILDID=$(sed -ne '/^BUILDID =/s/.*= *//p' lustre/META) - -load_target - -if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then - download_ofed - unpack_ofed || fatal 1 "Error unpacking OFED tarball" -fi - -# make sure the RPM build environment is set up -create_rpmbuild_dirs - -# if an unpacked kernel source tree was given on the command line -# just build lustre with it (nothing distro kernel specific here) -if [ -n "$LINUX" ]; then - build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" || - fatal 1 "error building OFED" - build_lustre "$LINUX" "$LINUXOBJ" -else - if [ -f "${0%/*}/lbuild-$DISTRO" ]; then - source ${0%/*}/lbuild-$DISTRO - - build_with_srpm || fatal 1 "Failed to build_with_srpm" - else - EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"} - source ${0%/*}/lbuild.old_school - - old_school_download_kernel - - build_success=false - if $PATCHLESS; then - patchless_build_sequence && build_success=true - else - [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true - if ! $build_success; then - build_sequence_reuse && build_success=true - if ! $build_success; then - build_sequence && build_success=true - if $build_success; then - store_for_reuse || echo "Cannot store for future reuse" - fi - fi - fi - fi - ( $build_success ) || fatal 1 "Cannot build lustre" - fi -fi - -stage diff --git a/build/lbuild b/build/lbuild new file mode 120000 index 0000000..a49b9c08 --- /dev/null +++ b/build/lbuild @@ -0,0 +1 @@ +../contrib/lbuild/lbuild \ No newline at end of file diff --git a/build/prepare-commit-msg b/build/prepare-commit-msg deleted file mode 100755 index cbb486e..0000000 --- a/build/prepare-commit-msg +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# A Git hook script to prepare the commit log message. Install into -# lustre/.git/hooks/prepare-commit-msg to enable for Lustre commits. -# -# Called by git-commit with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# Commit hook to check the patch against the Lustre coding style. -# It adds any checkpatch warnings/errors as commit comments, which -# means that they can currently be ignored, but are at least visible. - -CHECKPATCH=build/checkpatch.pl -CHECKPATCH_OPTS="--no-signoff --no-tree" -[ -r "$CHECKPATCH" ] || exit 0 - -# If there are no comments in the commit, it is likely a rebase and -# this shouldn't be adding new comments, or they appear in the commit. -grep -q "^#" "$1" || exit 0 - -# Add a commented-out Signed-off-by: line. This shouldn't be added in an -# uncommented form, otherwise sanity checking for an emtpy commit fails. -SIGNOFF=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -grep -qs "^$SIGNOFF" "$1" || echo "# $SIGNOFF" >> "$1" - -# Add the checkpatch.pl output as comments, but don't cause a commit error -# yet, until there is more certainty that it is working correctly. -echo "" >> "$1" -echo "#" >> "$1" -git diff --cached | $CHECKPATCH $CHECKPATCH_OPTS - | sed -e 's/^/# /' >> "$1" -echo "# vim:textwidth=70:" >> "$1" diff --git a/build/prepare-commit-msg b/build/prepare-commit-msg new file mode 120000 index 0000000..9526639 --- /dev/null +++ b/build/prepare-commit-msg @@ -0,0 +1 @@ +../contrib/git-hooks/prepare-commit-msg \ No newline at end of file diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 0000000..34eb9d3 --- /dev/null +++ b/config/.gitignore @@ -0,0 +1,6 @@ +/Makefile.in +/config.guess +/config.sub +/depcomp +/install-sh +/missing diff --git a/build/autoconf/Makefile.am b/config/Makefile.am similarity index 100% rename from build/autoconf/Makefile.am rename to config/Makefile.am diff --git a/build/autoconf/lustre-build-darwin.m4 b/config/lustre-build-darwin.m4 similarity index 100% rename from build/autoconf/lustre-build-darwin.m4 rename to config/lustre-build-darwin.m4 diff --git a/build/autoconf/lustre-build-ldiskfs.m4 b/config/lustre-build-ldiskfs.m4 similarity index 100% rename from build/autoconf/lustre-build-ldiskfs.m4 rename to config/lustre-build-ldiskfs.m4 diff --git a/build/autoconf/lustre-build-linux.m4 b/config/lustre-build-linux.m4 similarity index 100% rename from build/autoconf/lustre-build-linux.m4 rename to config/lustre-build-linux.m4 diff --git a/build/autoconf/lustre-build-zfs.m4 b/config/lustre-build-zfs.m4 similarity index 100% rename from build/autoconf/lustre-build-zfs.m4 rename to config/lustre-build-zfs.m4 diff --git a/build/autoconf/lustre-build.m4 b/config/lustre-build.m4 similarity index 99% rename from build/autoconf/lustre-build.m4 rename to config/lustre-build.m4 index c949dc1..820b8bb 100644 --- a/build/autoconf/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -565,8 +565,12 @@ AC_DEFUN([LB_CONFIG_FILES], AC_CONFIG_FILES([ Makefile autoMakefile] + config/Makefile [Rules:build/Rules.in] AC_PACKAGE_TARNAME[.spec] + contrib/Makefile + contrib/lbuild/Makefile + contrib/scripts/Makefile ) ]) diff --git a/configure.ac b/configure.ac index aec60ab..96b4968 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,9 @@ AC_PREREQ([2.57]) AC_INIT([Lustre], [LUSTRE_VERSION], [http://bugs.whamcloud.com/], [lustre]) sinclude(lustre/autoconf/lustre-version.ac) +AC_CONFIG_AUX_DIR([config]) +AC_CONFIG_MACRO_DIR([config]) + # Overridden by --without-ldiskfs/--with-zfs configure options AM_CONDITIONAL(LDISKFS_ENABLED, true) AM_CONDITIONAL(ZFS_ENABLED, false) diff --git a/contrib/.gitignore b/contrib/.gitignore new file mode 100644 index 0000000..70845e0 --- /dev/null +++ b/contrib/.gitignore @@ -0,0 +1 @@ +Makefile.in diff --git a/contrib/Makefile.am b/contrib/Makefile.am new file mode 100644 index 0000000..d48d6bf --- /dev/null +++ b/contrib/Makefile.am @@ -0,0 +1,2 @@ +EXTRA_DIST = rdac_spec patches +DIST_SUBDIRS = lbuild scripts diff --git a/contrib/README b/contrib/README new file mode 100644 index 0000000..1cfb708 --- /dev/null +++ b/contrib/README @@ -0,0 +1,8 @@ +This directory is a catch-all location for useful contributed files and +scripts that are _not_ part of the lustre package proper. For +instance, scripts that are useful to lustre developers, but not used +by lustre's own build system in configuring, compiling, or packaging lustre. + +An example would be the git hook scripts. We do not package these files, +and while they are an important part of the lustre development process +they are not an essential part of the lustre build system. diff --git a/contrib/git-hooks/commit-msg b/contrib/git-hooks/commit-msg new file mode 100755 index 0000000..e0803ea --- /dev/null +++ b/contrib/git-hooks/commit-msg @@ -0,0 +1,292 @@ +#!/bin/bash +# +# A hook script to check the commit log message to ensure that it has +# a well-formed commit summary and body, a valid Signed-off-by: line, +# and a Gerrit Change-Id: line (added automatically if missing). +# +# Called by git-commit with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# Should be installed as .git/hooks/commit-msg. +# + +init() { + set -a + readonly ORIGINAL="$1" + readonly REVISED="$(mktemp "$ORIGINAL.XXXXXX")" + readonly SAVE="$(basename $ORIGINAL).$(date +%Y%m%d.%H%M%S)" + readonly SIGNOFF="Signed-off-by:" + readonly CHANGEID="Change-Id:" + readonly TESTPARAMS="Test-Parameters:" + readonly INNOCUOUS=$(echo \ + Acked-by \ + Tested-by \ + Reported-by \ + Reviewed-by \ + CC \ + | tr ' ' '|') + readonly WIDTH_SUM=62 + readonly WIDTH_REG=70 + readonly JIRA_FMT_A="^[A-Z]\{2,5\}-[0-9]\{1,5\} [-a-z0-9]\{2,11\}: " + readonly JIRA_FMT_B="^[A-Z]\{2,5\}-[0-9]\{1,5\} " + + # Identify a name followed by an email address. + # + readonly EMAILPAT=$'[ \t]*[^<> ]* [^<>]* <[^@ \t>]+@[a-zA-Z0-9.-]+\.[a-z]+>' + + HAS_ERROR=false + HAS_SUMMARY=false + HAS_LAST_BLANK=false + HAS_BODY=false + HAS_SIGNOFF=false + HAS_CHANGEID=false + + IS_WRAPPING_UP=false + + LINE="" + NUM=0 + set +a +} + +# die: commit-msg fatal error: script error or empty input message +# All output redirected to stderr. +# +die() { + echo "commit-msg fatal error: $*" + test -f "$REVISED" && rm -f "$REVISED" + exit 1 +} 1>&2 + +# Called when doing the final "wrap up" clause because we've found +# one of the tagged lines that belongs in the final section. +# +function ck_wrapup() { + $IS_WRAPPING_UP && return + + $HAS_LAST_BLANK || error "blank line must preceed signoff section" + $HAS_SUMMARY || error "missing commit summary line." + $HAS_BODY || error "missing commit description." + + HAS_LAST_BLANK=false + IS_WRAPPING_UP=true +} + +function do_signoff() { + ck_wrapup + # Signed-off-by: First Last + local txt=$(echo "${LINE#*: }" | grep -E "${EMAILPAT}") + if (( ${#txt} == 0 )); then + error "$SIGNOFF line requires name and email address" + else + HAS_SIGNOFF=true # require at least one + fi +} + +function do_changeid() { + ck_wrapup + $HAS_CHANGEID && error "multiple $CHANGEID lines are not allowed" + + # Change-Id: I1234567890123456789012345678901234567890 + # capital "I" plus 40 hex digits + # + local txt=$(echo "$LINE" | grep "^$CHANGEID I[0-9a-fA-F]\{40\}\$") + (( ${#txt} > 0 )) || + error "has invalid $CHANGEID line for Gerrit tracking" + + HAS_CHANGEID=true +} + +# All "innocuous" lines specify a person and email address +# +function do_innocuous() { + ck_wrapup + local txt=$(echo "${LINE#*: }" | grep -E "${EMAILPAT}") + (( ${#txt} == 0 )) && error "invalid name and address" +} + +function do_default_line() { + $IS_WRAPPING_UP && { + error "invalid signoff section line" + return + } + if (( NUM == 1 )); then + HAS_JIRA_COMPONENT=$(echo "$LINE" | grep "$JIRA_FMT_A") + + if (( ${#HAS_JIRA_COMPONENT} == 0 )); then + HAS_JIRA=$(echo "$LINE" | grep "$JIRA_FMT_B") + if (( ${#HAS_JIRA} > 0 )); then + error "has no component in summary." + else + error "missing JIRA ticket number." + fi + elif (( ${#LINE} > WIDTH_SUM )); then + error "summary longer than $WIDTH_SUM columns." + else + HAS_SUMMARY=true + fi + + elif (( ${#LINE} > WIDTH_REG )); then + error "has line longer than $WIDTH_REG columns." + elif ! $HAS_BODY && ! $HAS_LAST_BLANK; then + error "has no blank line after summary." + else + HAS_BODY=true + fi + HAS_LAST_BLANK=false +} + +# Add a new unique Change-Id +# +new_changeid() { + local NEWID=$({ + git var GIT_AUTHOR_IDENT + git var GIT_COMMITTER_IDENT + git write-tree + git rev-parse HEAD 2>/dev/null + grep -v "^$SIGNOFF" "$ORIGINAL" | git stripspace -s + } | git hash-object --stdin) + (( ${#NEWID} > 0 )) || + die "git hash-object failed for $CHANGEID:" + + echo "$CHANGEID I$NEWID" +} + +# A commit message error was encountered. +# All output redirected to stderr. +# +error() { + (( ${#LINE} > 0 )) && echo "line $NUM: $LINE" + echo "error: commit message $*" | fmt + HAS_ERROR=true +} 1>&2 + +usage() { + exec 1>&2 + cat <<- EOF + + See http://wiki.whamcloud.com/display/PUB/Commit+Comments + for full details. An example valid commit comment is: + + LU-nnn component: short description of change under 64 columns + + The "component:" should be a lower-case single-word subsystem of the + Lustre code that best encompasses the change being made. Examples of + components include modules like: llite, lov, lmv, osc, mdc, ldlm, lnet, + ptlrpc, mds, oss, osd, ldiskfs, libcfs, socklnd, o2iblnd; functional + subsystems like: recovery, quota, grant; and auxilliary areas like: + build, tests, docs. This list is not exhaustive, but is a guideline. + + The commit comment should contain a detailed explanation of the change + being made. This can be as long as you'd like. Please give details + of what problem was solved (including error messages or problems that + were seen), a good high-level description of how it was solved, and + which parts of the code were changed (including important functions + that were changed, if this is useful to understand the patch, and + for easier searching). Wrap lines at/under $WIDTH_REG columns. + + Finish the comment with a blank line and a blank-line-free + sign off section: + + $SIGNOFF Your Real Name + $CHANGEID Ixxxx(added automatically if missing)xxxx + + The "$CHANGEID" line should only be there when updating a previous + commit/submission. Copy the one from the original commit. + + The "sign off section" may also include several other tag lines: + $(for T in $(tr '|' ' ' <<< "$INNOCUOUS"); do \ + echo " $T: Some Person "; \ + done) + $TESTPARAMS optional additional test parameters + {Organization}-bug-id: associated external change identifier + EOF + + mv "$ORIGINAL" "$SAVE" && + echo "$0: saved original commit comment to $SAVE" 1>&2 +} + +init ${1+"$@"} +exec 3< "$ORIGINAL" 4> "$REVISED" || exit 1 + +while IFS= read -u3 LINE; do + ((NUM += 1)) + case "$LINE" in + $SIGNOFF* ) do_signoff ;; + $CHANGEID* ) do_changeid ;; + $TESTPARAMS* ) ck_wrapup ;; + + "") + HAS_LAST_BLANK=true + $IS_WRAPPING_UP && continue + ;; + + \#*) + continue ## ignore and suppress comments + ;; + + "diff --git a/"* ) + # Beginning of uncommented diffstat from "commit -v". If + # there are diff and index lines, skip the rest of the input: + # diff --git a/build/commit-msg b/build/commit-msg + # index 80a3442..acb4c50 100755 + # deleted file mode 100644 + # old mode 100644 + # If a "diff --git" line is not followed by one of these + # lines, do the default line processing on both lines. + # + IFS= read -u3 INDEX || break + ((NUM += 1)) + case "$INDEX" in + "index "[0-9a-fA-F]*) break ;; + "deleted file mode "*) break ;; + "old mode "*) break ;; + "new file mode "*) break ;; + esac + LINE=${LINE}$'\n'${INDEX} + do_default_line + ;; + + *) + if [[ "$LINE" =~ ^($INNOCUOUS): ]]; then + do_innocuous + elif [[ "$LINE" =~ ^[A-Za-z0-9_-]+-bug-id: ]]; then + ck_wrapup + else + # Allow arbitrary external bug identifiers for tracking. + # I can't seem to find a pattern for the "case" that + # checks for "*-bug-id", so this is checked here. + do_default_line + fi + ;; + esac + + echo "$LINE" >&4 +done + +(( NUM <= 0 )) && die "empty commit message" + +unset LINE +$HAS_SIGNOFF || error "missing valid $SIGNOFF: line." + +if $HAS_ERROR; then + exec 3<&- 4>&- + usage + rm "$REVISED" + exit 1 +fi + +$HAS_CHANGEID || new_changeid >&4 +exec 3<&- 4>&- + +mv "$REVISED" "$ORIGINAL" + +## Local Variables: +## Mode: shell-script +## sh-basic-offset: 8 +## sh-indent-after-do: 8 +## sh-indentation: 8 +## sh-indent-for-case-label: 0 +## sh-indent-for-case-alt: 8 +## End: diff --git a/contrib/git-hooks/prepare-commit-msg b/contrib/git-hooks/prepare-commit-msg new file mode 100755 index 0000000..9acb19e --- /dev/null +++ b/contrib/git-hooks/prepare-commit-msg @@ -0,0 +1,34 @@ +#!/bin/bash +# +# A Git hook script to prepare the commit log message. Install into +# lustre/.git/hooks/prepare-commit-msg to enable for Lustre commits. +# +# Called by git-commit with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# Commit hook to check the patch against the Lustre coding style. +# It adds any checkpatch warnings/errors as commit comments, which +# means that they can currently be ignored, but are at least visible. + +CHECKPATCH=contrib/scripts/checkpatch.pl +CHECKPATCH_OPTS="--no-signoff --no-tree" +[ -r "$CHECKPATCH" ] || exit 0 + +# If there are no comments in the commit, it is likely a rebase and +# this shouldn't be adding new comments, or they appear in the commit. +grep -q "^#" "$1" || exit 0 + +# Add a commented-out Signed-off-by: line. This shouldn't be added in an +# uncommented form, otherwise sanity checking for an emtpy commit fails. +SIGNOFF=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +grep -qs "^$SIGNOFF" "$1" || echo "# $SIGNOFF" >> "$1" + +# Add the checkpatch.pl output as comments, but don't cause a commit error +# yet, until there is more certainty that it is working correctly. +echo "" >> "$1" +echo "#" >> "$1" +git diff --cached | $CHECKPATCH $CHECKPATCH_OPTS - | sed -e 's/^/# /' >> "$1" +echo "# vim:textwidth=70:" >> "$1" diff --git a/build/commit.badcid b/contrib/git-hooks/tests/commit.badcid similarity index 100% rename from build/commit.badcid rename to contrib/git-hooks/tests/commit.badcid diff --git a/build/commit.bademail b/contrib/git-hooks/tests/commit.bademail similarity index 100% rename from build/commit.bademail rename to contrib/git-hooks/tests/commit.bademail diff --git a/build/commit.badname b/contrib/git-hooks/tests/commit.badname similarity index 100% rename from build/commit.badname rename to contrib/git-hooks/tests/commit.badname diff --git a/build/commit.badsign b/contrib/git-hooks/tests/commit.badsign similarity index 100% rename from build/commit.badsign rename to contrib/git-hooks/tests/commit.badsign diff --git a/build/commit.dupcid b/contrib/git-hooks/tests/commit.dupcid similarity index 100% rename from build/commit.dupcid rename to contrib/git-hooks/tests/commit.dupcid diff --git a/build/commit.nobody b/contrib/git-hooks/tests/commit.nobody similarity index 100% rename from build/commit.nobody rename to contrib/git-hooks/tests/commit.nobody diff --git a/build/commit.nocmp b/contrib/git-hooks/tests/commit.nocmp similarity index 100% rename from build/commit.nocmp rename to contrib/git-hooks/tests/commit.nocmp diff --git a/build/commit.nojira b/contrib/git-hooks/tests/commit.nojira similarity index 100% rename from build/commit.nojira rename to contrib/git-hooks/tests/commit.nojira diff --git a/build/commit.nosign b/contrib/git-hooks/tests/commit.nosign similarity index 100% rename from build/commit.nosign rename to contrib/git-hooks/tests/commit.nosign diff --git a/build/commit.nosum b/contrib/git-hooks/tests/commit.nosum similarity index 100% rename from build/commit.nosum rename to contrib/git-hooks/tests/commit.nosum diff --git a/build/commit.ok_bugid b/contrib/git-hooks/tests/commit.ok_bugid similarity index 100% rename from build/commit.ok_bugid rename to contrib/git-hooks/tests/commit.ok_bugid diff --git a/build/commit.ok_chmod b/contrib/git-hooks/tests/commit.ok_chmod similarity index 100% rename from build/commit.ok_chmod rename to contrib/git-hooks/tests/commit.ok_chmod diff --git a/build/commit.ok_cid b/contrib/git-hooks/tests/commit.ok_cid similarity index 100% rename from build/commit.ok_cid rename to contrib/git-hooks/tests/commit.ok_cid diff --git a/build/commit.ok_deleted b/contrib/git-hooks/tests/commit.ok_deleted similarity index 100% rename from build/commit.ok_deleted rename to contrib/git-hooks/tests/commit.ok_deleted diff --git a/build/commit.ok_diff b/contrib/git-hooks/tests/commit.ok_diff similarity index 100% rename from build/commit.ok_diff rename to contrib/git-hooks/tests/commit.ok_diff diff --git a/build/commit.ok_diffinside b/contrib/git-hooks/tests/commit.ok_diffinside similarity index 100% rename from build/commit.ok_diffinside rename to contrib/git-hooks/tests/commit.ok_diffinside diff --git a/build/commit.ok_dupsign b/contrib/git-hooks/tests/commit.ok_dupsign similarity index 100% rename from build/commit.ok_dupsign rename to contrib/git-hooks/tests/commit.ok_dupsign diff --git a/build/commit.ok_innocuous b/contrib/git-hooks/tests/commit.ok_innocuous similarity index 100% rename from build/commit.ok_innocuous rename to contrib/git-hooks/tests/commit.ok_innocuous diff --git a/build/commit.ok_nocid b/contrib/git-hooks/tests/commit.ok_nocid similarity index 100% rename from build/commit.ok_nocid rename to contrib/git-hooks/tests/commit.ok_nocid diff --git a/build/commit.ok_params b/contrib/git-hooks/tests/commit.ok_params similarity index 100% rename from build/commit.ok_params rename to contrib/git-hooks/tests/commit.ok_params diff --git a/build/commit.ok_signoff b/contrib/git-hooks/tests/commit.ok_signoff similarity index 100% rename from build/commit.ok_signoff rename to contrib/git-hooks/tests/commit.ok_signoff diff --git a/build/test-commit-msg.sh b/contrib/git-hooks/tests/test-commit-msg.sh similarity index 93% rename from build/test-commit-msg.sh rename to contrib/git-hooks/tests/test-commit-msg.sh index facd9f3..2f1c565 100755 --- a/build/test-commit-msg.sh +++ b/contrib/git-hooks/tests/test-commit-msg.sh @@ -23,7 +23,7 @@ for f; do esac cp $f $TEMPFILE - results=$(exec 2>&1 ${SHELL:-sh} $progdir/commit-msg $TEMPFILE) + results=$(exec 2>&1 ${SHELL:-sh} $progdir/../commit-msg $TEMPFILE) case $'\n'"$results" in ( *$'\nerror:'* ) OK=0 ;; ( * ) OK=1 ;; diff --git a/contrib/lbuild/Makefile.am b/contrib/lbuild/Makefile.am new file mode 100644 index 0000000..269c845 --- /dev/null +++ b/contrib/lbuild/Makefile.am @@ -0,0 +1,5 @@ +EXTRA_DIST = lbuild +EXTRA_DIST += lbuild-fc lbuild-fc11 lbuild-fc12 lbuild-fc15 +EXTRA_DIST += lbuild-rhel lbuild-rhel5 lbuild-rhel6 +EXTRA_DIST += lbuild-sles lbuild-sles10 lbuild-sles11 +EXTRA_DIST += funcs.sh exit_traps.sh find_linux_rpms diff --git a/build/exit_traps.sh b/contrib/lbuild/exit_traps.sh similarity index 100% rename from build/exit_traps.sh rename to contrib/lbuild/exit_traps.sh diff --git a/build/find_linux_rpms b/contrib/lbuild/find_linux_rpms similarity index 100% rename from build/find_linux_rpms rename to contrib/lbuild/find_linux_rpms diff --git a/build/funcs.sh b/contrib/lbuild/funcs.sh similarity index 100% rename from build/funcs.sh rename to contrib/lbuild/funcs.sh diff --git a/contrib/lbuild/lbuild b/contrib/lbuild/lbuild new file mode 100755 index 0000000..bf424ee --- /dev/null +++ b/contrib/lbuild/lbuild @@ -0,0 +1,2059 @@ +#!/bin/bash + +# vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4: + +# this is an alternative FD for stdout, to be used especially when we are +# taking stdout from a function as it's return value. i.e. foo=$(bar) +# this is a workaround until a version of bash where we can put xtrace +# on a specific FD +exec 3>&1; STDOUT=3 + +#set -x +xtrace="+x" +if [[ $SHELLOPTS = *xtrace* ]]; then + xtrace="-x" +fi +shopt -s extdebug + +# Assume that lbuild's support files can be found in the same +# canonicalized path as this very script. +LBUILD_SCRIPT=$(readlink -f ${0}) +LBUILD_DIR=${LBUILD_DIR:-$(dirname ${LBUILD_SCRIPT})} + +# include the exit_traps library +. ${LBUILD_DIR}/exit_traps.sh +. ${LBUILD_DIR}/funcs.sh + +# our children should die when we do +push_exit_trap "kill -INT -$$ || true" kill_children + +# increment this if you have made a change that should force a new kernel +# to build built +#BUILD_GEN=1 +#BUILD_GEN=2 # bz19952: remove -lustre tag from kernel RPM names +#BUILD_GEN=3 # bz19975: enable the building of src.rpms by default +#BUILD_GEN=4 # bz22281: use the git hash in the kernel extra version +BUILD_GEN=5 # TT-107: don't cache the BUILD dir + +TOPDIR=$PWD + +# CVSROOT is inherited from the environment +KERNELDIR= +LINUX= +LUSTRE= +RELEASE=false +# XXX - some recent hacking has pretty much neutered this option. +# search through this file for "-bb" and see how many places +# simply don't account for this option +DO_SRC=true +DOWNLOAD=true +TAG= +CANONICAL_TARGET= +TARGET= +TARGET_ARCH="$(uname -m)" +# change default behavior to only build for the current arch +TARGET_ARCHS="$TARGET_ARCH" +TARGET_ARCHS_ALL="$TARGET_ARCH" +[ "$TARGET_ARCH" = "i686" ] && TARGET_ARCHS_ALL="i686 i586 i386" +CONFIGURE_FLAGS= +EXTERNAL_PATCHES= +EXTRA_VERSION= +STAGEDIR= +TMPDIR=${TMPDIR:-"/var/tmp"} +TIMESTAMP= +# this is a dir to try reuse old kernel RPMs in (although, it seems to be +# unused in any real manner +REUSERPM= +# this is the dir that should be used to store reuse products +REUSEBUILD= +# should cached products be used or force rebuilding? +USE_BUILD_CACHE=true +# what does this do exactly? does it imply no kernel build? +NORPM=false +IOKITRPM=true +LDISKFSRPM=true +OSDLDISKFSRPM=true +OSDZFSRPM=false +SKIPLDISKFSRPM="v1_4_* b1_4" +SMPTYPES="smp bigsmp default ''" +PATCHLESS=false +XEN=false +LINUXOBJ= +DISTRO= +KERNELTREE= +# default to not adding -lustre- into the kernel RPM package names +KERNEL_LUSTRE_NAMING=false +# default not use kabi check. +USE_KABI=false + +# patchless build +KERNELRPMSBASE= +RPMSMPTYPE= + +# from target file +SERIES= +BASE_ARCHS= +BIGMEM_ARCHS= +BOOT_ARCHS= +JENSEN_ARCHS= +SMP_ARCHS= +BIGSMP_ARCHS= +PSERIES64_ARCHS= +UP_ARCHS= + +# not in the target file any more +CONFIG= + +# build the lustre-tests rpm? +LUSTRE_TESTS=true + +DATE=$(date) + +USE_DATESTAMP=1 +RPMBUILD= + +export CC=${CC:-gcc} + +# Readlink is not present on some older distributions: emulate it. +readlink() { + local path=$1 ll + + if [ -L "$path" ]; then + ll="$(LC_ALL=C ls -l "$path" 2> /dev/null)" && + echo "${ll/* -> }" + else + return 1 + fi +} + +usage() { + cat <] + + -d CVSROOT + Specifies the CVS Root to use when pulling files from CVS. The + environment variable \$CVSROOT is used if this option is not + present. + + --external-patches=EXTERNAL_PATCHES + Directory similar to lustre/lustre/kernel_patches/ that lbuild should + look for seres and config files in before looking in the lustre + tree. + + --extraversion=EXTRAVERSION + Text to use for the rpm release and kernel extraversion. + + --timestamp=TIMESTAMP + Date of building lustre in format YYYYMMDDhhmmss + + --reuserpm=DIR + Try to reuse old kernel RPMs from DIR + + --reusebuild=DIR + Try to reuse old kernel builds from DIR + + --kernelrpm=DIR + Path to distro kernel RPM collection + + --ccache + Use ccache + + --norpm + Do not build RPMs (compile only mode) + + --patchless + Build lustre client only + + --distro=DISTRO + Which distro using. Autodetect by default + + --kerneldir=KERNELDIR + Directory containing Linux source tarballs referenced by target + files. + + --kerneltree=KERNELTREE + Directory containing dirs with Linux source tarballs referenced by target + files. Dir names in format kernel version ('2.6.9', etc.) + + --linux=LINUX --with-linux=LINUX + Directory of Linux kernel sources. When this option is used, only + Lustre modules and userspace are built. + + --lustre=LUSTRE + Path to an existing lustre source tarball to use instead of + pulling from CVS. + + --nodownload + Do not try to download a kernel from downloads.lustre.org + + --nosrc + Do not build a .src.rpm, a full kernel patch, or a patched kernel + tarball. + + --ldiskfs + Do ldiskfs RPM. Now true by default + + --noiokit + Do not build lustre-iokit RPM. Now true by default + + --publish + Unused. + + --release + Specifies that the files generated do not include timestamps, and + that this is an official release. + + --src + Build a .src.rpm, a full kernel patch, and a patched kernel tarball. + + --stage=DIR + Directory used to stage packages for release. RPMs will be placed + more or less in DIR/-, and the tarball will be + placed in DIR. + + --tag=TAG + A CVS branch/tag name to build from when pulling from CVS. + + --target=TARGET + The name of the target to build. The available targets are listed + below. + + --target-archs=TARGET_ARCHS + A (space delimited) list of architectures to build. By default, + all of the archs supported by the TARGET will be built, in + addition to a .src.rpm. This option can limit those, for machines + that can only build certain archs or if you only want a certain + arch built (for testing, or a one-off kernel). + + Also note that by using a non-"base" arch (eg, i386) only kernels + will be built - there will be no lustre-lite-utils package. + + --disable-datestamp + Prevents the datestamp flag (-D) from being passed to cvs for + checkouts. This is a workaround for a problem encountered when + using lbuild with tinderbox. + + --xen + Builds a Xen domX kernel. + + --set-value + Set's a variable to a given value. + +EOF + +# list_targets + + fatal "$1" "$2" +} + +# canonicalize a relative path to a file +canon_filepath() { + local PATH="$1" + + if [ ! -f "$PATH" ]; then + return 1 + fi + + local FILE=${PATH##*/} + local DIR=${PATH%/*} + + echo $(canon_path "$DIR")/$FILE + return 0 +} + +# canonicalize a relative path to a dir +canon_path() { + local PATH="$1" + + if [ ! -d "$PATH" ]; then + return 1 + fi + + pushd "$PATH" >/dev/null || return 1 + local CANONPATH=$PWD + popd >/dev/null + + echo "$CANONPATH" + return 0 +} + +check_options() { + + if [ "$LUSTRE" ]; then + [ -r "$LUSTRE" ] || \ + usage 1 "Could not find Lustre source tarball '$LUSTRE'." + else + [ "$CVSROOT" ] || \ + usage 1 "Either specify a CVS Root with -d, or a Lustre source tarball with --lustre." + [ "$TAG" ] || \ + usage 1 "A branch/tag name must be specified with --tag when not building from a tarball." + fi + + [ -z "$DISTRO" ] && DISTRO=$(autodetect_distro) + + if [ -z "$LINUX" ]; then + [ "$KERNELDIR" -o "$KERNELTREE" ] || \ + usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree." + + [ -d "$KERNELDIR" -o -d "$KERNELTREE" ] || \ + usage 1 "$KERNELDIR and $KERNELTREE are not a directory." + + if ! $RELEASE; then + [ "$TAG" ] || \ + usage 1 "When building a snapshot, a tag name must be used." + fi + + [ "$TARGET" ] || TARGET=$(autodetect_target "$DISTRO") +# TARGET_FILE="$TOPDIR/lustre/kernel_patches/targets/$TARGET.target" +# [ -r "$TARGET_FILE" ] || \ +# usage 1 "Target '$TARGET' was not found." + fi + + case $TARGET in + 2.6-rhel6) + CANONICAL_TARGET="rhel6" + ;; + 2.6-rhel5) + CANONICAL_TARGET="rhel5" + ;; + 2.6-rhel4) + CANONICAL_TARGET="rhel-2.6" + ;; + 2.6-suse) + CANONICAL_TARGET="sles-2.6" + ;; + 2.6-sles10) + CANONICAL_TARGET="sles10-2.6" + ;; + 2.6-sles11 | 3.0-sles11) + CANONICAL_TARGET="sles11" + ;; + 2.6-oel5) + CANONICAL_TARGET="oel5" + ;; + hp_pnnl-2.4) + CANONICAL_TARGET="hp-pnnl-2.4" + ;; + 2.6-vanilla \ + | suse-2.4.21-2 \ + | rh-2.4 \ + | rhel-2.4 \ + | sles-2.4 \ + | 2.6-patchless) + CANONICAL_TARGET="$TARGET" + ;; + esac + + local timestampnodig=$(echo $TIMESTAMP | sed -e s/[0-9]*//g) + [ "$timestampnodig" = "" ] || TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S") + local timestamplength="${#TIMESTAMP}" + if [ $timestamplength -eq 12 ]; then + TIMESTAMP="${TIMESTAMP}00" + elif [ $timestamplength -ne 14 ]; then + TIMESTAMP=$(date -d "$DATE" "+%Y%m%d%H%M%S") + fi + + RPMBUILD=$(which rpmbuild 2>/dev/null | head -1) + if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then + RPMBUILD=$(which rpm 2>/dev/null | head -1) + if [ ! "$RPMBUILD" -o "$RPMBUILD" == "" ]; then + usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)." + fi + fi + + if [ -n "$CCACHE" ]; then + which "$DISTCC" &>/dev/null && export DISTCC RPM_BUILD_NCPUS + + if which "$CCACHE" &>/dev/null; then + local ccache=$(which "$CCACHE") + local bindir="$TOPDIR/bin" + + if [ ! -d $bindir ]; then + mkdir -p $bindir || fatal 1 "error trying to create $bindir" + else + rm ${bindir}/* > /dev/null 2>&1 || true + fi + ln -s "$ccache" ${bindir}/ccache + ln -s "$ccache" ${bindir}/cc + ln -s "$ccache" ${bindir}/$CC + export PATH=$bindir:$PATH + export CCACHE && export CC="ccache $CC" + # zero the cache so we can see how effective we are being with it + echo -n "ccache " + ccache -z + + # get some ccache stats when we are done + push_exit_trap '[ -n "$CCACHE" ] && ccache -s' "ccache_summary" + # should remove the ccache trap if lbuild is interrupted + trap 'echo "Received an INT TERM or HUP signal, terminating."; delete_exit_trap "ccache_summary"; exit 1' INT TERM HUP + fi + fi + + return 0 + +} + +# compare two versions $1 and $2. if $1 < $2, return 0 otherwise return 1. +compare_version () { + [[ $1 == $2 ]] && return 1 + local IFS=. + local i val1=($1) val2=($2) + + # padding zero to val1 if it needs + for ((i=${#val1[@]}; i<${#val2[@]}; i++)); do + val1[i]=0 + done + for ((i=0; i<${#val1[@]}; i++)); do + [[ -z ${val2[i]} ]] && return 1 + + if [[ ${val1[i]} < ${val2[i]} ]]; then + return 0 + elif [[ ${val1[i]} > ${val2[i]} ]]; then + return 1 + fi + done +} + +uniqify() { + + echo $(echo "$*" | xargs -n 1 | sort -u) + +} + +fetch_url() { + local url="$1" + local target="$2" + + local rc=0 + if which wget >/dev/null 2>&1; then + if ! wget -nv "$url" -O "$target"; then + rc=${PIPESTATUS[0]} + fi + elif which curl >/dev/null 2>&1; then + if ! curl -L -s -o "$target" "$url"; then + rc=${PIPESTATUS[0]} + fi + else + fatal 1 "Could not find either wget or curl to fetch URLs." + fi + + return $rc + +} + +download_srpm() { + local target=$1 + local srpm=$2 + local force="${3:-false}" + + if $force || [ ! -r "$KERNELDIR/$srpm" ] || + [ ! -s "$KERNELDIR/$srpm" ]; then + if $DOWNLOAD; then + local location="http://downloads.lustre.org/public/kernels/$target/old" + # get the location from a distro specific method if it exists + if type -p kernel_srpm_location; then + location=$(kernel_srpm_location) + fi + echo "Downloading $location/$srpm..." + if ! fetch_url "$location/$srpm" "$KERNELDIR/$srpm" 2>&1 || + [ ! -s "$KERNELDIR/$srpm" ]; then + rm -f $KERNELDIR/$srpm + # punt to a distro specific method if it exists + if ! type -p download_srpm-$DISTRO; then + fatal 1 "Could not download target $target's kernel SRPM $srpm from $location." + else + if ! download_srpm-$DISTRO "$target" "$srpm" "$force"; then + fatal 1 "Could not download target $target's kernel SRPM $srpm using download_srpm-$DISTRO." + fi + fi + fi + else + fatal 1 "$srpm not found in directory $KERNELDIR." + fi + fi + +} + +download_file() { + local from="$1" + local to="$2" + local force="$3" + + local file=${from##*/} + + if [ -d $to ]; then + to="$to/$file" + fi + + local semaphore="$to-downloading" + + is_downloading() { + if [ ! -f $semaphore ]; then + return 1 + fi + + # make sure the download has not been aborted + local now=$(date +%s) + local file_mtime=$(stat -c %Y "$to") + local staleness=$((now - file_mtime)) + # let's assume an active download will write at least once a minute + if [ $staleness -gt 60 ]; then + return 1 + fi + + return 0 + } + + is_downloaded() { + # if the semaphore file exists, the file is either still downloading + # or a download was aborted and we cannot trust the target file + if [ -f $semaphore ]; then + return 1 + fi + + if ! is_downloading && [ -r "$to" ] && [ -s "$to" ]; then + return 0 + fi + + return 1 + } + + if $force || ! is_downloaded; then + if is_downloading; then + echo "Somebody else is downloading $from..." + while is_downloading; do + echo "Waiting for $to to finish downloading" + sleep 60 + done + if is_downloaded; then + return 0 + else + echo "The download we were waiting for seems to have been aborted" + fi + + fi + + if $DOWNLOAD; then + echo "Downloading $from..." + # flag others so they don't try to download also + push_exit_trap "rm -f $to $semaphore" "download" + touch $semaphore + if ! fetch_url "$from" "$to" || [ ! -s "$to" ]; then + # the trap will remove the files via the fatal below + fatal 1 "Could not download ${to##*/} from ${from%/*}/." + fi + rm -f $semaphore + delete_exit_trap "download" + else + fatal 1 "${to##*/} not found in directory ${to%/*}." + fi + fi + + return 0 + +} + +download_ofed() { + local force="${1:-false}" + + if [ -z "$OFED_VERSION" -o "$OFED_VERSION" = "inkernel" ]; then + return 0 + fi + + local OFED_BASE_VERSION=$OFED_VERSION + if [[ $OFED_VERSION = *.*.*.* ]]; then + OFED_BASE_VERSION=${OFED_VERSION%.*} + fi + + local location="http://www.openfabrics.org/downloads/OFED/ofed-${OFED_BASE_VERSION}/" + + if [[ $OFED_VERSION = *-rc[0-9] ]]; then + local Mmv + Mmv=${OFED_VERSION%%-*} + location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}/" + fi + + if [[ $OFED_VERSION = daily-* ]]; then + local Mmv daily + OFED_VERSION=${OFED_VERSION/daily-/} + Mmv=${OFED_VERSION%%-*} + daily=${OFED_VERSION##$Mmv-} + location="http://www.openfabrics.org/downloads/OFED/ofed-${Mmv}-daily/" + # find the filename for the version for the date specified + OFED_VERSION=$(curl -s "$location" | sed -nre "/${daily}-/s/.*href=\"OFED-(${Mmv//./\\.}-${daily}-[0-9]{4,4}).tgz.*$/\1/p" | tail -1) + if [ -z "$OFED_VERSION" ]; then + fatal 1 "Could not determine the filename of the OFED snapshot for ${daily}" + fi + fi + + local file="OFED-${OFED_VERSION}.tgz" + download_file "$location/$file" "$KERNELTREE" "$force" + +} + +load_target() { + + EXTRA_VERSION_save="$EXTRA_VERSION" + for patchesdir in "$EXTERNAL_PATCHES" \ + "$TOPDIR/lustre/lustre/kernel_patches"; do + TARGET_FILE="$patchesdir/targets/$TARGET.target" + [ -r "$TARGET_FILE" ] && break + done + [ -r "$TARGET_FILE" ] || fatal 1 "Target $TARGET was not found." + + echo "Loading target config file $TARGET.target..." + + # if the caller specified an OFED_VERSION it should override whatever + # the target file specifies + local env_OFED_VERSION="$OFED_VERSION" + + . "$TARGET_FILE" + + if [ -n "$env_OFED_VERSION" ]; then + OFED_VERSION="$env_OFED_VERSION" + fi + + # doesn't make any sense to build OFED for xen domX's + if $XEN; then + OFED_VERSION="" + fi + + # XXX - set_rpm_smp_type is an ugly undeterministic hack. it needs to + # go away and the target just specify the $RPMSMPTYPE + [ -z "$RPMSMPTYPE" ] && set_rpm_smp_type + + # CC might have been overwriten in TARGET_FILE + if [[ $CC != ccache\ * ]] && which "$CCACHE" &>/dev/null; then + export CCACHE && export CC="ccache $CC" + fi + + if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then + KERNELDIR="$KERNELTREE/${lnxmaj}" + [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR" + fi + + # verify the series is available + if [ "$SERIES" ]; then + for series in $SERIES; do + for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do + [ -r "$patchesdir/series/$series" ] && continue 2 + done + fatal 1 "Target $TARGET's series $SERIES could not be found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n\t$TOPDIR/lustre/lustre/kernel_patches/series." + done + fi + + # set the location of the .config file + local XENPOSTFIX="" + if $XEN; then + XENPOSTFIX="-xen" + fi + + if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then + CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH${RPMSMPTYPE:+-}${RPMSMPTYPE}.config" + fi + + local lnxrelnew=${lnxrel//-/_} + + # remember the EXTRA_VERSION before we diddle it here + # XXX - we really should not diddle with any values read in from the + # target file. if we want to modify a value, we should create + # a new variable. + PRISTINE_EXTRA_VERSION=$EXTRA_VERSION + + if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then + fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/." + fi + + if [ "$EXTRA_VERSION_save" ]; then + EXTRA_VERSION="$EXTRA_VERSION_save" + elif ! $RELEASE; then + # if there is no patch series, then this is not a lustre specific + # kernel. don't make it look like one + if $PATCHLESS || [ -n "$SERIES" ]; then + EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/") +# EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}" + if ! $PATCHLESS && [ -n "$BUILDID" ]; then + EXTRA_VERSION="${EXTRA_VERSION}.${BUILDID}" + fi + fi + fi + # EXTRA_VERSION=${EXTRA_VERSION//-/_} + + ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS" + + BUILD_ARCHS= + for arch in $(uniqify "$ALL_ARCHS"); do + if [ -z "$TARGET_ARCHS" ] || + [[ \ $TARGET_ARCHS\ = *\ $arch\ * ]]; then + BUILD_ARCHS="$BUILD_ARCHS $arch" + fi + done + [ "$BUILD_ARCHS" ] || usage 1 "No available target archs to build." + echo "Building for: $BUILD_ARCHS" +} + +tarflags() { + local file="$1" + + case "$file" in + '') + fatal 1 "tarflags(): File name argument missing." + ;; + *.tar.gz | *.tgz) + echo 'zxf' + ;; + *.tar.bz2) + echo 'jxf' + ;; + *.tar) + echo 'xf' + ;; + *) + fatal 1 "tarflags(): Unrecognized tar extension in file: $1" + ;; + esac + +} + +untar() { + local tarfile="$1" + shift + local extractfile="$@" + + echo "Untarring ${tarfile##*/}..." + tar $(tarflags "$tarfile") "$tarfile" $extractfile + +} + +unpack_ofed() { + + if ! untar "$KERNELTREE/OFED-${OFED_VERSION}.tgz"; then + return 1 + fi + [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED + +} + +unpack_lustre() { + + if [ -z "$LUSTRE" ]; then + local DATESTAMP="" + + if [ -n "$USE_DATESTAMP" ]; then + DATESTAMP="-D '$DATE'" + fi + + local DIRNAME="lustre-$TAG-$TIMESTAMP" + + cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \ + fatal 1 "There was an error checking out toplevel Lustre from CVS." + pushd "$DIRNAME" > /dev/null + ./lustrecvs "$TAG" || \ + fatal 1 "There was an error checking out Lustre/Portals/Build from CVS." + echo "Creating lustre tarball..." + sh autogen.sh || fatal 1 "There was an error running autogen.sh." + ./configure --enable-dist || \ + fatal 1 "There was an error running ./configure to create makefiles." + make dist || fatal 1 "There was an error running 'make dist'." + LUSTRE=$PWD/lustre-*.tar.gz + popd > /dev/null + fi + + untar "$LUSTRE" || fatal 1 "Error unpacking Lustre tarball" + [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre + +} + +do_patch_linux() { + + local do_patch=${1:-true} + + FULL_PATCH="$PWD/lustre-kernel-${TARGET}-${EXTRA_VERSION}.patch" + [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH" + $do_patch && pushd linux >/dev/null + for series in $SERIES; do + echo -n "Applying series $series:" + for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do + [ -r "$patchesdir/series/$series" ] || continue + SERIES_FILE="$patchesdir/series/$series" + for patch in $(<"$SERIES_FILE"); do + echo -n " $patch" + PATCH_FILE="$patchesdir/patches/$patch" + [ -r "$PATCH_FILE" ] || \ + fatal 1 "Patch $patch does not exist in Lustre tree." + cat "$PATCH_FILE" >> "$FULL_PATCH" || { + rm -f $FULL_PATCH + fatal 1 "Error adding patch $patch to full patch." + } + if $do_patch; then + patch -s -p1 < "$PATCH_FILE" 2>&1 || { + rm -f $FULL_PATCH + fatal 1 "Error applying patch $patch." + } + fi + done + break + done + echo + done + $do_patch && popd >/dev/null + echo "Full patch has been saved in ${FULL_PATCH##*/}." + +} + +build_iokit() { + local rpmbuildopt="$1" + + pushd lustre-iokit > /dev/null || return 255 + + if ! ./configure; then + echo "failed to configure in lustre-iokit" + popd >/dev/null # pushd lustre-iokit + return 255 + fi + + if ! make dist; then + echo "failed to make dist in lustre-iokit" + popd >/dev/null # pushd lustre-iokit + return 255 + fi + + if ! $RPMBUILD $rpmbuildopt lustre-iokit*.tar.gz \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + popd >/dev/null # pushd lustre-iokit + return 255 + fi + + if $DO_SRC && ! $RPMBUILD -ts lustre-iokit*.tar.gz \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + popd >/dev/null # pushd lustre-iokit + return 255 + fi + popd >/dev/null # pushd lustre-iokit +} + +build_lustre() { + local linux="$1" + local linuxobj="$2" + + cp "$LUSTRE" SOURCES + + pushd lustre >/dev/null + + echo "Building Lustre RPMs for: $BUILD_ARCHS..." + local targets arch + for arch in $BUILD_ARCHS; do + targets="--target $arch $targets" + done + + local confoptions="" + + if $PATCHLESS; then + confoptions="$confoptions --disable-server" + fi + + local rpmbuildopt='-tb' + if $NORPM; then + rpmbuildopt='-tc' + echo NORPM mode. Only compiling. + fi + + # If server we now build the spl and zfs modules against the lustre kernel. + # These are required prior to the building of lustre server. Client does + # not require spl/zfs. Use !PATCHLESS to indicate server which follows the + # line above so is at least consistant. + if [ $PATCHLESS == false ] && [ "x$ZFSNOTSUPPORTED" == "x" ]; then + if ! build_spl_zfs; then + popd >/dev/null # pushd lustre + return 255 + fi + fi + + ( $(skeep_ldiskfs_rpm $TAG) ) || { + + pushd ldiskfs > /dev/null || return 255 + + if ! ./configure --enable-dist; then + echo "failed to configure in ldiskfs" + popd >/dev/null # pushd ldiskfs + popd >/dev/null # pushd lustre + return 255 + fi + + if ! make dist 2>&1; then + popd >/dev/null # pushd ldiskfs + popd >/dev/null # pushd lustre + return 255 + fi + + #cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES || \ + # fatal 1 "Could not copy lustre-ldiskfs*.tar.gz to $TOPDIR/SOURCES" + + if ! $RPMBUILD $targets $rpmbuildopt lustre-ldiskfs*.tar.gz \ + --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ + --define "kdir $linux" \ + ${linuxobj:+--define "kobjdir $linuxobj"} \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + popd >/dev/null # pushd ldiskfs + popd >/dev/null # pushd lustre + return 255 + fi + + if $DO_SRC; then + if ! $RPMBUILD -ts lustre-ldiskfs*.tar.gz \ + --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ + --define "kdir $linux" \ + ${linuxobj:+--define "kobjdir $linuxobj"} \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + popd >/dev/null # pushd ldiskfs + popd >/dev/null # pushd lustre + return 255 + fi + fi + popd >/dev/null # pushd ldiskfs + + # tell lustre where ldiskfs is + # XXX - pointing to the RPM BUILD dir is a hack. we need to flesh + # out the ldiskfs RPM build so that it builds a + # lustre-ldiskfs-devel RPM and install that and point lustre + # to that instead + confoptions="$confoptions --with-ldiskfs=$(ls -d $TOPDIR/BUILD/lustre-ldiskfs-*)" + } + + if $IOKITRPM; then + if ! build_iokit $rpmbuildopt; then + echo "failed to build lustre-iokit" + popd >/dev/null # pushd lustre + return 255 + fi + fi + + # convert the $PATCHLESS boolean to an empty/not-empty boolean + # as silly as this seems, it makes the syntax of the rpmbuild command + # simpler and not need an eval to deal with the quotes in the quotes + local is_patchless="" + if $PATCHLESS; then + is_patchless="yes" + fi + + # ditto for the lustre-tests boolean + local lustre_tests="" + if ! $LUSTRE_TESTS; then + lustre_tests="no" + fi + + local osd_zfs="" + if $OSDZFSRPM; then + osd_zfs="yes" + fi + + local osd_ldiskfs="" + if $OSDLDISKFSRPM; then + osd_ldiskfs="yes" + fi + + $RPMBUILD $targets $rpmbuildopt "$LUSTRE" \ + ${is_patchless:+--define "lustre_name lustre-client"} \ + ${lustre_tests:+--define "build_lustre_tests 0"} \ + ${osd_zfs:+--define "build_lustre_osd_zfs 1"} \ + ${osd_ldiskfs:+--define "build_lustre_osd_ldiskfs 1"} \ + ${FIND_REQUIRES:+--define "__find_requires $FIND_REQUIRES"} \ + --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ + --define "kdir $linux" \ + ${linuxobj:+--define "kobjdir $linuxobj"} \ + --define "_tmppath $TMPDIR" \ + --define "_topdir $TOPDIR" 2>&1 || \ + fatal 1 "Error building rpms for $BUILD_ARCHS." + + if $DO_SRC; then + if ! $RPMBUILD -ts "$LUSTRE" \ + ${is_patchless:+--define "lustre_name lustre-client"} \ + ${lustre_tests:+--define "build_lustre_tests 0"} \ + ${FIND_REQUIRES:+--define "__find_requires $FIND_REQUIRES"} \ + --define "configure_args $confoptions ${CONFIGURE_FLAGS}" \ + --define "kdir $linux" \ + ${linuxobj:+--define "kobjdir $linuxobj"} \ + --define "_tmppath $TMPDIR" \ + --define "_topdir $TOPDIR" 2>&1; then + popd + return 255 + fi + fi + popd >/dev/null + +} + +### +# build_spl_zfs +# +# Fetch spl/zfs from the git repo and prepare for lustre build +# +# return 0 if successful, else 255 +build_spl_zfs() { + # make sure the RPM build environment is set up + create_rpmbuild_dirs + + # The spl/zfs spec files expect RPM_BUILD_ROOT to point to the root of the + # destination for the rpms + export RPM_BUILD_ROOT=$TOPDIR + + # The files expect a kver to be set to the kernel version . + kver=$(cat ${LINUX}/include/config/kernel.release) + + # build and install the spl and zfs (and -devel) RPMs for lustre to use + local pkg + for pkg in spl zfs; do + + local rpmmod spldir + + [ "$pkg" == "zfs" ] && spldir="$(ls -d $TOPDIR/usr/src/spl-*/*)" + rpmmod=$pkg-modules + + # need to fetch the repo in order to build it. + # default to github but allow override + git clone ${SPLZFSGITREPO:-"https://github.com/zfsonlinux"}/$pkg.git $pkg 2>&1 + + pushd $pkg || return 255 + + # XXX - _having_ to give a package a kernel just to have it configure + # enough to do a "make dist" is truely bogus! + if ! ./configure --with-linux=${LINUX} \ + ${spldir:+--with-spl="${spldir}"} 2>&1 || + ! make dist 2>&1; then + popd + return 255 + fi + popd + + # XXX - dirty hack time. ~sigh~ + # because the spl tarball contains two .spec files, we cannot + # simply rebuild the tarball + ln $pkg/$pkg-*.tar.gz $TOPDIR/SOURCES || + error "failed to link $pkg/$pkg-*.tar.gz into $TOPDIR/SOURCES" + + # First build the userspace tools RPMs + if ! $RPMBUILD $targets -bb $pkg/$pkg.spec \ + --nodeps -v \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + + if $DO_SRC; then + if ! $RPMBUILD -bs $pkg/$pkg.spec \ + --nodeps -v \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + fi + + # Now the kernel module RPMs + # Need to provide pointers to the lustre kernel source, objects, usr/src + if ! $RPMBUILD $targets -bb $pkg/$rpmmod.spec \ + --nodeps -v \ + --define "require_kdir ${linux}" \ + ${linuxobj:+--define "require_kobj ${linuxobj}"} \ + ${spldir:+--define "require_spldir ${spldir}"} \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_usrsrc $TOPDIR/usr/src" \ + --define "kver $kver" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + + if $DO_SRC; then + if ! $RPMBUILD -bs $pkg/$rpmmod.spec \ + --nodeps -v \ + --define "require_kdir ${linux}" \ + ${linuxobj:+--define "require_kobj ${linuxobj}"} \ + ${spldir:+--define "require_spldir ${spldir}"} \ + --define "configure_args ${CONFIGURE_FLAGS}" \ + --define "_usrsrc $TOPDIR/usr/src" \ + --define "kver $kver" \ + --define "_tmppath /var/tmp" \ + --define "_topdir $TOPDIR" 2>&1; then + return 255 + fi + fi + + # We have built the rpms for the package. No we need to extract the + # contained files so we can build further things against them + local rpm=$(ls $TOPDIR/RPMS/*/$rpmmod-devel-*.rpm) + + # cpio only extract to pwd so we need to go there. + pushd $TOPDIR + rpm2cpio < $rpm | cpio -id + popd + + CONFIGURE_FLAGS="--with-$pkg=$(ls -d $TOPDIR/usr/src/$pkg-*/*) ${CONFIGURE_FLAGS}" + done + + OSDZFSRPM=true + + return 0 +} + +stage() { + + [ "$STAGEDIR" ] || return 0 + + for arch in $BUILD_ARCHS; do + rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}" + echo "${0##*/}: Copying RPMs into ${rpmdir}" + mkdir -p "${rpmdir}" + cp -v RPMS/${arch}/*.rpm "${rpmdir}" + if [ -d RPMS/noarch ]; then + cp -v RPMS/noarch/*.rpm "${rpmdir}" + fi + done + + cp -v "$LUSTRE" "$STAGEDIR" + +} + +#check if we need to build separate ldiskfs RPM +skeep_ldiskfs_rpm() { + local tag="$1" + + local skip=false + + if ! $LDISKFSRPM; then + skip=true + elif $PATCHLESS; then + skip=true + else + for skiptag in $SKIPLDISKFSRPM; do + [[ $tag == $skiptag ]] && skip=true && break + done + fi + + echo $skip + +} + +set_rpm_smp_type() { + + local infact_arch="${TARGET_ARCH}" + + RPMSMPTYPE="" + [ "$infact_arch" == "i586" ] && infact_arch="i686" + + local smp_type + for smp_type in $SMP_ARCHS; do + [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break + done + + for smp_type in $BIGSMP_ARCHS; do + [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break + done + + for smp_type in $PPC64_ARCHS; do + [ $infact_arch == $smp_type ] && RPMSMPTYPE=ppc64 && break + done + + for smp_type in $DEFAULT_ARCHS; do + [ $infact_arch == $smp_type ] && RPMSMPTYPE=default && break + done + +} + +# This function takes a linux source pool and digs out the linux release +# from it +find_linux_release() { + local SRCDIR="$1" + + local LINUXRELEASEHEADER=$SRCDIR/include/linux/version.h + if [ -s $SRCDIR/include/linux/utsrelease.h ]; then + LINUXRELEASEHEADER=$SRCDIR/include/linux/utsrelease.h + fi + + sed -ne 's/#define UTS_RELEASE "\(.*\)"$/\1/p' $LINUXRELEASEHEADER + +} + +# unpack kernel(/source/devel) RPM +# +# This function and it's setting of $LINUX and $LINUXOBJ is a total hack that +# needs to completely refactored. It completely ingores that $BUILD_ARCHS may +# contain a list of arches for which rpmbuild commands (including the one for +# lustre itself) +unpack_linux_devel_rpm() { + local kernelrpm="${1}" + + [ -f "$kernelrpm" ] || return 255 + [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused || return 255 + + pushd $TOPDIR/reused &>/dev/null || return 255 + + if ! rpm2cpio < "$kernelrpm" | cpio -id > /dev/null 2>&1; then + return 255 + fi + + # call a distro specific hook, if available + if type -p unpack_linux_devel_rpm-$DISTRO; then + if ! unpack_linux_devel_rpm-$DISTRO "$kernelrpm"; then + return 255 + fi + fi + + popd &>/dev/null + + find_linux_devel_paths $TOPDIR/reused + + return 0 + +} + +build_kernel_ib() { + local linux="$1" + local kib_prefix="$2" + local kib_rpm="$3" + + # build kernel-ib{,-devel}/compat-rdma{,-devel} + local K_SRC="K_SRC" + # ofed 1.3 had a bug in the rpm spec + if [ "$OFED_VERSION" = "1.3" ]; then + K_SRC="KSRC" + fi + + local OFED_CORE="--with-core-mod --with-ipoib-mod --with-sdp-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod" + local OFED_HARDWARE="--with-mthca-mod --with-mlx4-mod --with-mlx4_en-mod --with-cxgb3-mod --with-nes-mod" + + if compare_version $OFED_VERSION 3.0; then + OFED_CORE="$OFED_CORE --with-madeye-mod --with-rds-mod" + else + OFED_HARDWARE="$OFED_HARDWARE --with-cxgb4-mod" + fi + + # some I/B drivers are architecture dependent and kernel-ib's configure + # does not figure it out for us ~sigh~ + case "$TARGET_ARCH" in + ppc64) + OFED_HARDWARE="$OFED_HARDWARE --with-ehca-mod" + ;; + esac + # we're no longer shipping the OFED iSCSI target + #OFED_ISCSI="--with-srp-mod --with-srp-target-mod" + OFED_ISCSI="--with-srp-mod" + ## ISER module has no backport support as of OFED 1.5 (i.e. only builds on + ##kernels >= 2.6.30) + #if [[ $OFED_VERSION = 1.[0-4]* ]]; then + # OFED_ISCSI="$OFED_ISCSI --with-iser-mod" + #fi + + # assume we are just rebuilding the SRPM + local BUILD_TYPE=${BUILD_TYPE:-"--rebuild"} + local SOURCE="${TOPDIR}/OFED/SRPMS/${kib_prefix}-*.src.rpm" + + # but switch to building from the SPEC if we need to apply patches + if ls ${TOPDIR}/lustre/build/patches/ofed/* >/dev/null; then + BUILD_TYPE="-bb" + rpm --define "_topdir ${TOPDIR}" -ivh $SOURCE + SOURCE="${TOPDIR}/SPECS/${kib_prefix}.spec" + local file ed_fragment1 ed_fragment2 n=1 + for file in $(ls ${TOPDIR}/lustre/build/patches/ofed/*.patch); do + ed_fragment1="$ed_fragment1 +Patch$n: ${file%%*/}" + ed_fragment2="$ed_fragment2 +%patch$n -p0" + cp $file ${TOPDIR}/SOURCES + let n=$n+1 + done + for file in $(ls ${TOPDIR}/lustre/build/patches/ofed/*.ed); do + ed_fragment3="$ed_fragment3 +$(cat $file)" + let n=$n+1 + done + + if [ $n -gt 1 ]; then + ed $SOURCE <&1; then + fatal 1 "Error building ${kib_rpm}" + fi + +} + +store_for_reuse() { + local articles="$1" + local module="$2" + local location="$3" + local signature="$4" + local use_links="$5" + + local linkflag="" + if $use_links; then + linkflag="l" + fi + + local default_iface=$(/sbin/ip route get 192.1.1.1 | sed -ne 's/.* dev \(.*\) * src .*/\1/p') + if [ -z "$default_iface" ]; then + fatal 1 "Failed to determine the default route interface" + fi + local unique_id=$(/sbin/ip addr show dev $default_iface | sed -ne '/ inet /s/ *inet \(.*\)\/.*/\1/p' | head -1) + if [ -z "$unique_id" ]; then + fatal 1 "Failed to determine a unique id from interface $default_interface" + fi + + local finallocation="$location"/"$signature"/"$module" + location="$location"/"$signature-${unique_id}"/"$module" + mkdir -p "$location" + # the cleanup script removes any directory that doesn't have a + # .lastused, so let's try to prevent that as soon as we can + # this solution still slightly racy with the cleanup script + # but the race is a lot tighter now + touch -t 197001010000 "$location/.lastused" + ## use eval/echo here to make sure shell expansions are performed + #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then + local article + for article in $(eval echo $articles); do + if ! cp -a${linkflag} "$article" "$location"; then + error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()" + # rename the cache location so that it's not cached + # product, but is around for analysis + mv "$location"{,-bad-$(date +%s)} || + error "failed to clean up a failed cache attempt" \ + "in \"$location\" -- manual cleanup will be" \ + "necessary" + return 1 + fi + done + + # flag the cache as complete (i.e. in case lbuild was previously + # interrupted while caching) + touch "$location/.lastused" + + # put the temporary location into the final location + # (last one wins) + mkdir -p "${finallocation%/*}" + mv "$location" "$finallocation" + rmdir "${location%/*}" + return 0 + +} + +reuse() { + local module="$1" + local dest="$2" + local use_links="${3:-false}" + local signature="$4" + + if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then + if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then + # the .lastused flag is populated at the end of the caching to + # signal that the caching was completed. if that flag is not + # there, then the cache is invalid (and should be removed in fact) + mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} || + fatal 1 "failed to clean up a bad cache in location $REUSEBUILD/$signature/$module\" -- manual cleanup will be necessary" + return 1 + fi + + # so that we know how stale this entry is + touch $REUSEBUILD/$signature/$module/.lastused + + if $use_links; then + if ls $REUSEBUILD/$signature/$module/* >/dev/null 2>&1; then + cp -al $REUSEBUILD/$signature/$module/* $dest/ + fi + else + # copying is pretty heavy + # cp -a $REUSEBUILD/$signature/$module/* $dest/ + # do some creative symlinking instead + local dir + for dir in BUILD SRPMS SPECS; do + if ls $REUSEBUILD/$signature/$module/$dir/* >/dev/null 2>&1; then + ln -s $REUSEBUILD/$signature/$module/$dir/* $dest/$dir + fi + done + # sources have to be copied by file because we need SOURCES to + # be a dir we can write into +# could overrun ls's arg list here + #ls $REUSEBUILD/$signature/$module/SOURCES/* | + find $REUSEBUILD/$signature/$module/SOURCES/ -type f | + xargs ln -t $dest/SOURCES -s + + # same for RPMS/* dirs +# could overrun ls's arg list here + #ls $REUSEBUILD/$signature/$module/RPMS/$TARGET_ARCH/* | + local dir + for dir in $REUSEBUILD/$signature/$module/RPMS/*; do + mkdir -p $dest/RPMS/${dir##*/} + find $dir -type f | + xargs ln -t $dest/RPMS/${dir##*/} -s + done + fi + return 0 + else + return 1 + fi +} + +basearch() { + local arch="$1" + + if [[ $arch = i[3456]86 ]]; then + echo "i386" + else + echo "$arch" + fi + +} + +build_kernel_with_srpm() { + local outfd=$1 + + if [ -z "$outfd" ] || [ $outfd = 1 ]; then + fatal 1 "You must supply a file descriptor to ${FUNCNAME[0]} and it cannot be 1" + fi + + # need to generate the patch for this target + do_patch_linux false >&${outfd} # sets global $FULL_PATCH (yeah, yuck) + + # get an md5sum of the kernel patch + config for reuse check + # XXX really, there needs to be a signature and a CONFIG_FILE per arch + # in BUILD_ARCHS + local release_str + if $RELEASE; then + local release_str="RELEASE=$RELEASE\n" + fi + + if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then + local REUSE_SIGNATURE=$({ echo -en $release_str; + echo $BUILD_GEN; + cat $CONFIG_FILE $TARGET_FILE $FULL_PATCH; } | + md5sum | cut -d" " -f1) + # see if we can link to the reuse pool + # XXX - hrm. i'm not convinced this doesn't belong in the reuse + # "library" + local CAN_LINK_FOR_REUSE=false + touch $REUSEBUILD/$$ + if cp -al $REUSEBUILD/$$ $TOPDIR/ 2>/dev/null; then + CAN_LINK_FOR_REUSE=true + fi + rm $REUSEBUILD/$$ + fi + + # the extra version string to use for the kernel (which might be a reused + # kernel, remember) + local kernel_extra_version="" + if ! $USE_BUILD_CACHE || ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \ + "$REUSE_SIGNATURE"; then + # nothing cached, build from scratch + if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then + echo "Downloading kernel SRPM" >&${outfd} + download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&${outfd} + fi + + if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \ + --define "_topdir $TOPDIR" >&${outfd} 2>&1; then + # should we clean this up or leave it for analysis? + #rm -rf $RPMTOPDIR + fatal 1 "Error installing kernel SRPM." + fi + + # put the Lustre kernel patch into the RPM build tree + cp $FULL_PATCH $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch + prepare_and_build_srpm >&${outfd} || + fatal 1 "failed to prepare_and_build_srpm" + + if [ -z "$REUSE_SIGNATURE" ]; then + echo "No reuse signature was caculated so not storing the built kernel" >&${outfd} + else + # store the resulting kernel RPM build tree for future use + echo "Storing the built kernel for future reuse" >&${outfd} + if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,SRPMS,RPMS}" \ + "kernel" "$REUSEBUILD" "$REUSE_SIGNATURE" \ + "$CAN_LINK_FOR_REUSE"; then + error "Failed to store kernel RPMS for reuse" + echo "unknown" >&${outfd} + return 1 + fi + fi + fi # build reuse + + # figure out the EXTRA_VERSION of the kernel we built or are re-using + local KERNEL_RPM + if ! KERNEL_RPM=$(find_rpm "$TOPDIR/RPMS/$TARGET_ARCH/" provides "^kernel ="); then + fatal 1 "Failed to find a kernel RPM in $TOPDIR/RPMS/$TARGET_ARCH/" + fi + kernel_extra_version=$(rpm -q --queryformat "%{RELEASE}" -p $TOPDIR/RPMS/$TARGET_ARCH/$KERNEL_RPM) + + # should now have the following RPMs + # $TOPDIR/RPMS/$arch/kernel-lustre-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm + # $TOPDIR/RPMS/$arch/kernel-lustre-devel-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm + # $TOPDIR/RPMS/$arch/kernel-lustre-headers-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm + # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-common-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm + # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm + + echo $kernel_extra_version + return 0 + +} + +# build OFED +# globals used: +# TOPDIR +# REUSEBUILD, USE_BUILD_CACHE +# CONFIGURE_FLAGS + +build_ofed() { + local linux="$1" + local ofed_version="$2" + local kib_prefix + local kib_rpm + + # if an ofed version is given, then it means use OFED proper, + # not any vendor specific "inkernel" version + if [ -z "$ofed_version" ]; then + return 0 + fi + + if [ "$ofed_version" = "inkernel" ]; then + # see if there is a distro specific override for this and use + # that if it exists + # XXX we need to better integrate a distro specific override with + # the rest of this function so that all of the reuse cache + # stuff is leveraged given that 80% of this function is reuse + if type -p build_ofed-${DISTRO}; then + local ofed_location + ofed_location=$(build_ofed-${DISTRO} ${STDOUT}) + local rc=${PIPESTATUS[0]} + CONFIGURE_FLAGS="--with-o2ib=${ofed_location} ${CONFIGURE_FLAGS}" + return $rc + else + return 0 + fi + elif compare_version $OFED_VERSION 3.0; then + kib_prefix="ofa_kernel" + kib_rpm="kernel-ib" + else + kib_prefix="compat-rdma" + kib_rpm="compat-rdma" + fi + + # build kernel-ib/compat-rdma + if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then + local REUSE_SIGNATURE=$({ echo "$ofed_version"; + echo "$(find_linux_release ${linux})"; + cat "${linux}/include/linux/autoconf.h"; } | + md5sum | cut -d" " -f1) + # see if we can link to the reuse pool + # XXX - hrm. i'm not convinced this doesn't belong in the reuse + # "library" + local CAN_LINK_FOR_REUSE=false + touch $REUSEBUILD/$$ + if cp -al $REUSEBUILD/$$ $TOPDIR/; then + CAN_LINK_FOR_REUSE=true + fi + rm $REUSEBUILD/$$ + fi + + if ! $USE_BUILD_CACHE || ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \ + "$REUSE_SIGNATURE"; then + if [ -n "$REUSE_SIGNATURE" ]; then + # stash away the existing built articles for a moment + mkdir bak + mv {BUILD,{S,}RPMS,S{OURCE,PEC}S} bak + function mv_back { + pushd bak + find . | cpio -pudlm .. + popd + rm -rf bak + } + create_rpmbuild_dirs + fi + # build it + build_kernel_ib "${linux}" "${kib_prefix}" "${kib_rpm}" + + if [ -z "$REUSE_SIGNATURE" ]; then + echo "No reuse signature was caculated so not storing the built ofed" + else + # store the resulting RPM build tree for future use + echo "Storing the built ofed for future reuse" + if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \ + "ofed" "$REUSEBUILD" "$REUSE_SIGNATURE" \ + "$CAN_LINK_FOR_REUSE"; then + error "Failed to store OFED RPMS for reuse" + mv_back + return 1 + fi + # put the stuff we stashed away back + mv_back + fi + fi + + pushd "$TOPDIR" >/dev/null + rm -rf ${kib_rpm}-devel + mkdir ${kib_rpm}-devel + cd ${kib_rpm}-devel + # the actual ofed RPMs don't have the -rc$n or -$date string appened that + # might be present on the file + local linuxrelease=$(find_linux_release "$linux") + ofed_version=$(echo $ofed_version | + sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//') + local rpm=$(ls $TOPDIR/RPMS/*/${kib_rpm}-devel-${ofed_version}-${linuxrelease//-/_}.*.rpm) + if ! rpm2cpio < $rpm | cpio -id; then + fatal 1 "could not unpack the ${kib_rpm}-devel rpm." + fi + CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/${kib_prefix} ${CONFIGURE_FLAGS}" + popd >/dev/null + +} + +build_with_srpm() { + + if ! $PATCHLESS; then + local kernel_extra_version + if ! kernel_extra_version=$(build_kernel_with_srpm ${STDOUT}); then + fatal 1 "Failed to build the kernel from it's SRPM" + fi + + for arch in $BUILD_ARCHS; do + local kernel_devel_rpm + if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name $KERNEL_LUSTRE_NAMING) ="); then + fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/" + fi + + # install the -devel RPM in preparation for modules builds + if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \ + "$TOPDIR/RPMS/$arch/$kernel_devel_rpm"; then + fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm" + fi + done + else + # need to find and unpack the vendor's own kernel-devel for patchless + # client build + local kernelrpm + if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE"); then + fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}" + fi + if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then + fatal 1 "Could not find the Linux tree in $kernelrpm" + fi + fi + + # ~sigh~ have to make copies of and modify some of the rpm + # infrastructure files so that find-requires can find our unpacked + # kernel-devel artifacts + cp $RPM_HELPERS_DIR/{symset-table,find-requires{,.ksyms}} . + FIND_REQUIRES="$(pwd)/find-requires" + chmod 755 {symset-table,find-requires{,.ksyms}} + local tmp="$(pwd)" + tmp="${tmp//\//\\/}" + ed find-requires < 0; j-- )); do + newarg=${BASH_ARGV[$j + $p - 1]} + args="${args:+${args} }'${newarg}'" + done + let p+=${BASH_ARGC[$n - 1]} + fi + echo " ${funcname} ${args:+${args} }at ${sourcefile}:${lineno}" + done + + echo + echo "BEGIN BACKTRACE" + + #echo ${BASH_LINENO[*]} + #echo ${BASH_SOURCE[*]} + #echo ${FUNCNAME[*]} + local i=$((${#FUNCNAME[@]} - 1)) + while [ $i -ge 0 ]; do + local lineno=${BASH_LINENO[$i]} + if [ $i = 0 ]; then + let lineno-=11 + fi + local SOURCELINE="${BASH_SOURCE[$i + 1]}:${lineno}" + # Can't figure out how to get function args from other frames... + local FUNCTION="${FUNCNAME[$i]}()" + echo "$SOURCELINE:$FUNCTION" + i=$((i - 1)) + done + + echo "END BACKTRACE" + + echo $BACKTRACE + +} + +seen_list=$(new_list) +trap 'set +x; +echo "An unexpected error has occurred at ${BASH_SOURCE[0]##*/}:$((LINENO-1)). +Unfortunately the above line number in the message may or may not be correct, +but details have been send to the lbuild maintainer. Attempting to continue."; (echo "Untrapped error" +echo +# have we seen this one +echo "checking seen list for ${BASH_SOURCE[0]}:${BASH_LINENO[0]}" + +if is_list_member "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}"; then + echo "seen this one already" +else + seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}") +fi +backtrace +echo +echo "Environment:" +set +) | mail -s "Untrapped error at ${BASH_SOURCE[0]##*/}:$((LINENO-15)) on $HOSTNAME" brian@whamcloud.com >&2; set $xtrace' ERR +set -E + +[ -r ~/.lbuildrc ] && . ~/.lbuildrc + +options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,ofed-version:,publish,release,set-value:,src,stage:,tag:,target:,target-archs:,with-linux:,xen -- "$@") + +if [ $? != 0 ]; then + usage 1 +fi + +eval set -- "$options" + +while [ "$1" ]; do + case "$1" in + '') + usage 1 + ;; + --ccache) + CCACHE='ccache' + shift + ;; + -d) + CVSROOT=$2 + shift 2 + ;; + -D) + DATE=$2 + shift 2 + ;; + --external-patches) + EXTERNAL_PATCHES=$2 + shift 2 + ;; + --extraversion) + EXTRA_VERSION=$2 + shift 2 + ;; + --help | -h) + usage 0 + ;; + --kerneldir) + KERNELDIR=$2 + shift 2 + ;; + --kerneltree) + if ! KERNELTREE=$(canon_path "$2"); then + fatal 1 "Could not determine the canonical location of $2" + fi + shift 2 + ;; + --linux | --with-linux) + if ! LINUX=$(canon_path "$2"); then + fatal 1 "Could not determine the canonical location of $2" + fi + shift 2 + ;; + --distro) + DISTRO=$2 + shift 2 + ;; + --reuserpm) + REUSERPM=$2 + shift 2 + ;; + --reusebuild) + if ! REUSEBUILD=$(canon_path "$2"); then + fatal 1 "Could not determine the canonical location of $2" + fi + shift 2 + ;; + --norpm) + NORPM=true + shift + ;; + --ldiskfs) + LDISKFSRPM=true + shift + ;; + --noiokit) + IOKITRPM=false + shift + ;; + --patchless) + PATCHLESS=true + shift + ;; + --kernelrpm) + if ! KERNELRPMSBASE=$(canon_path "$2"); then + fatal 1 "Could not determine the canonical location of $2" + fi + shift 2 + ;; + --timestamp) + TIMESTAMP=$2 + shift 2 + ;; + --lustre) + if ! LUSTRE=$(canon_filepath "$2"); then + fatal 1 "Could not determine the canonical location of $2" + fi + shift 2 + ;; + --nodownload) + DOWNLOAD=false + shift 1 + ;; + --nosrc) + DO_SRC=false + shift 1 + ;; + --ofed-version) + OFED_VERSION="$2" + shift 2 + ;; + --publish) + shift + ;; + --release) + RELEASE=true + shift + ;; + --src) + DO_SRC=true + shift 1 + ;; + --stage) + STAGEDIR=$2 + shift 2 + ;; + --tag) + TAG=$2 + shift 2 + ;; + --target) + TARGET=$2 + shift 2 + ;; + --target-archs) + TARGET_ARCHS=$2 + shift 2 + ;; + --disable-datestamp) + USE_DATESTAMP= + shift + ;; + --xen) + XEN=true + shift + ;; + --set-value) + eval $2 + shift 2 + ;; + --) + shift + # there are actually some lustre configure flags that we need to + # handle ourselves (but we still give them to configure) + if [[ \ $@\ == *\ --disable-tests\ * ]]; then + LUSTRE_TESTS=false + fi + CONFIGURE_FLAGS=$@ + CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests" + break + ;; + *) + usage 1 "Unrecognized option: $1" + ;; + esac +done + +check_options + +unpack_lustre + +# XXX - should we _always_ get the buildid from the META file? what are the +# other (i.e. non-lustre-tarball use cases of lbuild)? +BUILDID=$(sed -ne '/^BUILDID =/s/.*= *//p' lustre/META) + +load_target + +if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then + download_ofed + unpack_ofed || fatal 1 "Error unpacking OFED tarball" +fi + +# make sure the RPM build environment is set up +create_rpmbuild_dirs + +# if an unpacked kernel source tree was given on the command line +# just build lustre with it (nothing distro kernel specific here) +if [ -n "$LINUX" ]; then + build_ofed "${LINUXOBJ:-$LINUX}" "$OFED_VERSION" || + fatal 1 "error building OFED" + build_lustre "$LINUX" "$LINUXOBJ" +else + if [ ! -f "${LBUILD_DIR}/lbuild-$DISTRO" ]; then + fatal 1 "${LBUILD_DIR}/lbuild-$DISTRO not found" + fi + source ${LBUILD_DIR}/lbuild-$DISTRO + build_with_srpm || fatal 1 "Failed to build_with_srpm" +fi + +stage diff --git a/build/lbuild-fc b/contrib/lbuild/lbuild-fc similarity index 93% rename from build/lbuild-fc rename to contrib/lbuild/lbuild-fc index f3f8615..4745343 100644 --- a/build/lbuild-fc +++ b/contrib/lbuild/lbuild-fc @@ -2,7 +2,7 @@ # Please see find_linux_devel_paths() in lbuild-rhel5 file for more details. DEVEL_PATH_ARCH_DELIMETER="." -source ${0%/*}/lbuild-rhel5 +source ${LBUILD_DIR}/lbuild-rhel5 # increment this if you have made a change that should force a new kernel # to build built diff --git a/build/lbuild-fc11 b/contrib/lbuild/lbuild-fc11 similarity index 94% rename from build/lbuild-fc11 rename to contrib/lbuild/lbuild-fc11 index 7f2c6bf..e705538 100644 --- a/build/lbuild-fc11 +++ b/contrib/lbuild/lbuild-fc11 @@ -5,7 +5,7 @@ if [ $TARGET_ARCH == 'i686' ]; then DEVEL_PATH_ARCH="i586" fi -source ${0%/*}/lbuild-fc +source ${LBUILD_DIR}/lbuild-fc # increment this if you have made a change that should force a new kernel # to build built diff --git a/build/lbuild-fc12 b/contrib/lbuild/lbuild-fc12 similarity index 92% rename from build/lbuild-fc12 rename to contrib/lbuild/lbuild-fc12 index a4f7b2b..7e54a85 100644 --- a/build/lbuild-fc12 +++ b/contrib/lbuild/lbuild-fc12 @@ -1,6 +1,6 @@ # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4: -source ${0%/*}/lbuild-fc +source ${LBUILD_DIR}/lbuild-fc # increment this if you have made a change that should force a new kernel # to build built diff --git a/build/lbuild-fc15 b/contrib/lbuild/lbuild-fc15 similarity index 84% rename from build/lbuild-fc15 rename to contrib/lbuild/lbuild-fc15 index 0666d41..ceca999 100644 --- a/build/lbuild-fc15 +++ b/contrib/lbuild/lbuild-fc15 @@ -1,6 +1,6 @@ # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4: -source ${0%/*}/lbuild-fc +source ${LBUILD_DIR}/lbuild-fc # increment this if you have made a change that should force a new kernel # to build built diff --git a/build/lbuild-oel5 b/contrib/lbuild/lbuild-oel5 similarity index 89% rename from build/lbuild-oel5 rename to contrib/lbuild/lbuild-oel5 index 6b5c38b..edb3917 100644 --- a/build/lbuild-oel5 +++ b/contrib/lbuild/lbuild-oel5 @@ -1,6 +1,6 @@ # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4: -source ${0%/*}/lbuild-rhel5 +source ${LBUILD_DIR}/lbuild-rhel5 # increment this if you have made a change that should force a new kernel # to build built for this distribution (only -- if you want to force a kernel diff --git a/build/lbuild-rhel b/contrib/lbuild/lbuild-rhel similarity index 100% rename from build/lbuild-rhel rename to contrib/lbuild/lbuild-rhel diff --git a/build/lbuild-rhel5 b/contrib/lbuild/lbuild-rhel5 similarity index 99% rename from build/lbuild-rhel5 rename to contrib/lbuild/lbuild-rhel5 index 111f816..4aab2c7 100644 --- a/build/lbuild-rhel5 +++ b/contrib/lbuild/lbuild-rhel5 @@ -11,7 +11,7 @@ BUILD_GEN+=".0" # use words that make the bash log readable. ZFSNOTSUPPORTED="Zfs Not Supported" -source ${0%/*}/lbuild-rhel +source ${LBUILD_DIR}/lbuild-rhel SPEC_NAME="kernel-2.6.spec" diff --git a/build/lbuild-rhel6 b/contrib/lbuild/lbuild-rhel6 similarity index 98% rename from build/lbuild-rhel6 rename to contrib/lbuild/lbuild-rhel6 index fb2afb7..137aaf2 100644 --- a/build/lbuild-rhel6 +++ b/contrib/lbuild/lbuild-rhel6 @@ -10,7 +10,7 @@ #BUILD_GEN+=".0" # TT-107: don't cache the BUILD dir (reset major to 5) BUILD_GEN+=".1" # LU-1361: enable kernel ABI -source ${0%/*}/lbuild-rhel +source ${LBUILD_DIR}/lbuild-rhel SPEC_NAME="kernel.spec" DEVEL_PATH_ARCH_DELIMETER="." diff --git a/build/lbuild-sles b/contrib/lbuild/lbuild-sles similarity index 100% rename from build/lbuild-sles rename to contrib/lbuild/lbuild-sles diff --git a/build/lbuild-sles10 b/contrib/lbuild/lbuild-sles10 similarity index 99% rename from build/lbuild-sles10 rename to contrib/lbuild/lbuild-sles10 index 9ca55fe..aeaa948 100644 --- a/build/lbuild-sles10 +++ b/contrib/lbuild/lbuild-sles10 @@ -5,7 +5,7 @@ # build on all distributions, update the BUILD_GEN variable in build/lbuild) BUILD_GEN+=".0" -source ${0%/*}/lbuild-sles +source ${LBUILD_DIR}/lbuild-sles # the location of the ofed-devel-..rpm OFED_DEVEL_LOCATION="$KERNELTREE" diff --git a/build/lbuild-sles11 b/contrib/lbuild/lbuild-sles11 similarity index 99% rename from build/lbuild-sles11 rename to contrib/lbuild/lbuild-sles11 index 6b6b36d..f7c2a75 100644 --- a/build/lbuild-sles11 +++ b/contrib/lbuild/lbuild-sles11 @@ -5,7 +5,7 @@ # build on all distributions, update the BUILD_GEN variable in build/lbuild) BUILD_GEN+=".0" -source ${0%/*}/lbuild-sles +source ${LBUILD_DIR}/lbuild-sles edit_specs() { diff --git a/build/nn-final-symbol-list.txt b/contrib/nn-final-symbol-list.txt similarity index 100% rename from build/nn-final-symbol-list.txt rename to contrib/nn-final-symbol-list.txt diff --git a/build/mptlinux.spec.patch b/contrib/patches/mptlinux.spec.patch similarity index 100% rename from build/mptlinux.spec.patch rename to contrib/patches/mptlinux.spec.patch diff --git a/build/patches/ofed/01-play-nice-with-RHEL5.ed b/contrib/patches/ofed/01-play-nice-with-RHEL5.ed similarity index 100% rename from build/patches/ofed/01-play-nice-with-RHEL5.ed rename to contrib/patches/ofed/01-play-nice-with-RHEL5.ed diff --git a/build/quiltrc b/contrib/quiltrc similarity index 100% rename from build/quiltrc rename to contrib/quiltrc diff --git a/build/rdac_spec b/contrib/rdac_spec similarity index 100% rename from build/rdac_spec rename to contrib/rdac_spec diff --git a/contrib/scripts/Makefile.am b/contrib/scripts/Makefile.am new file mode 100644 index 0000000..136a191 --- /dev/null +++ b/contrib/scripts/Makefile.am @@ -0,0 +1 @@ +EXTRA_DIST = update_oldconfig diff --git a/build/checkpatch.pl b/contrib/scripts/checkpatch.pl similarity index 100% rename from build/checkpatch.pl rename to contrib/scripts/checkpatch.pl diff --git a/build/checkstack.pl b/contrib/scripts/checkstack.pl similarity index 100% rename from build/checkstack.pl rename to contrib/scripts/checkstack.pl diff --git a/build/clearpatches.sh b/contrib/scripts/clearpatches.sh similarity index 100% rename from build/clearpatches.sh rename to contrib/scripts/clearpatches.sh diff --git a/build/confirmpatches.sh b/contrib/scripts/confirmpatches.sh similarity index 100% rename from build/confirmpatches.sh rename to contrib/scripts/confirmpatches.sh diff --git a/build/libcfs_cleanup.sed b/contrib/scripts/libcfs_cleanup.sed similarity index 100% rename from build/libcfs_cleanup.sed rename to contrib/scripts/libcfs_cleanup.sed diff --git a/build/nn-check.py b/contrib/scripts/nn-check.py similarity index 100% rename from build/nn-check.py rename to contrib/scripts/nn-check.py diff --git a/build/update_oldconfig b/contrib/scripts/update_oldconfig similarity index 100% rename from build/update_oldconfig rename to contrib/scripts/update_oldconfig diff --git a/build/updatecw.sh b/contrib/scripts/updatecw.sh similarity index 100% rename from build/updatecw.sh rename to contrib/scripts/updatecw.sh -- 1.8.3.1