ips.mk revision 883
5911N/A#
5911N/A# CDDL HEADER START
5911N/A#
5911N/A# The contents of this file are subject to the terms of the
5911N/A# Common Development and Distribution License (the "License").
5911N/A# You may not use this file except in compliance with the License.
5911N/A#
5911N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5911N/A# or http://www.opensolaris.org/os/licensing.
5911N/A# See the License for the specific language governing permissions
5911N/A# and limitations under the License.
5911N/A#
5911N/A# When distributing Covered Code, include this CDDL HEADER in each
5911N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5911N/A# If applicable, add the following below this CDDL HEADER, with the
5911N/A# fields enclosed by brackets "[]" replaced with your own identifying
5911N/A# information: Portions Copyright [yyyy] [name of copyright owner]
5911N/A#
5911N/A# CDDL HEADER END
5911N/A#
5911N/A# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
5911N/A#
5911N/A
5911N/A#
5911N/A# Rules and Macros for generating an IPS package manifest and publishing an
5911N/A# IPS package to a pkg depot.
5911N/A#
5911N/A# To use these rules, include ../make-rules/ips.mk in your Makefile
5911N/A# and define an "install" target appropriate to building your component.
5911N/A# Ex:
5911N/A#
5911N/A# install: $(BUILD_DIR)/build/$(MACH32)/.installed \
5911N/A# $(BUILD_DIR)/build/$(MACH64)/.installed
5911N/A#
7395N/A# This set of rules makes the "publish" target the default target for make(1)
7395N/A#
5911N/A
5911N/APKGDEPEND = /usr/bin/pkgdepend
7395N/APKGFMT = /usr/bin/pkgfmt
6532N/APKGMOGRIFY = /usr/bin/pkgmogrify
5911N/APKGSEND = /usr/bin/pkgsend
5911N/APKGLINT = /usr/bin/pkglint
5911N/APKGMANGLE = $(WS_TOOLS)/userland-mangler
7391N/A
5911N/A# Package headers should all pretty much follow the same format
6552N/AMETADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template
6552N/ACOPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template
6552N/A
6552N/A# order is important
6552N/AGENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
5911N/A
5911N/APKGMOGRIFY_TRANSFORMS += $(WS_TOP)/transforms/libtool-drop
5911N/A
5911N/ACOMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup
6552N/ACOMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
5911N/A
5911N/A# order is important
5911N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/variant-cleanup
5911N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/autopyc
5911N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults
5911N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/actuators
5911N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/devel
5911N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/docs
5911N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/locale
6532N/APUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
6532N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup
6532N/A
5911N/APKG_MACROS += MACH=$(MACH)
5911N/APKG_MACROS += MACH32=$(MACH32)
5911N/APKG_MACROS += MACH64=$(MACH64)
6539N/APKG_MACROS += PUBLISHER=$(PUBLISHER)
5911N/APKG_MACROS += PUBLISHER_LOCALIZABLE=$(PUBLISHER_LOCALIZABLE)
5911N/APKG_MACROS += CONSOLIDATION=$(CONSOLIDATION)
5911N/APKG_MACROS += BUILD_VERSION=$(BUILD_VERSION)
5911N/APKG_MACROS += SOLARIS_VERSION=$(SOLARIS_VERSION)
5911N/APKG_MACROS += OS_VERSION=$(OS_VERSION)
5911N/APKG_MACROS += HUMAN_VERSION=$(HUMAN_VERSION)
5911N/APKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
5911N/APKG_MACROS += COMPONENT_VERSION=$(COMPONENT_VERSION)
5911N/APKG_MACROS += COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL)
5911N/APKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
5911N/APKG_MACROS += COMPONENT_HG_URL=$(COMPONENT_HG_URL)
5911N/APKG_MACROS += COMPONENT_HG_REV=$(COMPONENT_HG_REV)
5911N/A
5911N/APKG_OPTIONS += $(PKG_MACROS:%=-D %)
5911N/A
5911N/AMANGLED_DIR = $(PROTO_DIR)/mangled
5911N/A
5911N/APKG_PROTO_DIRS += $(MANGLED_DIR) $(PROTO_DIR) $(@D) $(COMPONENT_DIR) $(COMPONENT_SRC)
5911N/A
5911N/AMANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
5911N/A
5911N/ACANONICAL_MANIFESTS = $(wildcard *.p5m)
5911N/AGENERATED = $(MANIFEST_BASE)-generated
5911N/ACOMBINED = $(MANIFEST_BASE)-combined
5911N/AMANIFESTS = $(CANONICAL_MANIFESTS:%=$(MANIFEST_BASE)-%)
5911N/A
5911N/A
5911N/ADEPENDED=$(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend)
5911N/ARESOLVED=$(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.depend.res)
5911N/APUBLISHED=$(RESOLVED:%.depend.res=%.published)
5911N/A
5911N/ACOPYRIGHT_FILE ?= $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
5911N/AIPS_COMPONENT_VERSION ?= $(COMPONENT_VERSION)
5911N/A
5911N/A.DEFAULT: publish
5911N/A
5911N/A.SECONDARY:
6539N/A
5911N/A# allow publishing to be overridden, such as when
5911N/A# a package is for one architecture only.
5911N/APUBLISH_STAMP ?= $(BUILD_DIR)/.published-$(MACH)
5911N/A
5911N/Apublish: build install $(PUBLISH_STAMP)
5911N/A
5911N/Asample-manifest: $(GENERATED).p5m
5911N/A
5911N/A$(GENERATED).p5m: install
5911N/A $(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
5911N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
5911N/A sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
5911N/A cat $(METADATA_TEMPLATE) - >$@
5911N/A
5911N/A# copy the canonical manifest(s) to the build tree
5911N/A$(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
5911N/A cat $(METADATA_TEMPLATE) $< >$@
5911N/A
5911N/A# mogrify the manifest
5911N/A$(MANIFEST_BASE)-%.mogrified: %.p5m $(BUILD_DIR) canonical-manifests
5911N/A $(PKGMOGRIFY) $(PKG_OPTIONS) $< \
5911N/A $(PUBLISH_TRANSFORMS) | \
5911N/A sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
5911N/A
5911N/A# mangle the file contents
5911N/A$(BUILD_DIR) $(MANGLED_DIR):
5911N/A $(MKDIR) $@
6532N/A
5911N/APKGMANGLE_OPTIONS = -D $(MANGLED_DIR) $(PKG_PROTO_DIRS:%=-d %)
5911N/A$(MANIFEST_BASE)-%.mangled: $(MANIFEST_BASE)-%.mogrified $(MANGLED_DIR)
6539N/A $(PKGMANGLE) $(PKGMANGLE_OPTIONS) -m $< >$@
6539N/A
5911N/A# generate dependencies
5911N/APKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
5911N/A$(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mangled
6539N/A $(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
6539N/A
5911N/A# resolve the dependencies all at once
5911N/A$(BUILD_DIR)/.resolved-$(MACH): $(DEPENDED)
5911N/A $(PKGDEPEND) resolve -m $(DEPENDED)
5911N/A $(TOUCH) $@
6539N/A
5911N/A# lint the manifests all at once
5911N/A$(BUILD_DIR)/.linted-$(MACH): $(BUILD_DIR)/.resolved-$(MACH)
5911N/A @echo "VALIDATING MANIFEST CONTENT: $(RESOLVED)"
5911N/A $(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)"\
5911N/A $(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
5911N/A -f $(WS_TOOLS)/pkglintrc $(RESOLVED)
5911N/A $(TOUCH) $@
5911N/A
5911N/A
5911N/A# published
5911N/APKGSEND_PUBLISH_OPTIONS = -s $(PKG_REPO) publish --fmri-in-manifest
5911N/APKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
5911N/APKGSEND_PUBLISH_OPTIONS += -T \*.py
5911N/A$(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.depend.res $(BUILD_DIR)/.linted-$(MACH)
5911N/A $(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
5911N/A $(PKGFMT) <$< >$@
5911N/A
5911N/A$(BUILD_DIR)/.published-$(MACH): $(PUBLISHED)
5911N/A $(TOUCH) $@
5911N/A
5911N/Aprint-package-names: canonical-manifests
6539N/A @cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
6539N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
6539N/A sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
6539N/A
6539N/Aprint-package-paths: canonical-manifests
6539N/A @cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
6539N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
5911N/A sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
5911N/A
5911N/Ainstall-packages: publish
5911N/A @if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
5911N/A cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
5911N/A $(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
5911N/A sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
5911N/A (cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
5911N/A else ; \
5911N/A echo "unsafe to install package(s) automatically" ; \
5911N/A fi
5911N/A
5911N/A$(RESOLVED): install
5911N/A
6539N/Acanonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
5911N/Aifeq ($(strip $(CANONICAL_MANIFESTS)),)
5911N/A # If there were no canonical manifests in the workspace, nothing will
# 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