Skip to content

Commit 476a7e9

Browse files
format shell scripts with beautysh
Signed-off-by: Patrick Williams <[email protected]> Change-Id: Ie72911e0f57a1f69b0bf317de8c52947886e1303
1 parent bc0d5a3 commit 476a7e9

21 files changed

+420
-420
lines changed

build-jenkins.sh

+73-73
Original file line numberDiff line numberDiff line change
@@ -92,34 +92,34 @@ j_url=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${j_vrs
9292

9393
# Make or Clean WORKSPACE
9494
if [[ -d "${workspace}" ]]; then
95-
rm -rf "${workspace}/Dockerfile" \
96-
"${workspace}/docker-jenkins" \
97-
"${workspace}/plugins.*" \
98-
"${workspace}/install-plugins.sh" \
99-
"${workspace}/jenkins.sh" \
100-
"${workspace}/jenkins-support" \
101-
"${workspace}/init.groovy"
95+
rm -rf "${workspace}/Dockerfile" \
96+
"${workspace}/docker-jenkins" \
97+
"${workspace}/plugins.*" \
98+
"${workspace}/install-plugins.sh" \
99+
"${workspace}/jenkins.sh" \
100+
"${workspace}/jenkins-support" \
101+
"${workspace}/init.groovy"
102102
else
103-
mkdir -p "${workspace}"
103+
mkdir -p "${workspace}"
104104
fi
105105

106106
# Determine the prefix of the Dockerfile's base image
107107
case ${ARCH} in
108-
"ppc64le")
109-
docker_base="ppc64le/"
110-
tini_arch="ppc64el"
111-
;;
112-
"x86_64")
113-
docker_base=""
114-
tini_arch="amd64"
115-
;;
116-
"aarch64")
117-
docker_base="arm64v8/"
118-
tini_arch="arm64"
119-
;;
120-
*)
121-
echo "Unsupported system architecture(${ARCH}) found for docker image"
122-
exit 1
108+
"ppc64le")
109+
docker_base="ppc64le/"
110+
tini_arch="ppc64el"
111+
;;
112+
"x86_64")
113+
docker_base=""
114+
tini_arch="amd64"
115+
;;
116+
"aarch64")
117+
docker_base="arm64v8/"
118+
tini_arch="arm64"
119+
;;
120+
*)
121+
echo "Unsupported system architecture(${ARCH}) found for docker image"
122+
exit 1
123123
esac
124124

125125
# Move Into the WORKSPACE
@@ -208,60 +208,60 @@ docker build -t "${img_name}" .
208208

209209
if [[ "${launch}" == "docker" ]]; then
210210

