chore: refactor and enhance dependency checking in build scripts (#908)

This refactors the way that the build shell-scripts check for dependencies
in order to cut down on code duplication, and also adds additional
dependency-checks that were missing previously.

Change-Type: minor
This commit is contained in:
Andrew Scheller 2016-11-29 23:37:31 +00:00 committed by Juan Cruz Viotti
parent 2397b5d2aa
commit b8ffd24cce
15 changed files with 151 additions and 56 deletions

View File

@ -21,6 +21,13 @@ set -u
set -e set -e
set -x set -x
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=`uname` OS=`uname`
if [[ "$OS" != "Darwin" ]]; then if [[ "$OS" != "Darwin" ]]; then
echo "This script is only meant to be run in OS X" 1>&2 echo "This script is only meant to be run in OS X" 1>&2

View File

@ -21,6 +21,13 @@ set -u
set -e set -e
set -x set -x
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=`uname` OS=`uname`
if [[ "$OS" != "Linux" ]]; then if [[ "$OS" != "Linux" ]]; then
echo "This script is only meant to be run in GNU/Linux" 1>&2 echo "This script is only meant to be run in GNU/Linux" 1>&2
@ -103,6 +110,8 @@ if [ "$COMMAND" == "installer-debian" ]; then
fi fi
if [ "$COMMAND" == "installer-appimage" ]; then if [ "$COMMAND" == "installer-appimage" ]; then
check_dep zip
./scripts/unix/dependencies.sh -p \ ./scripts/unix/dependencies.sh -p \
-r "$ARCH" \ -r "$ARCH" \
-v "$ELECTRON_VERSION" \ -v "$ELECTRON_VERSION" \

View File

@ -19,16 +19,24 @@
set -u set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=$(uname) OS=$(uname)
if [[ "$OS" != "Darwin" ]]; then if [[ "$OS" != "Darwin" ]]; then
echo "This script is only meant to be run in OS X" 1>&2 echo "This script is only meant to be run in OS X" 1>&2
exit 1 exit 1
fi fi
if ! command -v afsctool 2>/dev/null 1>&2; then check_dep hdiutil
echo "Dependency missing: afsctool" 1>&2 check_dep xattr
exit 1 check_dep tiffutil
fi check_dep osascript
check_dep afsctool
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"

View File

@ -19,6 +19,15 @@
set -u set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
check_dep zip
OS=$(uname) OS=$(uname)
if [[ "$OS" != "Darwin" ]]; then if [[ "$OS" != "Darwin" ]]; then
echo "This script is only meant to be run in OS X" 1>&2 echo "This script is only meant to be run in OS X" 1>&2

View File

@ -19,12 +19,21 @@
set -u set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=$(uname) OS=$(uname)
if [[ "$OS" != "Darwin" ]]; then if [[ "$OS" != "Darwin" ]]; then
echo "This script is only meant to be run in OS X" 1>&2 echo "This script is only meant to be run in OS X" 1>&2
exit 1 exit 1
fi fi
check_dep /usr/libexec/PlistBuddy
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"
echo "" echo ""

View File

@ -19,12 +19,22 @@
set -u set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=$(uname) OS=$(uname)
if [[ "$OS" != "Darwin" ]]; then if [[ "$OS" != "Darwin" ]]; then
echo "This script is only meant to be run in OS X" 1>&2 echo "This script is only meant to be run in OS X" 1>&2
exit 1 exit 1
fi fi
check_dep codesign
check_dep spctl
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"
echo "" echo ""

View File

@ -19,21 +19,21 @@
set -u set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=$(uname) OS=$(uname)
if [[ "$OS" != "Linux" ]]; then if [[ "$OS" != "Linux" ]]; then
echo "This script is only meant to be run in GNU/Linux" 1>&2 echo "This script is only meant to be run in GNU/Linux" 1>&2
exit 1 exit 1
fi fi
if ! command -v upx 2>/dev/null 1>&2; then check_dep upx
echo "Dependency missing: upx" 1>&2 check_dep wget
exit 1
fi
if ! command -v wget 2>/dev/null 1>&2; then
echo "Dependency missing: wget" 1>&2
exit 1
fi
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"

View File

@ -19,16 +19,20 @@
set -u set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=$(uname) OS=$(uname)
if [[ "$OS" != "Linux" ]]; then if [[ "$OS" != "Linux" ]]; then
echo "This script is only meant to be run in GNU/Linux" 1>&2 echo "This script is only meant to be run in GNU/Linux" 1>&2
exit 1 exit 1
fi fi
if ! command -v electron-installer-debian 2>/dev/null 1>&2; then check_dep electron-installer-debian
echo "Dependency missing: electron-installer-debian" 1>&2
exit 1
fi
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"

View File

@ -19,6 +19,13 @@
set -u set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
OS=$(uname) OS=$(uname)
if [[ "$OS" != "Linux" ]]; then if [[ "$OS" != "Linux" ]]; then
echo "This script is only meant to be run in GNU/Linux" 1>&2 echo "This script is only meant to be run in GNU/Linux" 1>&2

View File

@ -20,13 +20,17 @@
set -u set -u
set -e set -e
if [ "$#" -ne 1 ]; then function check_dep() {
echo "Usage: $0 <file>" 1>&2 if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1 exit 1
fi fi
}
if ! command -v aws 1>/dev/null 2>/dev/null; then check_dep aws
echo "Dependency missing: aws cli" 1>&2
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <file>" 1>&2
exit 1 exit 1
fi fi

View File

@ -1,7 +1,34 @@
#!/bin/bash #!/bin/bash
###
# Copyright 2016 resin.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
set -u
set -e set -e
function check_dep() {
if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1
fi
}
check_dep curl
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo "Usage: $0 <debfile>" 1>&2 echo "Usage: $0 <debfile>" 1>&2
exit 1 exit 1

View File

@ -19,10 +19,14 @@
set -u set -u
set -e set -e
if ! command -v asar 2>/dev/null 1>&2; then function check_dep() {
echo "Dependency missing: asar" 1>&2 if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1 exit 1
fi fi
}
check_dep asar
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"

View File

@ -19,20 +19,16 @@
set -u set -u
set -e set -e
if ! command -v npm 2>/dev/null 1>&2; then function check_dep() {
echo "Dependency missing: npm" 1>&2 if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1 exit 1
fi fi
}
if ! command -v bower 2>/dev/null 1>&2; then check_dep npm
echo "Dependency missing: bower" 1>&2 check_dep bower
exit 1 check_dep python
fi
if ! command -v python 2>/dev/null 1>&2; then
echo "Dependency missing: python" 1>&2
exit 1
fi
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"

View File

@ -19,10 +19,15 @@
set -u set -u
set -e set -e
if ! command -v wget 2>/dev/null 1>&2; then function check_dep() {
echo "Dependency missing: wget" 1>&2 if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1 exit 1
fi fi
}
check_dep wget
check_dep unzip
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"

View File

@ -19,20 +19,16 @@
set -u set -u
set -e set -e
if ! command -v browserify 2>/dev/null 1>&2; then function check_dep() {
echo "Dependency missing: browserify" 1>&2 if ! command -v $1 2>/dev/null 1>&2; then
echo "Dependency missing: $1" 1>&2
exit 1 exit 1
fi fi
}
if ! command -v wget 2>/dev/null 1>&2; then check_dep browserify
echo "Dependency missing: wget" 1>&2 check_dep wget
exit 1 check_dep rsync
fi
if ! command -v rsync 2>/dev/null 1>&2; then
echo "Dependency missing: rsync" 1>&2
exit 1
fi
function usage() { function usage() {
echo "Usage: $0" echo "Usage: $0"