Add prerequisite keep_artifacts var

This commit is contained in:
Joshua Boniface 2019-02-05 18:40:31 -05:00
parent d351fa0c1e
commit 546f4cd46f
2 changed files with 19 additions and 6 deletions

23
build
View File

@ -23,7 +23,7 @@ usage() {
echo -e "Usage:" echo -e "Usage:"
echo -e " $ build --list-platforms" echo -e " $ build --list-platforms"
echo -e " $ build --list-actions <platform>" echo -e " $ build --list-actions <platform>"
echo -e " $ build [-b/--web-branch <web_branch>] <platform> <action>" echo -e " $ build [-k/--keep-artifacts] [-b/--web-branch <web_branch>] <platform> <action>"
echo -e "" echo -e ""
echo -e "The web_branch defaults to the same branch name as the current main branch." echo -e "The web_branch defaults to the same branch name as the current main branch."
echo -e "To build all platforms, use 'all'." echo -e "To build all platforms, use 'all'."
@ -67,6 +67,14 @@ if [[ $1 == '--list-actions' ]]; then
exit 0 exit 0
fi fi
# Parse keep-artifacts option
if [[ $1 == '-k' || $1 == '--keep-artifacts' ]]; then
keep_artifacts="y"
shift 1
else
keep_artifacts="n"
fi
# Parse branch option # Parse branch option
if [[ $1 == '-b' || $1 == '--web-branch' ]]; then if [[ $1 == '-b' || $1 == '--web-branch' ]]; then
web_branch="$2" web_branch="$2"
@ -193,6 +201,13 @@ for target_platform in ${platform[@]}; do
echo -e "> Processing platform ${target_platform}" echo -e "> Processing platform ${target_platform}"
date_start=$( date +%s ) date_start=$( date +%s )
pushd ${target_platform} pushd ${target_platform}
cleanup() {
echo -e ">> Processing action clean"
if [[ -f clean.sh && -x clean.sh ]]; then
./clean.sh ${keep_artifacts}
fi
}
trap cleanup EXIT INT
for target_action in ${action[@]}; do for target_action in ${action[@]}; do
echo -e ">> Processing action ${target_action}" echo -e ">> Processing action ${target_action}"
if [[ -f ${target_action}.sh && -x ${target_action}.sh ]]; then if [[ -f ${target_action}.sh && -x ${target_action}.sh ]]; then
@ -204,12 +219,8 @@ for target_platform in ${platform[@]}; do
target_dir="../../../jellyfin-build/${target_platform}" target_dir="../../../jellyfin-build/${target_platform}"
mkdir -p ${target_dir} mkdir -p ${target_dir}
mv pkg-dist/* ${target_dir}/ mv pkg-dist/* ${target_dir}/
echo -e ">> Processing action clean"
if [[ -f clean.sh && -x clean.sh ]]; then
./clean.sh
fi
fi fi
cleanup
date_end=$( date +%s ) date_end=$( date +%s )
echo -e "> Completed platform ${target_platform} in $( expr ${date_end} - ${date_start} ) seconds." echo -e "> Completed platform ${target_platform} in $( expr ${date_end} - ${date_start} ) seconds."
popd popd

View File

@ -55,6 +55,8 @@ These builds are not necessarily run from the `build` script, but are present fo
* The `clean` action should always `exit 0` even if no work is done or it fails. * The `clean` action should always `exit 0` even if no work is done or it fails.
* The `clean` action can be passed a variable as argument 1, named `keep_artifacts`. It is indended to handle situations when the user runs `build --keep-artifacts` and should be handled intelligently. Usually, this is used to preserve Docker images while still removing temporary directories.
### Output Files ### Output Files
* Upon completion of the defined actions, at least one output file must be created in the `<platform>/pkg-dist` directory. * Upon completion of the defined actions, at least one output file must be created in the `<platform>/pkg-dist` directory.