|
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 SVN = /usr/bin/svn |
|
25 |
|
26 # |
|
27 # Anything that we pull from a Subversion repo must have a SVN_REPO{_[0-9]+} and |
|
28 # SVN_REV{_[0-9]+} to match. |
|
29 # |
|
30 |
|
31 TMP_SUFFIXES = $(subst SVN_REPO_,, $(filter SVN_REPO_%, $(.VARIABLES))) |
|
32 |
|
33 define subversion-rules |
|
34 ifdef SVN_REPO$(1) |
|
35 ifdef SVN_REV$(1) |
|
36 |
|
37 COMPONENT_SRC$(1) = $(COMPONENT_NAME)-$(COMPONENT_VERSION)-$$(SVN_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 # when complete. |
|
49 $$(USERLAND_ARCHIVES)$$(COMPONENT_ARCHIVE$(1)): $(MAKEFILE_PREREQ) |
|
50 $$(FETCH) --file $$@ $$(SVN_HASH$(1):%=--hash %) || \ |
|
51 (TMP_REPO=$$$$(mktemp --directory --dry-run) && \ |
|
52 $(SVN) export $$(SVN_REPO$(1)) $$(SVN_REV$(1):%=--revision %) \ |
|
53 $$$${TMP_REPO} && \ |
|
54 /usr/gnu/bin/tar --create --file - --absolute-names \ |
|
55 --transform="s;$$$${TMP_REPO};$$(COMPONENT_SRC$(1));g" \ |
|
56 --bzip2 $$$${TMP_REPO} >$$@ && \ |
|
57 $(RM) -rf $$$${TMP_REPO} && \ |
|
58 SVN_HASH=$$$$(digest -a sha256 $$@) && \ |
|
59 $(GSED) -i \ |
|
60 -e "s/^SVN_HASH$(1)=.*/SVN_HASH$(1)= sha256:$$$${SVN_HASH}/" \ |
|
61 Makefile) |
|
62 |
|
63 REQUIRED_PACKAGES += developer/versioning/subversion |
|
64 |
|
65 endif |
|
66 endif |
|
67 endef |
|
68 |
|
69 # |
|
70 # Define the rules required to download any source archives and augment any |
|
71 # cleanup macros. |
|
72 # |
|
73 $(eval $(call subversion-rules,)) |
|
74 $(foreach suffix, $(TMP_SUFFIXES), $(eval $(call subversion-rules,_$(suffix)))) |