github.com/google/fleetspeak@v0.1.15-0.20240426164851-4f31f62c1aea/fleetspeak/build.sh (about) 1 #!/bin/bash 2 # Copyright 2017 Google Inc. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # https://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 cat >&2 <<EOF 17 18 ************************************************************** 19 * * 20 * Dear Fleetspeak users, * 21 * * 22 * Fleetspeak has become a regular Go module, * 23 * and you can stop using the build.sh script. * 24 * * 25 * To build from an existing repo clone, use: * 26 * $ go install ./cmd/... * 27 * * 28 * To build without first doing a clone, use: * 29 * $ go install github.com/google/fleetspeak/cmd/...@latest * 30 * (and replace @latest with the revision of your choice) * 31 * * 32 * The build.sh script will disappear in the near future. * 33 * * 34 ************************************************************** 35 36 EOF 37 38 readonly ARGV0=${0} 39 40 # Make sure Fleetspeak client and server binaries are static. 41 export CGO_ENABLED=0 42 43 # Exit on error. 44 set -e 45 46 # Get absolute path to symlink's directory 47 SCRIPT_DIR="$(/usr/bin/dirname "$(readlink -e "${ARGV0}" 2>/dev/null || true)")" 48 if [[ -z "${SCRIPT_DIR}" ]]; then 49 SCRIPT_DIR="$(/usr/bin/dirname "${BASH_SOURCE[0]}")" 50 if [[ -z "${SCRIPT_DIR}" ]]; then 51 /bin/echo 'Failed to resolve script directory.' 52 exit 1 53 fi 54 fi 55 # Go one above this script's directory. 56 cd "${SCRIPT_DIR}"/.. 57 58 readonly GOS=$(/usr/bin/find ./cmd -name '*.go') 59 # ${GOS} should not be double-quoted; disable lint check 60 # shellcheck disable=SC2086 61 readonly MAIN_FILES=$(grep -l 'func main' ${GOS}) 62 63 if ! python -c 'import fleetspeak'; then 64 /bin/echo >&2 ' 65 Warning: Python fleetspeak module is not importable. 66 You can install it with pip if you intend to use it. 67 ' 68 if [[ "${STRICT}" == 'true' ]]; then 69 exit 2 70 fi 71 fi 72 73 for f in ${MAIN_FILES}; do 74 COMPILED="${f%.go}$(go env GOEXE)" 75 /bin/echo >&2 "Building ${f} => ${COMPILED}" 76 go build -o "${COMPILED}" "${f}" 77 done 78