|
1 # |
|
2 # CDDL HEADER START |
|
3 # |
|
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. |
|
7 # |
|
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. |
|
12 # |
|
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] |
|
18 # |
|
19 # CDDL HEADER END |
|
20 # |
|
21 # Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. |
|
22 # |
|
23 |
|
24 HG = /usr/bin/hg |
|
25 |
|
26 # |
|
27 # Anything that we pull from a Mercurial repo must have a HG_REPO{_[0-9]+} and |
|
28 # HG_REV{_[0-9]+} to match. |
|
29 # |
|
30 |
|
31 TMP_SUFFIXES = $(subst HG_REPO_,, $(filter HG_REPO_%, $(.VARIABLES))) |
|
32 |
|
33 define mercurial-rules |
|
34 ifdef HG_REPO$(1) |
|
35 ifdef HG_REV$(1) |
|
36 |
|
37 COMPONENT_SRC$(1) = $(COMPONENT_NAME)-$(COMPONENT_VERSION)-$$(HG_REV$(1)) |
|
38 COMPONENT_ARCHIVE$(1) = $$(COMPONENT_SRC$(1)).tar.bz2 |
|
39 |
|
40 CLEAN_PATHS += $$(COMPONENT_SRC$(1)) |
|
41 CLOBBER_PATHS += $$(COMPONENT_ARCHIVE$(1)) |
|
42 SOURCE_DIR$(1) = $$(COMPONENT_DIR)/$(COMPONENT_SRC$(1)) |
|
43 |
|
44 download:: $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)) |
|
45 |
|
46 # First attempt to download a cached archive of the SCM repo at the proper |
|
47 # changeset ID. If that fails, create an archive by cloning the SCM repo, |
|
48 # updating to the selected changeset, archiving that directory, and cleaning up |
|
49 # when complete. |
|
50 $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ) |
|
51 $$(FETCH) --file $$@ $$(HG_HASH$(1):%=--hash %) || \ |
|
52 (TMP_REPO=$$$$(mktemp --directory) && \ |
|
53 $(HG) clone $$(HG_REPO$(1)) $$(HG_REV$(1):%=--rev %) \ |
|
54 $$(HG_REV$(1):%=--updaterev %) \ |
|
55 $$(HG_BRANCH$(1):%=--branch %) \ |
|
56 $$$${TMP_REPO} && \ |
|
57 $(HG) -R $$$${TMP_REPO} archive --prefix $$(COMPONENT_SRC$(1)) $$@ && \ |
|
58 $(RM) -rf $${TMP_REPO} && \ |
|
59 HG_HASH=$$$$(digest -a sha256 $$@) && \ |
|
60 $(GSED) -i \ |
|
61 -e "s/^HG_HASH$(1)=.*/HG_HASH$(1)= sha256:$$$${HG_HASH}/" \ |
|
62 Makefile) |
|
63 |
|
64 REQUIRED_PACKAGES += developer/versioning/mercurial |
|
65 |
|
66 endif |
|
67 endif |
|
68 endef |
|
69 |
|
70 # |
|
71 # Define the rules required to download any source archives and augment any |
|
72 # cleanup macros. |
|
73 # |
|
74 $(eval $(call mercurial-rules,)) |
|
75 $(foreach suffix, $(TMP_SUFFIXES), $(eval $(call mercurial-rules,_$(suffix)))) |