ips.mk revision 181
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#
59N/A# Copyright (c) 2010, 2011, 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
38N/APKGLINT = /usr/bin/pkglint
26N/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
26N/ACOMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup
26N/ACOMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
26N/A
26N/A# order is important
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/variant-cleanup
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
2N/APUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
26N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup
26N/A
26N/APKG_MACROS += MACH=$(MACH)
26N/APKG_MACROS += MACH32=$(MACH32)
26N/APKG_MACROS += MACH64=$(MACH64)
26N/APKG_MACROS += PUBLISHER=$(PUBLISHER)
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)
26N/APKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
2N/APKG_MACROS += COMPONENT_VERSION=$(COMPONENT_VERSION)
26N/APKG_MACROS += COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL)
26N/APKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
59N/A
12N/APKG_OPTIONS += $(PKG_MACROS:%=-D %)
30N/A
26N/AMANGLED_DIR = $(PROTO_DIR)/mangled
26N/A
26N/APKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
2N/A
26N/AMANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
30N/A
26N/ACANONICAL_MANIFESTS = $(wildcard *.p5m)
2N/AGENERATED = $(MANIFEST_BASE)-generated
7N/ACOMBINED = $(MANIFEST_BASE)-combined
27N/AMANIFESTS = $(CANONICAL_MANIFESTS:%=$(MANIFEST_BASE)-%)
27N/A
27N/A
21N/ARESOLVED=$(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.resolved)
7N/APUBLISHED=$(RESOLVED:%.resolved=%.published)
26N/A
26N/ACOPYRIGHT_FILE = $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
38N/AIPS_COMPONENT_VERSION ?= $(COMPONENT_VERSION)
26N/A
59N/A.DEFAULT: publish
26N/A
30N/A.SECONDARY:
26N/A
46N/Apublish: build install $(BUILD_DIR)/.published-$(MACH)
46N/A
46N/Asample-manifest: $(GENERATED).p5m
64N/A
64N/A$(GENERATED).p5m: install
26N/A $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
46N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
46N/A sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
46N/A cat $(METADATA_TEMPLATE) - >$@
2N/A
46N/A# copy the canonical manifest(s) to the build tree
53N/A$(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
53N/A cat $(METADATA_TEMPLATE) $< >$@
46N/A
46N/A# mogrify the manifest
26N/A$(MANIFEST_BASE)-%.mogrified: %.p5m canonical-manifests
76N/A $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
46N/A $(PUBLISH_TRANSFORMS) | \
53N/A sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
26N/A
46N/A# mangle the file contents
46N/A$(MANGLED_DIR):
46N/A $(MKDIR) $@
53N/A
46N/APKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %)
53N/A$(MANIFEST_BASE)-%.mangled: $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR)
53N/A $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@
2N/A
46N/A# generate dependencies
38N/APKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
46N/A$(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mangled
53N/A $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
70N/A
53N/A# resolve dependencies, prepend the mogrified manifest, less the unresolved
46N/A# dependencies to the result.
38N/A$(MANIFEST_BASE)-%.resolved: $(MANIFEST_BASE)-%.depend
46N/A ($(PKGMOGRIFY) $(@:%.resolved=%.mogrified) \
46N/A $(WS_TOP)/transforms/drop-unresolved-dependencies | \
26N/A sed -e '/^$$/d' -e '/^#.*$$/d' ; \
48N/A $(PKGDEPEND) resolve -o $< | sed -e '1d') | uniq >$@
46N/A
2N/A$(BUILD_DIR)/.resolved-$(MACH): $(RESOLVED)
59N/A $(TOUCH) $@
26N/A
2N/A# lint the manifests all at once
32N/A$(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH)
32N/A @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
32N/A $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)"\
32N/A $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
32N/A -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
32N/A $(TOUCH) $@
32N/A
32N/A
32N/A# published
32N/APKGSEND_PUBLISH_OPTIONS = -s $(PKG_REPO) publish --fmri-in-manifest
38N/APKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
38N/A$(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.resolved $(BUILD_DIR)/.linted-$(MACH)
38N/A $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
38N/A $(PKGFMT) <$< >$@
38N/A
38N/A$(BUILD_DIR)/.published-$(MACH): $(PUBLISHED)
38N/A $(TOUCH) $@
38N/A
38N/Aprint-package-names: canonical-manifests
38N/A @cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
38N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
38N/A sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
38N/A
26N/Aprint-package-paths: canonical-manifests
26N/A @cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
26N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
26N/A sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
26N/A
26N/Ainstall-packages: publish
26N/A @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
26N/A cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
26N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
32N/A sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
32N/A (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
32N/A else ; \
32N/A echo "unsafe to install package(s) automatically" ; \
32N/A fi
32N/A
32N/A$(RESOLVED): install
32N/A
38N/Acanonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
38N/Aifeq ($(strip $(CANONICAL_MANIFESTS)),)
38N/A # If there were no canonical manifests in the workspace, nothing will
32N/A # be published and we should fail. A sample manifest can be generated
# with
# $ gmake sample-manifest
# Once created, it will need to be reviewed, edited, and added to the
# workspace.
$(error Missing canonical manifest(s))
endif
# This converts required paths to containing package names for be able to
# properly setup the build environment for a component.
required-pkgs.mk: Makefile
@echo "generating $@ from Makefile REQUIRED_* data"
@pkg search -H -l '<$(DEPENDS:%=% OR) /bin/true>' \
| sed -e 's/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@
pre-prep: required-pkgs.mk
CLEAN_PATHS += required-pkgs.mk