Blame docker-builder-data/build/script/common/manager.sh

e14835
#!/bin/bash
e14835
e14835
# options
e14835
e14835
if [ -z "$PLATFORM" ]; then
e14835
	PLATFORM="linux-x64"
e14835
fi
e14835
export PLATFORM
e14835
e14835
if [ -z "$THREADS" ]; then
e14835
	THREADS=8
e14835
fi
e14835
export THREADS
e14835
e14835
e14835
# root
e14835
e7b20d
OLDDIR=`pwd`
e7b20d
ROOT_DIR=$(cd `dirname "$0"`; pwd)
e7b20d
cd "$OLDDIR"
e14835
ROOT_DIR=`dirname "$ROOT_DIR"`
e14835
ROOT_DIR=`dirname "$ROOT_DIR"`
e14835
export ROOT_DIR
e14835
e14835
# dirs
e14835
e14835
export SCRIPT_DIR=$ROOT_DIR/script
e14835
export COMMON_SCRIPT_DIR=$SCRIPT_DIR/common
e14835
export INCLUDE_SCRIPT_DIR=$SCRIPT_DIR/include
e14835
export PACKET_SCRIPT_DIR=$SCRIPT_DIR/packet
e14835
export PACKET_DIR=$ROOT_DIR/packet/$PLATFORM
e14835
dd482a
if [ ! -z $PACKET_BUILD_DIR ]; then
dd482a
	export PACKET_DIR=$PACKET_BUILD_DIR/$PLATFORM
