Skip to content

Commit dcafada

Browse files
committed
[fix] : Quart the string
1 parent 6155119 commit dcafada

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

tools/docker-build.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ EOF
1414
exit 1
1515
fi
1616

17-
script_path=$(cd -P $(dirname $(readlink -f ${0})) && cd .. && pwd)
17+
script_path="$(cd -P $(dirname $(readlink -f ${0})) && cd .. && pwd)"
1818

1919
_usage () {
2020
echo "usage ${0} [options]"
@@ -32,24 +32,24 @@ _usage () {
3232
}
3333

3434
# Start define var
35-
if [[ -d /var/cache/pacman/pkg ]] && [[ -d /var/lib/pacman/sync ]]; then
36-
SHARE_PKG_DIR=/var/cache/pacman/pkg
37-
SHARE_DB_DIR=/var/lib/pacman/sync
35+
if [[ -d "/var/cache/pacman/pkg" ]] && [[ -d "/var/lib/pacman/sync" ]]; then
36+
SHARE_PKG_DIR="/var/cache/pacman/pkg"
37+
SHARE_DB_DIR="/var/lib/pacman/sync"
3838
else
39-
SHARE_PKG_DIR=${script_path}/cache/pkg
40-
SHARE_DB_DIR=${script_path}/cache/sync
39+
SHARE_PKG_DIR="${script_path}/cache/pkg"
40+
SHARE_DB_DIR="${script_path}/cache/sync"
4141
fi
4242
# End define var
4343

4444
# Start parse options
45-
DIST_DIR=${script_path}/out
45+
DIST_DIR="${script_path}/out"
4646
DOCKER_BUILD_OPTS=()
4747
BUILD_SCRIPT_OPTS=()
48-
while (( $# > 0 )); do
49-
case ${1} in
48+
while (( ${#} > 0 )); do
49+
case "${1}" in
5050
-o | --build-opiton)
5151
# -o: dists output dir option in build.sh
52-
if [[ ${2} == *"-o"* ]]; then
52+
if [[ "${2}" == *"-o"* ]]; then
5353
echo "The -o option cannot be set with docker build. Please use -d option instead." 1>&2
5454
exit 1
5555
fi
@@ -58,19 +58,19 @@ while (( $# > 0 )); do
5858
shift 2
5959
;;
6060
-d | --dist-out-dir)
61-
mkdir -p ${2} || {
61+
mkdir -p "${2}" || {
6262
echo "Error: failed creating output directory: ${2}" 1>&2
6363
exit 1
6464
}
6565
DIST_DIR=$(cd -P ${2} && pwd)
6666
shift 2
6767
;;
6868
-w | --work-dir)
69-
mkdir -p ${2} || {
69+
mkdir -p "${2}" || {
7070
echo "Error: failed creating working directory: ${2}" 1>&2
7171
exit 1
7272
}
73-
EXTERNAL_WORK_DIR=$(cd -P ${2} && pwd)
73+
EXTERNAL_WORK_DIR=$(cd -P "${2}" && pwd)
7474
shift 2
7575
;;
7676
-n | --noninteractive)
@@ -87,12 +87,12 @@ while (( $# > 0 )); do
8787
shift 1
8888
;;
8989
-p | --pkg-cache-dir)
90-
if [[ -d ${2} ]] && \
91-
mkdir -p ${2}/pkg && \
92-
mkdir -p ${2}/sync
90+
if [[ -d "${2}" ]] && \
91+
mkdir -p "${2}/pkg" && \
92+
mkdir -p "${2}/sync"
9393
then
94-
SHARE_PKG_DIR=${2}/pkg
95-
SHARE_DB_DIR=${2}/sync
94+
SHARE_PKG_DIR="${2}/pkg"
95+
SHARE_DB_DIR="${2}/sync"
9696
else
9797
echo "Error: The directory is not found or cannot make directory." 1>&2
9898
exit 1
@@ -114,10 +114,10 @@ while (( $# > 0 )); do
114114
done
115115
# End parse options
116116

117-
if [[ -d /usr/lib/modules/$(uname -r) ]]; then
118-
KMODS_DIR=/usr/lib/modules
117+
if [[ -d "/usr/lib/modules/$(uname -r)" ]]; then
118+
KMODS_DIR="/usr/lib/modules"
119119
else
120-
KMODS_DIR=/lib/modules
120+
KMODS_DIR="/lib/modules"
121121
fi
122122

123123
DOCKER_RUN_OPTS=()
@@ -132,5 +132,5 @@ DOCKER_RUN_OPTS+=(-v "${KMODS_DIR}:/usr/lib/modules:ro")
132132

133133
tty >/dev/null 2>&1 && OPT_TTY="-it" || OPT_TTY=""
134134

135-
docker build "${DOCKER_BUILD_OPTS[@]}" -t alterlinux-build:latest ${script_path}
135+
docker build "${DOCKER_BUILD_OPTS[@]}" -t alterlinux-build:latest "${script_path}"
136136
exec docker run --rm ${OPT_TTY} --privileged -e _DOCKER=true "${DOCKER_RUN_OPTS[@]}" alterlinux-build "${BUILD_SCRIPT_OPTS[@]}"

0 commit comments

Comments
 (0)