Build: Introduce shellcheck (#18081)
* Build: introduce shellcheck Fixes #16198
This commit is contained in:
+16
-17
@@ -6,6 +6,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
# shellcheck disable=SC2124
|
||||
EXTRA_OPTS="$@"
|
||||
|
||||
CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
|
||||
@@ -15,9 +16,6 @@ CCOSX64=/tmp/osxcross/target/bin/o64-clang
|
||||
CCWIN64=x86_64-w64-mingw32-gcc
|
||||
CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
|
||||
|
||||
GOPATH=/go
|
||||
REPO_PATH=$GOPATH/src/github.com/grafana/grafana
|
||||
|
||||
cd /go/src/github.com/grafana/grafana
|
||||
echo "current dir: $(pwd)"
|
||||
|
||||
@@ -34,16 +32,16 @@ echo "current dir: $(pwd)"
|
||||
|
||||
# build only amd64 for enterprise
|
||||
if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
|
||||
go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build
|
||||
go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
|
||||
go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
|
||||
go run build.go -goos darwin -cc ${CCOSX64} ${OPT} build
|
||||
go run build.go -goarch armv6 -cc "${CCARMV6}" "${OPT}" build
|
||||
go run build.go -goarch armv7 -cc "${CCARMV7}" "${OPT}" build
|
||||
go run build.go -goarch arm64 -cc "${CCARM64}" "${OPT}" build
|
||||
go run build.go -goos darwin -cc "${CCOSX64}" "${OPT}" build
|
||||
fi
|
||||
|
||||
go run build.go -goos windows -cc ${CCWIN64} ${OPT} build
|
||||
go run build.go -goos windows -cc "${CCWIN64}" "${OPT}" build
|
||||
|
||||
# Do not remove CC from the linux build, its there for compatibility with Centos6
|
||||
CC=${CCX64} go run build.go ${OPT} build
|
||||
CC=${CCX64} go run build.go "${OPT}" build
|
||||
|
||||
yarn install --pure-lockfile --no-progress
|
||||
|
||||
@@ -53,35 +51,36 @@ else
|
||||
echo "Building frontend and packaging incremental build for $CIRCLE_BRANCH"
|
||||
fi
|
||||
echo "Building frontend"
|
||||
go run build.go ${OPT} build-frontend
|
||||
go run build.go "${OPT}" build-frontend
|
||||
|
||||
if [ -d "dist" ]; then
|
||||
rm -rf dist
|
||||
fi
|
||||
|
||||
mkdir dist
|
||||
go run build.go -gen-version ${OPT} > dist/grafana.version
|
||||
go run build.go -gen-version "${OPT}" > dist/grafana.version
|
||||
|
||||
# Load ruby, needed for packing with fpm
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/profile.d/rvm.sh
|
||||
|
||||
echo "Packaging"
|
||||
go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only
|
||||
go run build.go -goos linux -pkg-arch amd64 "${OPT}" package-only
|
||||
#removing amd64 phantomjs bin for armv7/arm64 packages
|
||||
rm tools/phantomjs/phantomjs
|
||||
|
||||
# build only amd64 for enterprise
|
||||
if echo "$EXTRA_OPTS" | grep -vq enterprise ; then
|
||||
go run build.go -goos linux -pkg-arch armv6 ${OPT} -skipRpm package-only
|
||||
go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only
|
||||
go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only
|
||||
go run build.go -goos linux -pkg-arch armv6 "${OPT}" -skipRpm package-only
|
||||
go run build.go -goos linux -pkg-arch armv7 "${OPT}" package-only
|
||||
go run build.go -goos linux -pkg-arch arm64 "${OPT}" package-only
|
||||
|
||||
if [ -d '/tmp/phantomjs/darwin' ]; then
|
||||
cp /tmp/phantomjs/darwin/phantomjs tools/phantomjs/phantomjs
|
||||
else
|
||||
echo 'PhantomJS binaries for darwin missing!'
|
||||
fi
|
||||
go run build.go -goos darwin -pkg-arch amd64 ${OPT} package-only
|
||||
go run build.go -goos darwin -pkg-arch amd64 "${OPT}" package-only
|
||||
fi
|
||||
|
||||
if [ -d '/tmp/phantomjs/windows' ]; then
|
||||
@@ -90,6 +89,6 @@ if [ -d '/tmp/phantomjs/windows' ]; then
|
||||
else
|
||||
echo 'PhantomJS binaries for Windows missing!'
|
||||
fi
|
||||
go run build.go -goos windows -pkg-arch amd64 ${OPT} package-only
|
||||
go run build.go -goos windows -pkg-arch amd64 "${OPT}" package-only
|
||||
|
||||
go run build.go latest
|
||||
|
||||
+12
-15
@@ -9,10 +9,6 @@ CCARMV6=/opt/rpi-tools/arm-bcm2708/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g
|
||||
CCARMV7=arm-linux-gnueabihf-gcc
|
||||
CCARM64=aarch64-linux-gnu-gcc
|
||||
CCX64=/tmp/x86_64-centos6-linux-gnu/bin/x86_64-centos6-linux-gnu-gcc
|
||||
##########
|
||||
GOPATH=/go
|
||||
REPO_PATH=$GOPATH/src/github.com/grafana/grafana
|
||||
##########
|
||||
|
||||
BUILD_FAST=0
|
||||
BUILD_BACKEND=1
|
||||
@@ -51,9 +47,9 @@ while [ "$1" != "" ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
# shellcheck disable=SC2124
|
||||
EXTRA_OPTS="$@"
|
||||
|
||||
|
||||
cd /go/src/github.com/grafana/grafana
|
||||
echo "current dir: $(pwd)"
|
||||
|
||||
@@ -73,7 +69,7 @@ function build_backend_linux_amd64() {
|
||||
if [ ! -d "dist" ]; then
|
||||
mkdir dist
|
||||
fi
|
||||
CC=${CCX64} go run build.go ${OPT} build
|
||||
CC=${CCX64} go run build.go "${OPT}" build
|
||||
}
|
||||
|
||||
function build_backend() {
|
||||
@@ -81,9 +77,9 @@ function build_backend() {
|
||||
mkdir dist
|
||||
fi
|
||||
|
||||
go run build.go -goarch armv6 -cc ${CCARMV6} ${OPT} build
|
||||
go run build.go -goarch armv7 -cc ${CCARMV7} ${OPT} build
|
||||
go run build.go -goarch arm64 -cc ${CCARM64} ${OPT} build
|
||||
go run build.go -goarch armv6 -cc ${CCARMV6} "${OPT}" build
|
||||
go run build.go -goarch armv7 -cc ${CCARMV7} "${OPT}" build
|
||||
go run build.go -goarch arm64 -cc ${CCARM64} "${OPT}" build
|
||||
build_backend_linux_amd64
|
||||
}
|
||||
|
||||
@@ -93,22 +89,22 @@ function build_frontend() {
|
||||
fi
|
||||
yarn install --pure-lockfile --no-progress
|
||||
echo "Building frontend"
|
||||
go run build.go ${OPT} build-frontend
|
||||
go run build.go "${OPT}" build-frontend
|
||||
echo "FRONTEND: finished"
|
||||
}
|
||||
|
||||
function package_linux_amd64() {
|
||||
echo "Packaging Linux AMD64"
|
||||
go run build.go -goos linux -pkg-arch amd64 ${OPT} package-only
|
||||
go run build.go -goos linux -pkg-arch amd64 "${OPT}" package-only
|
||||
go run build.go latest
|
||||
echo "PACKAGE LINUX AMD64: finished"
|
||||
}
|
||||
|
||||
function package_all() {
|
||||
echo "Packaging ALL"
|
||||
go run build.go -goos linux -pkg-arch armv6 ${OPT} -skipRpm package-only
|
||||
go run build.go -goos linux -pkg-arch armv7 ${OPT} package-only
|
||||
go run build.go -goos linux -pkg-arch arm64 ${OPT} package-only
|
||||
go run build.go -goos linux -pkg-arch armv6 "${OPT}" -skipRpm package-only
|
||||
go run build.go -goos linux -pkg-arch armv7 "${OPT}" package-only
|
||||
go run build.go -goos linux -pkg-arch arm64 "${OPT}" package-only
|
||||
package_linux_amd64
|
||||
echo "PACKAGE ALL: finished"
|
||||
}
|
||||
@@ -119,8 +115,9 @@ function package_setup() {
|
||||
rm -rf dist
|
||||
fi
|
||||
mkdir dist
|
||||
go run build.go -gen-version ${OPT} > dist/grafana.version
|
||||
go run build.go -gen-version "${OPT}" > dist/grafana.version
|
||||
# Load ruby, needed for packing with fpm
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/profile.d/rvm.sh
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /tmp
|
||||
cd /tmp || exit 1
|
||||
tar xfJ x86_64-centos6-linux-gnu.tar.xz
|
||||
tar xfJ osxcross.tar.xz
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
WORKING_DIRECTORY=`pwd`
|
||||
WORKING_DIRECTORY=$(pwd)
|
||||
# copy zip file to /tmp/dist
|
||||
mkdir -p /tmp/dist
|
||||
cp ./dist/*.zip /tmp/dist
|
||||
@@ -23,12 +23,12 @@ echo "Building MSI"
|
||||
python3 generator/build.py "$@"
|
||||
chmod a+x /tmp/scratch/*.msi
|
||||
echo "MSI: Copy to $WORKING_DIRECTORY/dist"
|
||||
cp /tmp/scratch/*.msi $WORKING_DIRECTORY/dist
|
||||
cp /tmp/scratch/*.msi "$WORKING_DIRECTORY/dist"
|
||||
echo "MSI: Generate SHA256"
|
||||
MSI_FILE=`ls $WORKING_DIRECTORY/dist/*.msi`
|
||||
SHA256SUM=`sha256sum $MSI_FILE | cut -f1 -d' '`
|
||||
echo $SHA256SUM > $MSI_FILE.sha256
|
||||
MSI_FILE=$(ls "$WORKING_DIRECTORY/dist/*.msi")
|
||||
SHA256SUM=$(sha256sum "$MSI_FILE" | cut -f1 -d' ')
|
||||
echo "$SHA256SUM" > "$MSI_FILE.sha256"
|
||||
echo "MSI: SHA256 file content:"
|
||||
cat $MSI_FILE.sha256
|
||||
cat "$MSI_FILE.sha256"
|
||||
echo "MSI: contents of $WORKING_DIRECTORY/dist"
|
||||
ls -al $WORKING_DIRECTORY/dist
|
||||
ls -al "$WORKING_DIRECTORY/dist"
|
||||
|
||||
@@ -21,7 +21,7 @@ ls -al /home/xclient/wix/light.exe.config
|
||||
cat /home/xclient/wix/light.exe.config
|
||||
cp /master/light.exe.config /home/xclient/wix/light.exe.config
|
||||
cat /home/xclient/wix/light.exe.config
|
||||
cd /master
|
||||
cd /master || exit 1
|
||||
echo "Building MSI"
|
||||
python3 generator/build.py "$@"
|
||||
#
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/bash
|
||||
cd /oss
|
||||
cd /oss || exit 1
|
||||
make
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
cd ..
|
||||
|
||||
|
||||
if [ -z "$CIRCLE_TAG" ]; then
|
||||
_target="master"
|
||||
else
|
||||
@@ -11,5 +10,5 @@ fi
|
||||
|
||||
git clone -b "$_target" --single-branch git@github.com:grafana/grafana-enterprise.git --depth 1
|
||||
|
||||
cd grafana-enterprise
|
||||
cd grafana-enterprise || exit
|
||||
./build.sh
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
# no relation to publish.go
|
||||
|
||||
# shellcheck disable=SC2124
|
||||
|
||||
EXTRA_OPTS="$@"
|
||||
|
||||
# Right now we hack this in into the publish script.
|
||||
@@ -10,7 +12,7 @@ _releaseNoteUrl="https://community.grafana.com/t/release-notes-v6-0-x/14010"
|
||||
_whatsNewUrl="http://docs.grafana.org/guides/whats-new-in-v6-0/"
|
||||
|
||||
./scripts/build/release_publisher/release_publisher \
|
||||
--wn ${_whatsNewUrl} \
|
||||
--rn ${_releaseNoteUrl} \
|
||||
--version ${CIRCLE_TAG} \
|
||||
--apikey ${GRAFANA_COM_API_KEY} ${EXTRA_OPTS}
|
||||
--wn "${_whatsNewUrl}" \
|
||||
--rn "${_releaseNoteUrl}" \
|
||||
--version "${CIRCLE_TAG}" \
|
||||
--apikey "${GRAFANA_COM_API_KEY}" "${EXTRA_OPTS}"
|
||||
|
||||
@@ -8,5 +8,5 @@ cp ./scripts/build/rpmmacros ~/.rpmmacros
|
||||
|
||||
for package in dist/*.rpm; do
|
||||
[ -e "$package" ] || continue
|
||||
./scripts/build/sign_expect $GPG_KEY_PASSWORD $package
|
||||
./scripts/build/sign_expect "$GPG_KEY_PASSWORD" "$package"
|
||||
done
|
||||
|
||||
@@ -9,7 +9,7 @@ GCP_REPO_BUCKET="${6:-grafana-repo}"
|
||||
|
||||
REPO="grafana"
|
||||
|
||||
if [ -z "$RELEASE_TYPE" -o -z "$GPG_PASS" -o -z "$DIST_PATH" ]; then
|
||||
if [ -z "$RELEASE_TYPE" ] || [ -z "$GPG_PASS" ] || [ -z "$DIST_PATH" ]; then
|
||||
echo "Both RELEASE_TYPE (arg 1), GPG_PASS (arg 2) and DIST_PATH (arg 4) has to be set"
|
||||
exit 1
|
||||
fi
|
||||
@@ -36,7 +36,7 @@ mkdir -p /deb-repo/db \
|
||||
gsutil -m rsync -r -d "gs://$GCP_DB_BUCKET/$RELEASE_TYPE" /deb-repo/db
|
||||
|
||||
# Add the new release to the repo
|
||||
cp $DIST_PATH/*.deb /deb-repo/tmp
|
||||
cp "$DIST_PATH/*.deb" /deb-repo/tmp
|
||||
rm /deb-repo/tmp/grafana_latest*.deb || true
|
||||
aptly repo add "$REPO" /deb-repo/tmp #adds too many packages in enterprise
|
||||
|
||||
@@ -64,5 +64,5 @@ gsutil -m rsync -r /deb-repo/repo/grafana/pool "gs://$GCP_REPO_BUCKET/$RELEASE_T
|
||||
gsutil -m rsync -r -d /deb-repo/repo/grafana "gs://$GCP_REPO_BUCKET/$RELEASE_TYPE/deb"
|
||||
|
||||
# usage:
|
||||
#
|
||||
#
|
||||
# deb https://packages.grafana.com/oss/deb stable main
|
||||
|
||||
@@ -8,7 +8,7 @@ GCP_REPO_BUCKET="${5:-grafana-repo}"
|
||||
|
||||
REPO="rpm"
|
||||
|
||||
if [ -z "$RELEASE_TYPE" -o -z "$GPG_PASS" -o -z "$DIST_PATH" ]; then
|
||||
if [ -z "$RELEASE_TYPE" ] || [ -z "$GPG_PASS" ] || [ -z "$DIST_PATH" ]; then
|
||||
echo "Both RELEASE_TYPE (arg 1), GPG_PASS (arg 2) and DIST_PATH (arg 4) has to be set"
|
||||
exit 1
|
||||
fi
|
||||
@@ -33,7 +33,7 @@ mkdir -p /rpm-repo
|
||||
gsutil -m rsync -r "$BUCKET" /rpm-repo
|
||||
|
||||
# Add the new release to the repo
|
||||
cp $DIST_PATH/*.rpm /rpm-repo # adds to many files for enterprise
|
||||
cp "$DIST_PATH/*.rpm" /rpm-repo # adds to many files for enterprise
|
||||
rm /rpm-repo/grafana-latest-1*.rpm || true
|
||||
createrepo /rpm-repo
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
_files=$*
|
||||
|
||||
ALL_SIGNED=0
|
||||
|
||||
for file in $_files; do
|
||||
rpm -K "$file" | grep "pgp.*OK" -q
|
||||
if [[ $? != 0 ]]; then
|
||||
if rpm -K "$file" | grep "pgp.*OK" -q; then
|
||||
ALL_SIGNED=1
|
||||
echo $file NOT SIGNED
|
||||
echo "$file" NOT SIGNED
|
||||
else
|
||||
echo $file OK
|
||||
echo "$file" OK
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user