python/werkzeug: update to 3.1.3
[oi-userland.git] / make-rules / prep-hg.mk
blob49881f257eddc387c2a62bb34273c064520548b6
2 # CDDL HEADER START
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
19 # CDDL HEADER END
23 # Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
26 HG = /usr/bin/hg
27 MKTEMP = /usr/gnu/bin/mktemp
29 COMPONENT_PREP_HG?=yes
30 ifeq ($(strip $(COMPONENT_PREP_HG)), yes)
33 # Anything that we pull from a Mercurial repo must have a HG_REPO{_[0-9]+} and
34 # HG_REV{_[0-9]+} to match.
37 HG_SUFFIXES = $(subst HG_REPO_,, $(filter HG_REPO_%, $(.VARIABLES)))
39 # Templates for download variables and rules. We separate the variable
40 # assignments from the rules so that all the variable assignments are given a
41 # chance to complete before those variables are used in targets or
42 # prerequisites, where they'll be expanded immediately.
43 define hg-variables
44 ifdef HG_REPO$(1)
45 ifdef HG_REV$(1)
47 # If the label is not already defined (including to empty), set it to the version.
48 COMPONENT_LABEL$(1) ?= $$(COMPONENT_VERSION$(1))
49 # The source directory is <name>-(<label>|<version>)[-(<tag>|<branch>)][-<commit].
50 COMPONENT_SRC$(1) ?= $$(COMPONENT_NAME$(1))$$(COMPONENT_LABEL$(1):%=-%)$$($$(or $$(HG_TAG$(1)),$$(HG_BRANCH$(1))))$$(HG_REV$(1):%=-%)
51 COMPONENT_ARCHIVE$(1) ?= $$(COMPONENT_SRC$(1)).tar.gz
52 COMPONENT_ARCHIVE_SRC$(1) = hg
54 CLEAN_PATHS += $$(COMPONENT_SRC$(1))
55 CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1))
56 SOURCE_DIR$(1) = $$(COMPONENT_DIR)/$$(COMPONENT_SRC$(1))
57 endif
58 endif
59 endef
61 define hg-rules
62 ifdef HG_REPO$(1)
63 ifdef HG_REV$(1)
64 download:: $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1))
66 # First attempt to download a cached archive of the SCM repo at the proper
67 # changeset ID. If that fails, create an archive by cloning the SCM repo,
68 # updating to the selected changeset, archiving that directory, and cleaning up
69 # when complete.
70 $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ)
71 $$(FETCH) --file $$@ $$(HG_HASH$(1):%=--hash %) --url HG || \
72 (TMP_REPO=$$$$($(MKTEMP) --directory) && \
73 $(HG) clone $$(HG_REPO$(1)) $$(HG_REV$(1):%=--rev %) \
74 $$(HG_REV$(1):%=--updaterev %) \
75 $$(HG_BRANCH$(1):%=--branch %) \
76 $$$${TMP_REPO} && \
77 $(HG) -R $$$${TMP_REPO} archive --prefix $$(COMPONENT_SRC$(1)) $$@ && \
78 $(RM) -rf $${TMP_REPO} && \
79 HG_HASH=$$$$(digest -a sha256 $$@) && \
80 $(GSED) -i \
81 -e "s/\(HG_HASH$(1)[[:space:]]*=[[:space:]]*\).*/\1sha256:$$$${HG_HASH}/" \
82 Makefile)
84 USERLAND_REQUIRED_PACKAGES += developer/versioning/mercurial
86 endif
87 endif
88 endef
90 # Evaluate the variable assignments immediately.
91 $(eval $(call hg-variables,))
92 $(foreach suffix, $(HG_SUFFIXES), $(eval $(call hg-variables,_$(suffix))))
94 $(eval $(call hg-rules,))
95 $(foreach suffix, $(HG_SUFFIXES), $(eval $(call hg-rules,_$(suffix))))
97 endif