[Ocfs2-commits] jlbec commits r2770 - in branches/ocfs2-1.2: . vendor/rhel4 vendor/sles9

svn-commits@oss.oracle.com svn-commits at oss.oracle.com
Wed Feb 22 16:57:55 CST 2006


Author: jlbec
Signed-off-by: mfasheh
Date: 2006-02-22 16:57:53 -0600 (Wed, 22 Feb 2006)
New Revision: 2770

Added:
   branches/ocfs2-1.2/Vendor.make
   branches/ocfs2-1.2/mbvendor.m4
   branches/ocfs2-1.2/svnrev.guess
   branches/ocfs2-1.2/vendor.guess
   branches/ocfs2-1.2/vendor/rhel4/Vendor.make
   branches/ocfs2-1.2/vendor/rhel4/kernel.guess
   branches/ocfs2-1.2/vendor/rhel4/rpmarch.guess
   branches/ocfs2-1.2/vendor/rhel4/vendor.guess
   branches/ocfs2-1.2/vendor/sles9/Vendor.make
   branches/ocfs2-1.2/vendor/sles9/kernel.guess
   branches/ocfs2-1.2/vendor/sles9/rpmarch.guess
   branches/ocfs2-1.2/vendor/sles9/vendor.guess
Log:

o Add the vendor infrastructure.  This is all the support scripts and
  makefiles.  They are not linked into the build process yet.

Signed-off-by: mfasheh



Added: branches/ocfs2-1.2/Vendor.make
===================================================================
--- branches/ocfs2-1.2/Vendor.make	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/Vendor.make	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,10 @@
+
+#
+# This Makefile snippet is to be included in Makebo Makefiles that
+# use the mbvendor infrastructure
+#
+
+PKG_VERSION = $(shell $(TOPDIR)/svnrev.guess $(PACKAGE))
+
+-include $(TOPDIR)/vendor/$(shell ./vendor.guess)/Vendor.make
+

Added: branches/ocfs2-1.2/mbvendor.m4
===================================================================
--- branches/ocfs2-1.2/mbvendor.m4	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/mbvendor.m4	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,73 @@
+# MB_VENDOR([VARIABLE])
+# ---------------------
+AC_DEFUN([MB_VENDOR],
+  [AC_MSG_CHECKING([for vendor])
+   AC_ARG_WITH(vendor, [  --with-vendor=VENDOR    Vendor to tailor build defaults and packages to [common]],[
+     mb_vendor="$withval"
+     if test -x "vendor/${mb_vendor}/vendor.guess"; then
+       if "vendor/${mb_vendor}/vendor.guess" >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+         AC_MSG_RESULT([$mb_vendor])
+       else
+         AC_MSG_RESULT([not found])
+         AC_MSG_ERROR([Vendor $mb_vendor not detected])
+       fi
+     else
+       AC_MSG_RESULT([not supported])
+       AC_MSG_ERROR([Vendor $mb_vendor not supported])
+     fi
+  ], [
+    mb_vendor=`./vendor.guess 2>&AS_MESSAGE_LOG_FD`
+    if test -z "$mb_vendor"; then
+       AC_MSG_RESULT([not found])
+    else
+       AC_MSG_RESULT([$mb_vendor])
+    fi
+  ])
+  dnl Use 2.13 safe ifelse()
+  ifelse([$1], [], [], [
+           $1="$mb_vendor"
+           AC_SUBST($1)
+         ])
+])  # MB_VENDOR
+
+# MB_VENDOR_KERNEL([VARIABLE])
+# ---------------------
+AC_DEFUN([MB_VENDOR_KERNEL],
+  [AC_MSG_CHECKING([for vendor kernel])
+   AC_ARG_WITH(vendorkernel, [  --with-vendorkernel=KERNELVERSION  Vendor kernel version to compile against [detected]], [
+     mb_vendorkernel="$withval"
+     if test -z "$mb_vendor"; then
+       AC_MSG_RESULT([no vendor])
+       AC_MSG_ERROR([No vendor specified or discovered])
+     fi
+     if test -x "vendor/${mb_vendor}/kernel.guess"; then
+       mb_vkinclude="`vendor/${mb_vendor}/kernel.guess build ${mb_vendorkernel} 2>&AS_MESSAGE_LOG_FD`"
+       if test -z "$mb_vkinclude"; then
+         AC_MSG_RESULT([not found])
+         AC_MSG_ERROR([Vendor kernel $mb_vendorkernel not detected])
+       else
+         AC_MSG_RESULT([$mb_vkinclude])
+       fi
+     else
+       AC_MSG_RESULT([not supported])
+       AC_MSG_ERROR([Vendor $mb_vendor does not support kernel detection])
+     fi
+   ], [
+     if test -x "vendor/${mb_vendor}/kernel.guess"; then
+       mb_vkinclude="`vendor/${mb_vendor}/kernel.guess build 2>&AS_MESSAGE_LOG_FD`"
+       if test -z "$mb_vkinclude"; then
+         AC_MSG_RESULT([not found])
+       else
+         AC_MSG_RESULT([$mb_vkinclude])
+       fi
+     else
+       mb_vkinclude=
+       AC_MSG_RESULT([not supported])
+     fi
+  ])
+  dnl Use 2.13 safe ifelse()
+  ifelse([$1], [], [], [
+           $1="$mb_vkinclude"
+           AC_SUBST($1)
+         ])
+])  # MB_VENDOR_KERNEL

