1#!/bin/bash -ef 2# 3# This is a temporary hack to verify the distribution archive is sound. 4# 5# The intent is to create a rule which does this and add to 6# rules_pkg. Comments within it are mostly for future me 7# while writing that. 8 9TARBALL=$(bazel build //distro:distro 2>&1 | grep 'rules_license-.*\.tar\.gz' | sed -e 's/ //g') 10REPO_NAME='rules_license' 11 12# This part can be standard from the rule 13 14 15TARNAME=$(basename "$TARBALL") 16 17TMP=$(mktemp -d) 18trap '/bin/rm -rf "$TMP"; exit 0' 0 1 2 3 15 19 20cp "$TARBALL" "$TMP" 21 22cd "$TMP" 23cat >WORKSPACE <<INP 24workspace(name = "test") 25 26load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 27 28http_archive( 29 name = "$REPO_NAME", 30 urls = ["file:$TARNAME"], 31) 32INP 33 34# 35# The rest is specific to the package under test. 36# 37 38# You always need a BUILD, so that can be an attribute 39cat >BUILD <<INP 40load("@rules_license//rules:license.bzl", "license") 41 42license( 43 name = "license", 44 license_kinds = ["@rules_license//licenses/generic:notice"], 45 license_text = "LICENSE" 46) 47INP 48 49# Need for a script to set up other files 50# Or it folds into the tests cases? 51echo license >LICENSE 52 53# Then a list of commands to run. This can be a template 54# too so we can substitute the path to bazel. 55bazel build ... 56bazel build @rules_license//rules/... 57bazel build @rules_license//licenses/... 58bazel query @rules_license//licenses/generic/... 59bazel query ... 60