211-
# Ensure directories that will be mounted exist
212-
if [[ -n "${host_import_mnt}" && ! -d "${host_import_mnt}" ]]; then
213-
mkdir -p "${host_import_mnt}"
214-
fi
215-
216-
if [[ ! -d "${home_mnt}" ]]; then
217-
mkdir -p "${home_mnt}"
218-
fi
219-
220-
# Ensure directories that will be mounted are owned by the jenkins user
221-
if [[ "$(id -u)" != 0 ]]; then
222-
echo "Not running as root:"
223-
echo "Checking if j_gid and j_uid are the owners of mounted directories"
224-
# shellcheck disable=SC2012 # use ls to get permissions.
225-
test_1="$(ls -nd "${home_mnt}" | awk '{print $3 " " $4}')"
226-
if [[ "${test_1}" != "${j_uid} ${j_gid}" ]]; then
227-
echo "Owner of ${home_mnt} is not the jenkins user"
228-
echo "${test_1} != ${j_uid} ${j_gid}"
229-
will_fail=1
211+
# Ensure directories that will be mounted exist
212+
if [[ -n "${host_import_mnt}" && ! -d "${host_import_mnt}" ]]; then
213+
mkdir -p "${host_import_mnt}"
230214
fi
231-
if [[ -n "${host_import_mnt}" ]]; then
232-
# shellcheck disable=SC2012 # use ls to get permissions.
233-
test_2="$(ls -nd "${host_import_mnt}" | awk '{print $3 " " $4}' )"
234-
if [[ "${test_2}" != "${j_uid} ${j_gid}" ]]; then
235-
echo "Owner of ${host_import_mnt} is not the jenkins user"
236-
echo "${test_2} != ${j_uid} ${j_gid}"
237-
will_fail=1
238-
fi
215+
216+
if [[ ! -d "${home_mnt}" ]]; then
217+
mkdir -p "${home_mnt}"
239218
fi
240-
if [[ "${will_fail}" == 1 ]]; then
241-
echo "Failing before attempting to launch container"
242-
echo "Try again as root or use correct uid/gid pairs"
243-
exit 1
219+
220+
# Ensure directories that will be mounted are owned by the jenkins user
221+
if [[ "$(id -u)" != 0 ]]; then
222+
echo "Not running as root:"
223+
echo "Checking if j_gid and j_uid are the owners of mounted directories"
224+
# shellcheck disable=SC2012 # use ls to get permissions.
225+
test_1="$(ls -nd "${home_mnt}" | awk '{print $3 " " $4}')"
226+
if [[ "${test_1}" != "${j_uid} ${j_gid}" ]]; then
227+
echo "Owner of ${home_mnt} is not the jenkins user"
228+
echo "${test_1} != ${j_uid} ${j_gid}"
229+
will_fail=1
230+
fi
231+
if [[ -n "${host_import_mnt}" ]]; then
232+
# shellcheck disable=SC2012 # use ls to get permissions.
233+
test_2="$(ls -nd "${host_import_mnt}" | awk '{print $3 " " $4}' )"
234+
if [[ "${test_2}" != "${j_uid} ${j_gid}" ]]; then
235+
echo "Owner of ${host_import_mnt} is not the jenkins user"
236+
echo "${test_2} != ${j_uid} ${j_gid}"
237+
will_fail=1
238+
fi
239+
fi
240+
if [[ "${will_fail}" == 1 ]]; then
241+
echo "Failing before attempting to launch container"
242+
echo "Try again as root or use correct uid/gid pairs"
243+
exit 1
244+
fi
245+
else
246+
if [[ -n "${host_import_mnt}" ]]; then
247+
chown -R "${j_uid}:${j_gid}" "${host_import_mnt}"
248+
fi
249+
chown -R "${j_uid}:${j_gid}" "${home_mnt}"
244250
fi
245-
else
251+
252+
#If we don't have import mount don't add to docker command
246253
if [[ -n "${host_import_mnt}" ]]; then
247-
chown -R "${j_uid}:${j_gid}" "${host_import_mnt}"
254+
import_vol_cmd="-v ${host_import_mnt}:${cont_import_mnt}"
248255
fi
249-
chown -R "${j_uid}:${j_gid}" "${home_mnt}"
250-
fi
251-
252-
#If we don't have import mount don't add to docker command
253-
if [[ -n "${host_import_mnt}" ]]; then
254-
import_vol_cmd="-v ${host_import_mnt}:${cont_import_mnt}"
255-
fi
256-
# Launch the jenkins image with Docker
257-
# shellcheck disable=SC2086 # import_vol_cmd is intentially word-split.
258-
docker run -d \
259-
${import_vol_cmd} \
260-
-v "${home_mnt}:${j_home}" \
261-
-p "${http_port}:8080" \
262-
-p "${agent_port}:${agent_port}" \
263-
--env JAVA_OPTS=\""${java_options}"\" \
264-
--env JENKINS_OPTS=\""${jenkins_options}"\" \
265-
"${img_name}"
256+
# Launch the jenkins image with Docker
257+
# shellcheck disable=SC2086 # import_vol_cmd is intentially word-split.
258+
docker run -d \
259+
${import_vol_cmd} \
260+
-v "${home_mnt}:${j_home}" \
261+
-p "${http_port}:8080" \
262+
-p "${agent_port}:${agent_port}" \
263+
--env JAVA_OPTS=\""${java_options}"\" \
264+
--env JENKINS_OPTS=\""${jenkins_options}"\" \
265+
"${img_name}"
266266

267267
fi

build-rootfs-size-docker.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ fi
5252

5353
if [[ "${DISTRO}" == "ubuntu"* ]]; then
5454

55-
if [[ -n "${http_proxy}" ]]; then
56-
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
57-
fi
55+
if [[ -n "${http_proxy}" ]]; then
56+
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
57+
fi
5858