dd482a
fi
dd482a
e14835
# vars
e14835
e14835
INITIAL_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
e14835
INITIAL_PATH=$PATH
e14835
INITIAL_LDFLAGS=$LDFLAGS
e14835
INITIAL_CFLAGS=$CFLAGS
e14835
INITIAL_CPPFLAGS=$CPPFLAGS
e14835
INITIAL_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
e14835
7f8f8f
DRY_RUN=
bce30d
FORCE=
bce30d
CLEAN_BEFORE_DO=
7f8f8f
NO_CHECK_DEPS=
7f8f8f
declare -A COMPLETION_STATUS
7f8f8f
7f8f8f
e14835
###################################
e14835
#
e14835
# Fairy Tale
e14835
# 
e14835
# Once upon time in faraway...
e14835
#
e14835
# Function dependency:
e14835
#
e14835
# 1. download 
e14835
#     |
e14835
# 2. unpack
e14835
#     |
e14835
#     | env^
e14835
#     |  |
e14835
# 3.  | envdeps  
7f8f8f
#     |  | | |
7f8f8f
# 4. build | |
7f8f8f
#     |    | |
e14835
# 5. install |
e14835
#     |    | |
e14835
# 6.  |    env
e14835
#     |    |
e14835
#     |    envdeps*
e14835
#     |
e14835
#     | env_release^
b0fa99
#     |  | 
b0fa99
# 7.  | envdeps_release
7f8f8f
#     |  |           | 
7f8f8f
# 8. install_release |
7f8f8f
#            |       |
7f8f8f
# 9.        env_release
7f8f8f
#            |
e14835
#    envdeps_release*
e14835
#
e14835
###################################
e14835
7f8f8f
FUNC_DEPS_download=""
7f8f8f
FUNC_DEPS_unpack="download"
7f8f8f
FUNC_DEPS_envdeps="-env"
427aed
FUNC_DEPS_build="envdeps unpack"
427aed
FUNC_DEPS_install="envdeps build"
427aed
FUNC_DEPS_env="envdeps install"
7f8f8f
FUNC_DEPS_envdeps_release="-env_release"
427aed
FUNC_DEPS_install_release="envdeps_release install"
427aed
FUNC_DEPS_env_release="envdeps_release install_release"
7f8f8f
e14835
e14835
copy() {
e14835
	if [ -d "$1" ]; then
e14835
		if ! mkdir -p $2; then
e14835
			return 1
e14835
		fi
e14835
		if [ "$(ls -A $1)" ]; then
7bd1ae
			if ! cp --remove-destination -rlP $1/* "$2/"; then
e14835
				return 1
e14835
			fi
e14835
		fi
e14835
	elif [ -f "$1" ]; then
7bd1ae
		if ! (mkdir -p `dirname $2` && cp --remove-destination -l "$1" "$2"); then
e14835
			return 1
e14835
		fi
e14835
	else
e14835
		return 1
e14835
	fi
e14835
}
e14835
d42249
readdir() {
d42249
    local FILE=$1
d42249
    if [ -d "$FILE" ]; then
d42249
        echo "directory begin"
d42249
        ls -1 "$1" | while read SUBFILE; do
d42249
            if [ "$SUBFILE" = ".git" ]; then
d42249
                continue
d42249
            fi
d42249
            local STAT=`stat -c%F:%a:%s "$FILE/$SUBFILE"`
d42249
            echo "$STAT:$SUBFILE"
d42249
            readdir "$FILE/$SUBFILE"
d42249
        done
d42249
        echo "directory end"
d42249
    else
d42249
        local MD5=`md5sum -b "$FILE"`
d42249
        echo "file:${MD5:0:32}"
d42249
    fi
d42249
}
d42249
d42249
md5() {
d42249
    local MD5=`readdir "$1" | md5sum -b`
d42249
    echo "${MD5:0:32}"
d42249
}
d42249
e14835
message() {
e14835
    echo " ------ $1"
e14835
}
e14835
7f8f8f
try_do_nothing() {
7f8f8f
	if [ -z "$DRY_RUN" ]; then
7f8f8f
		return 1
7f8f8f
	fi
7f8f8f
	set_done $1 $2
7f8f8f
}
7f8f8f
e14835
set_done() {
7f8f8f
	local COMPLETION_KEY="$1:$2"
7f8f8f
	if [ -z "$DRY_RUN" ]; then
7f8f8f
		touch "$PACKET_DIR/$1/$2.done"
7f8f8f
	fi
7f8f8f
	COMPLETION_STATUS[$COMPLETION_KEY]=complete
e14835
}
e14835
e14835
set_undone_silent() {
d42249
	local COMPLETION_KEY="$1:$2"
7f8f8f
	if [ -z "$DRY_RUN" ]; then
7f8f8f
    	rm -f $PACKET_DIR/$1/$2.*.done
7f8f8f
		rm -f "$PACKET_DIR/$1/$2.done"
7f8f8f
	fi
7f8f8f
	COMPLETION_STATUS[$COMPLETION_KEY]=incomplete
e14835
}
e14835
e14835
set_undone() {
e14835
	message "$1 set_undone $2"
e14835
	set_undone_silent $1 $2
e14835
}
e14835
e14835
clean_packet_directory_silent() {
e14835
	set_undone_silent $1 $2
7f8f8f
    try_do_nothing $1 $2 && return 0
dd482a
    rm -rf "$PACKET_DIR/$1/$2"
e14835
}
e14835
e14835
clean_packet_directory() {
e14835
	message "$1 clean $2"
e14835
	clean_packet_directory_silent $1 $2
e14835
}
e14835
e14835
check_packet_function() {
bce30d
	if [ ! -z "$FORCE" ]; then
bce30d
		return 1
bce30d
	fi
e14835
    if [ ! -f "$PACKET_DIR/$1/$2.done" ]; then
e14835
        return 1
e14835
    fi
e14835
}
e14835
e14835
prepare_build() {
e14835
    if ! copy "$UNPACK_PACKET_DIR" "$BUILD_PACKET_DIR"; then
e14835
        return 1
e14835
    fi
e14835
}
e14835
d32e1c
prepare_install() {
ec0475
    if ls $BUILD_PACKET_DIR/version-* 1> /dev/null 2>&1; then
ec0475
        cp --remove-destination $BUILD_PACKET_DIR/version-* "$INSTALL_PACKET_DIR/" || true
ec0475
    fi
d32e1c
}
d32e1c
d32e1c
prepare_install_release() {
ec0475
    if ls $INSTALL_PACKET_DIR/version-* 1> /dev/null 2>&1; then
ec0475
        cp --remove-destination $INSTALL_PACKET_DIR/version-* "$INSTALL_RELEASE_PACKET_DIR/" || true
ec0475
    fi
d32e1c
}
d32e1c
e14835
set_environment_vars() {
e14835
    export NAME=$1
e14835
e14835
    export CURRENT_PACKET_DIR=$PACKET_DIR/$NAME
e14835
	export FILES_PACKET_DIR=$PACKET_SCRIPT_DIR/$NAME.files
e14835
    export DOWNLOAD_PACKET_DIR=$CURRENT_PACKET_DIR/download
e14835
    export UNPACK_PACKET_DIR=$CURRENT_PACKET_DIR/unpack
e14835
    export ENVDEPS_PACKET_DIR=$CURRENT_PACKET_DIR/envdeps
e14835
    export BUILD_PACKET_DIR=$CURRENT_PACKET_DIR/build
e14835
    export INSTALL_PACKET_DIR=$CURRENT_PACKET_DIR/install
e14835
    export INSTALL_RELEASE_PACKET_DIR=$CURRENT_PACKET_DIR/install_release
e14835
    export ENV_PACKET_DIR=$CURRENT_PACKET_DIR/env
e14835
    export ENVDEPS_RELEASE_PACKET_DIR=$CURRENT_PACKET_DIR/envdeps_release
e14835
    export ENV_RELEASE_PACKET_DIR=$CURRENT_PACKET_DIR/env_release
e14835
e14835
    export LD_LIBRARY_PATH="$ENV_PACKET_DIR/lib:$ENV_PACKET_DIR/lib64:$ENVDEPS_PACKET_DIR/lib:$ENVDEPS_PACKET_DIR/lib64:$INITIAL_LD_LIBRARY_PATH"
e14835
    export PATH="$ENVDEPS_PACKET_DIR/bin:$INITIAL_PATH"
e14835
    export LDFLAGS="-L$ENVDEPS_PACKET_DIR/lib $INITIAL_LDFLAGS"
e14835
    export CFLAGS="-I$ENVDEPS_PACKET_DIR/include $INITIAL_CFLAGS"
e14835
    export CPPFLAGS="-I$ENVDEPS_PACKET_DIR/include $INITIAL_CPPFLAGS"
e14835
    export PKG_CONFIG_PATH="$ENVDEPS_PACKET_DIR/lib/pkgconfig:$INITIAL_PKG_CONFIG_PATH" 
e14835
}
e14835
e14835
call_packet_function() {
e14835
    local NAME=$1
e14835
    local FUNC=$2
e14835
    local PREPARE_FUNC=$3
e14835
    local FINALIZE_FUNC=$4
7f8f8f
    local COMPARE_RESULTS=$5
e14835
e14835
    set_environment_vars $NAME
e14835
e14835
    local FUNC_NAME=pk$FUNC
e14835
    local FUNC_CURRENT_PACKET_DIR=$CURRENT_PACKET_DIR/$FUNC
e14835
e14835
    message "$NAME $FUNC"
7f8f8f
    try_do_nothing $NAME $FUNC && return 0
7f8f8f
	echo "${DRY_RUN_DONE[@]}"
7f8f8f
7f8f8f
	local PREV_HASH=
7f8f8f
	if [ "$COMPARE_RESULTS" = "compare_results" ]; then
7f8f8f
		if check_packet_function $NAME $FUNC; then
d42249
			PREV_HASH=`md5 "$FUNC_CURRENT_PACKET_DIR"` 
7f8f8f
			[ ! $? -eq 0 ] && return 1
7f8f8f
		fi
d42249
	else
d42249
   		set_undone_silent $NAME $FUNC
7f8f8f
	fi
e14835
e14835
    mkdir -p $FUNC_CURRENT_PACKET_DIR
e14835
    cd $FUNC_CURRENT_PACKET_DIR
e14835
    
69b66f
	source $INCLUDE_SCRIPT_DIR/inc-pkall-none.sh
7f8f8f
    [ ! $? -eq 0 ] && return 1
e14835
    source "$PACKET_SCRIPT_DIR/$NAME.sh"
e14835
    [ ! $? -eq 0 ] && return 1
e14835
e14835
    if [ ! -z "$PREPARE_FUNC" ]; then
e14835
        if ! "$PREPARE_FUNC"; then
e14835
            return 1
e14835
        fi
e14835
    fi
e14835
e14835
    if ! "$FUNC_NAME"; then
e14835
        return 1
e14835
    fi
e14835
e14835
    if [ ! -z "$FINALIZE_FUNC" ]; then
e14835
        if ! "$FINALIZE_FUNC"; then
e14835
            return 1
e14835
        fi
e14835
    fi
e14835
9ab948
	if [ ! -z "$PREV_HASH" ]; then
9ab948
		local HASH=`md5 "$FUNC_CURRENT_PACKET_DIR"` 
9ab948
		[ ! $? -eq 0 ] && return 1
9ab948
		if [ "$HASH" = "$PREV_HASH" ]; then
9ab948
			message "$NAME $FUNC - not changed"
9ab948
			return 0
7f8f8f
		fi
7f8f8f
	fi
7f8f8f
e14835
    set_done $NAME $FUNC
e14835
}
e14835
e14835
foreach_deps() {
e14835
    local NAME=$1
e14835
    local FUNC=$2
e14835
    local RECURSIVE=$3
e14835
    
7f8f8f
	source $INCLUDE_SCRIPT_DIR/inc-pkall-none.sh
7f8f8f
    [ ! $? -eq 0 ] && return 1
7f8f8f
    source "$PACKET_SCRIPT_DIR/$NAME.sh"
e14835
    [ ! $? -eq 0 ] && return 1
e14835
    
e14835
    local CURRENT_DEPS=$DEPS
e14835
    for DEP in $CURRENT_DEPS; do
e14835
        if [ ! -z "$DEP" ]; then
e14835
        	local DEP_LOCAL=$DEP 
e14835
        	if [ "$RECURSIVE" = "recursive" ]; then
e14835
        		if ! foreach_deps "$DEP_LOCAL" "$FUNC" "$RECURSIVE"; then
e14835
                	return 1
e14835
        		fi
e14835
        	fi
e14835
            if ! "$FUNC" "$DEP_LOCAL" "$NAME"; then
e14835
                return 1
e14835
            fi
e14835
        fi
e14835
	done
e14835
}
e14835
7f8f8f
is_complete() {
7f8f8f
	local NAME=$1
7f8f8f
	local FUNC=$2
7f8f8f
	local SUBFUNCS_VAR_NAME=FUNC_DEPS_$FUNC
7f8f8f
    local SUBFUNCS=${!SUBFUNCS_VAR_NAME}
7f8f8f
    local COMPLETION_KEY="$NAME:$FUNC"
7f8f8f
	if [ ! -z ${COMPLETION_STATUS[$COMPLETION_KEY]} ]; then
7f8f8f
		if [ "${COMPLETION_STATUS[$COMPLETION_KEY]}" = "complete" ]; then
7f8f8f
			return 0
7f8f8f
		else
7f8f8f
			return 1
7f8f8f
		fi
7f8f8f
	fi
7f8f8f
	
7f8f8f
	COMPLETION_STATUS[$COMPLETION_KEY]=incomplete
7f8f8f
	
7f8f8f
	if ! check_packet_function $1 $2; then
7f8f8f
		return 1
7f8f8f
	fi
7f8f8f
	if [ ! -z "$NO_CHECK_DEPS" ]; then
7f8f8f
		COMPLETION_STATUS[$COMPLETION_KEY]=complete
7f8f8f
		return 0
7f8f8f
	fi
7f8f8f
7f8f8f
	source $INCLUDE_SCRIPT_DIR/inc-pkall-none.sh
7f8f8f
    [ ! $? -eq 0 ] && return 1
7f8f8f
    source "$PACKET_SCRIPT_DIR/$NAME.sh"
7f8f8f
    [ ! $? -eq 0 ] && return 1
7f8f8f
7f8f8f
	local CURRENT_DEPS=$DEPS
7f8f8f
	for SUBFUNC in $SUBFUNCS; do
7f8f8f
		local SUBFUNC_LOCAL=$SUBFUNC
7f8f8f
		if [ "${SUBFUNC_LOCAL:0:1}" = "-" ]; then
7f8f8f
			SUBFUNC_LOCAL=${SUBFUNC_LOCAL:1}
7f8f8f
		    for DEP in $CURRENT_DEPS; do
7f8f8f
		        if [ ! -z "$DEP" ]; then
7f8f8f
		        	local DEP_LOCAL=$DEP
7f8f8f
					if ! is_complete $DEP_LOCAL $SUBFUNC_LOCAL; then
7f8f8f
						return 1
7f8f8f
					fi
7f8f8f
		    	    if [ "$PACKET_DIR/$NAME/$FUNC.done" -ot "$PACKET_DIR/$DEP_LOCAL/$SUBFUNC_LOCAL.done" ]; then
7f8f8f
		        		return 1
7f8f8f
		    	    fi
7f8f8f
		        fi
7f8f8f
		    done 
7f8f8f
		else
7f8f8f
			if ! is_complete $NAME $SUBFUNC_LOCAL; then
7f8f8f
				return 1
7f8f8f
			fi
7f8f8f
    	    if [ "$PACKET_DIR/$NAME/$FUNC.done" -ot "$PACKET_DIR/$NAME/$SUBFUNC_LOCAL.done" ]; then
7f8f8f
        		return 1
7f8f8f
    	    fi
7f8f8f
		fi
7f8f8f
	done
7f8f8f
7f8f8f
	COMPLETION_STATUS[$COMPLETION_KEY]=complete
7f8f8f
}
7f8f8f
7f8f8f
prepare() {
7f8f8f
	local NAME=$1
7f8f8f
	local FUNC=$2
7f8f8f
	local SUBFUNCS_VAR_NAME=FUNC_DEPS_$FUNC
7f8f8f
    local SUBFUNCS=${!SUBFUNCS_VAR_NAME}
7f8f8f
	
7f8f8f
	source $INCLUDE_SCRIPT_DIR/inc-pkall-none.sh
7f8f8f
    [ ! $? -eq 0 ] && return 1
7f8f8f
    source "$PACKET_SCRIPT_DIR/$NAME.sh"
7f8f8f
    [ ! $? -eq 0 ] && return 1
7f8f8f
7f8f8f
	local CURRENT_DEPS=$DEPS
7f8f8f
	local DODEPS=
7f8f8f
	for SUBFUNC in $SUBFUNCS; do
7f8f8f
		local SUBFUNC_LOCAL=$SUBFUNC
7f8f8f
		if [ "${SUBFUNC_LOCAL:0:1}" = "-" ]; then
7f8f8f
			SUBFUNC_LOCAL=${SUBFUNC_LOCAL:1}
7f8f8f
		    for DEP in $CURRENT_DEPS; do
7f8f8f
		        if [ ! -z "$DEP" ]; then
7f8f8f
					if ! $SUBFUNC_LOCAL $DEP; then
7f8f8f
						return 1
7f8f8f
					fi
7f8f8f
		        fi
7f8f8f
		    done 
7f8f8f
		elif ! $SUBFUNC_LOCAL $NAME; then
7f8f8f
			return 1
7f8f8f
		fi
7f8f8f
	done
bce30d
	
bce30d
	if [ ! -z "$CLEAN_BEFORE_DO" ]; then
bce30d
		if ! clean_packet_directory $NAME $FUNC; then
bce30d
			return 1
bce30d
		fi
bce30d
	fi
7f8f8f
}
7f8f8f
e14835
add_envdeps() {
e14835
	if ! copy "$PACKET_DIR/$1/env" "$PACKET_DIR/$2/envdeps"; then
e14835
	    return 1
e14835
	fi
e14835
}
e14835
e14835
add_envdeps_release() {
e14835
	if ! copy "$PACKET_DIR/$1/env_release" "$PACKET_DIR/$2/envdeps_release"; then
e14835
	    return 1
e14835
	fi
e14835
}
e14835
7f8f8f
update() {
7f8f8f
    local NAME=$1
7f8f8f
    prepare $NAME download || return 1
7f8f8f
    call_packet_function $NAME download "" "" compare_results || return 1
7f8f8f
}
7f8f8f
e14835
download() {
7f8f8f
    local NAME=$1
7f8f8f
    is_complete $NAME download && return 0
7f8f8f
    prepare     $NAME download || return 1
7f8f8f
    call_packet_function $NAME download || return 1
e14835
}
e14835
e14835
unpack() {
7f8f8f
    local NAME=$1
7f8f8f
    is_complete $NAME unpack && return 0
7f8f8f
    prepare     $NAME unpack || return 1
7f8f8f
    call_packet_function $NAME unpack || return 1
e14835
}
e14835
e14835
envdeps() {
e14835
    local NAME=$1
7f8f8f
    is_complete $NAME envdeps && return 0 
7f8f8f
	prepare     $NAME envdeps || return 1
e14835
e14835
    message "$NAME envdeps"
7f8f8f
    try_do_nothing $NAME envdeps && return 0
e14835
e14835
    clean_packet_directory_silent $NAME envdeps
e14835
    mkdir -p "$PACKET_DIR/$NAME/envdeps"
e14835
	if ! foreach_deps $NAME add_envdeps; then
e14835
		return 1
e14835
	fi
e14835
	set_done $NAME envdeps
e14835
}
e14835
e14835
build() {
7f8f8f
    local NAME=$1
7f8f8f
    is_complete $NAME build && return 0
7f8f8f
    prepare     $NAME build || return 1
7f8f8f
    call_packet_function $NAME build prepare_build || return 1
e14835
}
e14835
e14835
install() {
7f8f8f
    local NAME=$1
7f8f8f
    is_complete $NAME install && return 0
7f8f8f
    prepare     $NAME install || return 1
d32e1c
    call_packet_function $NAME install prepare_install || return 1
e14835
}
e14835
e14835
env() {
e14835
    local NAME=$1
7f8f8f
    is_complete $NAME env && return 0
7f8f8f
    prepare     $NAME env || return 1
e14835
e14835
    message "$NAME env"
7f8f8f
    try_do_nothing $NAME env && return 0
e14835
            
e14835
    clean_packet_directory_silent $NAME env
e14835
    mkdir -p "$PACKET_DIR/$NAME/env"
e14835
	if ! (copy "$PACKET_DIR/$NAME/envdeps" "$PACKET_DIR/$NAME/env" \
e14835
	&& copy "$PACKET_DIR/$NAME/install" "$PACKET_DIR/$NAME/env"); then
e14835
	    return 1
e14835
	fi
e14835
	set_done $NAME env
e14835
}
e14835
e14835
envdeps_release() {
e14835
    local NAME=$1
7f8f8f
    is_complete $NAME envdeps_release && return 0
7f8f8f
	prepare     $NAME envdeps_release || return 1
e14835
e14835
	message "$NAME envdeps_release"
7f8f8f
    try_do_nothing $NAME envdeps_release && return 0
e14835
e14835
    clean_packet_directory_silent $NAME envdeps_release
e14835
    mkdir -p "$PACKET_DIR/$NAME/envdeps_release"
e14835
	if ! foreach_deps $NAME add_envdeps_release; then
e14835
		return 1
e14835
	fi
e14835
	set_done $NAME envdeps_release
e14835
}
e14835
b0fa99
install_release() {
7f8f8f
    local NAME=$1
7f8f8f
    is_complete $NAME install_release && return 0
7f8f8f
    prepare     $NAME install_release || return 1
d32e1c
    call_packet_function $NAME install_release prepare_install_release || return 1
b0fa99
}
b0fa99
e14835
env_release() {
e14835
    local NAME=$1
7f8f8f
    is_complete $NAME env_release && return 0
7f8f8f
    prepare     $NAME env_release || return 1
e14835
e14835
	message "$NAME env_release"
7f8f8f
    try_do_nothing $NAME env_release && return 0
e14835
            
e14835
    clean_packet_directory_silent $NAME env_release
e14835
    mkdir -p "$PACKET_DIR/$NAME/env_release"
e14835
	if ! (copy "$PACKET_DIR/$NAME/envdeps_release" "$PACKET_DIR/$NAME/env_release" \
e14835
	&& copy "$PACKET_DIR/$NAME/install_release" "$PACKET_DIR/$NAME/env_release"); then
e14835
	    return 1
e14835
	fi
e14835
	set_done $NAME env_release
e14835
}
e14835
e14835
e14835
#############
e14835
e14835
clean_download() {
e14835
    clean_packet_directory $1 download
e14835
}
e14835
e14835
clean_unpack() {
e14835
    clean_packet_directory $1 download
e14835
}
e14835
e14835
clean_envdeps() {
e14835
    clean_packet_directory $1 envdeps
e14835
}
e14835
e14835
clean_build() {
e14835
    clean_packet_directory $1 build
e14835
}
e14835
e14835
clean_install() {
e14835
    clean_packet_directory $1 install
e14835
}
e14835
e14835
clean_env() {
e14835
    clean_packet_directory $1 env
e14835
}
e14835
e14835
clean_install_release() {
e14835
    clean_packet_directory $1 install_release
e14835
}
e14835
e14835
clean_envdeps_release() {
e14835
    clean_packet_directory $1 envdeps_release
e14835
}
e14835
e14835
clean_env_release() {
e14835
    clean_packet_directory $1 env_release
e14835
}
e14835
1dcb0e
clean_all_env() {
e14835
    clean_install $1
e14835
    clean_install_release $1
1dcb0e
    clean_envdeps $1
1dcb0e
    clean_env $1
e14835
    clean_envdeps_release $1
e14835
    clean_env_release $1
e14835
}
e14835
dd482a
clean_all_install() {
dd482a
    clean_build $1
1dcb0e
    clean_all_env $1
dd482a
}
dd482a
1dcb0e
clean_all_unpack() {
1dcb0e
    clean_download $1
1dcb0e
    clean_unpack $1
1dcb0e
}
1dcb0e
1dcb0e
clean() {
223f41
	message "$1 clean all"
7f8f8f
	try_do_nothing $NAME clean_all && return 0
223f41
    rm -rf "$PACKET_DIR/$1"
1cbd1f
}
1cbd1f
e14835
#############
e14835
e14835
set_undone_download() {
e14835
    set_undone $1 download
e14835
}
e14835
e14835
set_undone_unpack() {
e14835
    set_undone $1 download
e14835
}
e14835
e14835
set_undone_envdeps() {
e14835
    set_undone $1 envdeps
e14835
}
e14835
e14835
set_undone_build() {
e14835
    set_undone $1 build
e14835
}
e14835
e14835
set_undone_install() {
e14835
    set_undone $1 install
e14835
}
e14835
e14835
set_undone_env() {
e14835
    set_undone $1 env
e14835
}
e14835
e14835
set_undone_install_release() {
e14835
    set_undone $1 install_release
e14835
}
e14835
e14835
set_undone_envdeps_release() {
e14835
    set_undone $1 envdeps_release
e14835
}
e14835
e14835
set_undone_env_release() {
e14835
    set_undone $1 env_release
e14835
}
e14835
1dcb0e
set_undone_all_env() {
e14835
    set_undone_install $1
e14835
    set_undone_install_release $1
1dcb0e
    set_undone_envdeps $1
1dcb0e
    set_undone_env $1
e14835
    set_undone_envdeps_release $1
e14835
    set_undone_env_release $1
e14835
}
e14835
1dcb0e
set_undone_all_install() {
1dcb0e
    set_undone_build $1
1dcb0e
    set_undone_all_env $1
1dcb0e
}
1dcb0e
1dcb0e
set_undone_all_unpack() {
1dcb0e
    set_undone_download $1
1dcb0e
    set_undone_unpack $1
1dcb0e
}
1dcb0e
1dcb0e
set_undone_all() {
1dcb0e
	set_undone_all_unpack $1
1dcb0e
    set_undone_all_install $1
1dcb0e
}
1dcb0e
e14835
#############
e14835
e14835
with_deps() {
e14835
	if ! foreach_deps "$2" "$1" "recursive"; then
e14835
		return 1
e14835
	fi
e14835
    if ! "$1" "$2"; then
e14835
        return 1
e14835
    fi
e14835
}
e14835
e14835
shell() {
d42249
	echo "Set environment for $1"
e14835
    set_environment_vars $1
e14835
    cd $PACKET_DIR/$1
d42249
    if [ -z "${*:2}" ]; then
223f41
    	/bin/bash -i
223f41
	else
d42249
		"${@:2}"
223f41
    fi
e14835
}
e14835
e14835
dry_run() {
e14835
    DRY_RUN=1
e14835
    "$@"
e14835
}
e14835
7f8f8f
no_check_deps() {
7f8f8f
    NO_CHECK_DEPS=1
7f8f8f
    "$@"
7f8f8f
}
7f8f8f
bce30d
force() {
bce30d
    FORCE=1
bce30d
    "$@"
bce30d
}
bce30d
bce30d
clean_before_do() {
bce30d
	CLEAN_BEFORE_DO=1
bce30d
    "$@"
bce30d
}
bce30d
e14835
"$@"
7f8f8f