4194N/A#
4194N/A# CDDL HEADER START
4194N/A#
4194N/A# The contents of this file are subject to the terms of the
4194N/A# Common Development and Distribution License (the "License").
4194N/A# You may not use this file except in compliance with the License.
4194N/A#
4194N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4194N/A# or http://www.opensolaris.org/os/licensing.
4194N/A# See the License for the specific language governing permissions
4194N/A# and limitations under the License.
4194N/A#
4194N/A# When distributing Covered Code, include this CDDL HEADER in each
4194N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4194N/A# If applicable, add the following below this CDDL HEADER, with the
4194N/A# fields enclosed by brackets "[]" replaced with your own identifying
4194N/A# information: Portions Copyright [yyyy] [name of copyright owner]
4194N/A#
4194N/A# CDDL HEADER END
4194N/A#
5680N/A
5680N/A#
5680N/A# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
4194N/A#
4194N/A
4194N/AHG = /usr/bin/hg
4194N/A
4194N/A#
4194N/A# Anything that we pull from a Mercurial repo must have a HG_REPO{_[0-9]+} and
4194N/A# HG_REV{_[0-9]+} to match.
4194N/A#
4194N/A
4249N/AHG_SUFFIXES = $(subst HG_REPO_,, $(filter HG_REPO_%, $(.VARIABLES)))
4194N/A
6909N/A# Templates for download variables and rules. We separate the variable
6909N/A# assignments from the rules so that all the variable assignments are given a
6909N/A# chance to complete before those variables are used in targets or
6909N/A# prerequisites, where they'll be expanded immediately.
6909N/Adefine hg-variables
4194N/Aifdef HG_REPO$(1)
4194N/Aifdef HG_REV$(1)
4194N/A
6909N/A# If the label is not already defined (including to empty), set it to the version.
6909N/ACOMPONENT_LABEL$(1) ?= $$(COMPONENT_VERSION$(1))
6909N/A# The source directory is <name>-(<label>|<version>)[-(<tag>|<branch>)][-<commit].
6909N/ACOMPONENT_SRC$(1) ?= $$(COMPONENT_NAME$(1))$$(COMPONENT_LABEL$(1):%=-%)$$($$(or $$(HG_TAG$(1)),$$(HG_BRANCH$(1))))$$(HG_REV$(1):%=-%)
6909N/ACOMPONENT_ARCHIVE$(1) ?= $$(COMPONENT_SRC$(1)).tar.gz
5680N/ACOMPONENT_ARCHIVE_SRC$(1) = hg
4194N/A
4194N/ACLEAN_PATHS += $$(COMPONENT_SRC$(1))
4194N/ACLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1))
4194N/ASOURCE_DIR$(1) = $$(COMPONENT_DIR)/$(COMPONENT_SRC$(1))
6909N/Aendif
6909N/Aendif
6909N/Aendef
4194N/A
6909N/Adefine hg-rules
6909N/Aifdef HG_REPO$(1)
6909N/Aifdef HG_REV$(1)
4194N/Adownload:: $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1))
4194N/A
4194N/A# First attempt to download a cached archive of the SCM repo at the proper
4194N/A# changeset ID. If that fails, create an archive by cloning the SCM repo,
4194N/A# updating to the selected changeset, archiving that directory, and cleaning up
4194N/A# when complete.
4194N/A$$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ)
4194N/A $$(FETCH) --file $$@ $$(HG_HASH$(1):%=--hash %) || \
4194N/A (TMP_REPO=$$$$(mktemp --directory) && \
4194N/A $(HG) clone $$(HG_REPO$(1)) $$(HG_REV$(1):%=--rev %) \
4194N/A $$(HG_REV$(1):%=--updaterev %) \
4194N/A $$(HG_BRANCH$(1):%=--branch %) \
4194N/A $$$${TMP_REPO} && \
4194N/A $(HG) -R $$$${TMP_REPO} archive --prefix $$(COMPONENT_SRC$(1)) $$@ && \
4194N/A $(RM) -rf $${TMP_REPO} && \
4194N/A HG_HASH=$$$$(digest -a sha256 $$@) && \
4194N/A $(GSED) -i \
6949N/A -e "s/\(HG_HASH$(1)[[:space:]]*=[[:space:]]*\).*/\1sha256:$$$${HG_HASH}/" \
4194N/A Makefile)
4194N/A
4194N/AREQUIRED_PACKAGES += developer/versioning/mercurial
4194N/A
4194N/Aendif
4194N/Aendif
4194N/Aendef
4194N/A
6909N/A# Evaluate the variable assignments immediately.
6909N/A$(eval $(call hg-variables,))
6909N/A$(foreach suffix, $(HG_SUFFIXES), $(eval $(call hg-variables,_$(suffix))))
6909N/A
6909N/A# Put the rule evaluations in a variable for deferred evaluation.
6909N/Adefine eval-hg-rules
6909N/A$(eval $(call hg-rules,))
6909N/A$(foreach suffix, $(HG_SUFFIXES), $(eval $(call hg-rules,_$(suffix))))
6909N/Aendef