Added: branches/ocfs2-1.2/svnrev.guess
===================================================================
--- branches/ocfs2-1.2/svnrev.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/svnrev.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,142 @@
+#!/bin/sh
+
+#
+# This script creates a package version for packages.  The package
+# version is the "release" or other version attached by the packaging
+# software (eg, RPM or Dpkg) after the upstream software version.
+#
+# This software must be invoked like so:
+#
+#     svnrev.guess <packagename>
+#
+# and it expects that release tags are of the form:
+#
+#     /tags/<packagename>-<version>
+#
+# Note that release tag versioning expects a working connection to
+# the repository (for SVN log), but all other branches don't require it.
+#
+# If there is no .svn directory or it cannot discover the repository
+# version, the script sets a version of 0.local.
+#
+
+if [ $# -lt 1 ]
+then
+    echo "Usage: svnrev.guess <packagename>" >&2
+    exit 1
+fi
+PACKAGE="$1"
+
+getstat()
+{
+    if [ ! -d .svn ]
+    then
+        return
+    fi
+    svn stat -v | awk 'BEGIN{modified = "false";lastrev = 0}
+                       /Status against/{next}
+                       /^\?/{next} 
+                       {
+                         col1=substr($0, 0, 1);
+                         if (col1 != " ") {modified = "true"}
+                         sub(/^......../, "");
+                         if ($1 > lastrev) { lastrev=$1 }
+                       }
+                       END{print modified,lastrev}'
+}
+
+#
+# Branches that are not releases get a work-in-progress package version.
+# This is 0.<svn_revision>[m].  The 0. ensures that an upcoming real
+# release, with an package version of 1, will supercede this package.
+# The "m" is added if the working tree has modifications to distinguish
+# it from a committed revision.
+#
+# If there is no repository or there is a problem getting the revision,
+# the package version is 0.local.
+#
+workingrev()
+{
+    STATINFO="$(getstat)"
+    MODIFIED=$(echo "$STATINFO" | cut -f1 -d" ")
+    LASTREV=$(echo "$STATINFO" | cut -f2 -d" ")
+
+    if [ -z "$LASTREV" ]
+    then
+        PKG_VERSION=0.local
+    else
+        PKG_VERSION=0.${LASTREV}
+        if [ "$MODIFIED" = "true" ]
+        then
+            PKG_VERSION="${PKG_VERSION}m"
+        fi
+    fi
+    echo "$PKG_VERSION"
+}
+
+#
+# If the branch is a tag (tags/project-x.y), it needs a release-based
+# package version (-1, -2, etc).  Generally, it will be the tip of the
+# branch (package version 1).  However, if there is a slight release
+# fixup, that warrants bumping the package version.
+#
+# The logic is pretty simple.  Walk the history looking for the
+# creation of the tag (A /tags/project-x.y).  For each revsion later
+# than the creation of the tag, bump the package version.
+# 
+releaserev()
+{
+    BRANCH="$1"
+    BRANCH_SEARCH="`echo "$BRANCH" | sed -e 's/\//\\\\\//g'`"
+    svn log -v | awk 'BEGIN{rev=0}
+                      /^r[0-9]+ \|/{rev += 1}
+                      /^ +A \/'"$BRANCH_SEARCH"'$/{exit}
+                      END{print rev}'
+}
+
+
+# 
+# Tag branches are releases, and need a release-style package version.
+# All other branches are non-release, and get an obviously
+# work-in-progress package version.
+#
+# guessbranch() expects the standard Subversion layout of
+#     /trunk
+#     /branches/<branchname>
+#     /tags/<tagname>
+#
+guessbranch()
+{
+    if [ ! -d .svn ]
+    then
+        return
+    fi
+    svn info | awk '/URL: .*\/trunk\/?$/{print "trunk"; exit 0}
+                    /URL: .*\/branches\/[^/]+\/?/{
+                                                   gsub(/\/$/, "", $2);
+                                                   sub(/^.*\/branches\//, "", $2);
+                                                   print "branches/"$2;
+                                                   exit 0;
+                                                 }
+                    /URL: .*\/tags\/[^/]+\/?/{
+                                                   gsub(/\/$/, "", $2);
+                                                   sub(/^.*\/tags\//, "", $2);
+                                                   print "tags/"$2;
+                                                   exit 0;
+                                                 }'
+}
+
+if ! which svn 1>/dev/null 2>&1
+then
+    echo "0.local"
+else
+    BRANCH=$(guessbranch)
+    case "$BRANCH" in
+    tags/${PACKAGE}*)
+        releaserev "$BRANCH"
+        ;;
+    *)
+        workingrev
+        ;;
+    esac
+fi

Added: branches/ocfs2-1.2/vendor/rhel4/Vendor.make
===================================================================
--- branches/ocfs2-1.2/vendor/rhel4/Vendor.make	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/rhel4/Vendor.make	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,21 @@
+#
+# RHEL 4
+#
+
+TOOLSARCH = $(shell $(TOPDIR)/vendor/rhel4/rpmarch.guess tools $(TOPDIR))
+MODULEARCH = $(shell $(TOPDIR)/vendor/rhel4/rpmarch.guess module $(TOPDIR))
+
+$(TOPDIR)/vendor/rhel4/ocfs2-%.spec: $(TOPDIR)/vendor/rhel4/ocfs2.spec-generic
+	SPECVER="$@"; \
+		SPECVER="$${SPECVER#*ocfs2-}"; \
+		SPECVER="$${SPECVER%.spec}"; \
+		sed -e 's/@@KVER@@/'$${SPECVER}'/' -e 's/@@PKG_VERSION@@/'$(PKG_VERSION)'/' < $< > $@
+
+rhel4_%_srpm: dist $(TOPDIR)/vendor/rhel4/ocfs2-%.spec
+	rpmbuild -bs --define "_sourcedir $(TOPDIR)" --define "_srcrpmdir $(TOPDIR)" $(TOPDIR)/vendor/rhel4/ocfs2-$(patsubst rhel4_%_srpm,%,$@).spec
+
+rhel4_%_rpm: rhel4_%_srpm
+	rpmbuild --rebuild $(MODULEARCH) "ocfs2-$(patsubst rhel4_%_rpm,%,$@)-$(DIST_VERSION)-$(PKG_VERSION).src.rpm"
+
+
+packages: $(shell $(TOPDIR)/vendor/rhel4/kernel.guess targets)

Added: branches/ocfs2-1.2/vendor/rhel4/kernel.guess
===================================================================
--- branches/ocfs2-1.2/vendor/rhel4/kernel.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/rhel4/kernel.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,233 @@
+#!/bin/sh
+
+
+RHEL4_KERNEL_BASE="/usr/src/kernels"
+
+#
+# This is a simple mapping of architectures to kernel flavors.  One
+# entry per architecture, <arch>:<flavor1>[,<flavor> ...]
+#
+# This is used when detecting kernels to build packages for.  A kernel
+# is only built if build trees for all flavors are installed.
+#
+# Unique to redhat, empty types (the 'default' kernel) are allowed.
+# Be careful parsing this!
+#
+RHEL4_KERNEL_TYPES="
+    i686:,smp,hugemem
+    x86_64:,smp
+    ia64:
+    ppc64:
+"
+
+
+guess_rhel4_arch()
+{
+    # This appears to DTRT (i686 on x86, ppc64 on pSeries).
+    uname -m
+}
+
+guess_rhel4_type()
+{
+    case "$1" in
+    *smp)
+        echo "smp"
+        ;;
+    *hugemem)
+        echo "hugemem"
+        ;;
+    *hugeproc)
+        echo "hugeproc"
+        ;;
+    *)
+        echo ""
+        ;;
+    esac
+}
+
+guess_rhel4_dir()
+{
+    KVER="$1"
+
+    DIRTYPE=$(guess_rhel4_type "$KVER")
+    ARCH=$(guess_rhel4_arch)
+
+    if [ -z "$DIRTYPE" ]
+    then
+        echo "${1%${DIRTYPE}}-${ARCH}"
+    else
+        echo "${1%${DIRTYPE}}-${DIRTYPE}-${ARCH}"
+    fi
+}
+
+verfromdir()
+{
+    TESTDIR="$1"
+    if [ -r "${TESTDIR}/include/linux/version.h" ]
+    then
+        awk '/UTS_RELEASE/{gsub(/"/,"",$3); print $3}' "${TESTDIR}/include/linux/version.h"
+    fi
+}
+
+validate_dir()
+{
+    KVER="$1"
+    DIR="$2"
+
+    if [ ! -d "${RHEL4_KERNEL_BASE}/${DIR}" ]
+    then
+        return 1
+    elif [ ! -f "${RHEL4_KERNEL_BASE}/${DIR}/include/linux/autoconf.h" ]
+    then
+        return 1
+    elif [ ! -f "${RHEL4_KERNEL_BASE}/${DIR}/include/linux/version.h" ]
+    then
+        return 1
+    fi
+
+    if [ "$KVER" != "$(verfromdir "${RHEL4_KERNEL_BASE}/${DIR}")" ]
+    then
+        return 1
+    fi
+
+    return 0
+}
+
+# Takes a `uname -r` and returns "ver type", where ver
+# is 2.6.9-NN.EL and type is "smp" or the like.
+validate_version()
+{
+    KVER="$1"
+
+    dir=$(guess_rhel4_dir "$KVER")
+    if validate_dir "$KVER" "$dir"
+    then
+        echo "${RHEL4_KERNEL_BASE}/${dir}"
+    fi
+}
+
+find_version()
+{
+    # Find the most recent valid kernel
+    ls -1 -t "$RHEL4_KERNEL_BASE" | while read kdir
+    do
+        KVER="$(verfromdir "${RHEL4_KERNEL_BASE}/${kdir}")"
+        if validate_dir "$KVER" "$kdir"
+        then
+            echo "${RHEL4_KERNEL_BASE}/${kdir}"
+            break
+        fi
+    done
+}
+
+# For a given KVER, see if all the -devel packages exist
+validate_target()
+{
+    KVER="$1"
+    ARCH="$2"
+    TYPELIST="$3"
+
+    typelist="${TYPELIST#$ARCH:}"
+    while :
+    do
+        type="${typelist%%,*}"
+        VERDIR="$(validate_version ${KVER}${type})"
+        if [ -z "$VERDIR" ]
+        then
+            return 1
+        fi
+    
+        # This loop walks the list of types being careful of the empty
+        # typename
+        tmp="${typelist#*,}"
+        if [ -z "$tmp" -o "$tmp" = "$typelist" ]
+        then
+            break
+        fi
+        typelist="$tmp"
+    done
+
+    return 0
+}
+
+find_targets()
+{
+    # Pre-calculate ARCH and TYPELIST, at least
+    ARCH="$(guess_rhel4_arch)"
+    if [ -z "$ARCH" ]
+    then
+        return
+    fi
+
+    TYPELIST=
+    for typelist in $RHEL4_KERNEL_TYPES
+    do
+        TARCH=$(echo "$typelist" | cut -f1 -d:)
+        if [ "$TARCH" = "$ARCH" ]
+        then
+            TYPELIST="$typelist"
+            break
+        fi
+    done
+
+    if [ -z "$TYPELIST" ]
+    then
+        return
+    fi
+    
+    ls -1 -t "$RHEL4_KERNEL_BASE" | while read kdir
+    do
+        case "$kdir" in
+        2.6.9-5.EL*)
+            # Missing get_sb_pseudo()
+            continue
+            ;;
+        *)
+            ;;
+        esac
+
+        KVER="$(verfromdir "${RHEL4_KERNEL_BASE}/${kdir}")"
+        if ! validate_dir "$KVER" "$kdir"
+        then
+            continue
+        fi
+        if validate_target "$KVER" "$ARCH" "$TYPELIST"
+        then
+            echo "rhel4_${KVER}_rpm"
+        fi
+    done
+}
+
+case "$1" in
+include|build)
+    if [ -n "$2" ]
+    then
+        KPATH="$(validate_version "$2")"
+    else
+        KVER="$(uname -r)"
+        KPATH="$(validate_version "$KVER")"
+        if [ -z "$KPATH" ]
+        then
+            KPATH="$(find_version)"
+        fi
+    fi
+    if [ -n "$KPATH" ]
+    then
+        if [ "$1" = "include" ]
+        then
+            KPATH="${KPATH}/include"
+        fi
+        echo "${KPATH}"
+    fi
+    ;;
+targets)
+    find_targets
+    ;;
+"")
+    echo "Missing operation" >&2
+    ;;
+*)
+    echo "Invalid operation: $1" >&2
+    exit 1
+    ;;
+esac

