unleashed-userland README
[unleashed-userland.git] / make-rules / ips.mk
blob0864d0b103e28058bcbe48e193fbab4277688d84
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
49 WS_TRANSFORMS = $(WS_TOP)/transforms
51 GENERATE_HISTORY= $(WS_TOOLS)/generate-history
52 HISTORY= history
54 # Package headers should all pretty much follow the same format
55 METADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template
56 COPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template
58 # order is important
59 GENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
61 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/libtool-drop
62 PKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/ignore-libs
64 COMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup
65 COMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
67 LICENSE_TRANSFORMS = $(WS_TOP)/transforms/license-changes
69 # order is important
70 PUBLISH_TRANSFORMS += $(LICENSE_TRANSFORMS)
71 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/variant-cleanup
72 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/autopyc
73 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults
74 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/actuators
75 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/devel
76 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/docs
77 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/locale
78 PUBLISH_TRANSFORMS += $(WS_TOP)/transforms/python-3-soabi
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_FILE=$(COMPONENT_LICENSE_FILE)
108 PKG_MACROS += TPNO=$(TPNO)
109 PKG_MACROS += USERLAND_GIT_REMOTE=$(USERLAND_GIT_REMOTE)
110 PKG_MACROS += USERLAND_GIT_BRANCH=$(USERLAND_GIT_BRANCH)
111 PKG_MACROS += USERLAND_GIT_REV=$(USERLAND_GIT_REV)
113 PKG_OPTIONS += $(PKG_MACROS:%=-D %) \
114 -D COMPONENT_SUMMARY="$(strip $(COMPONENT_SUMMARY))" \
115 -D COMPONENT_CLASSIFICATION="org.opensolaris.category.2008:$(strip $(COMPONENT_CLASSIFICATION))" \
116 -D COMPONENT_DESCRIPTION="$(strip $(COMPONENT_DESCRIPTION))" \
117 -D COMPONENT_LICENSE="$(strip $(COMPONENT_LICENSE))"
119 PKG_PROTO_DIRS += $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
121 MANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
123 SAMPLE_MANIFEST_DIR = $(COMPONENT_DIR)/manifests
124 SAMPLE_MANIFEST_FILE = $(SAMPLE_MANIFEST_DIR)/sample-manifest.p5m
126 CANONICAL_MANIFESTS = $(wildcard *.p5m)
127 ifneq ($(wildcard $(HISTORY)),)
128 HISTORICAL_MANIFESTS = $(shell $(NAWK) -v FUNCTION=name -f $(GENERATE_HISTORY) < $(HISTORY))
129 endif
131 # Look for manifests which need to be duplicated for each version of python.
132 ifeq ($(findstring -PYVER,$(CANONICAL_MANIFESTS)),-PYVER)
133 UNVERSIONED_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PYVER.p5m,$(CANONICAL_MANIFESTS)))
134 PY_MANIFESTS = $(filter %-PYVER.p5m,$(CANONICAL_MANIFESTS))
135 PYV_MANIFESTS = $(foreach v,$(shell echo $(PYTHON_VERSIONS) | tr -d .),$(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER.p5m/-$(v).p5m/g'))
136 PYNV_MANIFESTS = $(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER//')
137 else
138 UNVERSIONED_MANIFESTS = $(CANONICAL_MANIFESTS)
139 endif
141 # Look for manifests which need to be duplicated for each version of perl.
142 ifeq ($(findstring -PERLVER,$(UNVERSIONED_MANIFESTS)),-PERLVER)
143 NOPERL_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS)))
144 PERL_MANIFESTS = $(filter %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS))
145 PERLV_MANIFESTS = $(foreach v,$(shell echo $(PERL_VERSIONS) | tr -d .),$(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER.p5m/-$(v).p5m/g'))
146 PERLNV_MANIFESTS = $(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER//')
147 else
148 NOPERL_MANIFESTS = $(UNVERSIONED_MANIFESTS)
149 endif
151 # Look for manifests which need to be duplicated for each version of ruby.
152 # NOPERL_MANIFESTS represents the manifests that are not Python or
153 # Perl manifests. Extract the Ruby Manifests from NOPERL_MANIFESTS.
154 # Any remaining manifests are stored in NONRUBY_MANIFESTS
155 ifeq ($(findstring -RUBYVER,$(NOPERL_MANIFESTS)),-RUBYVER)
156 NORUBY_MANIFESTS = $(filter-out %GENFRAG.p5m,\
157 $(filter-out %-RUBYVER.p5m,$(NOPERL_MANIFESTS)))
158 RUBY_MANIFESTS = $(filter %-RUBYVER.p5m,$(NOPERL_MANIFESTS))
159 RUBYV_MANIFESTS = $(foreach v,$(shell echo $(RUBY_VERSIONS)),\
160 $(shell echo $(RUBY_MANIFESTS) |\
161 sed -e 's/-RUBYVER.p5m/-$(shell echo $(v) |\
162 cut -d. -f1,2 | tr -d .).p5m/g'))
163 RUBYNV_MANIFESTS = $(shell echo $(RUBY_MANIFESTS) | sed -e 's/-RUBYVER//')
164 else
165 NORUBY_MANIFESTS = $(NOPERL_MANIFESTS)
166 endif
168 VERSIONED_MANIFESTS = \
169 $(PYV_MANIFESTS) $(PYNV_MANIFESTS) \
170 $(PERLV_MANIFESTS) $(PERLNV_MANIFESTS) \
171 $(RUBYV_MANIFESTS) $(RUBYNV_MANIFESTS) \
172 $(NORUBY_MANIFESTS) $(HISTORICAL_MANIFESTS)
174 GENERATED = $(MANIFEST_BASE)-generated
175 COMBINED = $(MANIFEST_BASE)-combined
176 MANIFESTS = $(VERSIONED_MANIFESTS:%=$(MANIFEST_BASE)-%)
179 DEPENDED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend)
180 RESOLVED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend.res)
181 PRE_PUBLISHED=$(RESOLVED:%.depend.res=%.pre-published)
182 PUBLISHED=$(RESOLVED:%.depend.res=%.published)
184 COPYRIGHT_FILE ?= $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
185 IPS_COMPONENT_VERSION ?= $(COMPONENT_VERSION)
187 .DEFAULT: publish
189 .SECONDARY:
191 # allow publishing to be overridden, such as when
192 # a package is for one architecture only.
193 PRE_PUBLISH_STAMP ?= $(BUILD_DIR)/.pre-published-$(MACH)
194 PUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH)
196 # Do all that is needed to ensure the package is consistent for publishing,
197 # except actually pushing to a repo, separately from the push to the repo.
198 pre-publish: build install $(PRE_PUBLISH_STAMP)
199 publish: pre-publish $(PUBLISH_STAMP)
201 sample-manifest: $(GENERATED).p5m
203 $(GENERATED).p5m: install
204 [ ! -d $(SAMPLE_MANIFEST_DIR) ] && $(MKDIR) $(SAMPLE_MANIFEST_DIR) || true
205 $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
206 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
207 sed -e '/^$$/d' -e '/^#.*$$/d' -e '/^dir .*$$/d' \
208 -e '/\.la$$/d' -e '/\.pyo$$/d' -e '/usr\/lib\/python[23]\..*\.pyc$$/d' \
209 -e '/.*\/__pycache__\/.*/d' | \
210 $(PKGFMT) | \
211 cat $(METADATA_TEMPLATE) - | \
212 $(TEE) $@ $(SAMPLE_MANIFEST_FILE) >/dev/null
214 # copy the canonical manifest(s) to the build tree
215 $(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
216 cat $(METADATA_TEMPLATE) $< >$@
218 # The text of a transform that will emit a dependency conditional on the
219 # presence of a particular version of a runtime, which will then draw in the
220 # runtime-version-specific version of the package we're operating on. $(1) is
221 # the name of the runtime package, and $(2) is the version suffix.
222 mkgeneric = \
223 echo "<transform set name=pkg.fmri value=(?:pkg:/)?(.+)-\#\#\#@(.*)" \
224 "-> emit depend nodrop=true type=conditional" \
225 "predicate=$(1)-$(2) fmri=%<1>-$(2)@%<2>>" >> $@;
227 # Define and execute a macro that generates a rule to create a manifest for a
228 # python module specific to a particular version of the python runtime.
229 define python-manifest-rule
230 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PYVER.p5m
231 $(PKGMOGRIFY) -D PYVER=$(1) -D PYV=$(shell echo $(1) | tr -d .) $$< > $$@
232 endef
233 $(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-manifest-rule,$(ver))))
235 # A rule to create a helper transform package for python, that will insert the
236 # appropriate conditional dependencies into a python library's
237 # runtime-version-generic package to pull in the version-specific bits when the
238 # corresponding version of python is on the system.
239 $(BUILD_DIR)/mkgeneric-python: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
240 $(RM) $@
241 $(foreach ver,$(shell echo $(PYTHON_VERSIONS) | tr -d .), \
242 $(call mkgeneric,runtime/python,$(ver)))
244 # Build Python version-wrapping manifests from the generic version.
245 $(MANIFEST_BASE)-%.p5m: %-PYVER.p5m $(BUILD_DIR)/mkgeneric-python
246 $(PKGMOGRIFY) -D PYV=### $(BUILD_DIR)/mkgeneric-python \
247 $(WS_TOP)/transforms/mkgeneric $< > $@
248 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
250 # Define and execute a macro that generates a rule to create a manifest for a
251 # perl module specific to a particular version of the perl runtime.
252 define perl-manifest-rule
253 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PERLVER.p5m
254 $(PKGMOGRIFY) -D PERLVER=$(1) -D PLV=$(shell echo $(1) | tr -d .) \
255 -D PERL_ARCH=$(call PERL_ARCH_FUNC,$(PERL.$(1))) $$< > $$@
256 endef
257 $(foreach ver,$(PERL_VERSIONS),$(eval $(call perl-manifest-rule,$(ver))))
259 # A rule to create a helper transform package for perl, that will insert the
260 # appropriate conditional dependencies into a perl library's
261 # runtime-version-generic package to pull in the version-specific bits when the
262 # corresponding version of perl is on the system.
263 $(BUILD_DIR)/mkgeneric-perl: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
264 $(RM) $@
265 $(foreach ver,$(shell echo $(PERL_VERSIONS) | tr -d .), \
266 $(call mkgeneric,runtime/perl,$(ver)))
268 # Build Perl version-wrapping manifests from the generic version.
269 $(MANIFEST_BASE)-%.p5m: %-PERLVER.p5m $(BUILD_DIR)/mkgeneric-perl
270 $(PKGMOGRIFY) -D PLV=### $(BUILD_DIR)/mkgeneric-perl \
271 $(WS_TOP)/transforms/mkgeneric $< > $@
272 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
274 # Rule to generate historical manifests from the $(HISTORY) file.
275 define history-manifest-rule
276 $(MANIFEST_BASE)-$(1): $(HISTORY) $(BUILD_DIR)
277 $(NAWK) -v TARGET=$(1) -v FUNCTION=manifest -f $(GENERATE_HISTORY) < \
278 $(HISTORY) > $$@
279 endef
280 $(foreach mfst,$(HISTORICAL_MANIFESTS),$(eval $(call history-manifest-rule,$(mfst))))
282 # Define and execute a macro that generates a rule to create a manifest for a
283 # ruby module specific to a particular version of the ruby runtime.
284 # Creates build/manifest-*-modulename-##.p5m file where ## is replaced with
285 # the version number.
286 define ruby-manifest-rule
287 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: \
288 PKG_MACROS += RUBY_VERSION=$(1) RUBY_LIB_VERSION=$(2) \
289 RUBYV=$(subst .,,$(1))
291 $(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-RUBYVER.p5m
292 if [ -f $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m ]; then \
293 cat $$*-$(shell echo $(1) | tr -d .)GENFRAG.p5m >> $$@; \
295 $(PKGMOGRIFY) -D RUBY_VERSION=$(1) -D RUBY_LIB_VERSION=$(2) \
296 -D RUBYV=$(shell echo $(1) | tr -d .) $$< > $$@
297 endef
298 $(foreach ver,$(RUBY_VERSIONS),\
299 $(eval $(call ruby-manifest-rule,$(shell echo $(ver) | \
300 cut -d. -f1,2),$(ver))))
302 # A rule to create a helper transform package for ruby, that will insert the
303 # appropriate conditional dependencies into a ruby library's
304 # runtime-version-generic package to pull in the version-specific bits when the
305 # corresponding version of ruby is on the system.
306 $(BUILD_DIR)/mkgeneric-ruby: $(WS_TOP)/make-rules/shared-macros.mk $(MAKEFILE_PREREQ)
307 $(RM) $@
308 $(foreach ver,$(RUBY_VERSIONS),\
309 $(call mkgeneric,runtime/ruby,$(shell echo $(ver) | \
310 cut -d. -f1,2 | tr -d .)))
312 # Build Ruby version-wrapping manifests from the generic version.
313 # Creates build/manifest-*-modulename.p5m file.
315 $(MANIFEST_BASE)-%.p5m: %-RUBYVER.p5m $(BUILD_DIR)/mkgeneric-ruby
316 $(PKGMOGRIFY) -D RUBYV=### $(BUILD_DIR)/mkgeneric-ruby \
317 $(WS_TOP)/transforms/mkgeneric $< > $@
318 if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
320 ifeq ($(strip $(COMPONENT_AUTOGEN_MANIFEST)),yes)
321 # auto-generate file/directory list
322 $(MANIFEST_BASE)-%.generated: %.p5m $(BUILD_DIR)
323 (cat $(METADATA_TEMPLATE); \
324 $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR)) | \
325 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(AUTOGEN_MANIFEST_TRANSFORMS) | \
326 sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
327 cat $< - >$@
329 # mogrify non-parameterized manifests
330 $(MANIFEST_BASE)-%.mogrified: %.generated
331 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
332 $(PUBLISH_TRANSFORMS) | \
333 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
335 # mogrify parameterized manifests
336 $(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.generated
337 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
338 $(PUBLISH_TRANSFORMS) | \
339 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
340 else
341 # mogrify non-parameterized manifests
342 $(MANIFEST_BASE)-%.mogrified: %.p5m $(BUILD_DIR)
343 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
344 $(PUBLISH_TRANSFORMS) | \
345 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
347 # mogrify parameterized manifests
348 $(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.p5m $(BUILD_DIR)
349 $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
350 $(PUBLISH_TRANSFORMS) | \
351 sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
352 endif
354 $(BUILD_DIR):
355 $(MKDIR) $@
357 # generate dependencies
358 PKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
359 $(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mogrified
360 $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
362 # These files should contain a list of packages that the component is known to
363 # depend on. Using resolve.deps is not required, but significantly speeds up
364 # the "pkg resolve" step.
365 # XXX existing pkg5 is too old for that
366 #EXTDEPFILES = $(wildcard $(sort $(addsuffix ../resolve.deps, $(dir $(DEPENDED)))))
368 # This is a target that should only be run by hand, and not something that
369 # .resolved-$(MACH) should depend on.
370 sample-resolve.deps:
371 echo "<transform depend type=(require|require-any) -> print %(fmri)>" > rd-trans
372 for i in build/*.depend; do \
373 $(PKGMOGRIFY) -O /dev/null $$i rd-trans | tr " " "\n" | sort -u > m1; \
374 $(PKGMOGRIFY) -O /dev/null $$i.res rd-trans | tr " " "\n" | sort -u > m2; \
375 comm -13 m1 m2; \
376 done | sed -e 's/@[^ ]*//g' -e 's,pkg:/,,g' | sort -u > resolve.deps
377 $(RM) rd-trans m1 m2
378 if [[ ! -s resolve.deps ]]; then \
379 echo "No computed dependencies found; removing empty resolve.deps."; \
380 $(RM) resolve.deps; \
384 # resolve the dependencies all at once
385 $(BUILD_DIR)/.resolved-$(MACH): $(DEPENDED)
386 $(PKGDEPEND) resolve $(EXTDEPFILES:%=-e %) -m $(DEPENDED)
387 $(TOUCH) $@
390 # Generate a set of REQUIRED_PACKAGES based on what is needed to for pkgdepend
391 # to resolve properly. Automatically append this to your Makefile for the truly
392 # lazy among us. This is only a piece of the REQUIRED_PACKAGES puzzle.
393 # You must still include packages for tools you build and test with.
395 REQUIRED_PACKAGES:: $(RESOLVED)
396 $(GMAKE) RESOLVE_DEPS= $(BUILD_DIR)/.resolved-$(MACH)
397 @echo "# Auto-generated contents below. Please manually verify and remove this comment" >>Makefile
398 @$(PKGMOGRIFY) $(WS_TRANSFORMS)/$@ $(RESOLVED) | \
399 $(GSED) -e '/^[\t ]*$$/d' -e '/^#/d' | sort -u >>Makefile
400 @echo "*** Please edit your Makefile and verify the new content at the end ***"
403 # lint the manifests all at once
404 $(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH)
405 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
406 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
407 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
408 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
409 $(TOUCH) $@
411 lintme: FRC
412 @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
413 $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)" $(COMPONENT_PKGLINT_ENV)\
414 $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
415 -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
417 FRC:
420 # published
421 PKGSEND_PUBLISH_OPTIONS = -s $(WS_REPO) publish --fmri-in-manifest
422 PKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
423 PKGSEND_PUBLISH_OPTIONS += -T \*.py
425 # Do all the hard work that is needed to ensure the package is consistent
426 # and ready for publishing, except actually pushing bits to a repository
427 $(MANIFEST_BASE)-%.pre-published: $(MANIFEST_BASE)-%.depend.res $(BUILD_DIR)/.linted-$(MACH)
428 $(CP) $< $@
429 @echo "NEW PACKAGE CONTENTS ARE LOCALLY VALIDATED AND READY TO GO"
431 # Push to the repo
432 $(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.pre-published
433 $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
434 $(PKGFMT) <$< >$@
436 $(BUILD_DIR)/.pre-published-$(MACH): $(PRE_PUBLISHED)
437 $(TOUCH) $@
439 $(BUILD_DIR)/.published-$(MACH): $(PUBLISHED)
440 $(TOUCH) $@
442 print-package-names: canonical-manifests
443 @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
444 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
445 sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
447 print-package-paths: canonical-manifests
448 @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
449 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
450 sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
452 install-packages: publish
453 @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
454 cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
455 $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
456 sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
457 (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
458 else ; \
459 echo "unsafe to install package(s) automatically" ; \
462 $(RESOLVED): install
464 canonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
465 ifeq ($(strip $(CANONICAL_MANIFESTS)),)
466 # If there were no canonical manifests in the workspace, nothing will
467 # be published and we should fail. A sample manifest can be generated
468 # with
469 # $ gmake sample-manifest
470 # Once created, it will need to be reviewed, edited, and added to the
471 # workspace.
472 $(error Missing canonical manifest(s))
473 endif
475 # This converts required paths to containing package names for be able to
476 # properly setup the build environment for a component.
477 required-pkgs.mk: Makefile
478 @echo "generating $@ from Makefile REQUIRED_* data"
479 @pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \
480 | sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@
482 pre-prep: required-pkgs.mk
485 CLEAN_PATHS += required-pkgs.mk
486 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-perl
487 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-python
488 CLEAN_PATHS += $(BUILD_DIR)/mkgeneric-ruby