#!/bin/bash # Copyright (C) 2026 Red Hat, Inc. # Written by: # Andrew John Hughes # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # Waive a gating issue RHEL_VER=${1} NVR=${2} TESTCASE=${3} COMMENT=${4} CURL=$(command -v curl) JSON_TOOL=$(command -v json_verify) JSON_FORMAT=$(command -v jq) JSON_FILE=$(mktemp --tmpdir waive.XXXXXX.json) HEADER_FILE=$(mktemp --tmpdir waive.XXXXXX.headers) JSON_OUT=$(mktemp --tmpdir out.XXXXXX.json) CACERT=/etc/ssl/certs/2022-IT-Root-CA.pem CACERT_DIR=$(dirname ${CACERT}) URL="https://waiverdb.engineering.redhat.com/api/v1.0/waivers/" if test -z "${JSON_TOOL}" -o ! -x "${JSON_TOOL}" ; then echo "JSON verifier not found. Skipping verification."; SKIP_JSON=1; else SKIP_JSON=0; fi if test "x${RHEL_VER}" = "x"; then echo "No RHEL version specified."; echo "${0} "; exit 1; fi if test "x${NVR}" = "x"; then echo "No NVR specified."; echo "${0} "; exit 2; fi if test "x${TESTCASE}" = "x"; then echo "No testcase specified."; echo "${0} "; exit 3; fi if test "x${COMMENT}" = "x"; then COMMENT="Gating broken"; echo "Setting COMMENT to default of '${COMMENT}'" fi if test "${CURL}" = ""; then echo "curl not found"; exit 4; fi if test "${JSON_FORMAT}" = ""; then echo "jq not found"; exit 5; fi { echo "{"; printf "\t\"subject_type\":\"brew-build\",\n"; printf "\t\"subject_identifier\":\"%s\",\n" "${NVR}"; printf "\t\"testcase\":\"%s\",\n" "${TESTCASE}"; printf "\t\"waived\":true,\n"; printf "\t\"product_version\":\"rhel-%d\",\n" "${RHEL_VER}" printf "\t\"comment\":\"%s\"\n" "${COMMENT}"; echo "}" } > "${JSON_FILE}" if [ "${SKIP_JSON}" -eq 0 ] ; then "${JSON_TOOL}" < "${JSON_FILE}" || exit 6; fi CMD=("${CURL}" --silent --show-error --capath "${CACERT_DIR}" --negotiate -u :) JSON_COMMAND="--json"; # Check --json is available ${CURL} ${JSON_COMMAND} 2> /dev/null if [ $? -eq 2 ] ; then echo "--json unsupported; falling back on --data-binary"; { echo "Content-Type: application/json"; echo "Accept: application/json"; } > "${HEADER_FILE}" echo "Header file:"; cat "${HEADER_FILE}" CMD=("${CMD[@]}" --header "@${HEADER_FILE}" --data-binary); else CMD=("${CMD[@]}" "${JSON_COMMAND}"); fi CMD=("${CMD[@]}" "@${JSON_FILE}" "${URL}") echo "Sending the following JSON..."; cat "${JSON_FILE}" echo "${CMD[@]}" if command "${CMD[@]}" > "${JSON_OUT}" ; then "${JSON_FORMAT}" < "${JSON_OUT}" else echo "Failed to file waiver"; exit 7; fi rm -v "${JSON_FILE}" rm -v "${HEADER_FILE}" # Local Variables: # compile-command: "shellcheck waive_issue.sh" # fill-column: 80 # indent-tabs-mode: nil # sh-basic-offset: 4 # End: