ips.mk revision 117
248N/A#
248N/A# CDDL HEADER START
248N/A#
248N/A# The contents of this file are subject to the terms of the
248N/A# Common Development and Distribution License (the "License").
248N/A# You may not use this file except in compliance with the License.
248N/A#
248N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
248N/A# or http://www.opensolaris.org/os/licensing.
248N/A# See the License for the specific language governing permissions
248N/A# and limitations under the License.
248N/A#
248N/A# When distributing Covered Code, include this CDDL HEADER in each
248N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
248N/A# If applicable, add the following below this CDDL HEADER, with the
248N/A# fields enclosed by brackets "[]" replaced with your own identifying
248N/A# information: Portions Copyright [yyyy] [name of copyright owner]
248N/A#
248N/A# CDDL HEADER END
248N/A#
248N/A# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
248N/A#
690N/A
248N/A#
248N/A# Rules and Macros for generating an IPS package manifest and publishing an
814N/A# IPS package to a pkg depot.
814N/A#
814N/A# To use these rules, include ../make-rules/ips.mk in your Makefile
814N/A# and define an "install" target appropriate to building your component.
248N/A# Ex:
248N/A#
248N/A# install: $(BUILD_DIR)/build/$(MACH32)/.installed \
248N/A# $(BUILD_DIR)/build/$(MACH64)/.installed
248N/A#
248N/A# This set of rules makes the "publish" target the default target for make(1)
248N/A#
248N/A
248N/APKGDEPEND = /usr/bin/pkgdepend
248N/APKGFMT = /usr/bin/pkgfmt
248N/APKGMOGRIFY = /usr/bin/pkgmogrify
248N/APKGSEND = /usr/bin/pkgsend
248N/APKGLINT = /usr/bin/pkglint
248N/A
248N/A# Package headers should all pretty much follow the same format
248N/AMETADATA_TEMPLATE = $(WS_TOP)/transforms/manifest-metadata-template
248N/ACOPYRIGHT_TEMPLATE = $(WS_TOP)/transforms/copyright-template
248N/A
248N/A# order is important
690N/AGENERATE_TRANSFORMS += $(WS_TOP)/transforms/generate-cleanup
248N/A
248N/ACOMPARISON_TRANSFORMS += $(WS_TOP)/transforms/comparison-cleanup
690N/ACOMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
248N/A
248N/A# order is important
248N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/defaults
248N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/actuators
248N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/devel
248N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/docs
248N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/locale
248N/APUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
248N/APUBLISH_TRANSFORMS += $(WS_TOP)/transforms/publish-cleanup
248N/A
248N/APKG_MACROS += MACH=$(MACH)
248N/APKG_MACROS += ARCH=$(MACH)
248N/APKG_MACROS += MACH32=$(MACH32)
248N/APKG_MACROS += MACH64=$(MACH64)
248N/APKG_MACROS += PUBLISHER=$(PUBLISHER)
248N/APKG_MACROS += CONSOLIDATION=$(CONSOLIDATION)
248N/APKG_MACROS += BUILD_VERSION=$(BUILD_VERSION)
248N/APKG_MACROS += SOLARIS_VERSION=$(SOLARIS_VERSION)
248N/APKG_MACROS += OS_VERSION=$(OS_VERSION)
248N/APKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
248N/APKG_MACROS += COMPONENT_VERSION=$(COMPONENT_VERSION)
248N/APKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
248N/A
248N/APKG_OPTIONS += $(PKG_MACROS:%=-D %)
248N/A
248N/APKG_PROTO_DIRS += $(PROTO_DIR) $(@D) $(COMPONENT_DIR)
248N/A
248N/AMANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
CANONICAL_MANIFESTS = $(wildcard *.p5m)
GENERATED = $(MANIFEST_BASE)-generated
COMBINED = $(MANIFEST_BASE)-combined
MANIFESTS = $(CANONICAL_MANIFESTS:%=$(MANIFEST_BASE)-%)
MOGRIFIED=$(CANONICAL_MANIFESTS:%.p5m=$(MANIFEST_BASE)-%.resolved)
PUBLISHED=$(MOGRIFIED:%.resolved=%.published)
COPYRIGHT_FILE = $(COMPONENT_NAME)-$(COMPONENT_VERSION).copyright
ifeq ($(IPS_PKG_NAME),)
IPS_PKG_NAME = $(COMPONENT_NAME)
endif
IPS_COMPONENT_VERSION = $(COMPONENT_VERSION)
.DEFAULT: publish
.SECONDARY:
publish: install $(BUILD_DIR)/.published
sample-manifest: $(GENERATED).p5m
$(GENERATED).p5m: install
$(PKGSEND) generate $(PKG_HARDLINKS:%=--target %) $(PROTO_DIR) | \
$(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 $(GENERATE_TRANSFORMS) | \
sed -e '/^$$/d' -e '/^#.*$$/d' | $(PKGFMT) | \
cat $(METADATA_TEMPLATE) - >$@
# copy the canonical manifest(s) to the build tree
$(MANIFEST_BASE)-%.generate: %.p5m canonical-manifests
cat $(METADATA_TEMPLATE) $< >$@
# mogrify the manifest
$(MANIFEST_BASE)-%.mogrified: %.p5m canonical-manifests
$(PKGMOGRIFY) $(PKG_OPTIONS) $< \
$(PUBLISH_TRANSFORMS) | \
sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
# generate dependencies
PKGDEPEND_GENERATE_OPTIONS = -m $(PKG_PROTO_DIRS:%=-d %)
$(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mogrified
$(PKGDEPEND) generate $(PKGDEPEND_GENERATE_OPTIONS) $< >$@
# resolve dependencies, prepend the mogrified manifest, less the unresolved
# dependencies to the result.
$(MANIFEST_BASE)-%.resolved: $(MANIFEST_BASE)-%.depend
($(PKGMOGRIFY) $(@:%.resolved=%.mogrified) \
$(WS_TOP)/transforms/drop-unresolved-dependencies | \
sed -e '/^$$/d' -e '/^#.*$$/d' ; \
$(PKGDEPEND) resolve -o $< | sed -e '1d') | uniq >$@
# lint the manifest before we publish with it.
$(MANIFEST_BASE)-%.linted: $(MANIFEST_BASE)-%.resolved
@echo "VALIDATING MANIFEST CONTENT: $<"
$(ENV) PYTHONPATH=$(WS_TOOLS)/python PROTO_PATH="$(PKG_PROTO_DIRS)"\
$(PKGLINT) $(CANONICAL_REPO:%=-c $(WS_LINT_CACHE)) \
-f $(WS_TOOLS)/pkglintrc $<
$(PKGFMT) <$< >$@
# published
PKGSEND_PUBLISH_OPTIONS = -s $(PKG_REPO) publish --fmri-in-manifest
PKGSEND_PUBLISH_OPTIONS += $(PKG_PROTO_DIRS:%=-d %)
$(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.linted
$(PKGSEND) $(PKGSEND_PUBLISH_OPTIONS) $<
$(PKGFMT) <$< >$@
$(BUILD_DIR)/.published: $(PUBLISHED)
$(TOUCH) $@
print-package-names: canonical-manifests
@cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-pkgs | \
$(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
print-package-paths: canonical-manifests
@cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
$(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
install-packages: publish
@if [ $(IS_GLOBAL_ZONE) = 0 -o x$(ROOT) != x ]; then \
cat $(CANONICAL_MANIFESTS) $(WS_TOP)/transforms/print-paths | \
$(PKGMOGRIFY) $(PKG_OPTIONS) /dev/fd/0 | \
sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
(cd $(PROTO_DIR) ; pfexec /bin/cpio -dump $(ROOT)) ; \
else ; \
echo "unsafe to install package(s) automatically" ; \
fi
$(MOGRIFIED): install
canonical-manifests: $(CANONICAL_MANIFESTS) Makefile $(PATCHES)
ifeq ($(strip $(CANONICAL_MANIFESTS)),)
# 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