Added: branches/ocfs2-1.2/vendor/rhel4/rpmarch.guess
===================================================================
--- branches/ocfs2-1.2/vendor/rhel4/rpmarch.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/rhel4/rpmarch.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,68 @@
+#! /bin/sh
+
+mode="$1"
+srcdir="$2"
+
+host_cpu=
+
+
+QUERYFILE=/etc/redhat-release
+
+if test -n "$QUERYFILE"; then
+  host_cpu="`rpm -qf $QUERYFILE --queryformat \"%{ARCH}\"`"
+fi
+
+if test -z "$host_cpu" -o "$host_cpu" = "noarch" ; then
+  host_alias=`$srcdir/config.guess`
+  host=`$srcdir/config.sub $host_alias`
+  host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+fi
+
+case "$host_cpu" in
+  x86_64|ia64|s390x)
+    TOOLSARCH="$host_cpu"
+    ;;
+  i386|i486|i586|i686|i786|k6|k7)
+    TOOLSARCH="i386"
+    ;;
+  ppc|ppc64|ppciseries|ppcpseries|ppc64iseries|ppc64pseries|powerpc|powerpc64)
+    TOOLSARCH="ppc64"
+    ;;
+  *)
+    echo "rpmarch.guess: Warning: unknown RPM CPU architecture: $host_cpu" >&2
+    TOOLSARCH=""
+    ;;
+esac
+
+# Only a few of these need to be overwritten from RPM's default
+case "$host_cpu" in
+  i386|i586)
+    MODULEARCH="i686"
+    ;;
+  ppc|ppc64|ppciseries|ppcpseries|ppc64iseries|ppc64pseries|powerpc|powerpc64)
+    MODULEARCH="ppc64"
+    ;;
+  *)
+    MODULEARCH=""
+    ;;
+esac
+
+case "$mode" in
+  module)
+    if [ -n "$MODULEARCH" ] ; then
+      echo "--target $MODULEARCH"
+    fi
+    ;;
+  tools)
+    if [ -n "$TOOLSARCH" ] ; then
+      echo "--target $TOOLSARCH"
+    fi
+    ;;
+  *)
+    echo "rpmarch.guess: Invalid mode: $mode" >&2
+    echo "error"
+    exit 1
+    ;;
+esac
+
+exit 0

