5325N/A# The contents of this file are subject to the terms of the
5325N/A# Common Development and Distribution License (the "License").
5325N/A# You may not use this file except in compliance with the License.
5325N/A# See the License for the specific language governing permissions
5325N/A# and limitations under the License.
5325N/A# When distributing Covered Code, include this CDDL HEADER in each
5325N/A# If applicable, add the following below this CDDL HEADER, with the
5325N/A# fields enclosed by brackets "[]" replaced with your own identifying
5325N/A# information: Portions Copyright [yyyy] [name of copyright owner]
5325N/A# Copyright (c) 2010, 2011, Oracle
and/or its affiliates. All rights reserved.
5680N/A# Rules and Macros for generating an IPS package manifest and publishing an
5325N/A# IPS package to a pkg depot.
5325N/A# and define an "install" target appropriate to building your component.
5325N/A# install: $(BUILD_DIR)/build/$(MACH32)/.installed \
5325N/A# $(BUILD_DIR)/build/$(MACH64)/.installed
5325N/A# This set of rules makes the "publish" target the default target for make(1)
5325N/A# Package headers should all pretty much follow the same format
5325N/ACOMPARISON_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
5325N/APUBLISH_TRANSFORMS += $(PKGMOGRIFY_TRANSFORMS)
5325N/APKG_MACROS += MACH32=$(MACH32)
5325N/APKG_MACROS += MACH64=$(MACH64)
5325N/APKG_MACROS += IPS_PKG_NAME=$(IPS_PKG_NAME)
5325N/APKG_MACROS += PUBLISHER=$(PUBLISHER)
5325N/APKG_MACROS += CONSOLIDATION=$(CONSOLIDATION)
5325N/APKG_MACROS += BUILD_VERSION=$(BUILD_VERSION)
5325N/APKG_MACROS += SOLARIS_VERSION=$(SOLARIS_VERSION)
5325N/APKG_MACROS += OS_VERSION=$(OS_VERSION)
5325N/APKG_MACROS += IPS_COMPONENT_VERSION=$(IPS_COMPONENT_VERSION)
5325N/APKG_MACROS += COMPONENT_PROJECT_URL=$(COMPONENT_PROJECT_URL)
5325N/APKG_MACROS += COMPONENT_ARCHIVE_URL=$(COMPONENT_ARCHIVE_URL)
5325N/APKG_OPTIONS += $(PKG_MACROS:%=-D %)
5325N/A# multi-word macros get broken up, so we handle them "specially"
5325N/APKG_OPTIONS += -D COMPONENT_SUMMARY=$(COMPONENT_SUMMARY)
5325N/APKG_OPTIONS += -D COMPONENT_DESCRIPTION=$(COMPONENT_DESCRIPTION)
5325N/APKG_OPTIONS += -D COMPONENT_CLASSIFICATION=$(COMPONENT_CLASSIFICATION)
5325N/AMANIFEST_BASE = $(BUILD_DIR)/manifest-$(MACH)
5325N/ACANONICAL_MANIFESTS = $(wildcard *.p5m)
5325N/AGENERATED = $(MANIFEST_BASE)-generated
5325N/ACOMBINED = $(MANIFEST_BASE)-combined
5325N/AMANIFESTS = $(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)
ifeq ($(COMPONENT_SUMMARY),)
COMPONENT_SUMMARY = $(COMPONENT_DESCRIPTION)
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 >$@
# generate dependencies, drop
variant.arch in set and depend actions because
# "pkgdepend resolve" fails when it's present.
$(MANIFEST_BASE)-%.depend: $(MANIFEST_BASE)-%.mogrified
$(PKGDEPEND) generate -m $< $(PROTO_DIR) >$@
# 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: $<"
PYTHONPATH=$(WS_TOOLS)/python $(PKGLINT) \
$(CANONICAL_REPO:%=-r % -c $(WS_LINT_CACHE)) \
-f $(WS_TOOLS)/pkglintrc $<
$(MANIFEST_BASE)-%.published: $(MANIFEST_BASE)-%.linted
$(PKGSEND) -s $(PKG_REPO) publish --fmri-in-manifest \
-d $(PROTO_DIR) -d $(@D) -d . $<
$(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' >$@