Whamcloud - gitweb
LU-384 land bz22281 on b1_8
authorBrian J. Murrell <brian@whamcloud.com>
Wed, 1 Jun 2011 16:53:06 +0000 (12:53 -0400)
committerJohann Lombardi <johann@whamcloud.com>
Wed, 8 Jun 2011 18:56:11 +0000 (11:56 -0700)
To facilitate distinctive naming, we need the work in bugzilla
22281 landed on b1_8.
Add an lbuild option to set the downstream-release.  Normally
this should not be exposed to/through lbuild as this was orig-
inally intended for downstream packages to add their own stamp
to the release string.

Include e4189c54470deff4a98f0b2bb03ac6be7ed85ce9:
    b=24095 don't really need configure --with-linux

    Don't really need to have run configure --with-linux for
    version-tag.pl to work.

    i=wangyb
    i=cliff

Expand the list of debian/* files that should be included in the
dist tarball.
Don't try to [un]patch the local-env.sh.  It should never really
be included in a landed patch.

Include most of 086ff8c46009479bfdac9f570331a6c93b7d52ac:

    b=24094 add kver; update kdir, kobjdir

    Add a new macro to allow the caller to simply define which kernel
    he wants to build for.
    Refactor the kdir and kobjdir to function more properly.
    Remove krequires.  Nothing is using it anymore.

    i=wangyb
    i=cliff

Include c1a61e3e9129d0e2062eed617d922e6dfa9ede5a:

    LU-284 strip .$arch off of kern vers for requires

    RHEL6 appends .arch to the end of the version in the utsrelease.h file.
    The kernel RPM however provides that value with the .arch stripped off,
    so do the same stripping in the lustre-modules RPM for it's Requires:.

Signed-off-by: Brian J. Murrell <brian@whamcloud.com>
    Change-Id: Ib6ff32c006f184edceb5d667b649bb106d503faf
    Reviewed-on: http://review.whamcloud.com/502
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Brian J. Murrell <brian@whamcloud.com>
Change-Id: I82f4f9a556fd1d1fc51ef8930e2017798ff88706
Reviewed-on: http://review.whamcloud.com/884
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
Tested-by: Hudson
18 files changed:
autoMakefile.am
build/autoMakefile.am.toplevel
build/autoconf/lustre-build-linux.m4
build/autoconf/lustre-build.m4
build/extract_patches
build/lbuild
build/lbuild-oel5
build/lbuild-sles10
build/lbuild-sles11
ldiskfs/autoMakefile.am
ldiskfs/configure.ac
ldiskfs/lustre-ldiskfs.spec.in
lustre.spec.in
lustre/scripts/Makefile.am
lustre/scripts/version_tag-cvs.pl [new file with mode: 0644]
lustre/scripts/version_tag-git.pl [new file with mode: 0644]
lustre/scripts/version_tag-none.pl [new file with mode: 0644]
lustre/scripts/version_tag.pl

index 057c556..1505d6b 100644 (file)
@@ -16,7 +16,18 @@ include build/autoMakefile.am.toplevel
 EXTRA_DIST += config.h.in
 
 if USES_DPKG
-EXTRA_DIST += debian/*
+EXTRA_DIST += debian/control.modules.in debian/control.main \
+             debian/linux-patch-lustre.kpatches \
+             debian/lustre-utils.examples debian/copyright debian/source \
+             debian/source/format debian/lustre-source.docs \
+             debian/lustre-utils.docs debian/lustre-utils.manpages \
+             debian/lustre-client-modules.install debian/README.Debian \
+             debian/.gitignore debian/linux-patch-lustre.dirs \
+             debian/linux-patch-lustre.unpatch debian/lustre-dev.install \
+             debian/lustre-source.dirs debian/liblustre.install debian/rules \
+             debian/lustre-dev.dirs debian/linux-patch-lustre.apply \
+             debian/control debian/changelog debian/lustre-tests.install \
+             debian/lustre-utils.install
 endif
 
 if LDISKFS_ENABLED
@@ -46,11 +57,14 @@ checkstack-clean:
 
 module-dist-hook:
        if [ -d CVS -o -d .git ]; then \
-           perl lustre/scripts/tree_status.pl > $(distdir)/tree_status; \
-       elif [ -f tree_status ]; then \
-           cp tree_status $(distdir)/tree_status; \
+           perl lustre/scripts/make_META.pl > $(distdir)/META; \
+           cp $(distdir)/META $(distdir)/ldiskfs/META; \
+       elif [ -f META ]; then \
+           cp META $(distdir)/META; \
+           cp $(distdir)/META $(distdir)/ldiskfs/META; \
        else \
-           echo -e "I have no idea how to create a tree_status file in $(distdir).\nPlease file a bug at http://bugzilla.lustre.org/"; \
+           echo -e "I have no idea how to create a META file in $(distdir).\nPlease file a bug at http://bugzilla.lustre.org/"; \
+           exit 1; \
        fi
        if [ -d .git ]; then \
                build/extract_patches $(distdir); \
index e55cb0a..71585e0 100644 (file)
@@ -112,10 +112,20 @@ EXTRA_DIST = @PACKAGE_TARNAME@.spec                                       \
 
 rpms-real: @PACKAGE_TARNAME@.spec dist Makefile
        CONFIGURE_ARGS=$$(echo $$(eval echo $(ac_configure_args)) | sed -re 's/--(en|dis)able-tests//'); \
-       RPMARGS="--define \"configure_args $$CONFIGURE_ARGS\""; \
+       if [ -n "@LINUX@" ]; then \
+               CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-linux=[^ ][^ ]*//'); \
+               RPMARGS="--define \"kdir @LINUX@\""; \
+               CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-linux-obj=[^ ][^ ]*//'); \
+               if [ -n "@LINUX_OBJ@" -a "@LINUX_OBJ@" != "@LINUX@" ]; then \
+                       RPMARGS="$$RPMARGS --define \"kobjdir @LINUX_OBJ@\""; \
+               fi; \
+       fi; \
+       CONFIGURE_ARGS=$$(echo $$(eval echo $$CONFIGURE_ARGS) | sed -re 's/--with-release=[^ ][^ ]*//'); \
+       RPMARGS="$$RPMARGS --define \"configure_args $$CONFIGURE_ARGS\""; \
        if ! $(BUILD_TESTS); then \
                RPMARGS="$$RPMARGS --define \"build_lustre_tests 0\""; \
        fi; \
+       echo "Building Lustre RPM with $$RPMARGS"; \
        eval rpmbuild $$RPMARGS -ta $(distdir).tar.gz
 
 srpm-real: @PACKAGE_TARNAME@.spec dist Makefile