Added: branches/ocfs2-1.2/vendor/rhel4/vendor.guess
===================================================================
--- branches/ocfs2-1.2/vendor/rhel4/vendor.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/rhel4/vendor.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ ! -f /etc/redhat-release ]
+then
+    exit 1
+fi
+
+if [ "`rpm -qf /etc/redhat-release --qf '%{VERSION}' 2>/dev/null`" != "4AS" ]
+then
+    exit 1
+fi
+
+exit 0

Added: branches/ocfs2-1.2/vendor/sles9/Vendor.make
===================================================================
--- branches/ocfs2-1.2/vendor/sles9/Vendor.make	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/sles9/Vendor.make	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,24 @@
+#
+# SLES 9
+#
+
+TOOLSARCH = $(shell $(TOPDIR)/vendor/sles9/rpmarch.guess tools $(TOPDIR))
+MODULEARCH = $(shell $(TOPDIR)/vendor/sles9/rpmarch.guess module $(TOPDIR))
+
+
+$(TOPDIR)/vendor/sles9/ocfs2-%.spec: $(TOPDIR)/vendor/sles9/ocfs2.spec-generic
+	SPECVER="$@"; \
+		SPECVER="$${SPECVER#*ocfs2-}"; \
+		SPECVER="$${SPECVER%.spec}"; \
+		sed -e 's/@@KVER@@/'$${SPECVER}'/' -e 's/@@PKG_VERSION@@/'$(PKG_VERSION)'/' < $< > $@
+
+sles9_%_srpm: dist $(TOPDIR)/vendor/sles9/ocfs2-%.spec
+	rpmbuild -bs --define "_sourcedir $(TOPDIR)" --define "_srcrpmdir $(TOPDIR)" $(TOPDIR)/vendor/sles9/ocfs2-$(patsubst sles9_%_srpm,%,$@).spec
+
+sles9_%_rpm: sles9_%_srpm
+	rpmbuild --rebuild $(MODULEARCH) "ocfs2-$(patsubst sles9_%_rpm,%,$@)-$(DIST_VERSION)-$(PKG_VERSION).src.rpm"
+
+
+include $(TOPDIR)/vendor/common/Vendor.make
+
+packages: $(shell $(TOPDIR)/vendor/sles9/kernel.guess targets) support_rpm