59-
Dockerfile=$(cat << EOF
59+
Dockerfile=$(cat << EOF
6060
FROM ${DOCKER_BASE}${DISTRO}
6161
6262
${PROXY}
@@ -86,7 +86,7 @@ RUN echo "${USER} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
8686
8787
RUN /bin/bash
8888
EOF
89-
)
89+
)
9090
fi
9191
################################# docker img # #################################
9292

build-setup.sh

+50-50
Original file line numberDiff line numberDiff line change
@@ -117,44 +117,44 @@ ARCH=$(uname -m)
117117

118118
# Determine the prefix of the Dockerfile's base image
119119
case ${ARCH} in
120-
"ppc64le")
121-
DOCKER_BASE="ppc64le/"
122-
;;
123-
"x86_64")
124-
DOCKER_BASE=""
125-
;;
126-
"aarch64")
127-
DOCKER_BASE="arm64v8/"
128-
;;
129-
*)
130-
echo "Unsupported system architecture(${ARCH}) found for docker image"
131-
exit 1
120+
"ppc64le")
121+
DOCKER_BASE="ppc64le/"
122+
;;
123+
"x86_64")
124+
DOCKER_BASE=""
125+
;;
126+
"aarch64")
127+
DOCKER_BASE="arm64v8/"
128+
;;
129+
*)
130+
echo "Unsupported system architecture(${ARCH}) found for docker image"
131+
exit 1
132132
esac
133133

134134
# Timestamp for job
135135
echo "Build started, $(date)"
136136

137137
# If the obmc_dir directory doesn't exist clone it in
138138
if [ ! -d "${obmc_dir}" ]; then
139-
echo "Clone in openbmc master to ${obmc_dir}"
140-
git clone https://github.com/openbmc/openbmc "${obmc_dir}"
139+
echo "Clone in openbmc master to ${obmc_dir}"
140+
git clone https://github.com/openbmc/openbmc "${obmc_dir}"
141141
fi
142142

143143
if [[ "$target" = repotest ]]; then
144-
DOCKER_IMAGE_NAME=$(./scripts/build-unit-test-docker)
145-
docker run --cap-add=sys_admin --rm=true \
146-
--network host \
147-
--privileged=true \
148-
-u "$USER" \
149-
-w "${obmc_dir}" -v "${obmc_dir}:${obmc_dir}" \
150-
-t "${DOCKER_IMAGE_NAME}" \
151-
"${obmc_dir}"/meta-phosphor/scripts/run-repotest
152-
exit
144+
DOCKER_IMAGE_NAME=$(./scripts/build-unit-test-docker)
145+
docker run --cap-add=sys_admin --rm=true \
146+
--network host \
147+
--privileged=true \
148+
-u "$USER" \
149+
-w "${obmc_dir}" -v "${obmc_dir}:${obmc_dir}" \
150+
-t "${DOCKER_IMAGE_NAME}" \
151+
"${obmc_dir}"/meta-phosphor/scripts/run-repotest
152+
exit
153153
fi
154154

155155
# Make and chown the xtrct_path directory to avoid permission errors
156156
if [ ! -d "${xtrct_path}" ]; then
157-
mkdir -p "${xtrct_path}"
157+
mkdir -p "${xtrct_path}"
158158
fi
159159
chown "${UID}:${GROUPS[0]}" "${xtrct_path}"
160160

@@ -168,11 +168,11 @@ BITBAKE_CMD="source ./setup ${MACHINE} ${build_dir}"
168168
# Configure Docker build
169169
if [[ "${distro}" == fedora ]];then
170170

171-
if [[ -n "${http_proxy}" ]]; then
172-
PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
173-
fi
171+
if [[ -n "${http_proxy}" ]]; then
172+
PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
173+
fi
174174

175-
Dockerfile=$(cat << EOF
175+
Dockerfile=$(cat << EOF
176176
FROM ${DOCKER_BASE}${distro}:${img_tag}
177177
178178
${PROXY}
@@ -217,15 +217,15 @@ if [[ "${distro}" == fedora ]];then
217217
ENV HOME ${HOME}
218218
RUN /bin/bash
219219
EOF
220-
)
220+
)
221221

