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# See the License for the specific language governing permissions
248N/A# and limitations under the License.
248N/A# When distributing Covered Code, include this CDDL HEADER in each
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# Copyright (c) 2010, 2011, Oracle
and/or its affiliates. All rights reserved.
248N/A# Rules and Macros for generating an IPS package manifest and publishing an
814N/A# IPS package to a pkg depot.
814N/A# and define an "install" target appropriate to building your component.
248N/A# install: $(BUILD_DIR)/build/$(MACH32)/.installed \
248N/A# $(BUILD_DIR)/build/$(MACH64)/.installed
248N/A# This set of rules makes the "publish" target the default target for make(1)
248N/A# Package headers should all pretty much follow the same format
690N/ACOMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
248N/APUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
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/APKG_OPTIONS += $(PKG_MACROS:%=-D %)
248N/APKG_PROTO_DIRS += $(PROTO_DIR) $(@D) $(COMPONENT_DIR)
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
IPS_PKG_NAME = $(COMPONENT_NAME)
IPS_COMPONENT_VERSION = $(COMPONENT_VERSION)
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) $< >$@
$(MANIFEST_BASE)-%.mogrified: %.p5m canonical-manifests
$(PKGMOGRIFY) $(PKG_OPTIONS) $< \
$(PUBLISH_TRANSFORMS) | \
sed -e '/^$$/d' -e '/^#.*$$/d' | uniq >$@
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) \
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 $<
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) $<
$(BUILD_DIR)/.published: $(PUBLISHED)
print-package-names: canonical-manifests
$(PKGMOGRIFY) $(PKG_OPTIONS)
/dev/fd/0 | \
sed -e '/^$$/d' -e '/^#.*$$/d' | sort -u
print-package-paths: canonical-manifests
$(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 \
$(PKGMOGRIFY) $(PKG_OPTIONS)
/dev/fd/0 | \
sed -e '/^$$/d' -e '/^#.*$$/d' -e 's;/;;' | sort -u | \
(cd $(PROTO_DIR) ; pfexec
/bin/cpio -dump $(ROOT)) ; \
echo "unsafe to install package(s) automatically" ; \
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
# $ gmake sample-manifest
# Once created, it will need to be reviewed, edited, and added to the
$(error Missing canonical manifest(s))
# This converts required paths to containing package names for be able to
# properly setup the build environment for a component.
@echo "generating $@ from Makefile REQUIRED_* data"
@pkg search -H -l '<$(DEPENDS:%=% OR)
/bin/true>' \
| sed -e '
s/pkg:\/\(.*\)@.*/REQUIRED_PKGS += \1/g' >$@