Skip to content

Commit cbab82c

Browse files
committed
Improve and unify logging
1 parent 417ecdb commit cbab82c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

linuxdeploy-plugin-conda.sh

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ show_usage() {
2323
echo " ARCH=\"x86_64\" (further supported values: i686)"
2424
}
2525

26+
log() {
27+
tput setaf 3
28+
tput bold
29+
echo -*- "$@"
30+
tput sgr0
31+
}
32+
2633
APPDIR=
2734

2835
while [ "$1" != "" ]; do
@@ -41,8 +48,8 @@ while [ "$1" != "" ]; do
4148
exit 0
4249
;;
4350
*)
44-
echo "Invalid argument: $1"
45-
echo
51+
log "Invalid argument: $1"
52+
log
4653
show_usage
4754
exit 1
4855
;;
@@ -57,7 +64,7 @@ fi
5764
mkdir -p "$APPDIR"
5865

5966
if [ "$CONDA_PACKAGES" == "" ]; then
60-
echo "WARNING: \$CONDA_PACKAGES not set, no packages will be installed!"
67+
log "WARNING: \$CONDA_PACKAGES not set, no packages will be installed!"
6168
fi
6269

6370
# the user can specify a directory into which the conda installer is downloaded
@@ -69,14 +76,14 @@ if [ "$CONDA_DOWNLOAD_DIR" != "" ]; then
6976
CONDA_DOWNLOAD_DIR="$(readlink -f "$CONDA_DOWNLOAD_DIR")"
7077
fi
7178

72-
echo "Using user-specified download directory: $CONDA_DOWNLOAD_DIR"
79+
log "Using user-specified download directory: $CONDA_DOWNLOAD_DIR"
7380
mkdir -p "$CONDA_DOWNLOAD_DIR"
7481
else
7582
# create temporary directory into which downloaded files are put
7683
CONDA_DOWNLOAD_DIR="$(mktemp -d)"
7784

7885
_cleanup() {
79-
if [ -d "$CONDA_DOWNLOAD_DIR"]; then
86+
if [ -d "$CONDA_DOWNLOAD_DIR" ]; then
8087
rm -rf "$CONDA_DOWNLOAD_DIR"
8188
fi
8289
}
@@ -85,8 +92,8 @@ else
8592
fi
8693

8794
if [ -d "$APPDIR"/usr/conda ]; then
88-
echo "Warning: conda prefix directory exists: $APPDIR/usr/conda"
89-
echo "Please make sure you perform a clean build before releases to make sure your process works properly."
95+
log "WARNING: conda prefix directory exists: $APPDIR/usr/conda"
96+
log "Please make sure you perform a clean build before releases to make sure your process works properly."
9097
fi
9198

9299
ARCH=${ARCH:-x86_64}
@@ -100,7 +107,7 @@ case "$ARCH" in
100107
miniconda_installer_filename=Miniconda3-latest-Linux-x86.sh
101108
;;
102109
*)
103-
echo "Error: Unknown Miniconda arch: $ARCH"
110+
log "ERROR: Unknown Miniconda arch: $ARCH"
104111
exit 1
105112
;;
106113
esac
@@ -162,7 +169,7 @@ mkdir -p "$APPDIR"/usr/bin/
162169
pushd "$APPDIR"
163170
for i in usr/conda/bin/*; do
164171
if [ -f usr/bin/"$(basename "$i")" ]; then
165-
echo "Warning: symlink exists, will not be touched: usr/bin/$i"
172+
log "WARNING: symlink exists, will not be touched: usr/bin/$i"
166173
else
167174
ln -s ../../"$i" usr/bin/
168175
fi

0 commit comments

Comments
 (0)