2020-09-28 12:53:39 +00:00
|
|
|
# ***
|
|
|
|
# WARNING: Do not EDIT or MERGE this file, it is generated by packagespec.
|
|
|
|
# ***
|
ci/packagespec (#9653)
* add packagespec build system
- The majority of changes in this commit are files generated
by packagespec (everything in the packages-oss.lock directory).
* add .yamllint
* update to packagespec@fd54aea4
* ci: bust packagespec cache
- Change to packagespec results in package IDs that can use
git tag refs, not just commit refs.
* update to packagepsec@5fc121d0
- This busts all caches, because of a change to the way we
no longer traverse from tag refs to commit refs, due to
the potential confusion this can cause.
- See https://github.com/hashicorp/packagespec/commit/fd54aea4827bb6cfd637c78a2ab6274111605330
for the original change to packagespec necessitating this.
* update to packagespec@5e6c87b6
- This completes the change to allowing git tag refs
to be used for source IDs, begun in f130b940a8fbe3e9398225b08ea1d63420bef7b6
* update to packagespec@4d3c9e8b
- This busts cache, needed to apply previous change.
* remove RELEASE_BUILD_WORKFLOW_NAME
* update packagespec, add watch-ci target
* fix package names (do not refer to EDITION)
* remove EDITION input from packages-oss.yml
* bump package cache, update packagespec
* update packagespec, add 'aliases' target
* update packagespec; less output noise
* ci: give release bundle file a better name
- When performing a release build, this will include the build ID
as part of the name, making it easier to distinguish from other
builds.
* ci: create aliases tarball artifact
* ci: cache package metadata files
* ci: add metadata artifact
* ci: bust circleci package cache
* Revert "ci: bust circleci package cache"
This reverts commit 1320d182613466f0999d63f5742db12ac17f8e92.
* ci: remove aliases artifact
* ci: use buildID not workflowName to id artifacts
* packages: add BUNDLE_NAME metadata
* do not cache package metadata with binaries
* ci: bump package cache
* ci: debugging
* ci: fix package cache; update packagespec
* ci: update packagespec to 10e7beb2
* ci: write package metadata and aliases
* ci: switch to .zip artifacts
* switch package bundle back to tar.gz (from zip)
- Because of the way zip works, the zip archive was over 2GB rather than under 750MB as with tar.gz.
* bump packagespec, adds list-staged-builds
* update packagespec
* add publish stub + general tidy up
* bump packagespec
* bump packagespec; add make publish-config
* Makefile: tidy up packagespec targets
* pass PRODUCT_REPO_ROOT to packagespec
* bump go to 1.14.6
* packages-oss.yml: use more explicit base image
* bump packagespec to b899b7c1
* bump packagespec to f040ce8f
* packages-oss.yml: pin base image to digest
- This digest is pointed to by debian:buster-20200720
- Using a specific digest ensures that builds use the same
base image in all contexts
* add release-repo; bump packagespec
* remove BUILD_TAGS and -tags flag
* bump packagespec to e444f742
* bump to go1.14.7
* ci: bump to go1.14.7
2020-08-11 09:00:59 +00:00
|
|
|
# build.mk builds the packages defined in packages.lock, first building all necessary
|
|
|
|
# builder images.
|
|
|
|
#
|
|
|
|
# NOTE: This file should always run as though it were in the repo root, so all paths
|
|
|
|
# are relative to the repo root.
|
|
|
|
|
|
|
|
# Include config.mk relative to repo root.
|
|
|
|
include $(shell git rev-parse --show-toplevel)/packages*.lock/config.mk
|
|
|
|
|
|
|
|
ifeq ($(PACKAGE_SPEC_ID),)
|
|
|
|
$(error You must set PACKAGE_SPEC_ID; 'make build' does this for you.)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(PRODUCT_VERSION),)
|
|
|
|
$(error You cannot set PRODUCT_VERSION for local builds, did you mean PRODUCT_REVISION?)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Include the layers driver.
|
|
|
|
include $(LOCKDIR)/layer.mk
|
|
|
|
|
|
|
|
# GET_IMAGE_MARKER_FILE gets the name of the Docker image marker file
|
|
|
|
# for the named build layer.
|
|
|
|
GET_IMAGE_MARKER_FILE = $($(1)_IMAGE)
|
|
|
|
# GET_IMAGE_NAME gets the Docker image name of the build layer.
|
|
|
|
GET_IMAGE_NAME = $($(1)_IMAGE_NAME)
|
|
|
|
|
|
|
|
# Determine the top-level build layer.
|
|
|
|
BUILD_LAYER_NAME := $(shell $(call QUERY_PACKAGESPEC,.meta.builtin.BUILD_LAYERS[0].name))
|
|
|
|
BUILD_LAYER_IMAGE = $(call GET_IMAGE_MARKER_FILE,$(BUILD_LAYER_NAME))
|
|
|
|
BUILD_LAYER_IMAGE_NAME = $(call GET_IMAGE_NAME,$(BUILD_LAYER_NAME))
|
|
|
|
|
|
|
|
BUILD_COMMAND := $(shell $(call QUERY_PACKAGESPEC,.["build-command"]))
|
|
|
|
BUILD_ENV := $(shell $(call QUERY_PACKAGESPEC,.inputs | to_entries[] | "\(.key)=\(.value)"))
|
|
|
|
ALIASES := $(shell $(call QUERY_PACKAGESPEC,.aliases[] | "\(.type)/\(.path)"))
|
|
|
|
ALIASES := $(addprefix $(BY_ALIAS)/,$(ALIASES))
|
|
|
|
|
|
|
|
ifeq ($(BUILD_COMMAND),)
|
|
|
|
$(error Unable to find build command for package spec ID $(PACKAGE_SPEC_ID))
|
|
|
|
endif
|
|
|
|
ifeq ($(BUILD_ENV),)
|
|
|
|
$(error Unable to find build inputs for package spec ID $(PACKAGE_SPEC_ID))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Configure paths and filenames.
|
|
|
|
OUTPUT_DIR := $(PACKAGE_STORE)
|
|
|
|
_ := $(shell mkdir -p $(OUTPUT_DIR))
|
|
|
|
# PACKAGE_NAME is the input-addressed name of the package.
|
|
|
|
PACKAGE_NAME := $(PACKAGE_SOURCE_ID)-$(PACKAGE_SPEC_ID)
|
|
|
|
PACKAGE_ZIP_NAME := $(PACKAGE_NAME).zip
|
|
|
|
PACKAGE := $(OUTPUT_DIR)/$(PACKAGE_ZIP_NAME)
|
2020-09-28 12:53:39 +00:00
|
|
|
# PACKAGE_CONTENTS is used when a built package needs to be unzipped to examine
|
|
|
|
# its contents. It is a path to a directory where these contents will be unzipped
|
|
|
|
# to. This is not needed to produce builds, but is useful for post-build tasks
|
|
|
|
# when the package contents need to be checked.
|
|
|
|
PACKAGE_CONTENTS := $(PACKAGE)_contents
|
ci/packagespec (#9653)
* add packagespec build system
- The majority of changes in this commit are files generated
by packagespec (everything in the packages-oss.lock directory).
* add .yamllint
* update to packagespec@fd54aea4
* ci: bust packagespec cache
- Change to packagespec results in package IDs that can use
git tag refs, not just commit refs.
* update to packagepsec@5fc121d0
- This busts all caches, because of a change to the way we
no longer traverse from tag refs to commit refs, due to
the potential confusion this can cause.
- See https://github.com/hashicorp/packagespec/commit/fd54aea4827bb6cfd637c78a2ab6274111605330
for the original change to packagespec necessitating this.
* update to packagespec@5e6c87b6
- This completes the change to allowing git tag refs
to be used for source IDs, begun in f130b940a8fbe3e9398225b08ea1d63420bef7b6
* update to packagespec@4d3c9e8b
- This busts cache, needed to apply previous change.
* remove RELEASE_BUILD_WORKFLOW_NAME
* update packagespec, add watch-ci target
* fix package names (do not refer to EDITION)
* remove EDITION input from packages-oss.yml
* bump package cache, update packagespec
* update packagespec, add 'aliases' target
* update packagespec; less output noise
* ci: give release bundle file a better name
- When performing a release build, this will include the build ID
as part of the name, making it easier to distinguish from other
builds.
* ci: create aliases tarball artifact
* ci: cache package metadata files
* ci: add metadata artifact
* ci: bust circleci package cache
* Revert "ci: bust circleci package cache"
This reverts commit 1320d182613466f0999d63f5742db12ac17f8e92.
* ci: remove aliases artifact
* ci: use buildID not workflowName to id artifacts
* packages: add BUNDLE_NAME metadata
* do not cache package metadata with binaries
* ci: bump package cache
* ci: debugging
* ci: fix package cache; update packagespec
* ci: update packagespec to 10e7beb2
* ci: write package metadata and aliases
* ci: switch to .zip artifacts
* switch package bundle back to tar.gz (from zip)
- Because of the way zip works, the zip archive was over 2GB rather than under 750MB as with tar.gz.
* bump packagespec, adds list-staged-builds
* update packagespec
* add publish stub + general tidy up
* bump packagespec
* bump packagespec; add make publish-config
* Makefile: tidy up packagespec targets
* pass PRODUCT_REPO_ROOT to packagespec
* bump go to 1.14.6
* packages-oss.yml: use more explicit base image
* bump packagespec to b899b7c1
* bump packagespec to f040ce8f
* packages-oss.yml: pin base image to digest
- This digest is pointed to by debian:buster-20200720
- Using a specific digest ensures that builds use the same
base image in all contexts
* add release-repo; bump packagespec
* remove BUILD_TAGS and -tags flag
* bump packagespec to e444f742
* bump to go1.14.7
* ci: bump to go1.14.7
2020-08-11 09:00:59 +00:00
|
|
|
META_JSON_NAME := $(PACKAGE_ZIP_NAME).meta.json
|
|
|
|
META := $(OUTPUT_DIR)/$(META_JSON_NAME)
|
|
|
|
|
|
|
|
# In the container, place the output dir at root. This makes 'docker cp' easier.
|
|
|
|
CONTAINER_OUTPUT_DIR := /$(OUTPUT_DIR)
|
|
|
|
|
|
|
|
FULL_BUILD_COMMAND := export $(BUILD_ENV) && mkdir -p $(CONTAINER_OUTPUT_DIR) && $(BUILD_COMMAND)
|
|
|
|
|
|
|
|
### Docker run command configuration.
|
|
|
|
|
|
|
|
DOCKER_SHELL := /bin/bash -euo pipefail -c
|
|
|
|
|
|
|
|
DOCKER_RUN_ENV_FLAGS := \
|
|
|
|
-e PACKAGE_SOURCE_ID=$(PACKAGE_SOURCE_ID) \
|
|
|
|
-e OUTPUT_DIR=$(CONTAINER_OUTPUT_DIR) \
|
|
|
|
-e PACKAGE_ZIP_NAME=$(PACKAGE_ZIP_NAME)
|
|
|
|
|
|
|
|
BUILD_CONTAINER_NAME := build-$(PACKAGE_SPEC_ID)-$(PACKAGE_SOURCE_ID)
|
|
|
|
DOCKER_RUN_FLAGS := $(DOCKER_RUN_ENV_FLAGS) --name $(BUILD_CONTAINER_NAME)
|
|
|
|
# DOCKER_RUN_COMMAND ties everything together to build the final package as a
|
|
|
|
# single docker run invocation.
|
|
|
|
DOCKER_RUN_COMMAND = docker run $(DOCKER_RUN_FLAGS) $(BUILD_LAYER_IMAGE_NAME) $(DOCKER_SHELL) '$(FULL_BUILD_COMMAND)'
|
|
|
|
# DOCKER_CP_COMMAND copies the built artefact from the build container.
|
|
|
|
DOCKER_CP_COMMAND = docker cp $(BUILD_CONTAINER_NAME):$(CONTAINER_OUTPUT_DIR)/$(PACKAGE_ZIP_NAME) $(PACKAGE)
|
|
|
|
|
|
|
|
# package builds the package according to the set PACKAGE_SPEC_ID and PRODUCT_REVISION.
|
|
|
|
.PHONY: package
|
|
|
|
package: $(ALIASES)
|
|
|
|
@echo $(PACKAGE)
|
|
|
|
|
2020-09-28 12:53:39 +00:00
|
|
|
# package-contents builds the package according to PACKAGE_SPEC_ID and PRODUCT_REVISION,
|
|
|
|
# and then extracts the zip file into an adjacent directory.
|
|
|
|
.PHONY: package-contents
|
|
|
|
package-contents: $(PACKAGE_CONTENTS)
|
|
|
|
@echo "$(PACKAGE_CONTENTS)/"
|
|
|
|
|
|
|
|
# copy-package-contents allows copying the contents of a package to a specific
|
|
|
|
# directory. You must set PACKAGE_CONTENTS_DEST_DIR to this directory.
|
|
|
|
# This is useful for implementing a top-level make target that places your
|
|
|
|
# build artifacts in a well-known location.
|
|
|
|
.PHONY: copy-package-contents
|
|
|
|
copy-package-contents: $(PACKAGE_CONTENTS)
|
|
|
|
@[ -n "$(PACKAGE_CONTENTS_DEST_DIR)" ] || { \
|
|
|
|
echo "==> ERROR: Must set PACKAGE_CONTENTS_DEST_DIR"; \
|
|
|
|
exit 1; \
|
|
|
|
}; \
|
|
|
|
mkdir -p "$(PACKAGE_CONTENTS_DEST_DIR)"; \
|
|
|
|
cp -r "$(PACKAGE_CONTENTS)"/* "$(PACKAGE_CONTENTS_DEST_DIR)"
|
|
|
|
|
ci/packagespec (#9653)
* add packagespec build system
- The majority of changes in this commit are files generated
by packagespec (everything in the packages-oss.lock directory).
* add .yamllint
* update to packagespec@fd54aea4
* ci: bust packagespec cache
- Change to packagespec results in package IDs that can use
git tag refs, not just commit refs.
* update to packagepsec@5fc121d0
- This busts all caches, because of a change to the way we
no longer traverse from tag refs to commit refs, due to
the potential confusion this can cause.
- See https://github.com/hashicorp/packagespec/commit/fd54aea4827bb6cfd637c78a2ab6274111605330
for the original change to packagespec necessitating this.
* update to packagespec@5e6c87b6
- This completes the change to allowing git tag refs
to be used for source IDs, begun in f130b940a8fbe3e9398225b08ea1d63420bef7b6
* update to packagespec@4d3c9e8b
- This busts cache, needed to apply previous change.
* remove RELEASE_BUILD_WORKFLOW_NAME
* update packagespec, add watch-ci target
* fix package names (do not refer to EDITION)
* remove EDITION input from packages-oss.yml
* bump package cache, update packagespec
* update packagespec, add 'aliases' target
* update packagespec; less output noise
* ci: give release bundle file a better name
- When performing a release build, this will include the build ID
as part of the name, making it easier to distinguish from other
builds.
* ci: create aliases tarball artifact
* ci: cache package metadata files
* ci: add metadata artifact
* ci: bust circleci package cache
* Revert "ci: bust circleci package cache"
This reverts commit 1320d182613466f0999d63f5742db12ac17f8e92.
* ci: remove aliases artifact
* ci: use buildID not workflowName to id artifacts
* packages: add BUNDLE_NAME metadata
* do not cache package metadata with binaries
* ci: bump package cache
* ci: debugging
* ci: fix package cache; update packagespec
* ci: update packagespec to 10e7beb2
* ci: write package metadata and aliases
* ci: switch to .zip artifacts
* switch package bundle back to tar.gz (from zip)
- Because of the way zip works, the zip archive was over 2GB rather than under 750MB as with tar.gz.
* bump packagespec, adds list-staged-builds
* update packagespec
* add publish stub + general tidy up
* bump packagespec
* bump packagespec; add make publish-config
* Makefile: tidy up packagespec targets
* pass PRODUCT_REPO_ROOT to packagespec
* bump go to 1.14.6
* packages-oss.yml: use more explicit base image
* bump packagespec to b899b7c1
* bump packagespec to f040ce8f
* packages-oss.yml: pin base image to digest
- This digest is pointed to by debian:buster-20200720
- Using a specific digest ensures that builds use the same
base image in all contexts
* add release-repo; bump packagespec
* remove BUILD_TAGS and -tags flag
* bump packagespec to e444f742
* bump to go1.14.7
* ci: bump to go1.14.7
2020-08-11 09:00:59 +00:00
|
|
|
.PHONY: package-meta
|
|
|
|
package-meta: $(META)
|
|
|
|
@echo $(META)
|
|
|
|
|
|
|
|
$(META): $(LOCK)
|
|
|
|
@$(call QUERY_PACKAGESPEC,.) > $@
|
|
|
|
|
|
|
|
# PACKAGE builds the package.
|
|
|
|
$(PACKAGE): $(BUILD_LAYER_IMAGE)
|
|
|
|
@mkdir -p $$(dirname $@)
|
|
|
|
@echo "==> Building package: $@"
|
|
|
|
@echo "PACKAGE_SOURCE_ID: $(PACKAGE_SOURCE_ID)"
|
|
|
|
@echo "PACKAGE_SPEC_ID: $(PACKAGE_SPEC_ID)"
|
|
|
|
@# Print alias info.
|
|
|
|
@$(call QUERY_PACKAGESPEC,.aliases[] | "alias type:\(.type) path:\(.path)") | column -t
|
|
|
|
@docker rm -f $(BUILD_CONTAINER_NAME) > /dev/null 2>&1 || true # Speculative cleanup.
|
|
|
|
$(DOCKER_RUN_COMMAND)
|
|
|
|
$(DOCKER_CP_COMMAND)
|
|
|
|
@docker rm -f $(BUILD_CONTAINER_NAME)
|
|
|
|
|
2020-09-28 12:53:39 +00:00
|
|
|
$(PACKAGE_CONTENTS): $(PACKAGE)
|
|
|
|
@mkdir -p "$@" && unzip "$<" -d "$@"
|
|
|
|
|
ci/packagespec (#9653)
* add packagespec build system
- The majority of changes in this commit are files generated
by packagespec (everything in the packages-oss.lock directory).
* add .yamllint
* update to packagespec@fd54aea4
* ci: bust packagespec cache
- Change to packagespec results in package IDs that can use
git tag refs, not just commit refs.
* update to packagepsec@5fc121d0
- This busts all caches, because of a change to the way we
no longer traverse from tag refs to commit refs, due to
the potential confusion this can cause.
- See https://github.com/hashicorp/packagespec/commit/fd54aea4827bb6cfd637c78a2ab6274111605330
for the original change to packagespec necessitating this.
* update to packagespec@5e6c87b6
- This completes the change to allowing git tag refs
to be used for source IDs, begun in f130b940a8fbe3e9398225b08ea1d63420bef7b6
* update to packagespec@4d3c9e8b
- This busts cache, needed to apply previous change.
* remove RELEASE_BUILD_WORKFLOW_NAME
* update packagespec, add watch-ci target
* fix package names (do not refer to EDITION)
* remove EDITION input from packages-oss.yml
* bump package cache, update packagespec
* update packagespec, add 'aliases' target
* update packagespec; less output noise
* ci: give release bundle file a better name
- When performing a release build, this will include the build ID
as part of the name, making it easier to distinguish from other
builds.
* ci: create aliases tarball artifact
* ci: cache package metadata files
* ci: add metadata artifact
* ci: bust circleci package cache
* Revert "ci: bust circleci package cache"
This reverts commit 1320d182613466f0999d63f5742db12ac17f8e92.
* ci: remove aliases artifact
* ci: use buildID not workflowName to id artifacts
* packages: add BUNDLE_NAME metadata
* do not cache package metadata with binaries
* ci: bump package cache
* ci: debugging
* ci: fix package cache; update packagespec
* ci: update packagespec to 10e7beb2
* ci: write package metadata and aliases
* ci: switch to .zip artifacts
* switch package bundle back to tar.gz (from zip)
- Because of the way zip works, the zip archive was over 2GB rather than under 750MB as with tar.gz.
* bump packagespec, adds list-staged-builds
* update packagespec
* add publish stub + general tidy up
* bump packagespec
* bump packagespec; add make publish-config
* Makefile: tidy up packagespec targets
* pass PRODUCT_REPO_ROOT to packagespec
* bump go to 1.14.6
* packages-oss.yml: use more explicit base image
* bump packagespec to b899b7c1
* bump packagespec to f040ce8f
* packages-oss.yml: pin base image to digest
- This digest is pointed to by debian:buster-20200720
- Using a specific digest ensures that builds use the same
base image in all contexts
* add release-repo; bump packagespec
* remove BUILD_TAGS and -tags flag
* bump packagespec to e444f742
* bump to go1.14.7
* ci: bump to go1.14.7
2020-08-11 09:00:59 +00:00
|
|
|
# ALIASES writes the package alias links.
|
|
|
|
# ALIASES must be phony to ensure they are updated to point to the
|
|
|
|
# latest builds.
|
|
|
|
.PHONY: $(ALIASES)
|
|
|
|
$(ALIASES): $(PACKAGE)
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@$(LN) -rfs $(PACKAGE) $@
|
|
|
|
@echo "==> Package alias written: $@"
|