ips.mk revision 2337
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2337N/A# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
2N/A#
2N/A
2N/A#
2N/A# Rules and Macros for generating an IPS package manifest and publishing an
2N/A# IPS package to a pkg depot.
2N/A#
2N/A# To use these rules, include ../make-rules/ips.mk in your Makefile
2N/A# and define an "install" target appropriate to building your component.
2N/A# Ex:
2N/A#
59N/A# install: $(BUILD_DIR)/build/$(MACH32)/.installed \
59N/A# $(BUILD_DIR)/build/$(MACH64)/.installed
2N/A#
2N/A# This set of rules makes the "publish" target the default target for make(1)
2N/A#
2N/A
26N/APKGDEPEND = /usr/bin/pkgdepend
26N/APKGFMT = /usr/bin/pkgfmt
2N/APKGMOGRIFY = /usr/bin/pkgmogrify
26N/APKGSEND = /usr/bin/pkgsend
2238N/Aifeq ($(strip $(PKGLINT_COMPONENT)),)
38N/APKGLINT = /usr/bin/pkglint
2238N/Aelse
2238N/APKGLINT = ${WS_TOOLS}/pkglint
2238N/Aendif
181N/APKGMANGLE = $(WS_TOOLS)/userland-mangler
26N/A
26N/A# Package headers should all pretty much follow the same format
26N/AMETADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template
26N/ACOPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template
26N/A
26N/A# order is important
26N/AGENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
26N/A
700N/APKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/libtool-drop
700N/A
26N/ACOMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup
26N/ACOMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
26N/A
1574N/ALICENSE_TRANSFORMS = $(WS_TOP)/transforms/license-changes
1574N/A
26N/A# order is important
1574N/APUBLISH_TRANSFORMS += $(LICENSE_TRANSFORMS)
151N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/variant-cleanup
206N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/autopyc
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/actuators
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/devel
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/docs
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/locale
26N/APUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup
2N/A
26N/APKG_MACROS += MACH=$(MACH)
26N/APKG_MACROS += MACH32=$(MACH32)
26N/APKG_MACROS += MACH64=$(MACH64)
26N/APKG_MACROS += PUBLISHER=$(PUBLISHER)
883N/APKG_MACROS += PUBLISHER_LOCALIZABLE=$(PUBLISHER_LOCALIZABLE)
26N/APKG_MACROS += CONSOLIDATION=$(CONSOLIDATION)
26N/APKG_MACROS += BUILD_VERSION=$(BUILD_VERSION)
26N/APKG_MACROS += SOLARIS_VERSION=$(SOLARIS_VERSION)
26N/APKG_MACROS += OS_VERSION=$(OS_VERSION)
586N/APKG_MACROS += HUMAN_VERSION=$(HUMAN_VERSION)
26N/APKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
93N/APKG_MACROS += COMPONENT_VERSION=$(COMPONENT_VERSION)
166N/APKG_MACROS += COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL)
26N/APKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
379N/APKG_MACROS += COMPONENT_HG_URL=$(COMPONENT_HG_URL)
379N/APKG_MACROS += COMPONENT_HG_REV=$(COMPONENT_HG_REV)
1574N/APKG_MACROS += COMPONENT_NAME=$(COMPONENT_NAME)
1574N/APKG_MACROS += TPNO=$(TPNO)
2271N/APKG_MACROS += PYTHON_2.6_ONLY=\#
2271N/APKG_MACROS += PYTHON_2.7_ONLY=\#
2N/A
26N/APKG_OPTIONS += $(PKG_MACROS:%=-D %)
26N/A
181N/AMANGLED_DIR = $(PROTO_DIR)/mangled
181N/A
181N/APKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
99N/A
59N/AMANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
12N/A
30N/ACANONICAL_MANIFESTS = $(wildcard *.p5m)
1622N/A
1622N/A# Look for manifests which need to be duplicated for each version of python.
1622N/Aifeq ($(findstring -PYVER,$(CANONICAL_MANIFESTS)),-PYVER)
1622N/AUNVERSIONED_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PYVER.p5m,$(CANONICAL_MANIFESTS)))
1622N/APY_MANIFESTS = $(filter %-PYVER.p5m,$(CANONICAL_MANIFESTS))
1622N/APYV_MANIFESTS = $(foreach v,$(shell echo $(PYTHON_VERSIONS) | tr -d .),$(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER.p5m/-$(v).p5m/g'))
1622N/APYNV_MANIFESTS = $(shell echo $(PY_MANIFESTS) | sed -e 's/-PYVER//')
1622N/Aelse
1622N/AUNVERSIONED_MANIFESTS = $(CANONICAL_MANIFESTS)
1622N/Aendif
1622N/A
1622N/A# Look for manifests which need to be duplicated for each version of perl.
1622N/Aifeq ($(findstring -PERLVER,$(UNVERSIONED_MANIFESTS)),-PERLVER)
1622N/ANOPERL_MANIFESTS = $(filter-out %-GENFRAG.p5m,$(filter-out %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS)))
1622N/APERL_MANIFESTS = $(filter %-PERLVER.p5m,$(UNVERSIONED_MANIFESTS))
1622N/APERLV_MANIFESTS = $(foreach v,$(shell echo $(PERL_VERSIONS) | tr -d .),$(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER.p5m/-$(v).p5m/g'))
1622N/APERLNV_MANIFESTS = $(shell echo $(PERL_MANIFESTS) | sed -e 's/-PERLVER//')
1622N/Aelse
1622N/ANOPERL_MANIFESTS = $(UNVERSIONED_MANIFESTS)
1622N/Aendif
1622N/A
1622N/AVERSIONED_MANIFESTS = \
1622N/A $(PYV_MANIFESTS) $(PYNV_MANIFESTS) \
1622N/A $(PERLV_MANIFESTS) $(PERLNV_MANIFESTS) \
1622N/A $(NOPERL_MANIFESTS)
1622N/A
26N/AGENERATED = $(MANIFEST_BASE)-generated
26N/ACOMBINED = $(MANIFEST_BASE)-combined
1622N/AMANIFESTS = $(VERSIONED_MANIFESTS:%=$(MANIFEST_BASE)-%)
2N/A
26N/A
1622N/ADEPENDED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend)
1622N/ARESOLVED=$(VERSIONED_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend.res)
185N/APUBLISHED=$(RESOLVED:%.depend.res=%.published)
2N/A
255N/ACOPYRIGHT_FILE ?= $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
145N/AIPS_COMPONENT_VERSION ?= $(COMPONENT_VERSION)
7N/A
26N/A.DEFAULT: publish
26N/A
38N/A.SECONDARY:
26N/A
197N/A# allow publishing to be overridden, such as when
197N/A# a package is for one architecture only.
197N/APUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH)
197N/A
197N/Apublish: build install $(PUBLISH_STAMP)
26N/A
30N/Asample-manifest: $(GENERATED).p5m
26N/A
46N/A$(GENERATED).p5m: install
46N/A $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
46N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
64N/A sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
64N/A cat $(METADATA_TEMPLATE) - >$@
26N/A
46N/A# copy the canonical manifest(s) to the build tree
46N/A$(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
46N/A cat $(METADATA_TEMPLATE) $< >$@
2N/A
1622N/A# The text of a transform that will emit a dependency conditional on the
1622N/A# presence of a particular version of a runtime, which will then draw in the
1622N/A# runtime-version-specific version of the package we're operating on. $(1) is
1622N/A# the name of the runtime package, and $(2) is the version suffix.
1622N/Amkgeneric = \
1622N/A echo "<transform set name=pkg.fmri value=(?:pkg:/)?(.+)-\#\#\#@(.*)" \
1622N/A "-> emit depend nodrop=true type=conditional" \
1622N/A "predicate=$(1)-$(2) fmri=%<1>-$(2)@%<2>>" >> $@;
1622N/A
1622N/A# Define and execute a macro that generates a rule to create a manifest for a
1622N/A# python module specific to a particular version of the python runtime.
1622N/Adefine python-manifest-rule
2271N/A$(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).mogrified: PKG_MACROS += PYTHON_$(1)_ONLY=
2271N/A
1622N/A$(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PYVER.p5m
1622N/A $(PKGMOGRIFY) -D PYVER=$(1) -D PYV=$(shell echo $(1) | tr -d .) $$< > $$@
1622N/Aendef
1622N/A$(foreach ver,$(PYTHON_VERSIONS),$(eval $(call python-manifest-rule,$(ver))))
1622N/A
1622N/A# A rule to create a helper transform package for python, that will insert the
1622N/A# appropriate conditional dependencies into a python library's
1622N/A# runtime-version-generic package to pull in the version-specific bits when the
1622N/A# corresponding version of python is on the system.
1948N/A$(BUILD_DIR)/mkgeneric-python: $(WS_TOP)/make-rules/shared-macros.mk
1622N/A $(RM) $@
1622N/A $(foreach ver,$(shell echo $(PYTHON_VERSIONS) | tr -d .), \
1622N/A $(call mkgeneric,runtime/python,$(ver)))
1622N/A
1622N/A# Build Python version-wrapping manifests from the generic version.
1948N/A$(MANIFEST_BASE)-%.p5m: %-PYVER.p5m $(BUILD_DIR)/mkgeneric-python
1948N/A $(PKGMOGRIFY) -D PYV=### $(BUILD_DIR)/mkgeneric-python \
1622N/A $(WS_TOP)/transforms/mkgeneric $< > $@
1622N/A if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
1622N/A
1622N/A# Define and execute a macro that generates a rule to create a manifest for a
1622N/A# perl module specific to a particular version of the perl runtime.
1622N/Adefine perl-manifest-rule
1622N/A$(MANIFEST_BASE)-%-$(shell echo $(1) | tr -d .).p5m: %-PERLVER.p5m
1622N/A $(PKGMOGRIFY) -D PERLVER=$(1) -D PLV=$(shell echo $(1) | tr -d .) \
1622N/A -D PERL_ARCH=$(call PERL_ARCH_FUNC,$(PERL.$(1))) $$< > $$@
1622N/Aendef
1622N/A$(foreach ver,$(PERL_VERSIONS),$(eval $(call perl-manifest-rule,$(ver))))
1622N/A
1622N/A# A rule to create a helper transform package for perl, that will insert the
1622N/A# appropriate conditional dependencies into a perl library's
1622N/A# runtime-version-generic package to pull in the version-specific bits when the
1622N/A# corresponding version of perl is on the system.
1948N/A$(BUILD_DIR)/mkgeneric-perl: $(WS_TOP)/make-rules/shared-macros.mk
1622N/A $(RM) $@
1622N/A $(foreach ver,$(shell echo $(PERL_VERSIONS) | tr -d .), \
1622N/A $(call mkgeneric,runtime/perl,$(ver)))
1622N/A
1622N/A# Build Perl version-wrapping manifests from the generic version.
1948N/A$(MANIFEST_BASE)-%.p5m: %-PERLVER.p5m $(BUILD_DIR)/mkgeneric-perl
1948N/A $(PKGMOGRIFY) -D PLV=### $(BUILD_DIR)/mkgeneric-perl \
1622N/A $(WS_TOP)/transforms/mkgeneric $< > $@
1622N/A if [ -f $*-GENFRAG.p5m ]; then cat $*-GENFRAG.p5m >> $@; fi
1622N/A
1622N/A# mogrify non-parameterized manifests
1622N/A$(MANIFEST_BASE)-%.mogrified: %.p5m $(BUILD_DIR)
1622N/A $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
1622N/A $(PUBLISH_TRANSFORMS) | \
1622N/A sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
1622N/A
1622N/A# mogrify parameterized manifests
1622N/A$(MANIFEST_BASE)-%.mogrified: $(MANIFEST_BASE)-%.p5m $(BUILD_DIR)
53N/A $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
46N/A $(PUBLISH_TRANSFORMS) | \
46N/A sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
26N/A
181N/A# mangle the file contents
369N/A$(BUILD_DIR) $(MANGLED_DIR):
181N/A $(MKDIR) $@
181N/A
181N/APKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %)
181N/A$(MANIFEST_BASE)-%.mangled: $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR)
181N/A $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@
181N/A
76N/A# generate dependencies
99N/APKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
181N/A$(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mangled
99N/A $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
26N/A
1640N/A# These files should contain a list of packages that the component is known to
1640N/A# depend on. Using resolve.deps is not required, but significantly speeds up
1640N/A# the "pkg resolve" step.
2238N/AEXTDEPFILES ?= $(wildcard $(sort $(addsuffix ../resolve.deps, $(dir $(DEPENDED)))))
2238N/A
2238N/A# If the package contains no automatically discoverable dependencies, then
2238N/A# we can speed up resolution by providing a dummy resolve.deps to skip loading
2238N/A# all the possible packages for resolution. Unfortunately, pkgdepend does not
2238N/A# accept a completely empty resolve.deps, so we pass the userland-incorporation
2238N/A# as a quick, content-free placeholder.
2238N/ANULLDEPFILE = $(BUILD_DIR)/null-resolve.deps
1640N/A
1640N/A# This is a target that should only be run by hand, and not something that
1640N/A# .resolved-$(MACH) should depend on.
1640N/Asample-resolve.deps:
1640N/A @echo "<transform depend type=(require|require-any) -> print %(fmri)>" > rd-trans
1640N/A @for i in build/*.depend; do \
1640N/A $(PKGMOGRIFY) -O /dev/null $$i rd-trans | tr " " "\n" | sort -u > m1; \
1640N/A $(PKGMOGRIFY) -O /dev/null $$i.res rd-trans | tr " " "\n" | sort -u > m2; \
1640N/A comm -13 m1 m2; \
1640N/A done | sed -e 's/@[^ ]*//g' -e 's,pkg:/,,g' | sort -u > resolve.deps
1640N/A @$(RM) rd-trans m1 m2
1640N/A @if [[ ! -s resolve.deps ]]; then \
1640N/A echo "No computed dependencies found; removing empty resolve.deps."; \
1640N/A $(RM) resolve.deps; \
1640N/A fi
1640N/A
185N/A# resolve the dependencies all at once
185N/A$(BUILD_DIR)/.resolved-$(MACH): $(DEPENDED)
2238N/A if [[ "$(EXTDEPFILES)" == "$(NULLDEPFILE)" ]] ; then \
2238N/A echo 'consolidation/userland/userland-incorporation' > $(NULLDEPFILE) ; \
2238N/A fi
1640N/A $(PKGDEPEND) resolve $(EXTDEPFILES:%=-e %) -m $(DEPENDED)
145N/A $(TOUCH) $@
145N/A
145N/A# lint the manifests all at once
145N/A$(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH)
145N/A @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
117N/A $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)"\
84N/A $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
145N/A -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
145N/A $(TOUCH) $@
145N/A
2337N/Alintme: FRC
2337N/A @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
2337N/A $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)"\
2337N/A $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
2337N/A -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
2337N/A
2337N/AFRC:
2337N/A
38N/A
46N/A# published
99N/APKGSEND_PUBLISH_OPTIONS = -s $(PKG_REPO) publish --fmri-in-manifest
1900N/APKGSEND_PUBLISH_OPTIONS += --no-catalog
99N/APKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
196N/APKGSEND_PUBLISH_OPTIONS += -T \*.py
185N/A$(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.depend.res $(BUILD_DIR)/.linted-$(MACH)
99N/A $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
46N/A $(PKGFMT) <$< >$@
2N/A
145N/A$(BUILD_DIR)/.published-$(MACH): $(PUBLISHED)
1900N/Aifndef DISABLE_IPS_CATALOG_AND_INDEX_UPDATES
1900N/A $(PKGREPO) refresh -s $(PKG_REPO)
1900N/Aendif
26N/A $(TOUCH) $@
2N/A
32N/Aprint-package-names: canonical-manifests
1622N/A @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
32N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
32N/A sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
32N/A
32N/Aprint-package-paths: canonical-manifests
1622N/A @cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
32N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
32N/A sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
32N/A
38N/Ainstall-packages: publish
38N/A @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
1622N/A cat $(VERSIONED_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
38N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
38N/A sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
38N/A (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
38N/A else ; \
38N/A echo "unsafe to install package(s) automatically" ; \
38N/A fi
38N/A
145N/A$(RESOLVED): install
38N/A
38N/Acanonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
26N/Aifeq ($(strip $(CANONICAL_MANIFESTS)),)
26N/A # If there were no canonical manifests in the workspace, nothing will
26N/A # be published and we should fail. A sample manifest can be generated
26N/A # with
26N/A # $ gmake sample-manifest
26N/A # Once created, it will need to be reviewed, edited, and added to the
26N/A # workspace.
26N/A $(error Missing canonical manifest(s))
26N/Aendif
32N/A
32N/A# This converts required paths to containing package names for be able to
32N/A# properly setup the build environment for a component.
32N/Arequired-pkgs.mk: Makefile
32N/A @echo "generating $@ from Makefile REQUIRED_* data"
32N/A @pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \
32N/A | sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@
32N/A
38N/Apre-prep: required-pkgs.mk
38N/A
38N/A
32N/ACLEAN_PATHS += required-pkgs.mk