Skip to content

Commit

Permalink
ocfs2-test: Add mbvendor.m4 pythondev.m4 and svnrev.guess files.
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Matsunaga <[email protected]>

Signed-off-by: Tristan Ye <[email protected]>
  • Loading branch information
Marcos Matsunaga authored and Marcos Matsunaga committed Nov 12, 2008
1 parent 50eb246 commit 990d75f
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 1 deletion.
73 changes: 73 additions & 0 deletions mbvendor.m4
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions pythondev.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Find the install dirs for the python installation.
## By James Henstridge

dnl a macro to check for ability to create python extensions
dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
dnl function also defines PYTHON_INCLUDES
AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
[AC_REQUIRE([AM_PATH_PYTHON])
AC_MSG_CHECKING(for headers required to compile python extensions)
dnl deduce PYTHON_INCLUDES
py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
if test "$py_prefix" != "$py_exec_prefix"; then
PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
fi
AC_SUBST(PYTHON_INCLUDES)
dnl check if the headers exist:
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
AC_TRY_CPP([#include <Python.h>],dnl
[AC_MSG_RESULT(found)
$1],dnl
[AC_MSG_RESULT(not found)
$2])
CPPFLAGS="$save_CPPFLAGS"
])
144 changes: 144 additions & 0 deletions svnrev.guess
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/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 2>&1 |
awk 'BEGIN{rev=0}
/^r[0-9]+ \|/{rev += 1}
/^ +A \/'"$BRANCH_SEARCH"'$/{exit}
/^ +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
2 changes: 1 addition & 1 deletion vendor/common/Vendor.make
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ $(TOPDIR)/ocfs2-test-$(DIST_VERSION)-$(PKG_VERSION).$(VENDOR_EXTENSION).src.rpm:
srpm: $(TOPDIR)/ocfs2-test-$(DIST_VERSION)-$(PKG_VERSION).$(VENDOR_EXTENSION).src.rpm

rpm: srpm
$(RPMBUILD) --rebuild $(TOOLSARCH) "ocfs2-test-$(DIST_VERSION)-$(PKG_VERSION).$(VENDOR_EXTENSION).src.rpm"
$(RPMBUILD) --rebuild $(TESTARCH) "ocfs2-test-$(DIST_VERSION)-$(PKG_VERSION).$(VENDOR_EXTENSION).src.rpm"

0 comments on commit 990d75f

Please sign in to comment.