Skip to content

Commit 39bdedb

Browse files
authored
Merge pull request #15 from StaticRocket/shellcheck
Shellcheck and various other oddities
2 parents c5db9ed + 7c3f06a commit 39bdedb

File tree

8 files changed

+446
-450
lines changed

8 files changed

+446
-450
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ all:
1313

1414
clean:
1515
docker container prune; \
16-
docker image ls|grep none|sed -e "s/\s\s*/ /g"|cut -d ' ' -f3|xargs docker rmi ${IMAGE_TOBUILD}
16+
docker image prune -f; \
17+
docker rmi ${IMAGE_TOBUILD}
1718

1819
deploy:
1920
docker push ${REPO}:${IMAGE_TOBUILD}

build-env.sh

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33
export HOME=/tmp
44
source /etc/profile
55
shopt -s expand_aliases
6-
NPROC=`nproc`
6+
NPROC=$(nproc)
77

88
# https://git.kernel.org/pub/scm/git/git.git/
99
export GIT_TAG=2.43.0
@@ -18,14 +18,16 @@ export COCCI_TAG=1.1.1
1818
# https://github.com/devicetree-org/dt-schema/tags
1919
export DTSCHEMA_REV=v2023.11
2020

21-
ARIA_OPTS="--timeout=180 --retry-wait=10 -m 0 -x 10 -j 10"
21+
ARIA_OPTS=(--timeout=180 --retry-wait=10 -m 0 -x 10 -j 10)
2222

2323
download_build_install_git()
2424
{
25-
cd /tmp/
25+
local FILE URL
2626
FILE=git-"$GIT_TAG".tar.gz
2727
URL="https://git.kernel.org/pub/scm/git/git.git/snapshot/${FILE}"
28-
aria2c $ARIA_OPTS -o "$FILE" "$URL"
28+
29+
cd /tmp/
30+
aria2c "${ARIA_OPTS[@]}" -o "$FILE" "$URL"
2931
mkdir /tmp/git
3032
tar -C /tmp/git --strip-components=1 -xvf "$FILE"
3133
rm $FILE
@@ -47,71 +49,90 @@ download_build_install_python_deps()
4749
python -m pip install --break-system-packages git+https://github.com/devicetree-org/dt-schema.git@$DTSCHEMA_REV
4850
}
4951

52+
clone_and_cd()
53+
{
54+
cd /tmp &&
55+
git clone --depth=1 --branch "$1" "$2" "$3" &&
56+
cd /tmp/"$3"
57+
return $?
58+
}
59+
5060
download_build_install_dtc()
5161
{
52-
cd /tmp/
62+
local FILE URL
63+
FILE='dtc'
5364
URL="https://git.kernel.org/pub/scm/utils/dtc/dtc.git"
54-
git clone --depth=1 --branch "$DTC_TAG" "$URL"
55-
cd /tmp/dtc
56-
make -j $NPROC PREFIX=/usr/local SETUP_PREFIX=/usr/local install NO_PYTHON=1
65+
66+
clone_and_cd "$DTC_TAG" "$URL" "$FILE"
67+
make -j "$NPROC" PREFIX=/usr/local SETUP_PREFIX=/usr/local install NO_PYTHON=1
5768
cd /tmp
58-
rm -rf /tmp/dtc
69+
rm -rf /tmp/"$FILE"
5970
}
6071

6172
download_build_install_sparse()
6273
{
63-
cd /tmp/
74+
local FILE URL
75+
FILE='sparse'
6476
URL="https://git.kernel.org/pub/scm/devel/sparse/sparse.git"
65-
git clone --depth=1 --branch "$SPARSE_TAG" "$URL"
66-
cd /tmp/sparse
67-
make -j $NPROC PREFIX=/usr/local install
77+
78+
clone_and_cd "$SPARSE_TAG" "$URL" "$FILE"
79+
make -j "$NPROC" PREFIX=/usr/local install
6880
cd /tmp
69-
rm -rf /tmp/sparse
81+
rm -rf /tmp/"$FILE"
7082
}
7183

