commit | author | age
|
9c75c0
|
1 |
# |
NJ |
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, Oracle and/or it's affiliates. All rights reserved. |
|
22 |
# |
|
23 |
|
|
24 |
# |
|
25 |
# Rules and Macros for generating an IPS package manifest and publishing an |
|
26 |
# IPS package to a pkg depot. |
|
27 |
# |
|
28 |
# To use these rules, include ../make-rules/ips.mk in your Makefile |
|
29 |
# and define an "install" target appropriate to building your component. |
|
30 |
# Ex: |
|
31 |
# |
5d461f
|
32 |
# install: $(COMPONENT_SRC)/build-$(MACH32)/.installed \ |
NJ |
33 |
# $(COMPONENT_SRC)/build-$(MACH64)/.installed |
9c75c0
|
34 |
# |
NJ |
35 |
# This set of rules makes the "publish" target the default target for make(1) |
|
36 |
# |
|
37 |
|
|
38 |
PKGDEPEND = /usr/bin/pkgdepend |
6514ee
|
39 |
PKGFMT = /usr/bin/pkgfmt |
NJ |
40 |
PKGMOGRIFY = /usr/bin/pkgmogrify |
|
41 |
PKGSEND = /usr/bin/pkgsend |
9c75c0
|
42 |
|
6514ee
|
43 |
# Package headers should all pretty much follow the same format |
NJ |
44 |
METADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template |
|
45 |
COPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template |
9c75c0
|
46 |
|
6514ee
|
47 |
# order is important |
NJ |
48 |
GENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup |
|
49 |
GENERATE_TRANSFORMS += $(WS_TOP)/transforms/variant.arch |
5d461f
|
50 |
|
6514ee
|
51 |
COMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup |
NJ |
52 |
COMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS) |
9c75c0
|
53 |
|
6514ee
|
54 |
# order is important |
NJ |
55 |
PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults |
|
56 |
PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/actuators |
|
57 |
PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/devel |
|
58 |
PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/docs |
|
59 |
PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/locale |
|
60 |
PUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS) |
|
61 |
PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup |
|
62 |
|
|
63 |
PKG_MACROS += MACH=$(MACH) |
|
64 |
PKG_MACROS += ARCH=$(MACH) |
|
65 |
PKG_MACROS += MACH32=$(MACH32) |
|
66 |
PKG_MACROS += MACH64=$(MACH64) |
|
67 |
PKG_MACROS += IPS_PKG_NAME=$(IPS_PKG_NAME) |
|
68 |
PKG_MACROS += PUBLISHER=$(PUBLISHER) |
|
69 |
PKG_MACROS += CONSOLIDATION=$(CONSOLIDATION) |
|
70 |
PKG_MACROS += BUILD_VERSION=$(BUILD_VERSION) |
|
71 |
PKG_MACROS += SOLARIS_VERSION=$(SOLARIS_VERSION) |
|
72 |
PKG_MACROS += OS_VERSION=$(OS_VERSION) |
|
73 |
PKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION) |
|
74 |
PKG_MACROS += COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL) |
|
75 |
PKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL) |
|
76 |
|
|
77 |
PKG_OPTIONS += $(PKG_MACROS:%=-D %) |
|
78 |
# multi-word macros get broken up, so we handle them "specially" |
224e81
|
79 |
PKG_OPTIONS += -D COMPONENT_SUMMARY=$(COMPONENT_SUMMARY) |
NJ |
80 |
PKG_OPTIONS += -D COMPONENT_DESCRIPTION=$(COMPONENT_DESCRIPTION) |
|
81 |
PKG_OPTIONS += -D COMPONENT_CLASSIFICATION=$(COMPONENT_CLASSIFICATION) |
6514ee
|
82 |
|
NJ |
83 |
MANIFEST_BASE = $(COMPONENT_SRC)/manifest-$(MACH) |
|
84 |
|
ff17eb
|
85 |
CANONICAL_MANIFESTS = $(wildcard *.p5m) |
6514ee
|
86 |
GENERATED = $(MANIFEST_BASE)-generated |
NJ |
87 |
COMBINED = $(MANIFEST_BASE)-combined |
|
88 |
MANIFESTS = $(CANONICAL_MANIFESTS:%=$(MANIFEST_BASE)-%) |
|
89 |
|
|
90 |
|
ff17eb
|
91 |
MOGRIFIED=$(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.resolved) |
6514ee
|
92 |
PUBLISHED=$(MOGRIFIED:%.resolved=%.published) |
9c75c0
|
93 |
|
153732
|
94 |
COPYRIGHT_FILE = $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright |
224e81
|
95 |
ifeq ($(IPS_PKG_NAME),) |
NJ |
96 |
IPS_PKG_NAME = $(COMPONENT_NAME) |
|
97 |
endif |
d6b79b
|
98 |
IPS_COMPONENT_VERSION = $(COMPONENT_VERSION) |
153732
|
99 |
|
6514ee
|
100 |
.DEFAULT: publish |
153732
|
101 |
|
6514ee
|
102 |
.SECONDARY: $(GENERATED).fdeps |
9c75c0
|
103 |
|
6514ee
|
104 |
publish: install $(COMPONENT_SRC)/.published |
9c75c0
|
105 |
|
ff17eb
|
106 |
sample-manifest: $(GENERATED).p5m |
9c75c0
|
107 |
|
6514ee
|
108 |
# |
NJ |
109 |
# Rules for generating a manifest automatically. Generated manifests will |
|
110 |
# contain the following: |
|
111 |
# copyright - template copyright information |
|
112 |
# metadata - mogrified template metadata |
|
113 |
# actions - "normalized" actions for the paths to be installed. |
|
114 |
# depends - automatically generated dependencies |
|
115 |
# |
9c75c0
|
116 |
|
6514ee
|
117 |
# transform template metadata into slightly more package specific metadata. |
NJ |
118 |
$(GENERATED).metadata: $(METADATA_TEMPLATE) install |
|
119 |
$(PKGMOGRIFY) -D IPS_PKG_NAME=$(IPS_PKG_NAME) $< | \ |
|
120 |
sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) >$@ |
|
121 |
|
|
122 |
# generate actions from the proto dir |
|
123 |
$(GENERATED).generate: install |
|
124 |
$(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) >$@ |
|
125 |
|
|
126 |
# convert actions to a "normalized" format |
|
127 |
$(GENERATED).actions: $(GENERATED).generate |
|
128 |
$(PKGMOGRIFY) $(PKG_OPTIONS) $< $(GENERATE_TRANSFORMS) | \ |
|
129 |
sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) >$@ |
|
130 |
|
|
131 |
# generate dependencies |
|
132 |
$(MANIFEST_BASE)-%.fdeps: $(MANIFEST_BASE)-%.generate |
|
133 |
$(PKGDEPEND) generate $(PKG_OPTIONS) $< $(PROTO_DIR) >$@ |
|
134 |
|
|
135 |
$(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.fdeps |
|
136 |
$(PKGDEPEND) resolve -o $< | sed -e '1d' >$@ |
|
137 |
|
|
138 |
# generate a complete manifest from the pieces |
ff17eb
|
139 |
$(GENERATED).p5m: $(GENERATED).metadata $(GENERATED).actions \ |
6514ee
|
140 |
$(GENERATED).depend |
NJ |
141 |
cat $(COPYRIGHT_TEMPLATE) $(GENERATED).metadata $(GENERATED).actions \ |
|
142 |
$(GENERATED).depend >$@ |
|
143 |
|
|
144 |
# |
|
145 |
# Rules to generate a combined manifest from the canonical manifest(s) checked |
|
146 |
# into the workspace. |
|
147 |
# |
|
148 |
|
|
149 |
# Combine the canonical manifest(s) for this component and "normalize" them |
|
150 |
# for comparison. |
ff17eb
|
151 |
$(COMBINED).p5m: canonical-manifests |
6514ee
|
152 |
cat $(CANONICAL_MANIFESTS) | $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \ |
NJ |
153 |
sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u | $(PKGFMT) >$@ |
|
154 |
|
ff17eb
|
155 |
$(MANIFEST_BASE)-%.compare: $(MANIFEST_BASE)-%.p5m |
6514ee
|
156 |
$(PKGMOGRIFY) $(PKG_OPTIONS) $(COMPARISON_TRANSFORMS) $< >$@ |
NJ |
157 |
|
|
158 |
manifest-compare: $(COMBINED).compare $(GENERATED).compare |
|
159 |
@echo "Manifest comparison" |
|
160 |
@pkgdiff $(GENERATED).compare $(COMBINED).compare |
|
161 |
|
|
162 |
# mogrify the canonical manifest(s) |
|
163 |
# |
ff17eb
|
164 |
$(MANIFEST_BASE)-%.resolved: %.p5m manifest-compare |
6514ee
|
165 |
$(PKGMOGRIFY) $(PKG_OPTIONS) $< $(PUBLISH_TRANSFORMS) >$@ |
NJ |
166 |
|
|
167 |
$(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.resolved |
|
168 |
$(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \ |
|
169 |
-d $(PROTO_DIR) -d . $< |
9c75c0
|
170 |
$(TOUCH) $@ |
6514ee
|
171 |
|
NJ |
172 |
$(COMPONENT_SRC)/.published: manifest-compare $(PUBLISHED) |
|
173 |
$(TOUCH) $@ |
|
174 |
|
a325d4
|
175 |
print-package-names: canonical-manifests |
NJ |
176 |
@cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \ |
|
177 |
$(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \ |
|
178 |
sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u |
|
179 |
|
|
180 |
print-package-paths: canonical-manifests |
|
181 |
@cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \ |
|
182 |
$(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \ |
|
183 |
sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u |
|
184 |
|
6514ee
|
185 |
canonical-manifests: $(CANONICAL_MANIFESTS) |
NJ |
186 |
ifeq ($(strip $(CANONICAL_MANIFESTS)),) |
|
187 |
# If there were no canonical manifests in the workspace, nothing will |
|
188 |
# be published and we should fail. A sample manifest can be generated |
|
189 |
# with |
|
190 |
# $ gmake sample-manifest |
|
191 |
# Once created, it will need to be reviewed, edited, and added to the |
|
192 |
# workspace. |
|
193 |
$(error Missing canonical manifest(s)) |
|
194 |
endif |
a325d4
|
195 |
|
NJ |
196 |
# This converts required paths to containing package names for be able to |
|
197 |
# properly setup the build environment for a component. |
|
198 |
required-pkgs.mk: Makefile |
|
199 |
@echo "generating $@ from Makefile REQUIRED_* data" |
|
200 |
@pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \ |
|
201 |
| sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@ |
|
202 |
|
|
203 |
CLEAN_PATHS += required-pkgs.mk |