[rkward] macports: more improvements for replace_port.sh
m.eik michalke
null at kde.org
Thu Apr 5 19:33:58 UTC 2018
Git commit c727b565a2b95eeebf5305d31fc1c35e1486c0b4 by m.eik michalke.
Committed on 05/04/2018 at 19:32.
Pushed by meikm into branch 'master'.
more improvements for replace_port.sh
M +63 -44 macports/replace_port.sh
https://commits.kde.org/rkward/c727b565a2b95eeebf5305d31fc1c35e1486c0b4
diff --git a/macports/replace_port.sh b/macports/replace_port.sh
index 2be492ff..68b3639f 100755
--- a/macports/replace_port.sh
+++ b/macports/replace_port.sh
@@ -4,32 +4,38 @@
MPTINST=/opt/rkward
# specify application dir used
APPLDIR=/Applications/RKWard
-# specify path to make
-MAKEPATH=/usr/bin/make
# specify deactivation suffix
DCTSFFX="_works"
DEACT=false
REACT=false
-IMAKE=false
RMDCT=false
-
+
+TXT_DGRAY="\033[1;30m"
+TXT_LRED="\033[1;31m"
+TXT_RED="\033[0;31m"
+TXT_BLUE="\033[0;34m"
+TXT_GREEN="\033[0;32m"
+TXT_BOLD="\033[1m"
+TXT_ITALIC="\033[3m"
+TXT_UNDERSCORE="\033[4m"
+TXT_ORANGE_ON_GREY="\033[48;5;240;38;5;202m"
+OFF="\033[0m"
+
if [[ $1 == "" ]] ; then
- echo "Usage: replace_port.sh OPTION
+ echo -e "Usage: replace_port.sh OPTION
OPTIONS:
-d (deactivate running RKWard installation)
-a (re-activate previous RKWard installation)
- -m (also include ${MAKEPATH} in the process)
- -x (!remove! the deactivated RKWard installation)
-"
+ -x (!remove! the deactivated RKWard installation)\n"
+ exit 0
fi
# get the options
-while getopts ":damx" OPT; do
+while getopts ":dax" OPT; do
case $OPT in
d) DEACT=true >&2 ;;
a) REACT=true >&2 ;;
- m) IMAKE=true >&2 ;;
x) RMDCT=true >&2 ;;
\?)
echo "Invalid option: -$OPTARG" >&2
@@ -42,44 +48,57 @@ while getopts ":damx" OPT; do
esac
done
+error() {
+ # $1: message to print
+ echo -e "${TXT_RED}ouch:${OFF} $1"
+ exit 1
+}
+
+warning() {
+ # $1: message to print
+ echo -e "${TXT_ORANGE_ON_GREY}warning:${OFF} $1"
+}
+
+alldone() {
+ echo -e " ${TXT_GREEN}done! ${OFF}"
+}
+
if $DEACT ; then
- if [ -d "${MPTINST}${DCTSFFX}" ] ; then
- echo "ouch: \"${MPTINST}${DCTSFFX}\" already exists, aborting!"
- exit 1
- fi
- if [ -d "${APPLDIR}${DCTSFFX}" ] ; then
- echo "ouch: \"${APPLDIR}${DCTSFFX}\" already exists, aborting!"
- exit 1
- fi
- sudo mv "${MPTINST}" "${MPTINST}${DCTSFFX}"
- sudo mv "${APPLDIR}" "${APPLDIR}${DCTSFFX}"
- if [[ $IMAKE ]] && [ -f "${MAKEPATH}${DCTSFFX}" ] ; then
- echo "ouch: \"${MAKEPATH}${DCTSFFX}\" already exists, skipping!"
- else
- sudo mv "${MAKEPATH}" "${MAKEPATH}${DCTSFFX}"
- fi
+ if [ -d "${MPTINST}${DCTSFFX}" ] ; then
+ error "${TXT_BLUE}\"${MPTINST}${DCTSFFX}\"${OFF} already exists, aborting!"
+ fi
+ if [ -d "${APPLDIR}${DCTSFFX}" ] ; then
+ error "${TXT_BLUE}\"${APPLDIR}${DCTSFFX}\"${OFF} already exists, aborting!"
+ fi
+ echo -en "renaming ${TXT_BLUE}${MPTINST}${OFF} into ${TXT_BLUE}${MPTINST}${DCTSFFX}${OFF}..."
+ sudo mv "${MPTINST}" "${MPTINST}${DCTSFFX}" || error "failed!"
+ alldone
+ echo -en "renaming ${TXT_BLUE}${APPLDIR}${OFF} into ${TXT_BLUE}${APPLDIR}${DCTSFFX}${OFF}..."
+ sudo mv "${APPLDIR}" "${APPLDIR}${DCTSFFX}" || error "failed!"
+ alldone
fi
if $REACT ; then
- if $IMAKE && ! [ -f "${MAKEPATH}${DCTSFFX}" ] ; then
- echo "ouch: \"${MAKEPATH}${DCTSFFX}\" doesn't exist, skipping!"
- else
- sudo mv "${MAKEPATH}${DCTSFFX}" "${MAKEPATH}"
- fi
- if ! [ -d "${MPTINST}${DCTSFFX}" ] ; then
- echo "ouch: \"${MPTINST}${DCTSFFX}\" doesn't exist, aborting!"
- exit 1
- else
- sudo rm -rf "${MPTINST}"
- sudo mv "${MPTINST}${DCTSFFX}" "${MPTINST}"
- fi
- if ! [ -d "${APPLDIR}${DCTSFFX}" ] ; then
- echo "ouch: \"${APPLDIR}${DCTSFFX}\" doesn't exist, aborting!"
- exit 1
- else
- sudo rm -rf "${APPLDIR}"
- sudo mv "${APPLDIR}${DCTSFFX}" "${APPLDIR}"
- fi
+ if ! [ -d "${MPTINST}${DCTSFFX}" ] ; then
+ error "${TXT_BLUE}\"${MPTINST}${DCTSFFX}\"${OFF} doesn't exist, aborting!"
+ else
+ echo -en "removing ${TXT_BLUE}${MPTINST}${OFF}..."
+ sudo rm -rf "${MPTINST}" || error "failed!"
+ alldone
+ echo -en "renaming ${TXT_BLUE}${MPTINST}${DCTSFFX}${OFF} into ${TXT_BLUE}${MPTINST}${OFF}..."
+ sudo mv "${MPTINST}${DCTSFFX}" "${MPTINST}" || error "failed!"
+ alldone
+ fi
+ if ! [ -d "${APPLDIR}${DCTSFFX}" ] ; then
+ error "${TXT_BLUE}\"${APPLDIR}${DCTSFFX}\"${OFF} doesn't exist, aborting!"
+ else
+ echo -en "removing ${TXT_BLUE}${APPLDIR}${OFF}..."
+ sudo rm -rf "${APPLDIR}" || error "failed!"
+ alldone
+ echo -en "renaming ${TXT_BLUE}${APPLDIR}${DCTSFFX}${OFF} into ${TXT_BLUE}${APPLDIR}${OFF}..."
+ sudo mv "${APPLDIR}${DCTSFFX}" "${APPLDIR}" || error "failed!"
+ alldone
+ fi
fi
exit 0
More information about the rkward-tracker
mailing list