Skip to content

Commit

Permalink
Merge pull request #15 from StaticRocket/shellcheck
Browse files Browse the repository at this point in the history
Shellcheck and various other oddities
  • Loading branch information
nmenon authored Mar 19, 2024
2 parents c5db9ed + 7c3f06a commit 39bdedb
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 450 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ all:

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

deploy:
docker push ${REPO}:${IMAGE_TOBUILD}
94 changes: 58 additions & 36 deletions build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
export HOME=/tmp
source /etc/profile
shopt -s expand_aliases
NPROC=`nproc`
NPROC=$(nproc)

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

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

download_build_install_git()
{
cd /tmp/
local FILE URL
FILE=git-"$GIT_TAG".tar.gz
URL="https://git.kernel.org/pub/scm/git/git.git/snapshot/${FILE}"
aria2c $ARIA_OPTS -o "$FILE" "$URL"

cd /tmp/
aria2c "${ARIA_OPTS[@]}" -o "$FILE" "$URL"
mkdir /tmp/git
tar -C /tmp/git --strip-components=1 -xvf "$FILE"
rm $FILE
Expand All @@ -47,71 +49,90 @@ download_build_install_python_deps()
python -m pip install --break-system-packages git+https://github.com/devicetree-org/dt-schema.git@$DTSCHEMA_REV
}

clone_and_cd()
{
cd /tmp &&
git clone --depth=1 --branch "$1" "$2" "$3" &&
cd /tmp/"$3"
return $?
}

download_build_install_dtc()
{
cd /tmp/
local FILE URL
FILE='dtc'
URL="https://git.kernel.org/pub/scm/utils/dtc/dtc.git"
git clone --depth=1 --branch "$DTC_TAG" "$URL"
cd /tmp/dtc
make -j $NPROC PREFIX=/usr/local SETUP_PREFIX=/usr/local install NO_PYTHON=1

clone_and_cd "$DTC_TAG" "$URL" "$FILE"
make -j "$NPROC" PREFIX=/usr/local SETUP_PREFIX=/usr/local install NO_PYTHON=1
cd /tmp
rm -rf /tmp/dtc
rm -rf /tmp/"$FILE"
}

download_build_install_sparse()
{
cd /tmp/
local FILE URL
FILE='sparse'
URL="https://git.kernel.org/pub/scm/devel/sparse/sparse.git"
git clone --depth=1 --branch "$SPARSE_TAG" "$URL"
cd /tmp/sparse
make -j $NPROC PREFIX=/usr/local install

clone_and_cd "$SPARSE_TAG" "$URL" "$FILE"
make -j "$NPROC" PREFIX=/usr/local install
cd /tmp
rm -rf /tmp/sparse
rm -rf /tmp/"$FILE"
}

download_build_install_smatch()
{
cd /tmp/
local FILE URL
FILE='smatch'
URL="https://repo.or.cz/smatch.git"
git clone --depth=1 --branch "$SMATCH_TAG" "$URL"
cd /tmp/smatch
make -j $NPROC PREFIX=/usr/local/smatch install

clone_and_cd "$SMATCH_TAG" "$URL" "$FILE"
make -j "$NPROC" PREFIX=/usr/local/smatch install
echo -e '#!/bin/bash\n/usr/local/smatch/bin/smatch -p=kernel $@'>/usr/local/smatch/bin/k_sm_check_script
chmod +x /usr/local/smatch/bin/k_sm_check_script
cd /tmp
rm -rf /tmp/smatch
rm -rf /tmp/"$FILE"
}

download_build_install_coccinelle()
{
cd /tmp/
local FILE URL
FILE='coccinelle'
URL="https://github.com/coccinelle/coccinelle.git"
git clone --depth=1 --branch "$COCCI_TAG" "$URL"
cd /tmp/coccinelle

clone_and_cd "$COCCI_TAG" "$URL" "$FILE"
./autogen
./configure --prefix=/usr/local
make install
cd /tmp
rm -rf /tmp/coccinelle
rm -rf /tmp/"$FILE"
}

download_and_install_armgcc()
download_and_install_armgcc_64()
{
local FILE URL
FILE='aarch64-gcc.tar.xz'
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"

cd /tmp
mkdir -p /opt/cross-gcc-linux-9/
#aarch64
F64='aarch64-gcc.tar.xz'
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"
aria2c $ARIA_OPTS -o "$F64" "$URL"
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$F64"
rm -f "$F64"
aria2c "${ARIA_OPTS[@]}" -o "$FILE" "$URL"
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$FILE"
rm -f /tmp/"$FILE"
}

#arch32
F32='aarch32-gcc.tar.xz'
download_and_install_armgcc_32()
{
local FILE URL
FILE='aarch32-gcc.tar.xz'
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"
aria2c $ARIA_OPTS -o "$F32" "$URL"
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$F32"
rm -f "$F32"

cd /tmp
mkdir -p /opt/cross-gcc-linux-9/
aria2c "${ARIA_OPTS[@]}" -o "$FILE" "$URL"
tar -C /usr/local/cross-gcc-linux-9/ --strip-components=1 -xf "$FILE"
rm -f /tmp/"$FILE"
}

download_build_install_git
Expand All @@ -121,7 +142,8 @@ download_build_install_smatch
download_build_install_sparse
download_build_install_coccinelle
if [ "$INSTALL_GCC" == "1" ]; then
download_and_install_armgcc
download_and_install_armgcc_64
download_and_install_armgcc_32
else
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-"
fi
Loading

0 comments on commit 39bdedb

Please sign in to comment.