[Freeswitch-branches] [commit] r2622 - in freeswitch/branches/stkn/buildsys/trunk: build libs

Freeswitch SVN stkn at freeswitch.org
Sun Sep 10 09:14:47 EDT 2006


Author: stkn
Date: Sun Sep 10 09:14:46 2006
New Revision: 2622

Added:
   freeswitch/branches/stkn/buildsys/trunk/build/newbuild.sh   (contents, props changed)
   freeswitch/branches/stkn/buildsys/trunk/libs/apr-1.2.7.pkg
   freeswitch/branches/stkn/buildsys/trunk/libs/site.conf

Log:
Add current version of a replacement for build.sh, sort of a mini-portage for freeswitch dependencies.

Added: freeswitch/branches/stkn/buildsys/trunk/build/newbuild.sh
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/build/newbuild.sh	Sun Sep 10 09:14:46 2006
@@ -0,0 +1,262 @@
+#!/bin/sh
+
+#
+# Buildlib.sh reimplementation
+#
+# (C) 2006 Stefan Knoblich <stkn at netdomination.org>
+#
+
+# clean environment
+unset WORKDIR DISTDIR D S A P PN PV 
+
+die() {
+	echo "!!! $@"
+	exit 1
+}
+
+unpack() {
+	for x in $@; do
+		case ${x} in
+			*.tar.gz|*.tgz)
+				tar -xzvf "${x}" || die "unpacking ${x} failed"
+				;;
+			*.tar.bz2|*.tbz2)
+				tar -xjvf "${x}" || die "unpacking ${x} failed"
+				;;
+			*)
+				echo "no idea how to unpack this ${x}, ignoring"
+				;;
+		esac
+	done
+	return 0
+}
+
+has() {
+	local tmp="${1}"
+
+	[[ $# -lt 2 ]] && {
+		echo "usage: has <flag> <list>" >&2
+		return 1
+	}
+	shift
+
+	for x in $@; do
+		[[ "${tmp}" = "${x}" ]] && return 0
+	done
+	return 1
+}
+
+use_enable() {
+	[[ $# -lt 1 ]] && {
+		echo "usage: use_enable <flag>" >&2
+		return 1
+	}
+
+	if [[ -n "${USE}" ]] && has ${1} ${USE}; then
+		echo "--enable-${1}"
+	else
+		echo "--disable-${1}"
+	fi
+	return 0
+}
+
+if [[ $# -lt 2 ]]; then
+	die "Usage: $0 <action> <package> [options]"
+fi
+
+#
+# override settings with site-specific values
+#
+if [[ -e "site.conf" ]]; then
+	# override settings
+	source "site.conf"
+fi
+
+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
+
+#
+# setup some constants
+#
+P="${PKG}"
+PN="${P%-*}"
+PV="${P##*-}"
+
+WORKDIR="${WORKDIR:-${PWD}}"
+DISTDIR="${DISTDIR:-${PWD}}"
+S="${WORKDIR}/${P}"
+
+D="${D:}"
+A=""
+
+unset PKG
+
+SAVE_CWD="${PWD}"
+
+#
+# default functions
+#
+src_fetch() {
+	echo "Fetching sources: ${SRC_URI}"
+}
+
+src_unpack() {
+	echo "foobar unpack"
+}
+
+src_compile() {
+	echo "foobar compile"
+}
+
+src_install() {
+	echo "foobar install"
+}
+
+#
+# source package
+#
+#
+# check for package description file
+#
+if [[ -e "${P}.pkg" ]]; then
+	source "${P}.pkg"
+else
+	die "package ${P} does not exist"
+fi
+
+#
+# check package parameters
+#
+
+if [[ -z "${SRC_URI}" ]]; then
+	die "No download location(s) specified"
+fi
+
+#
+# fill A
+#
+for x in ${SRC_URI}; do
+	A="${A} $(basename "${x}")"
+done
+A="$(echo "${A}" | sed -e "s:^[ \t]\+::")"
+
+#
+# handle actions
+#
+
+case $1 in
+	install|compile|fetch|unpack|clean)
+		action="${1}"
+		;;
+	*)
+		die "Possible actions: fetch unpack compile install clean"
+		;;
+esac
+
+echo "*************************************************"
+echo "P  = ${P}"
+echo "PV = ${PV}"
+echo "PN = ${PN}"
+echo "S  = ${S}"
+echo "D  = ${D}"
+echo ""
+echo "WORKDIR = ${WORKDIR}"
+echo "DISTDIR = ${DISTDIR}"
+echo "SRC_URI = ${SRC_URI}"
+echo "A       = ${A}"
+echo "************************************************"
+
+#exit 0
+
+#
+# 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}")" ]]
+	then
+		rm -r "${S}"
+	fi
+
+#	if [[ -n "${S}" ]] && [[ -d "${S}" ]] && [[ "${S}" != "/" ]]; then
+#		rm -r "${S}"
+#	fi
+fi
+cd "${SAVE_CWD}"
+[[ "${action}" = "clean" ]] && exit 0
+
+#
+# fetch
+#
+if [[ ! -e "${WORKDIR}/.fetched" ]] || \
+   [[ "${action}" = "fetch" ]]
+then
+	for x in ${SRC_URI}; do
+		F="$(basename "${x}")"
+
+		# distfile does not exist, fetch it
+		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
+	cd "${WORKDIR}"
+	src_unpack
+	touch "${WORKDIR}/.unpacked"
+fi
+cd "${SAVE_CWD}"
+[[ "${action}" = "unpack" ]] && exit 0
+
+
+#
+# compile
+#
+if [[ ! -e "${WORKDIR}/.compiled" ]] || \
+   [[ "${action}" = "compile" ]]
+then
+	cd "${S}"
+	src_compile
+	touch "${WORKDIR}/.compiled"
+fi
+cd "${SAVE_CWD}"
+[[ "${action}" = "compile" ]] && exit 0
+
+#
+# install
+#
+if [[ ! -e "${WORKDIR}/.installed" ]] || \
+   [[ "${action}" = "install" ]]
+then
+	cd "${S}"
+	src_install
+	touch "${WORKDIR}/.installed"
+fi
+cd "${SAVE_CWD}"
+
+exit 0

Added: freeswitch/branches/stkn/buildsys/trunk/libs/apr-1.2.7.pkg
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/libs/apr-1.2.7.pkg	Sun Sep 10 09:14:46 2006
@@ -0,0 +1,22 @@
+#
+#
+#
+
+SRC_URI="http://www.freeswitch.org/downloads/${P}.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/site.conf
==============================================================================
--- (empty file)
+++ freeswitch/branches/stkn/buildsys/trunk/libs/site.conf	Sun Sep 10 09:14:46 2006
@@ -0,0 +1 @@
+D="/tmp/"



More information about the Freeswitch-branches mailing list