Added: branches/ocfs2-1.2/vendor/sles9/kernel.guess
===================================================================
--- branches/ocfs2-1.2/vendor/sles9/kernel.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/sles9/kernel.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,286 @@
+#!/bin/sh
+
+SLES9_KERNEL_BASE="/usr/src"
+
+#
+# SLES9 has wacky names for its kernel flavors.  So we'll just create
+# a list here of the mappings.  It's pretty simple.  One entry per
+# architecture, <arch>:<flavor1>[,<flavor> ...]
+#
+# Anyway, we can even reuse this when detecting kernels to build
+# packages for.  A kernel is only built if build trees for all flavors
+# are installed.
+#
+SLES9_KERNEL_TYPES="
+    x86_64:default,smp
+    ppc64:pseries64,iseries64,pmac64
+    ia64:default,64k-pagesize,sn2
+    i386:default,smp,bigsmp
+    s390:s390x
+"
+    
+
+
+guess_sles9_arch()
+{
+    ARCH=$(uname -m)
+    case "$ARCH" in
+    i386|i586|i686)
+	echo "i386"
+        ;;
+    s390x)
+        echo "s390"
+        ;;
+    *)
+        # This appears to be correct on ppc64
+        echo "$ARCH"
+        ;;
+    esac
+}
+
+guess_sles9_type()
+{
+    KVER="$1"
+
+    ARCH="$(guess_sles9_arch)"
+    if [ -z "$ARCH" ]
+    then
+        return
+    fi
+
+    for typelist in $SLES9_KERNEL_TYPES
+    do
+        TARCH=$(echo $typelist | cut -f1 -d:)
+        if [ "$TARCH" = "$ARCH" ]
+        then
+            for type in $(echo $typelist | cut -f2 -d: | sed -e 's/,/ /g')
+            do
+                case "$KVER" in
+                *-${type})
+                    echo "$type"
+                    break
+                    ;;
+                *)
+                    ;;
+                esac
+            done
+            break
+        fi
+    done
+}
+
+guess_sles9_dir()
+{
+    KVER="$1"
+
+    DIRTYPE=$(guess_sles9_type "$KVER")
+    ARCH=$(guess_sles9_arch)
+
+    if [ -n "$DIRTYPE" ]
+    then
+        echo "linux-${1%-${DIRTYPE}}-obj/${ARCH}/${DIRTYPE}"
+    fi
+}
+
+verfromdir()
+{
+    TESTDIR="$1"
+    if [ -r "${TESTDIR}/include/linux/version.h" ]
+    then
+        awk '/UTS_RELEASE/{gsub(/"/,"",$3); print $3}' "${TESTDIR}/include/linux/version.h"
+    fi
+}
+
+validate_dir()
+{
+    KVER="$1"
+    DIR="$2"
+
+    if [ ! -d "${SLES9_KERNEL_BASE}/${DIR}" ]
+    then
+        return 1
+    elif [ ! -f "${SLES9_KERNEL_BASE}/${DIR}/include/linux/autoconf.h" ]
+    then
+        return 1
+    elif [ ! -f "${SLES9_KERNEL_BASE}/${DIR}/include/linux/version.h" ]
+    then
+        return 1
+    fi
+
+    if [ "$KVER" != "`verfromdir "${SLES9_KERNEL_BASE}/${DIR}"`" ]
+    then
+        return 1
+    fi
+
+    return 0
+}
+
+# Takes a `uname -r` and returns "ver type", where ver
+# is 2.6.9-NN.EL and type is "smp" or the like.
+validate_version()
+{
+    KVER="$1"
+
+    dir=`guess_sles9_dir "$KVER"`
+    if validate_dir "$KVER" "$dir"
+    then
+        echo "${SLES9_KERNEL_BASE}/${dir}"
+    fi
+}
+
+find_version()
+{
+    ARCH="$(guess_sles9_arch)"
+    if [ -z "$ARCH" ]
+    then
+        return
+    fi
+
+    types=
+    for typelist in $SLES9_KERNEL_TYPES
+    do
+        TARCH=$(echo $typelist | cut -f1 -d:)
+        if [ "$TARCH" = "$ARCH" ]
+        then
+            types=$(echo $typelist | cut -f2 -d: | sed -e 's/,/ /g')
+            break
+        fi
+    done
+
+    if [ -z "$types" ]
+    then
+        return
+    fi
+
+     # Find the most recent valid kernel
+    ls -1 -t "$SLES9_KERNEL_BASE" | while read kdir
+    do
+        if [ -L "${SLES9_KERNEL_BASE}/${kdir}" -o ! -d "${SLES9_KERNEL_BASE}/${kdir}" ]
+        then
+            continue
+        fi
+
+        case "$kdir" in
+        *-obj)
+            ;;
+        *)
+            continue
+            ;;
+        esac
+        KERNELDIR=
+        for type in $types
+        do
+            KVER="`verfromdir "${SLES9_KERNEL_BASE}/${kdir}/${ARCH}/${type}"`"
+            if validate_dir "$KVER" "$kdir/${ARCH}/${type}"
+            then
+                KERNELDIR="${SLES9_KERNEL_BASE}/${kdir}/${ARCH}/${type}"
+                break
+            fi
+        done
+        if [ -n "$KERNELDIR" ]
+        then
+            echo "$KERNELDIR"
+            break
+        fi
+    done
+}
+
+validate_target()
+{
+    DIR="$1"
+    ARCH="$2"
+    types="$3"
+    for type in $types
+    do
+        KVER="`verfromdir "${SLES9_KERNEL_BASE}/${kdir}/${ARCH}/${type}"`"
+        if ! validate_dir "$KVER" "$kdir/${ARCH}/${type}"
+        then
+            return 1
+        fi
+    done
+
+    return 0
+}
+
+find_targets()
+{
+    ARCH="$(guess_sles9_arch)"
+    if [ -z "$ARCH" ]
+    then
+        return
+    fi
+
+    types=
+    for typelist in $SLES9_KERNEL_TYPES
+    do
+        TARCH=$(echo $typelist | cut -f1 -d:)
+        if [ "$TARCH" = "$ARCH" ]
+        then
+            types=$(echo $typelist | cut -f2 -d: | sed -e 's/,/ /g')
+            break
+        fi
+    done
+
+    if [ -z "$types" ]
+    then
+        return
+    fi
+
+    ls -1 -t "$SLES9_KERNEL_BASE" | while read kdir
+    do
+        # Avoid the symlinks
+        if [ -L "${SLES9_KERNEL_BASE}/${kdir}" -o ! -d "${SLES9_KERNEL_BASE}/${kdir}" ]
+        then
+            continue
+        fi
+        case "$kdir" in
+        linux-*-obj)
+            if validate_target "$kdir" "$ARCH" "$types"
+            then
+                KVER="${kdir#linux-}"
+                KVER="${KVER%-obj}"
+                if rpm -q "kernel-syms-${KVER}" 1>/dev/null 2>&1
+                then
+                    echo "sles9_${KVER}_rpm"
+                fi
+            fi
+            ;;
+        *)
+            ;;
+        esac
+    done
+}
+
+case "$1" in
+include|build)
+    if [ -n "$2" ]
+    then
+        KPATH="`validate_version "$2"`"
+    else
+        KVER="`uname -r`"
+        KPATH="`validate_version "$KVER"`"
+        if [ -z "$KPATH" ]
+        then
+            KPATH="`find_version`"
+        fi
+    fi
+    if [ -n "$KPATH" ]
+    then
+        if [ "$1" = "include" ]
+        then
+            KPATH="${KPATH}/include"
+        fi
+        echo "${KPATH}"
+    fi
+    ;;
+targets)
+    find_targets
+    ;;
+"")
+    echo "Missing operation" >&2
+    ;;
+*)
+    echo "Invalid operation: $1" >&2
+    exit 1
+    ;;
+esac

