sample-manifest should store sample-manifests in special dirs
[unleashed-userland.git] / make-rules / ips.mk
blobc116ceeb3f8ebe7e7e43a69cb30f36a657ded8a2
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
21 # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
22 # Copyright 2014 Andrzej Szeszo. All rights reserved.
26 # Rules and Macros for generating an IPS package manifest and publishing an
27 # IPS package to a pkg depot.
29 # To use these rules, include ../make-rules/ips.mk in your Makefile
30 # and define an "install" target appropriate to building your component.
31 # Ex:
33 # install: $(BUILD_DIR)/build/$(MACH32)/.installed \
34 # $(BUILD_DIR)/build/$(MACH64)/.installed
36 # This set of rules makes the "publish" target the default target for make(1)
39 PKGDEPEND = /usr/bin/pkgdepend
40 PKGFMT = /usr/bin/pkgfmt
41 PKGMOGRIFY = /usr/bin/pkgmogrify
42 PKGSEND = /usr/bin/pkgsend
43 ifeq ($(strip $(PKGLINT_COMPONENT)),)
44 PKGLINT = /usr/bin/pkglint
45 else
46 PKGLINT = ${WS_TOOLS}/pkglint
47 endif
48 PKGMANGLE = $(WS_TOOLS)/userland-mangler
50 WS_TRANSFORMS = $(WS_TOP)/transforms
52 GENERATE_HISTORY= $(WS_TOOLS)/generate-history
53 HISTORY= history
55 # Package headers should all pretty much follow the same format
56 METADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template
57 COPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template
59 # order is important
60 GENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
62 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/libtool-drop
63 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/ignore-libs
65 COMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup
66 COMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
68 LICENSE_TRANSFORMS = $(WS_TOP)/transforms/license-changes
70 # order is important
71 PUBLISH_TRANSFORMS += $(LICENSE_TRANSFORMS)
72 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/variant-cleanup
73 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/autopyc
74 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults
75 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/actuators
76 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/devel
77 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/docs
78 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/locale
79 PUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
80 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup
82 ifeq ($(strip $(COMPONENT_AUTOGEN_MANIFEST)),yes)
83 AUTOGEN_MANIFEST_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
84 else
85 AUTOGEN_MANIFEST_TRANSFORMS += $(WS_TOP)/transforms/drop-all
86 endif
88 PKG_MACROS += MACH=$(MACH)
89 PKG_MACROS += MACH32=$(MACH32)
90 PKG_MACROS += MACH64=$(MACH64)
91 PKG_MACROS += PUBLISHER=$(PUBLISHER)
92 PKG_MACROS += PUBLISHER_LOCALIZABLE=$(PUBLISHER_LOCALIZABLE)
93 PKG_MACROS += CONSOLIDATION=$(CONSOLIDATION)
94 PKG_MACROS += BUILD_VERSION=$(BUILD_VERSION)
95 PKG_MACROS += SOLARIS_VERSION=$(SOLARIS_VERSION)
96 PKG_MACROS += OS_VERSION=$(OS_VERSION)
97 PKG_MACROS += PKG_SOLARIS_VERSION=$(PKG_SOLARIS_VERSION)
98 PKG_MACROS += HUMAN_VERSION=$(HUMAN_VERSION)
99 PKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
100 PKG_MACROS += COMPONENT_VERSION=$(COMPONENT_VERSION)
101 PKG_MACROS += COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL)
102 PKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
103 PKG_MACROS += COMPONENT_HG_URL=$(COMPONENT_HG_URL)
104 PKG_MACROS += COMPONENT_HG_REV=$(COMPONENT_HG_REV)
105 PKG_MACROS += COMPONENT_NAME=$(COMPONENT_NAME)
106 PKG_MACROS += COMPONENT_FMRI=$(COMPONENT_FMRI)
107 PKG_MACROS += COMPONENT_LICENSE="$(COMPONENT_LICENSE)"
108 PKG_MACROS += COMPONENT_LICENSE_FILE=$(COMPONENT_LICENSE_FILE)
109 PKG_MACROS += TPNO=$(TPNO)
110 PKG_MACROS += USERLAND_GIT_REMOTE=$(USERLAND_GIT_REMOTE)
111 PKG_MACROS += USERLAND_GIT_BRANCH=$(USERLAND_GIT_BRANCH)
112 PKG_MACROS += USERLAND_GIT_REV=$(USERLAND_GIT_REV)
114 PKG_OPTIONS += $(PKG_MACROS:%=-D %) -D COMPONENT_SUMMARY="$(COMPONENT_SUMMARY)" -D COMPONENT_CLASSIFICATION="org.opensolaris.category.2008:$(COMPONENT_CLASSIFICATION)"
116 MANGLED_DIR = $(PROTO_DIR)/mangled
118 PKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
120 MANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
122 SAMPLE_MANIFEST_DIR = $(COMPONENT_DIR)/manifests
123 SAMPLE_MANIFEST_FILE = $(SAMPLE_MANIFEST_DIR)/sample-manifest.p5m
125 CANONICAL_MANIFESTS = $(wildcard *.p5m)
126 ifneq ($(wildcard $(HISTORY)),)
127 HISTORICAL_MANIFESTS = $(shell $(NAWK) -v FUNCTION=name -f $(GENERATE_HISTORY) < $(HISTORY))
128 endif
130 # Look for manifests which need to be duplicated for each version of python.
131 ifeq ($(findstring -PYVER,$(CANONICAL_MANIFESTS)),-PYVER)
132 UNVERSIONED_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PYVER.p5m,$(CANONICAL_MANIFESTS)))
133 PY_MANIFESTS = $(filter %-PYVER.p5m,$(CANONICAL_MANIFESTS))
134 PYV_MANIFESTS = $(foreach v,$(shell echo $(PYTHON_VERSIONS) | tr -d .),$(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER.p5m/-$(v).p5m/g'))
135 PYNV_MANIFESTS = $(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER//')
136 else
137 UNVERSIONED_MANIFESTS = $(CANONICAL_MANIFESTS)
138 endif
140 # Look for manifests which need to be duplicated for each version of perl.
141 ifeq ($(findstring -PERLVER,$(UNVERSIONED_MANIFESTS)),-PERLVER)
142 NOPERL_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS)))
143 PERL_MANIFESTS = $(filter %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS))
144 PERLV_MANIFESTS = $(foreach v,$(shell echo $(PERL_VERSIONS) | tr -d .),$(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER.p5m/-$(v).p5m/g'))
145 PERLNV_MANIFESTS = $(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER//')
146 else
147 NOPERL_MANIFESTS = $(UNVERSIONED_MANIFESTS)
148 endif
150 # Look for manifests which need to be duplicated for each version of ruby.
151 # NOPERL_MANIFESTS represents the manifests that are not Python or
152 # Perl manifests. Extract the Ruby Manifests from NOPERL_MANIFESTS.
153 # Any remaining manifests are stored in NONRUBY_MANIFESTS
154 ifeq ($(findstring -RUBYVER,$(NOPERL_MANIFESTS)),-RUBYVER)
155 NORUBY_MANIFESTS = $(filter-out %GENFRAG.p5m,\
156 $(filter-out %-RUBYVER.p5m,$(NOPERL_MANIFESTS)))
157 RUBY_MANIFESTS = $(filter %-RUBYVER.p5m,$(NOPERL_MANIFESTS))
158 RUBYV_MANIFESTS = $(foreach v,$(shell echo $(RUBY_VERSIONS)),\
159 $(shell echo $(RUBY_MANIFESTS) |\
160 sed -e 's/-RUBYVER.p5m/-$(shell echo $(v) |\
161 cut -d. -f1,2 | tr -d .).p5m/g'))
162 RUBYNV_MANIFESTS = $(shell echo $(RUBY_MANIFESTS) | sed -e 's/-RUBYVER//')
163 else
164 NORUBY_MANIFESTS = $(NOPERL_MANIFESTS)
165 endif
167 VERSIONED_MANIFESTS = \
168 $(PYV_MANIFESTS) $(PYNV_MANIFESTS) \
169 $(PERLV_MANIFESTS) $(PERLNV_MANIFESTS) \
170 $(RUBYV_MANIFESTS) $(RUBYNV_MANIFESTS) \
171 $(NORUBY_MANIFESTS) $(HISTORICAL_MANIFESTS)
173 GENERATED = $(MANIFEST_BASE)-generated
174 COMBINED = $(MANIFEST_BASE)-combined
175 MANIFESTS = $(VERSIONED_MANIFESTS:%=$(MANIFEST_BASE)-%)
178 DEPENDED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend)
179 RESOLVED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend.res)
180 PRE_PUBLISHED=$(RESOLVED:%.depend.res=%.pre-published)
181 PUBLISHED=$(RESOLVED:%.depend.res=%.published)
183 COPYRIGHT_FILE ?= $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
184 IPS_COMPONENT_VERSION ?= $(COMPONENT_VERSION)
186 .DEFAULT: publish
188 .SECONDARY:
190 # allow publishing to be overridden, such as when
191 # a package is for one architecture only.
192 PRE_PUBLISH_STAMP ?= $(BUILD_DIR)/.pre-published-$(MACH)
193 PUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH)
195 # Do all that is needed to ensure the package is consistent for publishing,
196 # except actually pushing to a repo, separately from the push to the repo.
197 pre-publish: build install $(PRE_PUBLISH_STAMP)
198 publish: pre-publish $(PUBLISH_STAMP)
200 sample-manifest: $(GENERATED).p5m
202 $(GENERATED).p5m: install
203 [ ! -d $(SAMPLE_MANIFEST_DIR) ] && $(MKDIR) $(SAMPLE_MANIFEST_DIR) || true
204 $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
205 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
206 sed -e '/^$$/d' -e '/^#.*$$/d' -e '/^dir .*$$/d' \
207 -e '/\.la$$/d' -e '/\.pyo$$/d' -e '/usr\/lib\/python[23]\..*\.pyc$$/d' \
208 -e '/.*\/__pycache__\/.*/d' | \
209 $(PKGFMT) | \
210 cat $(METADATA_TEMPLATE) - | \
211 $(TEE) $@ $(SAMPLE_MANIFEST_FILE) >/dev/null
213 # copy the canonical manifest(s) to the build tree
214 $(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
215 cat $(METADATA_TEMPLATE) $< >$@
217 # The text of a transform that will emit a dependency conditional on the
218 # presence of a particular version of a runtime, which will then draw in the
219 # runtime-version-specific version of the package we're operating on. $(1) is
220 # the name of the runtime package, and $(2) is the version suffix.
221 mkgeneric = \
222 echo "<transform set name=pkg.fmri value=(?:pkg:/)?(.+)-\#\#\#@(.*)" \
223 "-> emit depend nodrop=true type=conditional" \
224 "predicate=$(1)-$(2) fmri=%<1>-$(2)@%<2>>" >> $@;
226 # Define and execute a macro that generates a rule to create a manifest for a
227 # python module specific to a particular version of the python runtime.
228 define python-manifest-rule
229 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PYVER.p5m
230 $(PKGMOGRIFY) -D PYVER=$(1) -D PYV=$(shell echo $(1) | tr -d .) $$< > $$@
231 endef
232 $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-manifest-rule,$(ver))))
234 # A rule to create a helper transform package for python, that will insert the
235 # appropriate conditional dependencies into a python library's
236 # runtime-version-generic package to pull in the version-specific bits when the
237 # corresponding version of python is on the system.
238 $(WS_TOP)/transforms/mkgeneric-python: $(WS_TOP)/make-rules/shared-macros.mk
239 $(RM) $@
240 $(foreach ver,$(shell echo $(PYTHON_VERSIONS) | tr -d .), \
241 $(call mkgeneric,runtime/python,$(ver)))
243 # Build Python version-wrapping manifests from the generic version.
244 $(MANIFEST_BASE)-%.p5m: %-PYVER.p5m $(WS_TOP)/transforms/mkgeneric-python
245 $(PKGMOGRIFY) -D PYV=### $(WS_TOP)/transforms/mkgeneric-python \
246 $(WS_TOP)/transforms/mkgeneric $< > $@
247 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
249 # Define and execute a macro that generates a rule to create a manifest for a
250 # perl module specific to a particular version of the perl runtime.
251 define perl-manifest-rule
252 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PERLVER.p5m
253 $(PKGMOGRIFY) -D PERLVER=$(1) -D PLV=$(shell echo $(1) | tr -d .) \
254 -D PERL_ARCH=$(call PERL_ARCH_FUNC,$(PERL.$(1))) $$< > $$@
255 endef
256 $(foreach ver,$(PERL_VERSIONS),$(eval $(call perl-manifest-rule,$(ver))))
258 # A rule to create a helper transform package for perl, that will insert the
259 # appropriate conditional dependencies into a perl library's
260 # runtime-version-generic package to pull in the version-specific bits when the
261 # corresponding version of perl is on the system.
262 $(WS_TOP)/transforms/mkgeneric-perl: $(WS_TOP)/make-rules/shared-macros.mk
263 $(RM) $@
264 $(foreach ver,$(shell echo $(PERL_VERSIONS) | tr -d .), \
265 $(call mkgeneric,runtime/perl,$(ver)))
267 # Build Perl version-wrapping manifests from the generic version.
268 $(MANIFEST_BASE)-%.p5m: %-PERLVER.p5m $(WS_TOP)/transforms/mkgeneric-perl
269 $(PKGMOGRIFY) -D PLV=### $(WS_TOP)/transforms/mkgeneric-perl \
270 $(WS_TOP)/transforms/mkgeneric $< > $@
271 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
273 # Rule to generate historical manifests from the $(HISTORY) file.
274 define history-manifest-rule
275 $(MANIFEST_BASE)-$(1): $(HISTORY) $(BUILD_DIR)
276 $(NAWK) -v TARGET=$(1) -v FUNCTION=manifest -f $(GENERATE_HISTORY) < \
277 $(HISTORY) > $$@
278 endef
279 $(foreach mfst,$(HISTORICAL_MANIFESTS),$(eval $(call history-manifest-rule,$(mfst))))
281 # Define and execute a macro that generates a rule to create a manifest for a
282 # ruby module specific to a particular version of the ruby runtime.
283 # Creates build/manifest-*-modulename-##.p5m file where ## is replaced with
284 # the version number.
285 define ruby-manifest-rule
286 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: \
287 PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) \
288 RUBYV=$(subst .,,$(1))
290 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-RUBYVER.p5m
291 if [ -f $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m ]; then \
292 cat $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m >> $$@; \
294 $(PKGMOGRIFY) -D RUBY_VERSION=$(1) -D RUBY_LIB_VERSION=$(2) \
295 -D RUBYV=$(shell echo $(1) | tr -d .) $$< > $$@
296 endef
297 $(foreach ver,$(RUBY_VERSIONS),\
298 $(eval $(call ruby-manifest-rule,$(shell echo $(ver) | \
299 cut -d. -f1,2),$(ver))))
301 # A rule to create a helper transform package for ruby, that will insert the
302 # appropriate conditional dependencies into a ruby library's
303 # runtime-version-generic package to pull in the version-specific bits when the
304 # corresponding version of ruby is on the system.
305 $(BUILD_DIR)/mkgeneric-ruby: $(WS_TOP)/make-rules/shared-macros.mk
306 $(RM) $@
307 $(foreach ver,$(RUBY_VERSIONS),\
308 $(call mkgeneric,runtime/ruby,$(shell echo $(ver) | \
309 cut -d. -f1,2 | tr -d .)))
311 # Build Ruby version-wrapping manifests from the generic version.
312 # Creates build/manifest-*-modulename.p5m file.
314 $(MANIFEST_BASE)-%.p5m: %-RUBYVER.p5m $(BUILD_DIR)/mkgeneric-ruby
315 $(PKGMOGRIFY) -D RUBYV=### $(BUILD_DIR)/mkgeneric-ruby \
316 $(WS_TOP)/transforms/mkgeneric $< > $@
317 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
319 ifeq ($(strip $(COMPONENT_AUTOGEN_MANIFEST)),yes)
320 # auto-generate file/directory list
321 $(MANIFEST_BASE)-%.generated: %.p5m $(BUILD_DIR)
322 (cat $(METADATA_TEMPLATE); \
323 $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR)) | \
324 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(AUTOGEN_MANIFEST_TRANSFORMS) | \
325 sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
326 cat $< - >$@
328 # mogrify non-parameterized manifests
329 $(MANIFEST_BASE)-%.mogrified: %.generated
330 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
331 $(PUBLISH_TRANSFORMS) | \
332 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
334 # mogrify parameterized manifests
335 $(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.generated
336 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
337 $(PUBLISH_TRANSFORMS) | \
338 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
339 else
340 # mogrify non-parameterized manifests
341 $(MANIFEST_BASE)-%.mogrified: %.p5m $(BUILD_DIR)
342 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
343 $(PUBLISH_TRANSFORMS) | \
344 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
346 # mogrify parameterized manifests
347 $(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.p5m $(BUILD_DIR)
348 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
349 $(PUBLISH_TRANSFORMS) | \
350 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
351 endif
353 # mangle the file contents
354 $(BUILD_DIR) $(MANGLED_DIR):
355 $(MKDIR) $@
357 PKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %)
358 $(MANIFEST_BASE)-%.mangled: $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR)
359 $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@
361 # generate dependencies
362 PKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
363 $(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mangled
364 $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
366 # These files should contain a list of packages that the component is known to
367 # depend on. Using resolve.deps is not required, but significantly speeds up
368 # the "pkg resolve" step.
369 # XXX existing pkg5 is too old for that
370 #EXTDEPFILES = $(wildcard $(sort $(addsuffix ../resolve.deps, $(dir $(DEPENDED)))))
372 # This is a target that should only be run by hand, and not something that
373 # .resolved-$(MACH) should depend on.
374 sample-resolve.deps:
375 echo "<transform depend type=(require|require-any) -> print %(fmri)>" > rd-trans
376 for i in build/*.depend; do \
377 $(PKGMOGRIFY) -O /dev/null $$i rd-trans | tr " " "\n" | sort -u > m1; \
378 $(PKGMOGRIFY) -O /dev/null $$i.res rd-trans | tr " " "\n" | sort -u > m2; \
379 comm -13 m1 m2; \
380 done | sed -e 's/@[^ ]*//g' -e 's,pkg:/,,g' | sort -u > resolve.deps
381 $(RM) rd-trans m1 m2
382 if [[ ! -s resolve.deps ]]; then \
383 echo "No computed dependencies found; removing empty resolve.deps."; \
384 $(RM) resolve.deps; \
388 # resolve the dependencies all at once
389 $(BUILD_DIR)/.resolved-$(MACH): $(DEPENDED)
390 $(PKGDEPEND) resolve $(EXTDEPFILES:%=-e %) -m $(DEPENDED)
391 $(TOUCH) $@
394 # Generate a set of REQUIRED_PACKAGES based on what is needed to for pkgdepend
395 # to resolve properly. Automatically append this to your Makefile for the truly
396 # lazy among us. This is only a piece of the REQUIRED_PACKAGES puzzle.
397 # You must still include packages for tools you build and test with.
399 REQUIRED_PACKAGES:: $(RESOLVED)
400 $(GMAKE) RESOLVE_DEPS= $(BUILD_DIR)/.resolved-$(MACH)
401 @echo "# Auto-generated contents below. Please manually verify and remove this comment" >>Makefile
402 @$(PKGMOGRIFY) $(WS_TRANSFORMS)/$@ $(RESOLVED) | \
403 $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' | sort -u >>Makefile
404 @echo "*** Please edit your Makefile and verify the new content at the end ***"
407 # lint the manifests all at once
408 $(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH)
409 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
410 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
411 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
412 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
413 $(TOUCH) $@
415 lintme: FRC
416 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
417 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
418 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
419 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
421 FRC:
424 # published
425 PKGSEND_PUBLISH_OPTIONS = -s $(WS_REPO) publish --fmri-in-manifest
426 PKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
427 PKGSEND_PUBLISH_OPTIONS += -T \*.py
429 # Do all the hard work that is needed to ensure the package is consistent
430 # and ready for publishing, except actually pushing bits to a repository
431 $(MANIFEST_BASE)-%.pre-published: $(MANIFEST_BASE)-%.depend.res $(BUILD_DIR)/.linted-$(MACH)
432 $(CP) $< $@
433 @echo "NEW PACKAGE CONTENTS ARE LOCALLY VALIDATED AND READY TO GO"
435 # Push to the repo
436 $(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.pre-published
437 $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
438 $(PKGFMT) <$< >$@
440 $(BUILD_DIR)/.pre-published-$(MACH): $(PRE_PUBLISHED)
441 $(TOUCH) $@
443 $(BUILD_DIR)/.published-$(MACH): $(PUBLISHED)
444 $(TOUCH) $@
446 print-package-names: canonical-manifests
447 @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
448 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
449 sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
451 print-package-paths: canonical-manifests
452 @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
453 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
454 sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
456 install-packages: publish
457 @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
458 cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
459 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
460 sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
461 (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
462 else ; \
463 echo "unsafe to install package(s) automatically" ; \
466 $(RESOLVED): install
468 canonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
469 ifeq ($(strip $(CANONICAL_MANIFESTS)),)
470 # If there were no canonical manifests in the workspace, nothing will
471 # be published and we should fail. A sample manifest can be generated
472 # with
473 # $ gmake sample-manifest
474 # Once created, it will need to be reviewed, edited, and added to the
475 # workspace.
476 $(error Missing canonical manifest(s))
477 endif
479 # This converts required paths to containing package names for be able to
480 # properly setup the build environment for a component.
481 required-pkgs.mk: Makefile
482 @echo "generating $@ from Makefile REQUIRED_* data"
483 @pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \
484 | sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@
486 pre-prep: required-pkgs.mk
489 CLEAN_PATHS += required-pkgs.mk