From 091e7b233a4549f118be37e1119df7afb674986e Mon Sep 17 00:00:00 2001 From: Robert Jacob Date: Sat, 8 Jul 2017 16:55:16 +0200 Subject: [PATCH] Use bash and set fail conditions. Reformat files. --- build.sh | 49 +++++++++++++++++++++++++------------------------ rename.sh | 25 +++++++++++++------------ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/build.sh b/build.sh index 6ba7fa5..03ccfb2 100644 --- a/build.sh +++ b/build.sh @@ -1,33 +1,34 @@ -#!/bin/sh +#!/usr/bin/env bash +set -euo errexit platforms=' - CONFIG_TARGET_arm64=y - CONFIG_TARGET_ath25=y - CONFIG_TARGET_ar71xx=y - CONFIG_TARGET_brcm2708=y\nCONFIG_TARGET_brcm2708_bcm2708=y - CONFIG_TARGET_brcm2708=y\nCONFIG_TARGET_brcm2708_bcm2709=y - CONFIG_TARGET_bcm53xx=y - CONFIG_TARGET_brcm47xx=y - CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_rt305x=y - CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_mt7620=y - CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_mt7621=y - CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_mt7628=y - CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_rt3883=y - CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_rt288x=y + CONFIG_TARGET_arm64=y + CONFIG_TARGET_ath25=y + CONFIG_TARGET_ar71xx=y + CONFIG_TARGET_brcm2708=y\nCONFIG_TARGET_brcm2708_bcm2708=y + CONFIG_TARGET_brcm2708=y\nCONFIG_TARGET_brcm2708_bcm2709=y + CONFIG_TARGET_bcm53xx=y + CONFIG_TARGET_brcm47xx=y + CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_rt305x=y + CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_mt7620=y + CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_mt7621=y + CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_mt7628=y + CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_rt3883=y + CONFIG_TARGET_ramips=y\nCONFIG_TARGET_ramips_rt288x=y ' for platform in $platforms; do - echo "$platform" > .config + echo "$platform" > .config - echo "CONFIG_TARGET_MULTI_PROFILE=y" >> .config - echo "CONFIG_TARGET_ALL_PROFILES=y" >> .config - echo "CONFIG_TARGET_PER_DEVICE_ROOTFS=y" >> .config - echo "CONFIG_PACKAGE_freifunk-basic=y" >> .config + echo "CONFIG_TARGET_MULTI_PROFILE=y" >> .config + echo "CONFIG_TARGET_ALL_PROFILES=y" >> .config + echo "CONFIG_TARGET_PER_DEVICE_ROOTFS=y" >> .config + echo "CONFIG_PACKAGE_freifunk-basic=y" >> .config - # Debug output - echo "Build: $platform" + # Debug output + echo "Build: $platform" - # Build image - make defconfig - make -j4 + # Build image + make defconfig + make -j4 done diff --git a/rename.sh b/rename.sh index d90552a..7d2737b 100644 --- a/rename.sh +++ b/rename.sh @@ -1,23 +1,24 @@ -#!/bin/bash +#!/usr/bin/env bash +set -euo errexit if [ $# -ne 2 -o ! -d "$2" ]; then - echo "usage: $0 " - echo "E.g. $0 0.5.0 bin/ar71xxx/" - exit 1 + echo "usage: $0 " + echo "E.g. $0 0.5.0 bin/ar71xxx/" + exit 1 fi ident="$1" path="$2" for path in $(find "$path" -iname "lede*"); do - dir="${path%/*}" - file="${path##*/}" - if [ "$file" != "${file/$ident/}" ]; then - echo "Already contains '$ident': $path" - continue - fi - new_file="$ident"`echo "$file" | sed -e "s/lede-[^-]*-[^-]*//"` - mv "$path" "$dir/$new_file" + dir="${path%/*}" + file="${path##*/}" + if [ "$file" != "${file/$ident/}" ]; then + echo "Already contains '$ident': $path" + continue + fi + new_file="$ident"`echo "$file" | sed -e "s/lede-[^-]*-[^-]*//"` + mv "$path" "$dir/$new_file" done exit 0