222222
elif [[ "${distro}" == ubuntu ]]; then
223223

224-
if [[ -n "${http_proxy}" ]]; then
225-
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
226-
fi
224+
if [[ -n "${http_proxy}" ]]; then
225+
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
226+
fi
227227

228-
Dockerfile=$(cat << EOF
228+
Dockerfile=$(cat << EOF
229229
FROM ${DOCKER_BASE}${distro}:${img_tag}
230230
231231
${PROXY}
@@ -268,7 +268,7 @@ elif [[ "${distro}" == ubuntu ]]; then
268268
ENV HOME ${HOME}
269269
RUN /bin/bash
270270
EOF
271-
)
271+
)
272272
fi
273273

274274
# Create the Docker run script
@@ -402,31 +402,31 @@ mount_obmc_dir="-v ""${obmc_dir}"":""${obmc_dir}"" "
402402
mount_ssc_dir="-v ""${ssc_dir}"":""${ssc_dir}"" "
403403
mount_workspace_dir="-v ""${WORKSPACE}"":""${WORKSPACE}"" "
404404
if [[ "${obmc_dir}" = "${HOME}/"* || "${obmc_dir}" = "${HOME}" ]];then
405-
mount_obmc_dir=""
405+
mount_obmc_dir=""
406406
fi
407407
if [[ "${ssc_dir}" = "${HOME}/"* || "${ssc_dir}" = "${HOME}" ]];then
408-
mount_ssc_dir=""
408+
mount_ssc_dir=""
409409
fi
410410
if [[ "${WORKSPACE}" = "${HOME}/"* || "${WORKSPACE}" = "${HOME}" ]];then
411-
mount_workspace_dir=""
411+
mount_workspace_dir=""
412412
fi
413413

414414
# Run the Docker container, execute the build.sh script
415415
# shellcheck disable=SC2086 # mount commands word-split purposefully
416416
docker run \
417-
--cap-add=sys_admin \
418-
--cap-add=sys_nice \
419-
--net=host \
420-
--rm=true \
421-
-e WORKSPACE="${WORKSPACE}" \
422-
-w "${HOME}" \
423-
-v "${HOME}:${HOME}" \
424-
${mount_obmc_dir} \
425-
${mount_ssc_dir} \
426-
${mount_workspace_dir} \
427-
--cpus="$num_cpu" \
428-
"${img_name}" \
429-
"${WORKSPACE}/build.sh"
417+
--cap-add=sys_admin \
418+
--cap-add=sys_nice \
419+
--net=host \
420+
--rm=true \
421+
-e WORKSPACE="${WORKSPACE}" \
422+
-w "${HOME}" \
423+
-v "${HOME}:${HOME}" \
424+
${mount_obmc_dir} \
425+
${mount_ssc_dir} \
426+
${mount_workspace_dir} \
427+
--cpus="$num_cpu" \
428+
"${img_name}" \
429+
"${WORKSPACE}/build.sh"
430430

431431
# To maintain function of resources that used an older path, add a link
432432
ln -sf "${xtrct_path}/deploy" "${WORKSPACE}/deploy"

docs-build.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ echo "Build started, $(date)"
1515

1616
# Configure docker build
1717
if [[ -n "${http_proxy}" ]]; then
18-
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
18+
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
1919
fi
2020

2121
Dockerfile=$(cat << EOF
@@ -42,8 +42,8 @@ EOF
4242

4343
# Build the docker container
4444
if ! docker build -t linux-build/ubuntu - <<< "${Dockerfile}" ; then
45-
echo "Failed to build docker container."
46-
exit 1
45+
echo "Failed to build docker container."
46+
exit 1
4747
fi
4848

4949
# Create the docker run script
@@ -71,4 +71,4 @@ chmod a+x "${WORKSPACE}/build.sh"
7171

7272
# Run the docker container, execute the build script we just built
7373
docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE="${WORKSPACE}" --user="${USER}" \
74-
-w "${HOME}" -v "${HOME}":"${HOME}" -t linux-build/ubuntu "${WORKSPACE}/build.sh"
74+
-w "${HOME}" -v "${HOME}":"${HOME}" -t linux-build/ubuntu "${WORKSPACE}/build.sh"

0 commit comments

Comments
 (0)