7284
download_build_install_smatch()
7385
{
74-
cd /tmp/
86+
local FILE URL
87+
FILE='smatch'
7588
URL="https://repo.or.cz/smatch.git"
76-
git clone --depth=1 --branch "$SMATCH_TAG" "$URL"
77-
cd /tmp/smatch
78-
make -j $NPROC PREFIX=/usr/local/smatch install
89+
90+
clone_and_cd "$SMATCH_TAG" "$URL" "$FILE"
91+
make -j "$NPROC" PREFIX=/usr/local/smatch install
7992
echo -e '#!/bin/bash\n/usr/local/smatch/bin/smatch -p=kernel $@'>/usr/local/smatch/bin/k_sm_check_script
8093
chmod +x /usr/local/smatch/bin/k_sm_check_script
8194
cd /tmp
82-
rm -rf /tmp/smatch
95+
rm -rf /tmp/"$FILE"
8396
}
8497

8598
download_build_install_coccinelle()
8699
{
87-
cd /tmp/
100+
local FILE URL
101+
FILE='coccinelle'
88102
URL="https://github.com/coccinelle/coccinelle.git"
89-
git clone --depth=1 --branch "$COCCI_TAG" "$URL"
90-
cd /tmp/coccinelle
103+
104+
clone_and_cd "$COCCI_TAG" "$URL" "$FILE"
91105
./autogen
92106
./configure --prefix=/usr/local
93107
make install
94108
cd /tmp
95-
rm -rf /tmp/coccinelle
109+
rm -rf /tmp/"$FILE"
96110
}
97111

98-
download_and_install_armgcc()
112+
download_and_install_armgcc_64()
99113
{
114+
local FILE URL
115+
FILE='aarch64-gcc.tar.xz'
116+
URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz?revision=61c3be5d-5175-4db6-9030-b565aae9f766&la=en&hash=0A37024B42028A9616F56A51C2D20755C5EBBCD7"
117+
100118
cd /tmp
101119
mkdir -p /opt/cross-gcc-linux-9/
102-
#aarch64
103-
F64='aarch64-gcc.tar.xz'
104-
URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz?revision=61c3be5d-5175-4db6-9030-b565aae9f766&la=en&hash=0A37024B42028A9616F56A51C2D20755C5EBBCD7"
105-
aria2c $ARIA_OPTS -o "$F64" "$URL"
106-
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$F64"
107-
rm -f "$F64"
120+
aria2c "${ARIA_OPTS[@]}" -o "$FILE" "$URL"
121+
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$FILE"
122+
rm -f /tmp/"$FILE"
123+
}
108124

109-
#arch32
110-
F32='aarch32-gcc.tar.xz'
125+
download_and_install_armgcc_32()
126+
{
127+
local FILE URL
128+
FILE='aarch32-gcc.tar.xz'
111129
URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz?revision=fed31ee5-2ed7-40c8-9e0e-474299a3c4ac&la=en&hash=76DAF56606E7CB66CC5B5B33D8FB90D9F24C9D20"
112-
aria2c $ARIA_OPTS -o "$F32" "$URL"
113-
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$F32"
114-
rm -f "$F32"
130+
131+
cd /tmp
132+
mkdir -p /opt/cross-gcc-linux-9/
133+
aria2c "${ARIA_OPTS[@]}" -o "$FILE" "$URL"
134+
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$FILE"
135+
rm -f /tmp/"$FILE"
115136
}
116137

117138
download_build_install_git
@@ -121,7 +142,8 @@ download_build_install_smatch
121142
download_build_install_sparse
122143
download_build_install_coccinelle
123144
if [ "$INSTALL_GCC" == "1" ]; then
124-
download_and_install_armgcc
145+
download_and_install_armgcc_64
146+
download_and_install_armgcc_32
125147
else
126148
echo "Skipping install GCC. INSTALL_GCC!=1. make sure that /opt/cross-gcc-linux-9/bin has aarch64-none-linux-gnu- and arm-none-linux-gnueabihf-"
127149
fi

0 commit comments

Comments
 (0)