index 45637d7..7d673c2 100644 (file)
@@ -95,7 +95,15 @@ AC_SUBST(modulenetdir)
 
 # ------------ RELEASE --------------------------------
 AC_MSG_CHECKING([for Lustre release])
-RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
+AC_ARG_WITH([release],
+       AC_HELP_STRING([--with-release=string],
+                      [set the release string (default=$kvers_YYYYMMDDhhmm)]),
+       [RELEASE=$withval],
+       RELEASE=""
+       if test -n "$DOWNSTREAM_RELEASE"; then
+               RELEASE="${DOWNSTREAM_RELEASE}_"
+       fi
+       RELEASE="$RELEASE`echo ${LINUXRELEASE} | tr '-' '_'`_$BUILDID")
 AC_MSG_RESULT($RELEASE)
 AC_SUBST(RELEASE)
 
@@ -159,12 +167,28 @@ AC_DEFUN([LB_ARG_CANON_PATH], [
 # Find paths for linux, handling kernel-source rpms
 #
 AC_DEFUN([LB_LINUX_PATH],
-[AC_MSG_CHECKING([for Linux sources])
+[# prep some default values
+for DEFAULT_LINUX in /lib/modules/$(uname -r)/{source,build} /usr/src/linux; do
+       if readlink -q -e $DEFAULT_LINUX; then
+               break
+       fi
+done
+if test "$DEFAULT_LINUX" = "/lib/modules/$(uname -r)/source"; then
+       PATHS="/lib/modules/$(uname -r)/build"
+fi
+PATHS+="$DEFAULT_LINUX"
+for DEFAULT_LINUX_OBJ in $PATHS; do
+       if readlink -q -e $DEFAULT_LINUX_OBJ; then
+               break
+       fi
+done
+AC_MSG_CHECKING([for Linux sources])
 AC_ARG_WITH([linux],
        AC_HELP_STRING([--with-linux=path],
-                      [set path to Linux source (default=/usr/src/linux)]),
-       [LB_ARG_CANON_PATH([linux], [LINUX])],
-       [LINUX=/usr/src/linux])
+                      [set path to Linux source (default=/lib/modules/$(uname -r)/{source,build},/usr/src/linux)]),
+       [LB_ARG_CANON_PATH([linux], [LINUX])
+       DEFAULT_LINUX_OBJ=$LINUX],
+       [LINUX=$DEFAULT_LINUX])
 AC_MSG_RESULT([$LINUX])
 AC_SUBST(LINUX)
 
@@ -176,9 +200,10 @@ LB_CHECK_FILE([$LINUX],[],
 AC_MSG_CHECKING([for Linux objects dir])
 AC_ARG_WITH([linux-obj],
        AC_HELP_STRING([--with-linux-obj=path],
-                       [set path to Linux objects dir (default=$LINUX)]),
+                       [set path to Linux objects dir (default=/lib/modules/$(uname -r)/build,/usr/src/linux)]),
        [LB_ARG_CANON_PATH([linux-obj], [LINUX_OBJ])],
-       [LINUX_OBJ=$LINUX])
+       [LINUX_OBJ=$DEFAULT_LINUX_OBJ])
+
 AC_MSG_RESULT([$LINUX_OBJ])
 AC_SUBST(LINUX_OBJ)
 
index 5991676..b827114 100644 (file)
@@ -29,6 +29,86 @@ AC_SUBST(lb_target_os)
 ])
 
 #
