Update loadup and medley scripts to use "tag" instead of "branch"; add ability to completely delete tagged loadups rather than just thin them (#2249)
* WIP in changing loadups to tagged nomeclature rather that branch and ability to delete tagged branches as well as thin them. * In loadup and medley scripts, changed the --branch (-br) command line argument to --tag (-tg). Correspondingly changed the MEDLEYDIR/loadups/branches directory to be MEDLEYDIR/loadups/tagged. Separately, added a + parameter to the --thinw and --thinl command line arguments which causes ALL files to be deleted, not just the versioned files. Added a --thin command line argument that is equivalent to --thinw followed by --thinl. Updated the man page to reflect all these changes. * Updated medley script man page to reflect the new tag nomenclature instead of branch nomenclature. * Fix issue#2063 - typo in medley man page * 1) In loadup script made --help (-h) be a synomym of --man (-z). 2) In both loadup and medley scripts added an optional parameter (+) to the --man (z) command line argument that when specified will display the man page without paging - i.e., sets the pager to cat. * Fix Issue#2251 LOADUPSDIRECTORIES settings by the MEDLEYDIR fn now takes into account tagged loadups
This commit is contained in:
@@ -14,12 +14,13 @@ main() {
|
||||
nocopy=false
|
||||
thinw=false
|
||||
thinl=false
|
||||
thinall=false
|
||||
override_lock=false
|
||||
ignore_lock=false
|
||||
export LOADUP_USE_VNC="-"
|
||||
man_flg=false
|
||||
use_branch=""
|
||||
branch_requested=false
|
||||
use_tag=""
|
||||
tag_requested=false
|
||||
|
||||
while [ "$#" -ne 0 ];
|
||||
do
|
||||
@@ -123,18 +124,18 @@ main() {
|
||||
end=1
|
||||
end_s=init
|
||||
;;
|
||||
-br | -branch | --branch)
|
||||
branch_requested=true
|
||||
-tg | -tag | --tag)
|
||||
tag_requested=true
|
||||
if [ "$2" = "-" ]
|
||||
then
|
||||
use_branch="-"
|
||||
use_tag="-"
|
||||
shift
|
||||
else
|
||||
if check_for_no_arg "$2"
|
||||
then
|
||||
use_branch="-"
|
||||
use_tag="-"
|
||||
else
|
||||
use_branch="$2"
|
||||
use_tag="$2"
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
@@ -142,11 +143,29 @@ main() {
|
||||
-nc | -nocopy | --nocopy)
|
||||
nocopy=true
|
||||
;;
|
||||
-th | -thin | --thin)
|
||||
thinall=true
|
||||
if [ "$2" = "+" ]
|
||||
then
|
||||
thinall="+"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
-tw | -thinw | --thinw)
|
||||
thinw=true
|
||||
if [ "$2" = "+" ]
|
||||
then
|
||||
thinw="+"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
-tl | -thinl | --thinl)
|
||||
thinl=true
|
||||
if [ "$2" = "+" ]
|
||||
then
|
||||
thinl="+"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
-d | -maikodir | --maikodir)
|
||||
if [ -n "$2" ]
|
||||
@@ -178,13 +197,15 @@ main() {
|
||||
# internal
|
||||
noendmsg=true
|
||||
;;
|
||||
--forcevnc)
|
||||
# internal - for testing
|
||||
# WSL only -otherwise warning msg from medley
|
||||
force_vnc="+"
|
||||
;;
|
||||
-z | -man | --man )
|
||||
-z | -man | --man | -h | -help | --help)
|
||||
man_flg=true
|
||||
if [ "$2" = "+" ]
|
||||
then
|
||||
man_no_pager=true
|
||||
shift
|
||||
else
|
||||
man_no_pager=false
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
output_error_msg "Error: unknown flag: $1${EOL}Exiting"
|
||||
@@ -206,6 +227,10 @@ main() {
|
||||
#
|
||||
if [ "${man_flg}" = true ]
|
||||
then
|
||||
if [ "${man_no_pager}" = true ]
|
||||
then
|
||||
export PAGER=cat
|
||||
fi
|
||||
if [ "$(uname)" = "Darwin" ]
|
||||
then
|
||||
/usr/bin/man "${LOADUP_SOURCEDIR}/man-page/loadup.1.gz"
|
||||
@@ -223,10 +248,10 @@ main() {
|
||||
|
||||
no_loadups=false
|
||||
|
||||
# check --branch is used correctly
|
||||
if [ "${branch_requested}" = true ] && [ -z "${use_branch}" ]
|
||||
# check --tag is used correctly
|
||||
if [ "${tag_requested}" = true ] && [ -z "${use_tag}" ]
|
||||
then
|
||||
output_warn_msg "The --branch (-br) flag was used. But either git is not installed on this system or \"${LOADUP_SOURCEDIR}\" is not a git directory.${EOL}The --branch flag will be ignored"
|
||||
output_warn_msg "The --tag (-tg) flag was used. But either git is not installed on this system or \"${LOADUP_SOURCEDIR}\" is not a git directory.${EOL}The --tg flag will be ignored"
|
||||
fi
|
||||
|
||||
#
|
||||
@@ -241,7 +266,7 @@ main() {
|
||||
start_sysout=starter.sysout
|
||||
aux=true
|
||||
db=false
|
||||
if [ "${thinw}" = true ] || [ "${thinl}" = true ]
|
||||
if [ ! "${thinw}" = false ] || [ ! "${thinl}" = false ] || [ ! "${thinall}" = false ]
|
||||
then
|
||||
no_loadups=true
|
||||
nocopy=true
|
||||
@@ -312,13 +337,32 @@ main() {
|
||||
|
||||
# if requested, thin the loadups and workdirs by eliminating all versioned (*.~[0-9]*~) files
|
||||
# from these directories
|
||||
if [ "${thinw}" = true ]
|
||||
case "${thinall}" in
|
||||
true) "${LOADUP_SCRIPTDIR}"/thin_loadups.sh lw ;;
|
||||
+) "${LOADUP_SCRIPTDIR}"/thin_loadups.sh lw + ;;
|
||||
*)
|
||||
case "${thinw}" in
|
||||
true) "${LOADUP_SCRIPTDIR}"/thin_loadups.sh w ;;
|
||||
+) "${LOADUP_SCRIPTDIR}"/thin_loadups.sh w + ;;
|
||||
esac
|
||||
case "${thinl}" in
|
||||
true) "${LOADUP_SCRIPTDIR}"/thin_loadups.sh l ;;
|
||||
+) "${LOADUP_SCRIPTDIR}"/thin_loadups.sh l + ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
# Exit if there's no more work to be done
|
||||
# Otherwise recreate ${LOADUP_WORKDIR} & ${LOADUP_OUTDIR} if they were
|
||||
# deleted during the thin process, if any
|
||||
if [ "${no_loadups}" = true ] && [ "${nocopy}" = true ]
|
||||
then
|
||||
"${LOADUP_SCRIPTDIR}"/thin_loadups.sh w
|
||||
fi
|
||||
if [ "${thinl}" = true ]
|
||||
then
|
||||
"${LOADUP_SCRIPTDIR}"/thin_loadups.sh l
|
||||
echo "+++++ loadup: SUCCESS +++++"
|
||||
remove_run_lock
|
||||
exit 0
|
||||
else
|
||||
mkdir -p "${LOADUP_OUTDIR}"
|
||||
mkdir -p "${LOADUP_WORKDIR}"
|
||||
fi
|
||||
|
||||
# find and place starting sysout
|
||||
|
||||
@@ -28,27 +28,34 @@ git_commit_info "${LOADUP_SOURCEDIR}"
|
||||
export LOADUP_COMMIT_ID="${COMMIT_ID}"
|
||||
export LOADUP_BRANCH="${BRANCH}"
|
||||
|
||||
if [ "${use_branch}" = "-" ]
|
||||
if [ "${use_tag}" = "-" ]
|
||||
then
|
||||
use_branch="${LOADUP_BRANCH}"
|
||||
use_tag="${LOADUP_BRANCH}"
|
||||
fi
|
||||
|
||||
slash_branch=""
|
||||
if [ -n "${use_branch}" ]
|
||||
slash_tag=""
|
||||
if [ -n "${use_tag}" ]
|
||||
then
|
||||
use_branch="$(printf %s "${use_branch}" | sed "s/[^a-zA-Z0-9_.-]/_/g")"
|
||||
slash_branch="/branches/${use_branch}"
|
||||
use_tag="$(printf %s "${use_tag}" | sed "s/[^a-zA-Z0-9_.-]/_/g")"
|
||||
slash_tag="/tagged/${use_tag}"
|
||||
# update dir structure for to use tag nomenclature rather than branch nomenclature
|
||||
# but keep compatibilty with branch nomenclature for now
|
||||
if [ -d "${MEDLEYDIR}/loadups/branches" ] && [ ! -h "${MEDLEYDIR}/loadups/branches" ]
|
||||
then
|
||||
mv "${MEDLEYDIR}/loadups/branches" "${MEDLEYDIR}/loadups/tagged"
|
||||
ln -s "${MEDLEYDIR}/loadups/tagged" "${MEDLEYDIR}/loadups/branches"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${LOADUP_OUTDIR}" ]
|
||||
then
|
||||
export LOADUP_OUTDIR="${MEDLEYDIR}/loadups${slash_branch}"
|
||||
export LOADUP_OUTDIR="${MEDLEYDIR}/loadups${slash_tag}"
|
||||
fi
|
||||
|
||||
if [ ! -d "${LOADUP_OUTDIR}" ];
|
||||
if [ ! -d "${LOADUP_OUTDIR}" ]
|
||||
then
|
||||
if [ ! -e "${LOADUP_OUTDIR}" ];
|
||||
if [ ! -e "${LOADUP_OUTDIR}" ]
|
||||
then
|
||||
mkdir -p "${LOADUP_OUTDIR}"
|
||||
else
|
||||
@@ -159,7 +166,6 @@ loadup_finish () {
|
||||
exit ${exit_code}
|
||||
}
|
||||
|
||||
force_vnc="-"
|
||||
run_medley () {
|
||||
/bin/sh "${MEDLEYDIR}/scripts/medley/medley.command" \
|
||||
--config - \
|
||||
|
||||
@@ -12,17 +12,48 @@ main() {
|
||||
|
||||
if [ "$1" = "w" ] || [ "$1" = "lw" ] || [ "$1" = "wl" ]
|
||||
then
|
||||
find "${LOADUP_WORKDIR}" -name "*.~[0-9]*~" -delete
|
||||
if [ ! "$2" = "+" ]
|
||||
then
|
||||
find "${LOADUP_WORKDIR}" -name "*.~[0-9]*~" -delete
|
||||
else
|
||||
rm -rf "${LOADUP_WORKDIR}"/*
|
||||
if istagged "${LOADUP_WORKDIR}"
|
||||
then
|
||||
rm -rf "${LOADUP_WORKDIR}"
|
||||
if istagged "${LOADUP_OUTDIR}" && [ -z "$(ls -a -1 "${LOADUP_OUTDIR}" | tail +3)" ]
|
||||
then
|
||||
rmdir "${LOADUP_OUTDIR}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "$1" = "l" ] || [ "$1" = "lw" ] || [ "$1" = "wl" ]
|
||||
then
|
||||
find "${LOADUP_OUTDIR}" -name "*.~[0-9]*~" -delete
|
||||
if [ ! "$2" = "+" ]
|
||||
then
|
||||
find "${LOADUP_OUTDIR}" -name "$(basename "${LOADUP_WORKDIR}")" -prune \
|
||||
-o -name "*.~[0-9]*~" -exec rm -f {} \;
|
||||
else
|
||||
find "${LOADUP_OUTDIR}" \( -name "$(basename "${LOADUP_WORKDIR}")" -prune \) \
|
||||
-o -path "${LOADUP_OUTDIR}" \
|
||||
-o -exec rm -rf {} \; 2>&1 >/dev/null \
|
||||
| grep -v "No such file"
|
||||
if istagged "${LOADUP_OUTDIR}" && [ ! -e "${LOADUP_WORKDIR}" ]
|
||||
then
|
||||
rm -rf "${LOADUP_OUTDIR}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
istagged() {
|
||||
echo "$1" | grep -q "^${MEDLEYDIR}/loadups/tagged"
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
# shellcheck disable=SC2164,SC2034
|
||||
if [ -z "${LOADUP_SCRIPTDIR}" ]
|
||||
then
|
||||
|
||||
Reference in New Issue
Block a user