8000 misc-scripts: Add check-distro-clang.sh · ClangBuiltLinux/misc-scripts@5cd26fc · GitHub
[go: up one dir, main page]

Skip to content

Commit 5cd26fc

Browse files
committed
misc-scripts: Add check-distro-clang.sh
This script allows us to easily check the version of clang available through various distributions. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
0 parents  commit 5cd26fc

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

.github/workflows/lint.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Run shellcheck and shfmt
2+
name: Lint checks
3+
on: [push, pull_request]
4+
jobs:
5+
shellcheck:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- name: shellcheck
10+
uses: bewuethr/shellcheck-action@v2
11+
shfmt-check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-go@v2
16+
with:
17+
go-version: '1.14.2'
18+
- uses: actions/cache@v2
19+
with:
20+
path: ~/go/pkg/mod
21+
key: ${{ runner.os }}-go
22+
restore-keys: |
23+
${{ runner.os }}-go-
24+
- name: Run shfmt
25+
run: |
26+
GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt
27+
while read -r f; do
28+
PATH=$HOME/go/bin:$PATH shfmt -ci -d -i 4 $f
29+
done < <(find . -type f -name "*.sh")

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
results.log
2+
run.sh

check-distro-clang.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
3+
# Make sure we have the required binaries
4+
for NAME in podman docker; do
5+
command -v "${NAME}" &>/dev/null && BINARY=${NAME}
6+
done
7+
if [[ -z ${BINARY} ]]; then
8+
echo "Neither podman nor docker could be found on your system! Please install one to use this script."
9+
exit 1
10+
fi
11+
12+
DOCKER_DISTROS=(
13+
archlinux/base:latest
14+
debian:stable-slim
15+
debian:testing-slim
16+
debian:unstable-slim
17+
fedora:latest
18+
fedora:rawhide
19+
opensuse/leap:latest
20+
opensuse/tumbleweed:latest
21+
ubuntu:18.04
22+
ubuntu:20.04
23+
ubuntu:latest
24+
ubuntu:rolling
25+
ubuntu:devel
26+
)
27+
28+
BASE=$(dirname "$(readlink -f "${0}")")
29+
RUN_SCRIPT=${BASE}/run.sh
30+
31+
cat <<'EOF' >"${RUN_SCRIPT}"
32+
#!/usr/bin/env bash
33+
34+
RESULTS=$(dirname "$(readlink -f "${0}")")/results.log
35+
36+
set -x
37+
38+
# Debian/Ubuntu
39+
if command -v apt-get &>/dev/null; then
40+
apt-get update
41+
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
42+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y clang
43+
# Fedora
44+
elif command -v dnf &>/dev/null; then
45+
dnf update -y
46+
dnf install -y clang
47+
# Arch
48+
elif command -v pacman &>/dev/null; then
49+
pacman -Syyu --noconfirm
50+
pacman -S --noconfirm clang
51+
# OpenSUSE Leap/Tumbleweed
52+
elif command -v zypper &>/dev/null; then
53+
zypper -n up
54+
zypper -n in clang
55+
fi
56+
57+
echo "${1}: $(clang --version | head -n1)" >> "${RESULTS}"
58+
EOF
59+
chmod +x "${RUN_SCRIPT}"
60+
61+
rm "${BASE}"/results.log
62+
for DISTRO in "${DOCKER_DISTROS[@]}"; do
63+
"${BINARY}" pull "${DISTRO}"
64+
"${BINARY}" run \
65+
--rm \
66+
--init \
67+
--volume="${BASE}:${BASE}" \
68+
--workdir="${BASE}" \
69+
"${DISTRO}" \
70+
"${BASE}"/run.sh "${DISTRO}"
71+
done
72+
73+
echo
74+
cat "${BASE}"/results.log

0 commit comments

Comments
 (0)
0