[Freeswitch-svn] [commit] r3146 - in freeswitch/branches/stkn/buildsys/trunk: . build libs/packages

Freeswitch SVN stkn at freeswitch.org
Sat Oct 21 20:33:58 EDT 2006


Author: stkn
Date: Sat Oct 21 20:33:57 2006
New Revision: 3146

Added:
   freeswitch/branches/stkn/buildsys/trunk/libs/packages/
   freeswitch/branches/stkn/buildsys/trunk/libs/packages/apr-util.pkg
   freeswitch/branches/stkn/buildsys/trunk/libs/packages/apr.pkg
   freeswitch/branches/stkn/buildsys/trunk/libs/packages/sofia-sip.pkg
   freeswitch/branches/stkn/buildsys/trunk/libs/packages/srtp.pkg   (contents, props changed)
   freeswitch/branches/stkn/buildsys/trunk/site.conf.in
Modified:
   freeswitch/branches/stkn/buildsys/trunk/build/newbuild.sh

Log:
updates

Modified: freeswitch/branches/stkn/buildsys/trunk/build/newbuild.sh
==============================================================================
--- freeswitch/branches/stkn/buildsys/trunk/build/newbuild.sh	(original)
+++ freeswitch/branches/stkn/buildsys/trunk/build/newbuild.sh	Sat Oct 21 20:33:57 2006
@@ -7,13 +7,43 @@
 #
 
 # clean environment
-unset WORKDIR DISTDIR D S A P PN PV 
+unset S A PKG_NAME PKG_VER BASEDIR CFLAGS LDFLAGS WORKDIR
 
+_PHASES="fetch unpack compile install merge clean"
+
 die() {
 	echo "!!! $@"
 	exit 1
 }
 