+# LB_DOWNSTREAM_RELEASE
+#
+AC_DEFUN([LB_DOWNSTREAM_RELEASE],
+[AC_ARG_WITH([downstream-release],
+       AC_HELP_STRING([--with-downstream-release=string],
+                      [set a string in the BUILD_VERSION and RPM Release: (default is nothing)]),
+       [DOWNSTREAM_RELEASE=$with_downstream_release],
+       [
+       # if not specified, see if it's in the META file
+       if test -f META; then
+               DOWNSTREAM_RELEASE=$(sed -ne '/^LOCAL_VERSION =/s/.*= *//p' META)
+       fi
+       ])
+AC_SUBST(DOWNSTREAM_RELEASE)
+])
+
+#
+# LB_BUILDID
+#
+# Check if the source is a GA release and if not, set a "BUILDID"
+#
+# Currently there are at least two ways/modes of/for doing this.  One
+# is if we are in a valid git repository, the other is if we are in a
+# non-git source tree of some form.  Building the latter from the former
+# will be handled here.
+AC_DEFUN([LB_BUILDID],
+[
+AC_MSG_CHECKING([for buildid])
+BUILDID=""
+if git branch >/dev/null 2>&1; then
+       ffw=0
+       hash=""
+       ver=$(git describe --match [[0-9v]]\* --tags)
+       if [[[ $ver = *-*-* ]]]; then
+               hash=${ver##*-}
+               ffw=${ver#*-}
+               ffw=${ffw%-*}
+               ver=${ver%%-*}
+       fi
+       # it's tempting to use [[ $ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$ ]]
+       # here but the portability of the regex on the right is dismal
+       # (thanx suse)
+       if echo "$ver" | egrep -q "^v([0-9]+_)+([0-9]+|RC[0-9]+)$"; then
+               ver=$(echo $ver | sed -e 's/^v\(.*\)/\1/' \
+                                     -e 's/_RC[[0-9]].*$//' -e 's/_/./g')
+       fi
+
+       # a "lustre fix" value of .0 should be truncated
+       if [[[ $ver = *.*.*.0 ]]]; then
+               ver=${ver%.0}
+       fi
+       # ditto for a "lustre fix" value of _0
+       if [[[ $ver = v*_*_*_0 ]]]; then
+               ver=${ver%_0}
+       fi
+
+
+       # only do this test for lustre (not ldiskfs)
+       if test "$PACKAGE" = "lustre" -a "$ver" != "$VERSION"; then
+               AC_MSG_ERROR([most recent tag found: $ver does not match current version $VERSION.])
+       fi
+
+       if test "$ffw" != "0"; then
+               BUILDID="$hash"
+               msg="$BUILDID (ahead by $ffw commits)"
+               AC_MSG_RESULT([$msg])
+       else
+               AC_MSG_RESULT([none... congratulations, you must be on a tag])
+       fi
+elif test -f META; then
+       BUILDID=$(sed -ne '/^BUILDID =/s/.*= *//p' META)
+       msg="$BUILDID (from META file)"
+       AC_MSG_RESULT([$msg])
+else
+       AC_MSG_WARN([FIXME: I don't know how to deal with source trees outside of git that don't have a META file.  Not setting a buildid.])
+fi
+AC_SUBST(BUILDID)
+])
+
+#
 # LB_CHECK_FILE
 #
 # Check for file existance even when cross compiling
@@ -227,7 +307,7 @@ case x$with_ldiskfs in
                ;;
        *)
                AC_MSG_RESULT([$with_ldiskfs])
-               LB_CHECK_FILE([$with_ldiskfs/ldiskfs/linux/ldiskfs_fs.h],[],[
+               LB_CHECK_FILE([$with_ldiskfs/ldiskfs/inode.c],[],[
                        AC_MSG_ERROR([A complete (built) external ldiskfs was not found.])
                ])
                LDISKFS_DIR=$with_ldiskfs
@@ -622,6 +702,30 @@ fi
 ])
 
 #
+# LB_CONFIG_DIST
+#
+# Just enough configure so that "make dist" is useful
+#
+# this simply re-adjusts some defaults, which of course can be overridden
+# on the configure line after the --for-dist option
+#
+AC_DEFUN([LB_CONFIG_DIST],
+[AC_MSG_CHECKING([whether to configure just enough for make dist])
+AC_ARG_ENABLE([dist],
+       AC_HELP_STRING([--enable-dist],
+                       [only configure enough for make dist]),
+       [enable_dist='yes'],[enable_dist='no'])
+AC_MSG_RESULT([$enable_dist])
+if test x$enable_dist != xno; then
+       enable_modules='no'
+       enable_utils='no'
+        enable_liblustre='no'
+        enable_doc='no'
+        enable_tests='no'
+fi
+])
+
+#
 # LB_CONFIG_DOCS
 #
 # Build docs?
@@ -836,6 +940,9 @@ AC_DEFUN([LB_CONFIGURE],
 
 LB_CONFIG_DIST
 
+LB_DOWNSTREAM_RELEASE
+LB_BUILDID
+
 LB_USES_DPKG
 
 LB_LIBCFS_DIR
@@ -856,7 +963,7 @@ LB_CONFIG_UTILS
 LB_CONFIG_TESTS
 LC_CONFIG_CLIENT_SERVER
 
-# two macros for cmd3 
+# two macros for cmd3
 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
 LN_CONFIG_CDEBUG
 LC_QUOTA
index de88c07..3764b42 100755 (executable)
@@ -34,6 +34,18 @@ if [ $ffw -gt 0 ]; then
        rm -f 00list *.dpatch
        for file in [0-9][0-9][0-9][0-9]-*.patch; do
                if [ -s $file ] && ! grep -q "^--- a/debian/" $file; then
+                       # remove patching of files that the debian packaging
+                       # should not be touching
+                       ed <<EOF $file
+/diff --git a\/local-env.sh b\/local-env.sh
+/diff --git a\//i
+endofrangemarker
+.
+?diff --git a\/
+/diff --git a\/local-env.sh b\/local-env.sh/,/endofrangemarker/d
+w
+q
+EOF
                        desc=$(cat $file | sed -e '1,/^$/d' \
                                                 -e '/^---$/,$d')
                        dpatch_file=${file/.patch/.dpatch}
index 76fb3e1..a050ff0 100755 (executable)
@@ -50,7 +50,6 @@ TARGET_ARCHS_ALL="$TARGET_ARCH"
 CONFIGURE_FLAGS=
 EXTERNAL_PATCHES=
 EXTRA_VERSION=
-LUSTRE_EXTRA_VERSION=
 STAGEDIR=
 TMPDIR=${TMPDIR:-"/var/tmp"}
 TIMESTAMP=
@@ -132,6 +131,9 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
     environment variable \$CVSROOT is used if this option is not
     present.
 
+  --downstream-release
+    Set the downstream version.
+
   --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
@@ -248,7 +250,22 @@ EOF
     fatal "$1" "$2"
 }
 
-# canonicalize a relative path
+# 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"
 
@@ -632,7 +649,9 @@ load_target() {
         if $PATCHLESS || [ -n "$SERIES" ]; then
             EXTRA_VERSION=$(echo $EXTRA_VERSION | sed -e "s/\(.*_lustre\)\..*/\1/")
 #            EXTRA_VERSION="${EXTRA_VERSION}-${TAG}.${TIMESTAMP}"
-            EXTRA_VERSION="${EXTRA_VERSION}.${TIMESTAMP}"
+            if ! $PATCHLESS && [ -n "$BUILDID" ]; then
+                EXTRA_VERSION="${EXTRA_VERSION}.${BUILDID}"
+            fi
         fi
     fi
     # EXTRA_VERSION=${EXTRA_VERSION//-/_}
@@ -728,7 +747,8 @@ unpack_lustre() {
             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 --disable-{modules,utils,liblustre,tests,doc} || \
+        ./configure --enable-dist \
+                    --with-downstream-release "$DOWNSTREAM_RELEASE" || \
             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
@@ -791,47 +811,71 @@ build_lustre() {
         targets="--target $arch $targets"
     done
 
-    local confoptions="--with-linux=${linux}"
+    local confoptions=""
+
     if $PATCHLESS; then
-        confoptions="--with-linux=${linux} --disable-server"
-    fi
-    if [ "$linuxobj" != "" ]; then
-        confoptions="$confoptions --with-linux-obj=${linuxobj}"
-    fi
-
-    ./configure $confoptions ${CONFIGURE_FLAGS} 2>&1
-    if [ "$?" != "0" ]; then
-        local saved_config="../config.log.$(date +%s)"
-        cp config.log $saved_config
-        chmod a+r $saved_config
-        echo "Saved config.log is at $saved_config"
-        cat /proc/mounts
-        ls -l /proc/$$
-        pwd
-        echo "config.log contents:"
-        cat config.log
-        popd
-        return 255
+        confoptions="$confoptions --disable-server"
     fi
 
-    gen_lustre_version
-
-    # hack. Somebody move build/lustre.spec to lustre.spec for b1_6
-    local lustre_spec
-    [ -f lustre.spec ] && lustre_spec=lustre.spec
-    [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec
-
-    [ -f "$lustre_spec" ] && sed \
-        -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
-        < $lustre_spec \
-        > ../lustre.spec
-
-    local rpmbuildopt='-bb'
+    local rpmbuildopt='-tb'
     if $NORPM; then
-        rpmbuildopt='-bc'
+        rpmbuildopt='-tc'
         echo NORPM mode. Only compiling.
     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-*)"
+    }
+
     # 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
@@ -846,50 +890,18 @@ build_lustre() {
         lustre_tests="no"
     fi
 
-    $RPMBUILD $targets $rpmbuildopt ../lustre.spec \
+    $RPMBUILD $targets $rpmbuildopt "$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 || \
         fatal 1 "Error building rpms for $BUILD_ARCHS."
 
     popd >/dev/null
-    ( $(skeep_ldiskfs_rpm $TAG) ) && return
-
-    pushd lustre/ldiskfs || return 255
-    make dist 2>&1
-    if [ "$?" != "0" ]; then
-        popd
-        return 255
-    fi
-    cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
-
-    gen_lustre_version
-
-    local ldiskfs_spec=lustre-ldiskfs.spec
-    [ -f "$ldiskfs_spec" ] && sed \
-    -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
-    < $ldiskfs_spec \
-    > ../lustre-ldiskfs.spec
-
-    if ! $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
-        --define "_tmppath /var/tmp" \
-        --define "_topdir $TOPDIR" 2>&1; then
-        popd
-        return 255
-    fi
-
-    if $DO_SRC; then
-        if ! $RPMBUILD -bs ../lustre-ldiskfs.spec \
-            --define "_tmppath /var/tmp" \
-            --define "_topdir $TOPDIR" 2>&1; then
-            popd
-            return 255
-        fi
-    fi
-    popd
 
 }
 
@@ -913,33 +925,21 @@ stage() {
 
 #check if we need to build separate ldiskfs RPM
 skeep_ldiskfs_rpm() {
-        local tag="$1"
+    local tag="$1"
 
-        local skip=false
+    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
-
-        pushd $TOPDIR/BUILD/lustre-[1-9]* >/dev/null
-        grep -q '^SERVER_TRUE[ \t]=[ \t]#$' autoMakefile && skip=true
-        popd >/dev/null
-
-        echo $skip
-
-}
-
-#generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
-gen_lustre_version() {
+    if ! $LDISKFSRPM; then
+        skip=true
+    elif $PATCHLESS; then
+        skip=true
+    else
+        for skiptag in $SKIPLDISKFSRPM; do
+            [[ $tag == $skiptag ]] && skip=true && break
+        done
+    fi
 
-    LUSTRE_EXTRA_VERSION="${lnxmaj}-${EXTRA_VERSION}${FLAVOR_DELIMITER}${RPMSMPTYPE}"
-    LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
+    echo $skip
 
 }
 
@@ -1454,7 +1454,7 @@ build_ofed() {
             return 0
         fi
     fi
-    
+
     # build kernel-ib
     if $USE_BUILD_CACHE && [ -n "$REUSEBUILD" ]; then
         local REUSE_SIGNATURE=$({ echo "$ofed_version";
@@ -1760,7 +1760,7 @@ 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,enable-mptlinux,enable-rdac -- "$@")
+options=$(getopt -o d:D:h -l kerneltree:,distro:,downstream-release:,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,enable-mptlinux,enable-rdac -- "$@")
 
 if [ $? != 0 ]; then
     usage 1
@@ -1785,6 +1785,10 @@ while [ "$1" ]; do
             DATE=$2
             shift 2
             ;;
+        --downstream-release)
+            DOWNSTREAM_RELEASE=$2
+            shift 2
+            ;;
         --external-patches)
             EXTERNAL_PATCHES=$2
             shift 2
@@ -1849,7 +1853,9 @@ while [ "$1" ]; do
             shift 2
             ;;
         --lustre)
-            LUSTRE=$2
+            if ! LUSTRE=$(canon_filepath "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --nodownload)
@@ -1932,6 +1938,10 @@ 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
index d1aaa94..6b5c38b 100644 (file)
@@ -3,8 +3,6 @@
 source ${0%/*}/lbuild-rhel5
 
 # 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
-
+# to build built for this distribution (only -- if you want to force a kernel
+# build on all distributions, update the BUILD_GEN variable in build/lbuild)
+BUILD_GEN+=".0"
index 35f5849..a96f9f8 100644 (file)
@@ -1,10 +1,9 @@
 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
 
 # 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
+# to build built for this distribution (only -- if you want to force a kernel
+# build on all distributions, update the BUILD_GEN variable in build/lbuild)
+BUILD_GEN+=".0"
 
 source ${0%/*}/lbuild-sles
 
index dce8239..737e806 100644 (file)
@@ -1,10 +1,9 @@
 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
 
 # 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
+# to build built for this distribution (only -- if you want to force a kernel
+# build on all distributions, update the BUILD_GEN variable in build/lbuild)
+BUILD_GEN+=".0"
 
 source ${0%/*}/lbuild-sles
 
index 163032b..e8b2d0e 100644 (file)
@@ -10,4 +10,14 @@ include build/autoMakefile.am.toplevel
 
 EXTRA_DIST += kernel_patches
 
+# this only needs to be done if disting stand-alone (i.e. not as a
+# subdir of lustre
 module-dist-hook:
+       if ! grep "AC_INIT(\[Lustre\], \[LUSTRE_VERSION\], \[https:\/\/bugzilla\.lustre\.org\/], \[lustre\])" ../configure.ac; then \
+           if [ -f META ]; then \
+               cp META $(distdir)/META; \
+           else \
+               echo -e "I have no idea how to create a META file in $(distdir).\nPlease file a bug at http://bugzilla.lustre.org/"; \
+               exit 1; \
+           fi; \
+       fi
index 21e3090..86f493d 100644 (file)
@@ -2,6 +2,7 @@
 
 AC_INIT([Lustre ldiskfs], 3.1.50, [https://bugzilla.lustre.org/])
 AC_CONFIG_SRCDIR([lustre-ldiskfs.spec.in])
+ldiskfs_is_ext4=yes
 
 # Don't look for install-sh, etc. in ..
 AC_CONFIG_AUX_DIR([.])
@@ -13,6 +14,11 @@ AM_INIT_AUTOMAKE([1.9 tar-ustar])
 AC_PROG_CC
 
 LB_CANONICAL_SYSTEM
+
+LB_DOWNSTREAM_RELEASE
+
+LB_BUILDID
+
 LB_INCLUDE_RULES
 LB_PROG_CC
 
@@ -106,6 +112,8 @@ AC_SUBST(BACKFSU) # We need a Upper string
 
 AM_CONDITIONAL(USE_EXT4, test x$enable_ext4 = xyes)
 
+if test x$enable_dist != xyes; then
+       # don't need to do this if only configuring for make dist
 AC_MSG_CHECKING([which ldiskfs series to use])
 case $LINUXRELEASE in
 2.6.5*) LDISKFS_SERIES="2.6-suse.series" ;;
@@ -132,6 +140,7 @@ case $LINUXRELEASE in
 *) AC_MSG_WARN([Unknown kernel version $LINUXRELEASE, fix ldiskfs/configure.ac])
 esac
 AC_MSG_RESULT([$LDISKFS_SERIES])
+fi
 AC_SUBST(LDISKFS_SERIES)
 
 AC_SUBST(ac_configure_args)
index fe0e7fa..047f623 100644 (file)
@@ -1,10 +1,25 @@
-%define version @VERSION@
-%define kversion @LINUXRELEASE@
+# lustre-ldiskfs.spec
+%{!?version: %define version @VERSION@}
+%{!?kdir: %define kdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else echo "/lib/modules/$(uname -r)/build"; fi)}
+
+%{!?kobjdir: %define kobjdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux-obj=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else echo "%kdir"; fi)}
+
+# as an alternative to this implementation we could simply "make -C $kdir kernelversion"
+%{!?kversion: %define kversion %(if test -s %kobjdir/include/linux/utsrelease.h ; then LINUXRELEASEHEADER=utsrelease.h; else LINUXRELEASEHEADER=version.h; fi; sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' %kobjdir/include/linux/$LINUXRELEASEHEADER)}
+
+%{!?downstream_release: %define downstream_release "@DOWNSTREAM_RELEASE@"}
+
+%define buildid %(if [ -n "@BUILDID@" ]; then echo "_@BUILDID@"; fi)
+
+%{!?release: %define release %(if [ -n "%downstream_release" ]; then echo -n "%{downstream_release}_"; fi; release=$(echo %kversion | tr '-' '_'); echo ${release})}
+
+# always append the buildid, even when the caller defines %release
+%define fullrelease %{release}%{buildid}
 
 Summary: ldiskfs backend file system
 Name: lustre-ldiskfs
 Version: %{version}
-Release: @RELEASE@
+Release: %{fullrelease}
 License: GPL
 Group: Development/Kernel
 Source: lustre-ldiskfs-%{version}.tar.gz
@@ -38,10 +53,27 @@ rm -rf $RPM_BUILD_ROOT
 
 # Set an explicit path to our Linux tree, if we can.
 cd $RPM_BUILD_DIR/lustre-ldiskfs-%{version}
-./configure @ac_configure_args@ %{?configure_flags:configure_flags} \
+CONFIGURE_ARGS="%{?configure_args} --with-release=%release"
+
+# if %%kdir was given, make sure it's not in the configure arguments
+if [ -n "%kdir" ]; then
+       CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux=[^ ][^ ]* \?//')
+fi
+# ditto for %%kobjdir
+if [ -n "%kobjdir" ]; then
+       CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux-obj=[^ ][^ ]* \?//')
+fi
+
+# we need to eval "configure" because $CONFIGURE_ARGS could have a quoted
+# string in it which we don't want word splitted by the shell
+%define eval_configure %(echo '%configure' | sed -e 's#\./configure#eval ./configure#')
+
+eval ./configure %{?configure_args} \
+       %{?kdir: --with-linux=%kdir} %{?kobjdir: --with-linux-obj=%kobjdir} \
        --sysconfdir=%{_sysconfdir} \
        --mandir=%{_mandir} \
-       --libdir=%{_libdir}
+       --libdir=%{_libdir} \
+       $CONFIGURE_ARGS
 make -j $RPM_BUILD_NCPUS -s
 
 %install
index ff26158..d5ec2b6 100644 (file)
@@ -1,7 +1,22 @@
 # lustre.spec
 %{!?version: %define version @VERSION@}
-%{!?kversion: %define kversion @LINUXRELEASE@}
-%{!?release: %define release @RELEASE@}
+%{!?kver: %define kver ""}
+%{!?kdir: %define kdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else if [ -n "%kver" ]; then kversion="%kver"; else kversion="$(uname -r)"; fi; echo "/lib/modules/$kversion/source"; fi)}
+
+%{!?kobjdir: %define kobjdir %(dir=$(echo "%configure_args" | sed -ne 's/.*--with-linux-obj=\\([^ ][^ ]*\\).*$/\\1/p'); if [ -n "$dir" ]; then echo "$dir"; else if [ -n "%kver" ]; then kversion="%kver"; else kversion="$(uname -r)"; fi; if [ "%kdir" = "/lib/modules/$kversion/source" ]; then echo "/lib/modules/$kversion/build"; else echo "%kdir"; fi; fi)}
+
+# as an alternative to this implementation we could simply "make -C $kdir kernelversion"
+%{!?kversion: %define kversion %(if test -s %kobjdir/include/linux/utsrelease.h ; then LINUXRELEASEHEADER=utsrelease.h; else LINUXRELEASEHEADER=version.h; fi; sed -ne '/^#define UTS_RELEASE/s/.*"\\(.*\\)"$/\\1/p' %kobjdir/include/linux/$LINUXRELEASEHEADER)}
+
+%{!?downstream_release: %define downstream_release "@DOWNSTREAM_RELEASE@"}
+
+%define buildid %(if [ -n "@BUILDID@" ]; then echo "_@BUILDID@"; fi)
+
+%{!?myrelease: %define myrelease %(if [ -n "%downstream_release" ]; then echo -n "%{downstream_release}_"; fi; echo %kversion | tr '-' '_')}
+
+# always append the buildid, even when the caller defines %release
+%define fullrelease %{myrelease}%{buildid}
+
 %{!?lustre_name: %define lustre_name lustre}
 %{!?build_lustre_tests: %define build_lustre_tests 1}
 
@@ -26,8 +41,9 @@
 #%%global _use_internal_dependency_generator 0
 
 %define is_client %(bash -c "if [[ %{lustre_name} = *-client ]]; then echo -n '1'; else echo -n '0'; fi")
-# for those uses that don't want the -smp/-bigsmp on the end of %kversion
-%define krequires %(bash -c "echo %{kversion} | sed -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
+# for those uses that don't want the -smp/-bigsmp (or the .arch) on the end
+# of %kversion
+%define krequires %(bash -c "echo %{kversion} | sed -e 's/\.x86_64$//' -e 's/\.i[3456]86$//' -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
 
 %define sles10 %(bash -c "if [ "%sles_version" = "10" ]; then echo -n '1'; else echo -n '0'; fi")
 
@@ -38,7 +54,7 @@
 Summary: Lustre File System
 Name: %{lustre_name}
 Version: %{version}
-Release: %{release}
+Release: %{fullrelease}
 License: GPL
 Group: Utilities/System
 Source: lustre-%{version}.tar.gz
@@ -143,13 +159,29 @@ cd $RPM_BUILD_DIR/lustre-%{version}
 # override %optflags so that the vendor's overzealous flags don't create
 # build failures
 %define optflags -g -O2 -Werror
-CONFIGURE_ARGS=""
+CONFIGURE_ARGS="%{?configure_args} --with-release=%release"
 %if %{build_lustre_tests}
 CONFIGURE_ARGS="$CONFIGURE_ARGS --enable-tests --enable-liblustre-tests"
 %else
 CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-tests --disable-liblustre-tests"
 %endif
-%configure %{?configure_args:%configure_args} $CONFIGURE_ARGS
+
+# if %%kdir was given, make sure it's not in the configure arguments
+if [ -n "%kdir" ]; then
+       CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux=[^ ][^ ]* \?//')
+fi
+# ditto for %%kobjdir
+if [ -n "%kobjdir" ]; then
+       CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux-obj=[^ ][^ ]* \?//')
+fi
+
+# we need to eval "configure" because $CONFIGURE_ARGS could have a quoted
+# string in it which we don't want word splitted by the shell
+%define eval_configure %(echo '%configure' | sed -e 's#\./configure#eval ./configure#')
+
+%eval_configure \
+       %{?kdir: --with-linux=%kdir} %{?kobjdir: --with-linux-obj=%kobjdir} \
+       $CONFIGURE_ARGS
 make -j $RPM_BUILD_NCPUS -s
 
 %install
@@ -232,6 +264,7 @@ fi
 %endif
 
 pushd $RPM_BUILD_ROOT >/dev/null
+> $RPM_BUILD_DIR/lustre-%{version}/lustre-modules.files
 find lib/modules/%{kversion}/updates -type f | awk "!/(ZZZZZZZZZZ$modules_excludes)/ {print \"%attr(-, root, root) /\"\$0}" >>$RPM_BUILD_DIR/lustre-%{version}/lustre-modules.files
 popd >/dev/null
 
index 2d53c56..9b00685 100644 (file)
@@ -43,9 +43,10 @@ genscripts = lustre_config lc_modprobe lc_net lc_hb lc_cluman lustre_createcsv \
 sbin_SCRIPTS = $(genscripts) $(sbinscripts)
 bin_SCRIPTS = lustre_req_history lfs_migrate
 
-EXTRA_DIST = license-status maketags.sh version_tag.pl lc_common \
+EXTRA_DIST = license-status maketags.sh version_tag.pl version_tag-git.pl \
+            version_tag-cvs.pl version_tag-none.pl lc_common \
             $(addsuffix .in,$(genscripts)) lc_mon $(sbinscripts) \
-            $(bin_SCRIPTS) tree_status.pl
+            $(bin_SCRIPTS) make_META.pl
 
 scriptlibdir = @libexecdir@/@PACKAGE@
 scriptlib_DATA = lc_common
@@ -56,5 +57,5 @@ $(genscripts): %: %.in
        sed -e 's#@scriptlibdir@#$(scriptlibdir)#' < $< > $@
        chmod +x $@
 
-tree_status.pl: version_tag.pl
-       ln -f version_tag.pl tree_status.pl
+make_META.pl: version_tag.pl
+       ln -f $< $@
diff --git a/lustre/scripts/version_tag-cvs.pl b/lustre/scripts/version_tag-cvs.pl
new file mode 100644 (file)
index 0000000..59d0e07
--- /dev/null
@@ -0,0 +1,147 @@
+use Time::Local;
+
+my ($last_mtime, $pristine);
+
+# for CVS, the buildid is that old "latest mtime" process
+sub get_buildid()
+{
+
+    return mtime2date($last_mtime);
+
+}
+
+# Use the CVS tag first otherwise use the portals version
+sub get_tag()
+{
+
+    my $tag;
+    my $line;
+
+    my $tagfile = new IO::File;
+    if (!$tagfile->open("lustre/CVS/Tag")) {
+        my $verfile = new IO::File;
+        if (!$verfile->open("config.h")) {
+          return "UNKNOWN";
+        }
+        while(defined($line = <$verfile>)) {
+            $line =~ /\#define VERSION "(.*)"/;
+            if ($1) {
+                $tag = $1;
+                last;
+            }
+        }
+        $verfile->close();
+        return $tag
+    } else {
+        my $tmp = <$tagfile>;
+        $tagfile->close();
+
+        $tmp =~ m/[TN](.*)/;
+        return $1;
+    }
+
+}
+
+sub get_latest_mtime()
+{
+
+    my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
+                "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
+                "Nov" => 10, "Dec" => 11);
+
+    my $last_mtime = 0;
+    my $pristine = 1;
+
+    # if we got here, we are operating in a CVS checkout
+    my @entries = `find . -name Entries`;
+    my $entry_file;
+    foreach $entry_file (@entries) {
+        chomp($entry_file);
+        my $entry = new IO::File;
+        if (!$entry->open($entry_file)) {
+            die "unable to open $entry_file: $!\n";
+        }
+        my $line;
+        while (defined($line = <$entry>)) {
+            chomp($line);
+            #print "line: $line\n";
+            my ($junk, $file, $version, $date) = split(/\//, $line);
+
+            #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
+            #print "last_mtime: " . localtime($last_mtime) . "\n";
+
+            if ($junk eq "D" ||
+                $file eq "lustre.spec.in") {
+                # also used to skip: "$file !~ m/\.(c|h|am|in)$/" but I see
+                # no good reason why only the above file patterns should
+                # count towards pristine/changed.  it should be any file,
+                # surely.
+                next;
+            }
+
+            my $cur_dir = $entry_file;
+            $cur_dir =~ s/\/CVS\/Entries$//;
+            my @statbuf = stat("$cur_dir/$file");
+            my $mtime = $statbuf[9];
+            if (!defined($mtime)) {
+                die "unable to get mtime of $cur_dir/$file: $!\n";
+            }
+            my $local_date = gmtime($mtime);
+            if ($local_date ne $date &&
+                $file ne "lustre.spec.in") {
+                #print "$file : " . localtime($mtime) . "\n";
+                $pristine = 0;
+            }
+
+            if ($mtime > $last_mtime) {
+                $last_mtime = $mtime;
+            }
+
+            if ($date) {
+                my @t = split(/ +/, $date);
+                if (int(@t) != 5) {
+                    #print "skipping: $date\n";
+                    next;
+                }
+                my ($hours, $min, $sec) = split(/:/, $t[3]);
+                my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
+                my $secs = 0;
+                $mon = $months{$mon};
+                $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
+                if ($secs > $last_mtime) {
+                    $last_mtime = $secs;
+                }
+            }
+        }
+        $entry->close();
+    }
+    return $last_mtime, $pristine;
+
+}
+
+sub mtime2date($)
+{
+
+    my $mtime = shift;
+
+    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
+      localtime($mtime);
+    $year += 1900;
+    $mon++;
+    my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday,
+                            $hour, $min, $sec);
+
+    return $show_last;
+
+}
+
+sub is_pristine()
+{
+
+    return $pristine;
+
+}
+
+($last_mtime, $pristine) = get_latest_mtime();
+
+1;
diff --git a/lustre/scripts/version_tag-git.pl b/lustre/scripts/version_tag-git.pl
new file mode 100644 (file)
index 0000000..4912de8
--- /dev/null
@@ -0,0 +1,39 @@
+my ($tag, $fcoms, $hash);
+
+sub get_buildid()
+{
+
+    return $main::am_buildid;
+
+}
+
+sub is_pristine()
+{
+
+    if ($fcoms > 0) {
+        return 0;
+    }
+
+    my $diffcount=`git diff | wc -l`;
+    if ($diffcount > 0) {
+        return 0;
+    }
+
+    return 1;
+
+}
+
+sub get_tag()
+{
+
+    return $tag;
+
+}
+
+my $desc=`git describe --tags`;
+$desc =~ /([^-]+)(?:-(.+)-(.+))?\n/;
+$tag = $1;
+$fcoms = $2;
+$hash = $3;
+
+1;
diff --git a/lustre/scripts/version_tag-none.pl b/lustre/scripts/version_tag-none.pl
new file mode 100644 (file)
index 0000000..bbbb0fa
--- /dev/null
@@ -0,0 +1,41 @@
+my ($tag, $version, $buildid, $pristine);
+
+sub get_tag()
+{
+
+    return $tag;
+
+}
+
+sub get_buildid()
+{
+
+    return $buildid;
+
+}
+
+sub is_pristine()
+{
+
+    return $pristine;
+
+}
+
+my $META = new IO::File;
+if (!$META->open("META")) {
+    die "unable to open the META file: $!\n";
+}
+my $line;
+while (defined($line = <$META>)) {
+    if ($line =~ /^TAG\s*=\s*(.+)/) {
+        $tag = $1;
+    } elsif ($line =~ /^VERSION\s*=\s*([\d\.])/) {
+        $version = $1;
+    } elsif ($line =~ /^BUILDID\s*=\s*([a-g\d]+)/) {
+        $buildid = $1;
+    } elsif  ($line =~ /^PRISTINE\s*=\s*([01])/) {
+        $pristine = $1;
+    }
+}
+
+1;
index 92655e1..eadb66a 100644 (file)
 #!/usr/bin/perl
 # -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
 
-use strict;
-use diagnostics;
 use IO::File;
-use Time::Local;
 
-my $pristine = 1;
-my $kernver = "";
+# get all of the values we want out of the autoMakefile
+sub read_autoMakefile() {
 
-# Use the CVS tag first otherwise use the portals version
-sub get_tag()
-{
-    my $tag;
-    my $line;
-
-    my $tagfile = new IO::File;
-    if (!$tagfile->open("lustre/CVS/Tag")) {
-        # is there a good way to do this with git or should the git case just
-        # fall through to use config.h?  it is always nice to know if we are
-        # working on a tag or branch.
-        my $verfile = new IO::File;
-        if (!$verfile->open("config.h")) {
-          return "UNKNOWN";
-        }
-        while(defined($line = <$verfile>)) {
-            $line =~ /\#define VERSION "(.*)"/;
-            if ($1) {
-                $tag = $1;
-                last;
-            }
-        }
-        $verfile->close();
-        return $tag
-    } else {
-        my $tmp = <$tagfile>;
-        $tagfile->close();
-
-        $tmp =~ m/[TN](.*)/;
-        return $1;
-    }
-}
-
-sub get_latest_mtime()
-{
-    my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
-                "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
-                "Nov" => 10, "Dec" => 11);
-
-    my $last_mtime = 0;
-
-    # a CVS checkout
-    if (-d "CVS") {
-        # if we got here, we are operating in a CVS checkout
-        my @entries = `find . -name Entries`;
-        my $entry_file;
-        foreach $entry_file (@entries) {
-            chomp($entry_file);
-            my $entry = new IO::File;
-            if (!$entry->open($entry_file)) {
-                die "unable to open $entry_file: $!\n";
-            }
-            my $line;
-            while (defined($line = <$entry>)) {
-                chomp($line);
-                #print "line: $line\n";
-                my ($junk, $file, $version, $date) = split(/\//, $line);
-
-                #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
-                #print "last_mtime: " . localtime($last_mtime) . "\n";
-
-                if ($junk eq "D" ||
-                    $file eq "lustre.spec.in") {
-                    # also used to skip: "$file !~ m/\.(c|h|am|in)$/" but I see
-                    # no good reason why only the above file patterns should
-                    # count towards pristine/changed.  it should be any file,
-                    # surely.
-                    next;
-                }
-
-                my $cur_dir = $entry_file;
-                $cur_dir =~ s/\/CVS\/Entries$//;
-                my @statbuf = stat("$cur_dir/$file");
-                my $mtime = $statbuf[9];
-                if (!defined($mtime)) {
-                    next;
-                }
-                my $local_date = gmtime($mtime);
-                if ($local_date ne $date &&
-                    $file ne "lustre.spec.in") {
-                    #print "$file : " . localtime($mtime) . "\n";
-                    $pristine = 0;
-                }
-
-                if ($mtime > $last_mtime) {
-                    $last_mtime = $mtime;
-                }
-
-                if ($date) {
-                    my @t = split(/ +/, $date);
-                    if (int(@t) != 5) {
-                        #print "skipping: $date\n";
-                        next;
-                    }
-                    my ($hours, $min, $sec) = split(/:/, $t[3]);
-                    my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
-                    my $secs = 0;
-                    $mon = $months{$mon};
-                    $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
-                    if ($secs > $last_mtime) {
-                        $last_mtime = $secs;
-                    }
-                }
-            }
-            $entry->close();
-        }
-    } elsif (-d ".git") {
-        # a git checkout
-        # TODO: figure out how to determine the most recently modified file
-        #       in a git working copy.
-        #       NOTE: this is not simply the newest file in the whole tree,
-        #             but the newest file in the tree that is from the
-        #             repository.
-        $last_mtime = time();
-    } else {
-        my $tree_status = new IO::File;
-        if (!$tree_status->open("tree_status")) {
-            die "unable to open the tree_status file: $!\n";
-        }
-        my $line;
-        while (defined($line = <$tree_status>)) {
-            if ($line =~ /^PRISTINE\s*=\s*(\d)/) {
-                $pristine = $1;
-            } elsif  ($line =~ /^MTIME\s*=\s*(\d+)/) {
-                $last_mtime = $1;
-            }
-        }
-    }
-    return $last_mtime;
-
-}
-
-sub get_linuxdir()
-{
-    my $config = new IO::File;
-    my ($line, $dir, $objdir);
-    if (!$config->open("autoMakefile")) {
+    my $file = new IO::File;
+    my ($line, $dir, $objdir, $modules, $version, $local_version, $buildid);
+    if (!$file->open("autoMakefile")) {
         die "Run ./configure first\n";
     }
-    while (defined($line = <$config>)) {
+    $modules = 1;
+    while (defined($line = <$file>)) {
         chomp($line);
-        if ($line =~ /LINUX :?= (.*)/) {
+        if ($line =~ /^LINUX :?= (.*)/) {
             $dir = $1;
-        } elsif ($line =~ /LINUX_OBJ :?= (.*)/) {
+        } elsif ($line =~ /^LINUX_OBJ :?= (.*)/) {
             $objdir = $1;
-        } elsif ($line =~ /MODULES_TRUE = #/ ||
-                $line =~ /MODULE_TARGET = $/) {
-            # nothing to do if modules are not being built
-            return ""
+        } elsif ($line =~ /^MODULES_TRUE = #/ ||
+                 $line =~ /^MODULE_TARGET = $/) {
+            # modules are not being built
+            $modules = 1;
+        } elsif ($line =~ /^VERSION = (.*)/) {
+            $version = "$1";
+        } elsif ($line =~ /^DOWNSTREAM_RELEASE = (.*)/ && $1 ne "") {
+            $local_version = "$1";
+        } elsif ($line =~ /^BUILDID = (.*)/ && $1 ne "") {
+            $buildid = "$1";
         }
     }
-    $config->close();
+    $file->close();
+
+    return ($dir, $objdir, $modules, $version, $local_version, $buildid);
+
+}
+
+sub get_kernver($$)
+{
+
+    my $dir = shift;
+    my $objdir = shift;
+
     my $ver = new IO::File;
     if (!$ver->open("$objdir/include/linux/utsrelease.h") &&
         !$ver->open("$objdir/include/linux/version.h") &&
         !$ver->open("$dir/include/linux/utsrelease.h") &&
         !$ver->open("$dir/include/linux/version.h")) {
             die "Run make dep on '$dir'\n";
-        }
+    }
 
     while(defined($line = <$ver>)) {
         $line =~ /\#define UTS_RELEASE "(.*)"/;
@@ -178,88 +59,103 @@ sub get_linuxdir()
     }
     $ver->close();
     chomp($kernver);
-    $dir =~ s/\//\./g;
-    return $dir;
-}
-
-sub mtime2date($)
-{
-    my $mtime = shift;
+    return $kernver;
 
-    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
-      localtime($mtime);
-    $year += 1900;
-    $mon++;
-    my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday,
-                            $hour, $min, $sec);
-
-    return $show_last;
 }
 
-sub generate_ver($$$)
+sub generate_ver($$$$$$$)
 {
+
     my $tag = shift;
-    my $mtime = shift;
+    my $local_version = shift;
+    my $buildid = shift;
     my $linuxdir = shift;
+    my $pristine = shift;
+    my $kernver = shift;
+    my $env_vers = shift;
 
-    # assume building without modules
-    my $postfix = "";
-
-    if ($linuxdir ne "") {
-        $postfix = "-$kernver";
-    }
-
-    #print "localtime: " . localtime($mtime) . "\n";
-
-    my $lustre_vers = $ENV{LUSTRE_VERS};
-
-    print "#define BUILD_VERSION \"";
+    print "#define BUILD_VERSION \"$tag";
 
-    if ($lustre_vers) {
-        print "$tag-$lustre_vers\"\n";
+    if ($env_vers) {
+        print "-$env_vers\"\n";
         return 0;
     }
 
-    my $show_last = mtime2date($mtime);
-
+    if ($local_version ne "") {
+        print "-$local_version";
+    }
+    print "-$buildid";
     # if we want to get rid of the PRISTINE/CHANGED thing, get rid of these
     # lines.  maybe we only want to print -CHANGED when something is changed
     # and print nothing when it's pristine
     if ($pristine) {
-        print "$tag-$show_last-PRISTINE$postfix\"\n";
+        print "-PRISTINE";
     } else {
-        print "$tag-$show_last-CHANGED$postfix\"\n";
+        print "-CHANGED";
+    }
+
+    if ($kernver ne "") {
+        print "-$kernver";
     }
+
+    print "\"\n";
+
 }
 
 my $progname = $0;
 $progname =~ s/.*\///;
 
-if ($progname eq "tree_status.pl" && !-d "CVS" && !-d ".git") {
-    die("a tree status can only be determined in an source code control system checkout\n");
-}
-
 chomp(my $cwd = `pwd`);
 
+my $path = $0;
+$path =~ s/(.+)\/.*/\1/;
+push(@INC, $cwd . "/" . $path);
+
+my $is_git = 0;
+my $is_cvs = 0;
+
 # ARGV[0] = srcdir
 # ARGV[1] = builddir
 
-# for get_latest_mtime and get_tag you need to be in srcdir
-
+# need to be in srcdir
 if ($ARGV[0]) {
     chdir($ARGV[0]);
 }
+
+if (-d ".git") {
+    $is_git = 1;
+    require "version_tag-git.pl";
+} elsif (-d "CVS") {
+    $is_cvs = 1;
+    require "version_tag-cvs.pl";
+} else {
+    die("a tree status can only be determined in an source code control system checkout\n")
+        if ($progname eq "make_META.pl");
+    require "version_tag-none.pl";
+}
+
+($am_linuxdir, $am_linuxobjdir, $am_modules, $am_version, $local_version,
+ $am_buildid) = read_autoMakefile();
+
 my $tag = get_tag();
-my $mtime = get_latest_mtime()
-    if (!defined($ENV{LUSTRE_VERS}));
+my $pristine = is_pristine();
+my $buildid = get_buildid();
 
 if ($progname eq "version_tag.pl") {
-    my $linuxdir = get_linuxdir();
-    $linuxdir =~ s/\//\./g;
-    generate_ver($tag, $mtime, $linuxdir);
-} elsif ($progname eq "tree_status.pl") {
+    my $kernver = "";
+    $kernver = get_kernver($am_linuxdir, $am_linuxobjdir)
+        if ($am_linuxdir ne "");
+
+    my $linuxdir =~ s/\//\./g;
+    generate_ver($tag, $local_version, $buildid, $linuxdir, $pristine, $kernver,
+                 $ENV{LUSTRE_VERS});
+} elsif ($progname eq "make_META.pl") {
+    print "TAG = $tag\n";
+    print "VERSION = $am_version\n";
+    print "BUILDID = $buildid\n";
     print "PRISTINE = $pristine\n";
-    print "MTIME = $mtime\n";
+    print "LOCAL_VERSION = $local_version\n";
 }
 
 exit(0);