Skip to content

Commit 05746fc

Browse files
committed
Merge branch 'austin987-sc'
2 parents 33ece20 + 6a5479d commit 05746fc

File tree

5 files changed

+113
-16
lines changed

5 files changed

+113
-16
lines changed

.github/workflows/shellcheck.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: shellcheck
2+
3+
on: [push, pull_request]
4+
jobs:
5+
build:
6+
name: build
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- name: checkout project
10+
uses: actions/checkout@v2
11+
- name: run shellcheck
12+
run: ./tests/shellcheck

kernel/resources/shared/FlashKernelPartition.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ is_device_veyron() {
5050
# returns the full path to the emmc device, in the form /dev/mmcblk#
5151
get_emmc_devname() {
5252
local devname=$(find /dev -name "mmcblk*boot0" | sed "s/boot0//")
53-
if [ -z "$devname" ]
54-
then
55-
echo "Unknown device! can't determine emmc devname. Please file an issue with the output of fdisk -l if you get this on a supported device"; exit 1;
53+
if [ -z "$devname" ]; then
54+
echo "Unknown device! can't determine emmc devname. Please file an issue with the output of fdisk -l if you get this on a supported device"
55+
exit 1
5656
fi
5757
echo $devname
5858
}

scripts/BuildScripts/KernelScripts/buildPerf.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,23 @@ set -e
2121
# You should have received a copy of the GNU General Public License
2222
# along with PrawnOS. If not, see <https://www.gnu.org/licenses/>.
2323

24-
if [ -z "$1" ]
25-
then
24+
if [ -z "$1" ]; then
2625
echo "No kernel version supplied"
2726
exit 1
2827
fi
29-
if [ -z "$2" ]
30-
then
28+
if [ -z "$2" ]; then
3129
echo "No resources directory"
3230
exit 1
3331
fi
34-
if [ -z "$3" ]
35-
then
32+
if [ -z "$3" ]; then
3633
echo "No build directory supplied"
3734
exit 1
3835
fi
39-
if [ -z "$4" ]
40-
then
36+
if [ -z "$4" ]; then
4137
echo "No PrawnOS initramfs supplied"
4238
exit 1
4339
fi
44-
if [ -z "$" ]
45-
then
40+
if [ -z "$5" ]; then
4641
echo "No PrawnOS target arch supplied"
4742
exit 1
4843
fi

scripts/InstallScripts/InstallPrawnOS.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ is_device_veyron() {
6666
# returns the full path to the emmc device, in the form /dev/mmcblk#
6767
get_emmc_devname() {
6868
local devname=$(find /dev -name "mmcblk*boot0" | sed "s/boot0//")
69-
if [ -z "$devname" ]
70-
then
71-
echo "Unknown device! can't determine emmc devname. Please file an issue with the output of fdisk -l if you get this on a supported device"; exit 1;
69+
if [ -z "$devname" ]; then
70+
echo "Unknown device! can't determine emmc devname. Please file an issue with the output of fdisk -l if you get this on a supported device"
71+
exit 1
7272
fi
7373
echo $devname
7474
}

tests/shellcheck

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# Wrapper around shellcheck
3+
#
4+
# Copyright (C) 2020 Austin English
5+
#
6+
# This software comes with ABSOLUTELY NO WARRANTY.
7+
#
8+
# This is free software, placed under the terms of the GNU Lesser
9+
# Public License version 2.1 (or later), as published by the Free
10+
# Software Foundation. Please see the file COPYING for details.
11+
12+
set -e
13+
set -x
14+
15+
###################################################################################################
16+
# Helpers
17+
###################################################################################################
18+
19+
w_die() {
20+
echo "$* failed"
21+
exit 1
22+
}
23+
24+
w_try() {
25+
"$@"
26+
status=$?
27+
if test ${status} -ne 0; then
28+
w_die "Note: command $* returned status ${status}. Aborting."
29+
fi
30+
}
31+
32+
###################################################################################################
33+
# Setup
34+
###################################################################################################
35+
36+
if [ ! -f makefile ] ; then
37+
w_die "$0 should be run from the top of the source tree"
38+
fi
39+
40+
temp="$(mktemp -d)"
41+
42+
trap 'rm -fr "$temp"' EXIT
43+
44+
###################################################################################################
45+
# Test functions
46+
###################################################################################################
47+
48+
# tests using shellcheck
49+
test_shellcheck() {
50+
shellcheck="$(command -v shellcheck)"
51+
52+
if [ -z "$shellcheck" ]; then
53+
apt-get -y install shellcheck
54+
fi
55+
56+
echo "======================== Begin shellcheck version info ==========================="
57+
"${shellcheck}" --version > /dev/null || w_die "shellcheck must be installed!"
58+
"${shellcheck}" --version
59+
echo "======================== End shellcheck version info ==========================="
60+
61+
echo "Checking ${shellscript} with shellcheck:"
62+
# FIXME: just the errors, for now:
63+
# FIXME: the SC2068 errors are likely legit (or should be explicitly silenced), but they count as errors
64+
# so ignoring for now
65+
w_try "${shellcheck}" -S error -e SC2068 "${shellscript}"
66+
}
67+
68+
###################################################################################################
69+
70+
# Test wrapper
71+
main() {
72+
# Use git ls-files if available, this prevents 'finding' scripts that aren't checked into git.
73+
# E.g., if patching foo fails, then foo.orig would also be 'found'.
74+
# The find fallback is for non git users, e.g., distros packaging shellcheck or end users
75+
# running shell-checks from a tarball download.
76+
if [ -d .git ] ; then
77+
files_to_check="$(git ls-files | xargs file | grep -e 'shell script' | cut -d : -f1)"
78+
else
79+
files_to_check="$(find . -type f -exec file {} \; | grep -e 'shell script' | cut -d : -f1)"
80+
fi
81+
82+
# Generic shellscript checks:
83+
for shellscript in ${files_to_check}; do
84+
test_shellcheck
85+
done
86+
}
87+
88+
main
89+
90+
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

0 commit comments

Comments
 (0)