Added: branches/ocfs2-1.2/vendor/sles9/rpmarch.guess
===================================================================
--- branches/ocfs2-1.2/vendor/sles9/rpmarch.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/sles9/rpmarch.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,70 @@
+#! /bin/sh
+
+mode="$1"
+srcdir="$2"
+
+host_cpu=
+
+QUERYFILE=/etc/SuSE-release
+
+if test -n "$QUERYFILE"; then
+  host_cpu="`rpm -qf $QUERYFILE --queryformat \"%{ARCH}\"`"
+fi
+
+if test -z "$host_cpu" -o "$host_cpu" = "noarch" ; then
+  host_alias=`$srcdir/config.guess`
+  host=`$srcdir/config.sub $host_alias`
+  host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+fi
+
+case "$host_cpu" in
+  x86_64|ia64|s390x)
+    TOOLSARCH="$host_cpu"
+    ;;
+  i386|i486|i586|i686|i786|k6|k7)
+    TOOLSARCH="i386"
+    ;;
+  ppc|ppc64|ppciseries|ppcpseries|ppc64iseries|ppc64pseries|powerpc|powerpc64)
+    TOOLSARCH="ppc64"
+    ;;
+  *)
+    echo "rpmarch.guess: Warning: unknown RPM CPU architecture: $host_cpu" >&2
+    TOOLSARCH=""
+    ;;
+esac
+
+# Only a few of these need to be overwritten from RPM's default
+case "$host_cpu" in
+  i586)
+    MODULEARCH="$host_cpu"
+    ;;
+  i386|i686)
+    MODULEARCH="i586"
+    ;;
+  ppc|ppc64|ppciseries|ppcpseries|ppc64iseries|ppc64pseries|powerpc|powerpc64)
+    MODULEARCH="ppc64"
+    ;;
+  *)
+    MODULEARCH=""
+    ;;
+esac
+
+case "$mode" in
+  module)
+    if [ -n "$MODULEARCH" ] ; then
+      echo "--target $MODULEARCH"
+    fi
+    ;;
+  tools)
+    if [ -n "$TOOLSARCH" ] ; then
+      echo "--target $TOOLSARCH"
+    fi
+    ;;
+  *)
+    echo "rpmarch.guess: Invalid mode: $mode" >&2
+    echo "error"
+    exit 1
+    ;;
+esac
+
+exit 0

