Browse Source

Conform to bashate standards for control structures

Enable bashate errors E010 and E011 which require "then" and "do"
tokens on the same lines as "if" and "while" respectively.

Change-Id: I4a167530a21ab95d5dbe9f903facc9566a0461e2
changes/15/426515/4
Ben Swartzlander 2 years ago
parent
commit
0358d1f175
5 changed files with 17 additions and 30 deletions
  1. 5
    7
      common-files/etc/init.d/S99metadata
  2. 4
    8
      init-buildroot.sh
  3. 2
    4
      make-bootable-disk.sh
  4. 5
    10
      run-buildroot.sh
  5. 1
    1
      tox.ini

+ 5
- 7
common-files/etc/init.d/S99metadata View File

@@ -6,11 +6,10 @@ check_net() {
6 6
         wget -q -O - -T 10 $url/public-keys 2> /dev/null || exit 1
7 7
         echo
8 8
     ) | (
9
-        while read line
10
-        do
11
-        key=$(echo $line | sed 's/\([0-9]\+\)=.*/\1/')
12
-        key_url=$url/public-keys/$key/openssh-key
13
-        wget -q -O - -T 10 $key_url 2> /dev/null || exit 1
9
+        while read line ; do
10
+            key=$(echo $line | sed 's/\([0-9]\+\)=.*/\1/')
11
+            key_url=$url/public-keys/$key/openssh-key
12
+            wget -q -O - -T 10 $key_url 2> /dev/null || exit 1
14 13
         done
15 14
     ) >> authorized_keys
16 15
 }
@@ -24,8 +23,7 @@ json_metadata() {
24 23
 check_cd() {
25 24
     [ -b /dev/sr0 ] || return
26 25
     mkdir /tmp/cd
27
-    if mount /dev/sr0 /tmp/cd
28
-    then
26
+    if mount /dev/sr0 /tmp/cd ; then
29 27
         json_metadata /tmp/cd >> authorized_keys
30 28
         umount /tmp/cd
31 29
     fi

+ 4
- 8
init-buildroot.sh View File

@@ -7,8 +7,7 @@
7 7
 # it under the terms of the GNU General Public License version 2 as
8 8
 # published by the Free Software Foundation.
9 9
 
10
-if which lsb_release 2> /dev/null && [ $(lsb_release -i -s) = "Ubuntu" ]
11
-then
10
+if which lsb_release 2> /dev/null && [ $(lsb_release -i -s) = "Ubuntu" ] ; then
12 11
     sudo apt-get -y install curl unzip bc python quilt parted qemu-utils \
13 12
         build-essential gcc-multilib
14 13
 fi
@@ -17,22 +16,19 @@ VERSION=2016.02
17 16
 FILENAME=buildroot-${VERSION}.tar.bz2
18 17
 
19 18
 # Download buildroot if we don't have it already
20
-if [ ! -f download/$FILENAME ]
21
-then
19
+if [ ! -f download/$FILENAME ] ; then
22 20
     wget -P download http://buildroot.org/downloads/$FILENAME
23 21
 fi
24 22
 
25 23
 # Untar buildroot if it's not already there
26
-if [ ! -d buildroot ]
27
-then
24
+if [ ! -d buildroot ] ; then
28 25
     mkdir buildroot
29 26
     tar -C buildroot -xf download/$FILENAME --strip 1
30 27
 fi
31 28
 
32 29
 # Apply patches to buildroot if we haven't done so before
33 30
 PATCH_FLAG_FILE=buildroot/.manila-patches-applied
34
-if [ ! -f $PATCH_FLAG_FILE ]
35
-then
31
+if [ ! -f $PATCH_FLAG_FILE ] ; then
36 32
     ( cd buildroot ; QUILT_PATCHES=../patches quilt push -a )
37 33
     touch $PATCH_FLAG_FILE
38 34
 fi

+ 2
- 4
make-bootable-disk.sh View File

@@ -10,8 +10,7 @@
10 10
 DISK_NAME=$1
11 11
 BR_OUTPUT=output-$1
12 12
 
13
-if [ -z "$DISK_NAME" ]
14
-then
13
+if [ -z "$DISK_NAME" ] ; then
15 14
     echo Specify disk name
16 15
     exit 2
17 16
 fi
@@ -52,8 +51,7 @@ sudo tar -C $MOUNT -xf $BR_OUTPUT/images/rootfs.tar
52 51
 echo Installing syslinux
53 52
 sudo $BR_OUTPUT/host/sbin/extlinux -z --install $MOUNT/boot
54 53
 
55
-if [ $DISK_NAME = server ]
56
-then
54
+if [ $DISK_NAME = server ] ; then
57 55
     echo Creating share dir
58 56
     SHARE_DIR=$MOUNT/share
59 57
     sudo mkdir -p $SHARE_DIR

+ 5
- 10
run-buildroot.sh View File

@@ -12,22 +12,19 @@
12 12
 # Grab JSON.sh for json parsing
13 13
 JSON_VERS=e05e69a0debdba68125a33ac786726cb860b2e7b
14 14
 JSON_SH=https://raw.githubusercontent.com/dominictarr/JSON.sh/$JSON_VERS/JSON.sh
15
-if [ ! -x download/JSON.sh ]
16
-then
15
+if [ ! -x download/JSON.sh ] ; then
17 16
     curl -s $JSON_SH > download/JSON.sh
18 17
     chmod +x download/JSON.sh
19 18
 fi
20 19
 
21 20
 # Create the filesystem overlays
22
-if [ ! -d overlay-client ]
23
-then
21
+if [ ! -d overlay-client ] ; then
24 22
     mkdir overlay-client
25 23
     cp -a common-files/* overlay-client
26 24
     mkdir -p overlay-client/usr/bin
27 25
     cp download/JSON.sh overlay-server/usr/bin
28 26
 fi
29
-if [ ! -d overlay-server ]
30
-then
27
+if [ ! -d overlay-server ] ; then
31 28
     mkdir overlay-server
32 29
     cp -a common-files/* overlay-server
33 30
     cp -a server-files/* overlay-server
@@ -44,8 +41,7 @@ cd buildroot
44 41
 BUILD_IMAGES="client server"
45 42
 
46 43
 # Setup the build directories with their configs
47
-for IMAGE in $BUILD_IMAGES
48
-do
44
+for IMAGE in $BUILD_IMAGES ; do
49 45
     make O=../output-${IMAGE} manila_${IMAGE}_defconfig
50 46
 done
51 47
 
@@ -53,8 +49,7 @@ done
53 49
 rm configs/manila_*_defconfig
54 50
 
55 51
 # Do the builds
56
-for IMAGE in $BUILD_IMAGES
57
-do
52
+for IMAGE in $BUILD_IMAGES ; do
58 53
     make O=../output-${IMAGE} all
59 54
     ( cd .. ; ./make-bootable-disk.sh $IMAGE )
60 55
 done

+ 1
- 1
tox.ini View File

@@ -13,4 +13,4 @@ commands = bash -c "find {toxinidir} \
13 13
                     -not \( -type d -name buildroot -prune \) \
14 14
                     -not \( -type d -name download -prune \) \
15 15
                     -type f -name \*.sh \
16
-                    -print0 | xargs -0 bashate -v -iE010,E011"
16
+                    -print0 | xargs -0 bashate -v"

Loading…
Cancel
Save