+get_basedir() {
+	cd "$(dirname $0)/.."
+	echo "${PWD}"
+	cd "${OLDPWD}"
+}
+
+append_cflags() {
+	[ $# -lt 1 ] && {
+		echo "usage: append-cflags <flag>" >&2
+		return 1
+	}
+
+	CFLAGS="${CFLAGS} $@"
+
+	return 0
+}
+
+append_ldflags() {
+	[ $# -lt 1 ] && {
+		echo "usage: append-ldflags <flag>" >&2
+		return 1
+	}
+
+	LDFLAGS="${LDFLAGS} $@"
+
+	return 0
+}
+
 unpack() {
 	for x in $@; do
 		case ${x} in
@@ -34,25 +64,25 @@
 has() {
 	local tmp="${1}"
 
-	[[ $# -lt 2 ]] && {
+	[ $# -lt 2 ] && {
 		echo "usage: has <flag> <list>" >&2
 		return 1
 	}
 	shift
 
 	for x in $@; do
-		[[ "${tmp}" = "${x}" ]] && return 0
+		[ "${tmp}" = "${x}" ] && return 0
 	done
 	return 1
 }
 
-use_enable() {
-	[[ $# -lt 1 ]] && {
-		echo "usage: use_enable <flag>" >&2
+option_enable() {
+	[ $# -lt 1 ] && {
+		echo "usage: option_enable <flag>" >&2
 		return 1
 	}
 
-	if [[ -n "${USE}" ]] && has ${1} ${USE}; then
+	if has ${1} ${OPTIONS} 2>/dev/null; then
 		echo "--enable-${1}"
 	else
 		echo "--disable-${1}"
@@ -60,49 +90,44 @@
 	return 0
 }
 
-if [[ $# -lt 2 ]]; then
+do_config() {
+	[ ! -x configure ] && die "No configure script found"
+
+	./configure \
+		--prefix="${PREFIX}" ${@}
+}
+
+do_install() {
+	make DESTDIR="${D}" INSTALL_PREFIX="${D}" install
+}
+
+
+if [ $# -lt 2 ]; then
 	die "Usage: $0 <action> <package> [options]"
 fi
 
 #
+# get base directory (aka $(top_srcdir))
+#
+BASEDIR="$(get_basedir)"
+PKGDIR="${BASEDIR}/libs/packages"
+
+#
 # override settings with site-specific values
 #
-if [[ -e "site.conf" ]]; then
+if [ -e "${BASEDIR}/site.conf" ]; then
 	# override settings
-	source "site.conf"
+	source "${BASEDIR}/site.conf"
 fi
 
+ACTION="${1}"
 PKG="${2}"
-#
-# check if package exists as specified
-# try to find newest version if only the package name has been given
-#
-if [[ ! -e "${PKG}.pkg" ]]; then
-	tmp="$(ls -1 "${PKG}-"[0-9.]*.pkg 2>/dev/null | sort | tail -n1)"
 
-	if [[ -n "${tmp}" ]]; then
-		PKG="$(echo "${tmp}" | sed -e "s:\.pkg\$::")"
-	fi
-fi
+WORKDIR="${WORKDIR:-${BASEDIR}/libs}"
+DISTDIR="${DISTDIR:-${BASEDIR}/libs}"
 
-#
-# setup some constants
-#
-P="${PKG}"
-PN="${P%-*}"
-PV="${P##*-}"
+declare -r WORKDIR DISTDIR BASEDIR PKG ACTION
 
-WORKDIR="${WORKDIR:-${PWD}}"
-DISTDIR="${DISTDIR:-${PWD}}"
-S="${WORKDIR}/${P}"
-
-D="${D:}"
-A=""
-
-unset PKG
-
-SAVE_CWD="${PWD}"
-
 #
 # default functions
 #
@@ -111,15 +136,18 @@
 }
 
 src_unpack() {
-	echo "foobar unpack"
+	unpack "${A}"
+	cd "${S}"
 }
 
 src_compile() {
-	echo "foobar compile"
+	do_config || die "configure failed"
+
+	make || die "building failed"
 }
 
 src_install() {
-	echo "foobar install"
+	do_install || die "installation failed"
 }
 
 #
@@ -128,135 +156,160 @@
 #
 # check for package description file
 #
-if [[ -e "${P}.pkg" ]]; then
-	source "${P}.pkg"
-else
-	die "package ${P} does not exist"
+if [ ! -e "${PKGDIR}/${PKG}" ]; then
+	die "package ${PKG} does not exist"
 fi
 
-#
-# check package parameters
-#
+source "${PKGDIR}/${PKG}" || die "failed to source ${PKG}"
 
-if [[ -z "${SRC_URI}" ]]; then
-	die "No download location(s) specified"
+[ -z "${PKG_NAME}" ] && die "Package name not specified in ${PKG}"
+[ -z "${PKG_VER}" ] && die "Package version not specified in ${PKG}"
+[ -z "${OPTIONS}" ] && OPTIONS=""
+
+if [ -z "${S}" ]; then
+	S="${WORKDIR}/${PKG_NAME}-${PKG_VER}"
 fi
 
 #
 # fill A
 #
-for x in ${SRC_URI}; do
+for x in ${PKG_URI}; do
 	A="${A} $(basename "${x}")"
 done
 A="$(echo "${A}" | sed -e "s:^[ \t]\+::")"
 
-#
-# handle actions
-#
+[ "${ACTION}" != "merge" ] && D="${BASEDIR}/built"
 
-case $1 in
-	install|compile|fetch|unpack|clean)
-		action="${1}"
-		;;
-	*)
-		die "Possible actions: fetch unpack compile install clean"
-		;;
-esac
+declare -r D A S PKG_NAME PKG_VER PKG_SRC
 
 echo "*************************************************"
-echo "P  = ${P}"
-echo "PV = ${PV}"
-echo "PN = ${PN}"
+echo "PKG_NAME = ${PKG_NAME}"
+echo "PKG_VER  = ${PKG_VER}"
 echo "S  = ${S}"
 echo "D  = ${D}"
 echo ""
+echo "BASEDIR = ${BASEDIR}"
 echo "WORKDIR = ${WORKDIR}"
 echo "DISTDIR = ${DISTDIR}"
-echo "SRC_URI = ${SRC_URI}"
+echo "PKG_URI = ${PKG_URI}"
 echo "A       = ${A}"
-echo "************************************************"
+echo "*************************************************"
 
-#exit 0
+handle_clean() {
+	#
+	# clean
+	#
+	cd "${WORKDIR}"
 
-#
-# clean
-#
-if [[ "${action}" = "clean" ]]; then
-	rm "${WORKDIR}"/{.fetched,.compiled,.unpacked,.installed} 2>/dev/null
-
 	# safety check
-	if [[ -n "${WORKDIR}" ]] && \
-	   [[ -n "${S}" ]] && \
-	   [[ -d "${S}" ]] && \
-	   [[ -n "$(echo "${S}" | grep "${WORKDIR}")" ]]
+	if [ -n "${S}" ] && \
+	   [ -d "${S}" ]
 	then
 		rm -r "${S}"
 	fi
+}
 
-#	if [[ -n "${S}" ]] && [[ -d "${S}" ]] && [[ "${S}" != "/" ]]; then
-#		rm -r "${S}"
-#	fi
-fi
-cd "${SAVE_CWD}"
-[[ "${action}" = "clean" ]] && exit 0
+handle_fetch() {
+	local F
+	#
+	# fetch
+	#
+	cd "${WORKDIR}"
 
-#
-# fetch
-#
-if [[ ! -e "${WORKDIR}/.fetched" ]] || \
-   [[ "${action}" = "fetch" ]]
-then
-	for x in ${SRC_URI}; do
+	for x in ${PKG_URI}; do
 		F="$(basename "${x}")"
 
 		# distfile does not exist, fetch it
-		if [[ ! -e "${DISTDIR}/${F}" ]]; then
+		if [ ! -e "${DISTDIR}/${F}" ]; then
 			wget -c "${x}" -O "${DISTDIR}/${F}" || die "Failed to fetch ${x}"
 		fi
 	done
-	touch "${WORKDIR}/.fetched"
-fi
-cd "${SAVE_CWD}"
-[[ "${action}" = "fetch" ]] && exit 0
+}
 
 
-#
-# unpack
-#
-if [[ ! -e "${WORKDIR}/.unpacked" ]] || \
-   [[ "${action}" = "unpack" ]]
-then
+handle_unpack() {
+	#
+	# unpack
+	#
 	cd "${WORKDIR}"
-	src_unpack
-	touch "${WORKDIR}/.unpacked"
-fi
-cd "${SAVE_CWD}"
-[[ "${action}" = "unpack" ]] && exit 0
 
+	if [ ! -e "${S}/.unpacked" ]
+	then
+		echo ">>> Unpacking package..."
+		src_unpack
+	else
+		echo "* Already unpacked, skipping"
+	fi
 
-#
-# compile
-#
-if [[ ! -e "${WORKDIR}/.compiled" ]] || \
-   [[ "${action}" = "compile" ]]
-then
-	cd "${S}"
-	src_compile
-	touch "${WORKDIR}/.compiled"
-fi
-cd "${SAVE_CWD}"
-[[ "${action}" = "compile" ]] && exit 0
+	touch "${S}/.unpacked"
+}
 
+handle_compile() {
+	#
+	# compile
+	#
+	[ -d "${S}" ] && cd "${S}"
+
+	if [ ! -e "${S}/.compiled" ]
+	then
+		echo ">>> Compiling package..."
+		src_compile
+	else
+		echo "* Already compiled, skipping"
+	fi
+	touch "${S}/.compiled"
+}
+
+handle_install() {
+	local D
+
+	#
+	# install
+	#
+	[ -d "${S}" ] && cd "${S}"
+
+	if [ ! -e "${S}/.installed" ]
+	then
+		echo ">>> Installing package..."
+		src_install
+	else
+		echo "* Already installed, skipping"
+	fi
+
+	cd "${WORKDIR}"
+
+	touch "${S}/.installed"
+}
+
+handle_merge() {
+	#
+	# Merge package
+	#
+	[ -d "${S}" ] && cd "${S}"
+
+	src_install
+}
+
 #
-# install
 #
-if [[ ! -e "${WORKDIR}/.installed" ]] || \
-   [[ "${action}" = "install" ]]
+#
+has "${ACTION}" "${_PHASES}" || die "Invalid action \"${ACTION}\", valid actions: ${_PHASES}"
+
+if [ "${ACTION}" = "clean" ]
 then
-	cd "${S}"
-	src_install
-	touch "${WORKDIR}/.installed"
-fi
-cd "${SAVE_CWD}"
+	handle_clean
+else
+	for x in ${_PHASES}; do
+		case ${x} in
+			fetch|unpack|compile|install)
+				handle_${x} || die "${x} failed"
+				;;
+			merge)
+				[ "`id -u`" != "root" ] && die "Need to be root to merge package!"
+				handle_${x}
+				;;
+		esac
 
-exit 0
+		[ "${x}" = "${ACTION}" ] && break 1
+	done
+fi

Added: freeswitch/branches/stkn/buildsys/trunk/libs/packages/apr-util.pkg
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/libs/packages/apr-util.pkg	Sat Oct 21 20:33:57 2006
@@ -0,0 +1,24 @@
+#
+#
+#
+PKG_NAME="apr-util"
+PKG_VER="1.2.7"
+
+PKG_URI="http://www.freeswitch.org/downloads/${PKG_NAME}-${PKG_VER}.tar.gz"
+
+src_unpack() {
+	unpack "${A}"
+	cd "${S}"
+}
+
+src_compile() {
+	./configure \
+		--prefix="${PREFIX}" \
+		$(option_enable debug) || die "configure failed"
+
+	make all || die "make all failed"
+}
+
+src_install() {
+	make DESTDIR="${D}" install || die "make install failed"
+}

Added: freeswitch/branches/stkn/buildsys/trunk/libs/packages/apr.pkg
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/libs/packages/apr.pkg	Sat Oct 21 20:33:57 2006
@@ -0,0 +1,25 @@
+#
+#
+#
+
+PKG_NAME="apr"
+PKG_VER="1.2.7"
+
+PKG_URI="http://www.freeswitch.org/downloads/${PKG_NAME}-${PKG_VER}.tar.gz"
+
+src_unpack() {
+	unpack "${A}"
+	cd "${S}"
+}
+
+src_compile() {
+	./configure \
+		--prefix="${PREFIX}" \
+		$(option_enable debug) || die "configure failed"
+
+	make all || die "make all failed"
+}
+
+src_install() {
+	make DESTDIR="${D}" install || die "make install failed"
+}

Added: freeswitch/branches/stkn/buildsys/trunk/libs/packages/sofia-sip.pkg
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/libs/packages/sofia-sip.pkg	Sat Oct 21 20:33:57 2006
@@ -0,0 +1,25 @@
+#
+#
+#
+
+PKG_NAME="sofia-sip"
+PKG_VER="1.12.1"
+
+PKG_URI="http://mesh.dl.sourceforge.net/sourceforge/${PKG_NAME}/${PKG_NAME}-${PKG_VER}.tar.gz"
+
+src_unpack() {
+	unpack "${A}"
+	cd "${S}"
+}
+
+src_compile() {
+	./configure \
+		--prefix="${PREFIX}" \
+		$(use_enable debug) || die "configure failed"
+
+	make all || die "make all failed"
+}
+
+src_install() {
+	make DESTDIR="${D}" install || die "make install failed"
+}

Added: freeswitch/branches/stkn/buildsys/trunk/libs/packages/srtp.pkg
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/libs/packages/srtp.pkg	Sat Oct 21 20:33:57 2006
@@ -0,0 +1,23 @@
+
+PKG_NAME="srtp"
+PKG_VER=""
+
+PKG_SRC=""
+
+ARCH="`uname -m`"
+
+src_compile() {
+	[ "$ARCH" = "x86_64" ] && \
+		OPTS="--enable-pic"
+
+	./configure \
+		--prefix="$(PREFIX)" \
+		${OPTS} || exit 1
+
+	make all || exit 1
+}
+
+
+
+
+

Added: freeswitch/branches/stkn/buildsys/trunk/site.conf.in
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/site.conf.in	Sat Oct 21 20:33:57 2006
@@ -0,0 +1,2 @@
+PREFIX="@prefix@"
+CFLAGS="@CFLAGS@"



More information about the Freeswitch-svn mailing list