Commit b9de76b6 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

auto-build: profile specific pattern variable replacements

parent 89c2b984
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -7,11 +7,12 @@ config ()

profile ()
{
	local build pattern
	local build pattern replace_cmd
	case "$1" in
		autotools)
			build='autoreconf --install && configure && make dist'
			pattern='$(distdir).{tar{,.*},zip}'
			replace_cmd=_make_variable_replace
			;;
		python)
			build='python setup.py bdist'
@@ -25,6 +26,7 @@ profile ()
	case "$2" in
		build) echo "$build" ;;
		pattern) echo "$pattern" ;;
		replace_cmd) echo "${replace_cmd-echo}" ;;
		*) return 1 ;;
	esac
}
@@ -114,7 +116,7 @@ _make_variable_replace ()

_find_dist ()
{
	local pattern=`_make_variable_replace "$1"`
	local pattern="$1"
	[ "$pattern" ] && eval ls "$pattern" 2>/dev/null || true
}

@@ -160,7 +162,7 @@ build ()
	local dbuild=`config location || echo /tmp/build/`
	local dmax=`config max-builds || echo 4`
	local dest=`config "$confsec" destination || echo /tmp`
	local profile cmd pattern
	local profile cmd pattern replace_cmd
	local i dir lock files file

	dest=`readlink -f "$dest"`
@@ -211,6 +213,7 @@ build ()
	profile=`config "$confsec" profile || determine_profile`
	cmd=`config "$confsec" command || profile "$profile" build`
	pattern=`config "$confsec" pattern || profile "$profile" pattern`
	replace_cmd=`profile "$profile" replace_cmd`
	backup=`config "$confsec" backup | tr '[:upper:]' '[:lower:]' || echo yes`

	# run the build command
@@ -220,9 +223,9 @@ build ()
	fi

	# find the generated files
	pattern=`$replace_cmd "$pattern"`
	if ! IFS=$'\n' files=( `_find_dist "$pattern"` ); then
		echo "failed to find files with pattern:" >&2
		_make_variable_replace "$pattern" >&2
		echo -e "failed to find files with pattern:\n  $pattern" >&2
		return 1
	fi