11#! /bin/bash -e
2- # Copyright (c) 2023 TurnKey GNU/Linux - https://www.turnkeylinux.org
2+ # Copyright (c) 2023-2025 TurnKey GNU/Linux - https://www.turnkeylinux.org
33#
44# This file is part of buildtasks.
55#
88# Free Software Foundation; either version 3 of the License, or (at your
99# option) any later version.
1010
11- fatal () { echo " FATAL [$( basename $0 ) ]: $@ " 1>&2 ; exit 1; }
12- warn () { echo -e " WARNING [$( basename $0 ) ]: $@ " ; }
13- info () { echo " INFO [$( basename $0 ) ]: $@ " ; }
11+ fatal () { echo " FATAL [$( basename " $0 " ) ]: $* " 1>&2 ; exit 1; }
12+ warn () { echo -e " WARNING [$( basename " $0 " ) ]: $* " ; }
13+ info () { echo " INFO [$( basename " $0 " ) ]: $* " ; }
1414
1515usage () {
16+ local msg=" $* "
1617 cat<< EOF
17- Syntax: $( basename $0 ) [APP_NAME]
18+ Syntax: $( basename " $0 " ) [APP_NAME]
1819Setup/update system ready for bt-iso (clicksnap & deps)
1920
2021Option::
@@ -29,20 +30,20 @@ Environment::
2930 BT_DEBUG turn on debugging
3031
3132EOF
32- if [[ -n " $1 " ]]; then
33- echo " Error: $@ " >&2
34- exit 1
33+ if [[ -n " $msg " ]]; then
34+ fatal " $msg "
3535 fi
3636 exit
3737}
3838
3939[ -n " $BT_DEBUG " ] && set -x
4040
41- export BT=$( dirname $( dirname $( readlink -f $0 ) ) )
41+ BT=$( dirname " $( dirname " $( readlink -f " $0 " ) " ) " )
42+ export BT
4243export BT_CONFIG=$BT /config
4344
4445[[ -n " $BASE_DIR " ]] || BASE_DIR=/turnkey/public
45- mkdir -p $BASE_DIR
46+ mkdir -p " $BASE_DIR "
4647GH_URL=https://github.com/turnkeylinux
4748
4849unset app
@@ -59,19 +60,20 @@ while [ "$1" != "" ]; do
5960done
6061
6162install () {
62- info " Updating apt cache and installing deps:" $@
63- info " installing $@ "
63+ info " Updating apt cache and installing deps: $* "
64+ info " installing $* "
6465 apt-get -qq update
65- DEBIAN_FRONTEND=noninteractive apt-get -y install $@
66+ DEBIAN_FRONTEND=noninteractive apt-get -y install " $@ "
6667}
6768
6869git_pull () {
6970 local dir=$1
7071 local app=$2
71- cd $dir
72- local remote=$( sed -En " s|(^[a-zA-Z0-9_-]*)[[:space:]].*|\1|p" \
73- <<< $( git remote -v | grep -m1 " turnkeylinux/$app " ) )
74- git pull $remote master
72+ cd " $dir "
73+ local remote
74+ remote=$( sed -En " s|(^[a-zA-Z0-9_-]*)[[:space:]].*|\1|p" \
75+ <<< " $(git remote -v | grep -m1 " turnkeylinux/$app " )" )
76+ git pull " $remote " master
7577}
7678
7779# dl & check for screenshot code first so we can bail as early as possible
@@ -86,14 +88,15 @@ for dl in tkldev-docker clicksnap; do
8688 fi
8789 else
8890 info " Downloading $dl source"
89- git clone --depth=1 $GH_URL /$dl $BASE_DIR /$dl
91+ git clone --depth=1 $GH_URL /$dl " $BASE_DIR /$dl "
9092 fi
9193done
9294
93- app=$( sed " s|-|_|g" <<< $app )
95+ # TODO use ${variable//search/replace} instead of sed here
96+ app=" $( sed " s|-|_|g" <<< " $app" ) "
9497if [[ -z " $app " ]]; then
9598 warn " App name not given - continuing, but may fail later"
96- elif ! ls $BASE_DIR /clicksnap/src/apps/ | grep -q -w " $app " \
99+ elif ! grep -r - q -w " $app " " $BASE_DIR " /clicksnap/src/apps/ \
97100 && [[ -z " $no_screens " ]] ; then
98101 fatal " Clicksnap code for $app not found (checked in $BASE_DIR /clicksnap/src/apps/)"
99102fi
102105deps=" podman sed fab deck"
103106missing=' '
104107for dep in $deps ; do
105- which $dep > /dev/null || missing=" $missing $dep "
108+ which " $dep " > /dev/null || missing=" $missing $dep "
106109done
107- [[ -z " $missing " ]] || install $missing
110+ [[ -z " $missing " ]] || install " $missing "
108111
109112case " $( which cargo || echo ' fail' ) " in
110113 " $HOME /.cargo/bin/cargo" )
111114 info " Rust installed via rustup detected, attempting update"
112- rustup update;;
115+ rustup update
116+ ;;
113117 /usr/bin/cargo)
114118 warn " system installed rust detected; continuing but may cause issues\n" \
115119 " - if you encountner issues, please remove rust and rerun" ;;
116120 fail)
117121 info " Installing rust via rustup"
118122 curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
119- echo " export PATH=\"\$ HOME/.cargo/bin:\$ PATH\" " > $HOME /.bashrc.d/rust
120- chmod +x $HOME /.bashrc.d/rust
121- source $HOME /.bashrc.d/rust;;
123+ echo " export PATH=\"\$ HOME/.cargo/bin:\$ PATH\" " > " $HOME " /.bashrc.d/rust
124+ chmod +x " $HOME " /.bashrc.d/rust
125+ source " $HOME /.bashrc.d/rust" ;;
122126 * )
123127 fatal " Unexpected cargo path: '$1 '" ;;
124128esac
125129
126- cd $BASE_DIR /clicksnap
130+ cd " $BASE_DIR " /clicksnap
127131info " Building & installing clicksnap"
128132cargo build
129- ln -sf $PWD /target/debug/clicksnap /usr/local/bin/clicksnap
130- ln -sf $BASE_DIR /tkldev-docker/dockerize.sh /usr/local/bin/dockerize
131- ln -sf $BASE_DIR /tkldev-docker/wait-ready.sh /usr/local/bin/tkl-docker-wait-ready
133+ ln -sf " $PWD " /target/debug/clicksnap /usr/local/bin/clicksnap
134+ ln -sf " $BASE_DIR " /tkldev-docker/dockerize.sh /usr/local/bin/dockerize
135+ ln -sf " $BASE_DIR " /tkldev-docker/wait-ready.sh /usr/local/bin/tkl-docker-wait-ready
0 commit comments