From c8a7a891e767efddf0346f93408d86aa46912499 Mon Sep 17 00:00:00 2001 From: Prakash Surya Date: Thu, 25 Feb 2021 13:08:07 -0800 Subject: [PATCH] TOOL-11187 leverage linux-pkg to build delphix-masking package --- lib/common.sh | 2 +- packages/masking/config.sh | 57 ++++++++++++++++++++++++++++++++++++++ query-packages.sh | 6 ++++ setup.sh | 4 ++- 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 packages/masking/config.sh diff --git a/lib/common.sh b/lib/common.sh index 5153767d..caf4fd80 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -89,7 +89,7 @@ function die() { } function logmust() { - echo Running: "$@" + [[ "$LOGGING" == "false" ]] || echo Running: "$@" >&2 "$@" || die "failed command '$*'" } diff --git a/packages/masking/config.sh b/packages/masking/config.sh new file mode 100644 index 00000000..a4daf383 --- /dev/null +++ b/packages/masking/config.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Copyright 2021 Delphix +# +# 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. +# +# shellcheck disable=SC2034 + +DEFAULT_PACKAGE_GIT_URL="https://gitlab.delphix.com/masking/dms-core-gate.git" +PACKAGE_DEPENDENCIES="adoptopenjdk" + +function prepare() { + logmust install_pkgs "$DEPDIR"/adoptopenjdk/*.deb +} + +function build() { + export JAVA_HOME + JAVA_HOME=$(cat "$DEPDIR/adoptopenjdk/JDK_PATH") || + die "Failed to read $DEPDIR/adoptopenjdk/JDK_PATH" + + logmust cd "$WORKDIR/repo" + + # + # The "appliance-build-stage0" Jenkins job consumes this file, + # along with various other files (e.g. licensing metadata). + # Thus, if we don't generate it here, the Jenkins job that + # builds the appliance will fail. + # + # shellcheck disable=SC2016 + logmust jq -n \ + --arg h "$(git rev-parse HEAD)" \ + --arg d "$(date --utc --iso-8601=seconds)" \ + '{ "dms-core-gate" : { "git-hash" : $h, "date": $d }}' \ + >"$WORKDIR/artifacts/metadata.json" + + logmust ./gradlew --no-daemon --stacktrace \ + -Porg.gradle.configureondemand=false \ + -PenvironmentName=linuxappliance \ + clean \ + generateLicenseReport \ + :dist:distDeb \ + :dist:distLicenseReport + + logmust rsync -av dist/build/distributions/ "$WORKDIR/artifacts/" + logmust cp -v \ + dist/build/reports/dependency-license/* "$WORKDIR/artifacts/" +} diff --git a/query-packages.sh b/query-packages.sh index b72f81af..8cab51fb 100755 --- a/query-packages.sh +++ b/query-packages.sh @@ -19,6 +19,12 @@ cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 TOP="$PWD" source "$TOP/lib/common.sh" +# +# Disable "logmust" output as that is unnecessary here, and actually +# trips up some of our testing (e.g. verify-query-packages.sh). +# +export LOGGING=false + ALL_OUTPUT_FIELDS=(name git-url dependencies can-update) function usage() { diff --git a/setup.sh b/setup.sh index 03192636..5fd99dd7 100755 --- a/setup.sh +++ b/setup.sh @@ -93,12 +93,14 @@ logmust sudo apt-get update # build dependencies from a control file. # - install_shfmt and shellcheck are needed for - make check - to be able to # make sure style checks are fine. +# - jq is used to generate a JSON formatted metadata file by some packages. # logmust install_pkgs \ debhelper \ devscripts \ equivs \ - shellcheck + shellcheck \ + jq logmust install_shfmt