Added: branches/ocfs2-1.2/vendor/sles9/vendor.guess
===================================================================
--- branches/ocfs2-1.2/vendor/sles9/vendor.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor/sles9/vendor.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ ! -f /etc/SuSE-release ]
+then
+    exit 1
+fi
+
+if [ "`rpm -qf /etc/SuSE-release --qf '%{VERSION}' 2>/dev/null`" != "9" ]
+then
+    exit 1
+fi
+
+exit 0

Added: branches/ocfs2-1.2/vendor.guess
===================================================================
--- branches/ocfs2-1.2/vendor.guess	2006-02-22 22:53:08 UTC (rev 2769)
+++ branches/ocfs2-1.2/vendor.guess	2006-02-22 22:57:53 UTC (rev 2770)
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+list_vendors()
+{
+    ls -1 vendor | while read -r line
+    do
+        if [ "$line" = "common" ]
+        then
+            continue
+        fi
+        if [ ! -d "vendor/$line" ]
+        then
+            continue
+        fi
+        echo $line
+    done
+
+    # Make common last
+    if [ -d "vendor/common" ]
+    then
+        echo "common"
+    fi
+}
+
+list_vendors | while read -r v
+do
+    if [ -x "vendor/${v}/vendor.guess" ]
+    then
+        if "vendor/${v}/vendor.guess" >/dev/null 2>&1
+        then
+            echo "$v"
+        fi
+    fi
+done




More information about the Ocfs2-commits mailing list