Makefile revision ebbab6bbae913efeadfa3c6a1b082664a125f95b
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# CDDL HEADER START
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The contents of this file are subject to the terms of the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Common Development and Distribution License (the "License").
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# You may not use this file except in compliance with the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# See the License for the specific language governing permissions
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# and limitations under the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# When distributing Covered Code, include this CDDL HEADER in each
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# If applicable, add the following below this CDDL HEADER, with the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# fields enclosed by brackets "[]" replaced with your own identifying
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# information: Portions Copyright [yyyy] [name of copyright owner]
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# CDDL HEADER END
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Make sure we're getting a consistent execution environment for the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# embedded scripts.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# To suppress package dependency generation on any system, regardless
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# of how it was installed, set SUPPRESSPKGDEP=true in the build
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# environment.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Comment this line out or set "PKGDEBUG=" in your build environment
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# to get more verbose output from the make processes in usr/src/pkg
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Cross platform packaging notes
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# By default, we package the proto area from the same architecture as
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# the packaging build. In other words, if you're running nightly or
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# bldenv on an x86 platform, it will take objects from the x86 proto
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# area and use them to create x86 repositories.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# If you want to create repositories for an architecture that's
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# different from $(uname -p), you do so by setting PKGMACH in your
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# build environment.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# For this to work correctly, the following must all happen:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# 1. You need the desired proto area, which you can get either by
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# doing a gatekeeper-style build with the -U option to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# nightly(1), or by using rsync. If you don't do this, you will
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# get packaging failures building all packages, because pkgsend
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# is unable to find the required binaries.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# 2. You need the desired tools proto area, which you can get in the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# same ways as the normal proto area. If you don't do this, you
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# will get packaging failures building SUNWonbld, because pkgsend is
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# unable to find the tools binaries.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# 3. You need to have built the appropriate third party license
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# files in $SRC, which generally means you should override SRC in
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# your build environment. If you don't do this, you will get
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# packaging failures because pkgsend is unable to find various
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# THIRDPARTYLICENSE files.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# 4. The remainder of this Makefile should never refer directly to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# $(MACH). Instead, $(PKGMACH) should be used whenever an
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# architecture-specific path or token is needed. If this is done
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# incorrectly, then packaging will fail, and you will see the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# value of $(uname -p) instead of the value of $(PKGMACH) in the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# commands that fail.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# 5. Each time a rule in this Makefile invokes $(MAKE), it should
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# pass PKGMACH=$(PKGMACH) explicitly on the command line. If
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# this is done incorrectly, then packaging will fail, and you
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# will see the value of $(uname -p) instead of the value of
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# $(PKGMACH) in the commands that fail.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Refer also to the convenience targets defined later in this
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# ROOT, TOOLS_PROTO, and PKGARCHIVE should be set by nightly or
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# bldenv. These macros translate them into terms of $PKGMACH, instead
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji OtaPKGROOT.cmd= print $(ROOT) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji OtaTOOLSROOT.cmd= print $(TOOLS_PROTO) | sed -e s:/root_$(MACH):/root_$(PKGMACH):
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji OtaPKGDEST.cmd= print $(PKGARCHIVE) | sed -e s:/$(MACH)/:/$(PKGMACH)/:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The publish transforms, EXCEPTIONS list, and some manifests need to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# know when we're building open-only and when we're using internal
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# crypto bits.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# We only use internal crypto when we're doing a closed build, the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# CODESIGN_USER env variable is not set, and ON_CRYPTO_BINS is not set.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# This matches the conditions under which the internal key and cert
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# are needed for the packaged objects.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# We use X_FLAG, as exported by nightly and bldenv, to decide when we
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# need IHV-related exceptions for protocmp.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota$(USE_INTERNAL_CRYPTO)USE_SIGNED_CRYPTO= $(POUND_SIGN)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Always build the redistributable repository, but only build the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# nonredistributable bits if we have access to closed source.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Some objects that result from the closed build are still
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# redistributable, and should be packaged as part of an open-only
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# build. Access to those objects is provided via the closed-bins
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# tarball. See usr/src/tools/scripts/bindrop.sh for details.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The packages directory will contain the processed manifests as
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# direct build targets and subdirectories for package metadata extracted
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# incidentally during manifest processing.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Nothing underneath $(PDIR) should ever be managed by SCM.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The tools proto must be specified for dependency generation.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Publication from the tools proto area is managed in the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# publication rule.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota$(PDIR)/developer-build-onbld.dep:= PKGROOT= $(TOOLSROOT)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota$(PKGDEST)/repo.extra:= PKGPUBLISHER= $(PKGPUBLISHER_NONREDIST)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# To get these defaults, manifests should simply refer to $(PKGVERS).
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji OtaPKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The ARCH32 and ARCH64 macros are used in the manifests to express
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# architecture-specific subdirectories in the installation paths
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# for isaexec'd commands.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# We can't simply use $(MACH32) and $(MACH64) here, because they're
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# only defined for the build architecture. To do cross-platform
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# packaging, we need both values.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# macros and transforms needed by pkgmogrify
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# If you append to this list using target-specific assignments (:=),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# be very careful that the targets are of the form $(PDIR)/pkgname. If
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# you use a higher level target, or a package list, you'll trigger a
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# complete reprocessing of all manifests because they'll fail command
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# dependency checking.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji OtaPM_TRANSFORMS= common_actions publish restart_fmri defaults extract_metadata
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'PLATFORM=i86hvm' \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'PLATFORM=i86pc' \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'PLATFORM=i86xpv' \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'ISALIST=amd64' \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'ISALIST=i386'
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'PLATFORM=sun4u' \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'PLATFORM=sun4v' \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'ISALIST=sparcv9' \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota 'ISALIST=sparc'
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The package lists are generated with $(PKGDEP_TYPE) as their
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# dependency types, so that they can be included by either an
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# incorporation or a group package.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota$(PDIR)/osnet-redist.mog $(PDIR)/osnet-extra.mog:= PKGDEP_TYPE= require
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota$(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota depend fmri=consolidation/osnet/osnet-incorporation type=require
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# All packaging build products should go into $(PDIR), so they don't
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# need to be included separately in CLOBBERFILES.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# By default, PKGS will list all manifests. To build and/or publish a
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# subset of packages, override this on the command line or in the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# build environment and then reference (implicitly or explicitly) the all
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# or install targets.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Track the synthetic manifests separately so we can properly express
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# build rules and dependencies. The synthetic and real packages use
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# different sets of transforms and macros for pkgmogrify.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# For each package, we determine the target repository based on
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# manifest-embedded metadata. Because we make that determination on
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# the fly, the publication target cannot be expressed as a
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# subdirectory inside the unknown-by-the-makefile target repository.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# In order to limit the target set to real files in known locations,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# we use a ".pub" file in $(PDIR) for each processed manifest, regardless
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# of content or target repository.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji OtaPUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Any given repository- and status-specific package list may be empty,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# but we can only determine that dynamically, so we always generate all
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# lists for each repository we're building.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The meanings of each package status are as follows:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# PKGSTAT meaning
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# ---------- ----------------------------------------------------
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# noincorp Do not include in incorporation or group package
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# obsolete Include in incorporation, but not group package
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# renamed Include in incorporation, but not group package
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# current Include in incorporation and group package
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Since the semantics of the "noincorp" package status dictate that
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# such packages are not included in the incorporation or group packages,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# there is no need to build noincorp package lists.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# For a single manifest, the dependency chain looks like this:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# raw manifest (mypkg.mf)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# | use pkgmogrify to process raw manifest
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# processed manifest (mypkg.mog)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# * | use pkgdepend generate to generate dependencies
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# manifest with TBD dependencies (mypkg.dep)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# % | use pkgdepend resolve to resolve dependencies
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# manifest with dependencies resolved (mypkg.res)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# | use pkgsend to publish the package
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# placeholder to indicate successful publication (mypkg.pub)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# * This may be suppressed via SUPPRESSPKGDEP. The resulting
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# packages will install correctly, but care must be taken to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# install all dependencies, because pkg will not have the input
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# it needs to determine this automatically.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# % This is included in this diagram to make the picture complete, but
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# this is a point of synchronization in the build process.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Dependency resolution is actually done once on the entire set of
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# manifests, not on a per-package basis.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The full dependency chain for generating everything that needs to be
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# published, without actually publishing it, looks like this:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# processed synthetic packages
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# package lists synthetic package manifests
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# processed real packages
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# package dir real package manifests
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Here, each item is a set of real or synthetic packages. For this
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# portion of the build, no reference is made to the proto area. It is
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# therefore suitable for the "all" target, as opposed to "install."
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Since each of these steps is expressed explicitly, "all" need only
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# depend on the head of the chain.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# From the end of manifest processing, the publication dependency
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# chain looks like this:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# repository metadata (catalogs and search indices)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# published packages
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# | | pkgsend publish
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# repositories resolved dependencies
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# pkgsend | | pkgdepend resolve
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# create-repository |
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# | generated dependencies
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# repo directories |
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# | pkgdepend
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# processed manifests
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Due to limitations in pkgdepend, we cannot simply treat synthetic
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# and real manifests identically. But we don't really want to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# maintain a separate chain for synthetic manifests, so for the left
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# side of this diagram, we actually do faux dependency generation and
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# resolution, so we end up with the expected set of files in $(PDIR),
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# per the individual file chain described above: mf, mog, dep, res,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# and pub files for each manifest.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# This will build the directory to contain the processed manifests
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# and the metadata symlinks.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# This rule resolves dependencies across all published manifests.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# We should be able to do this with
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# pkgdepend resolve -m $(PUB_PKGS:%.pub=%.dep)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# but until 14113 is fixed, the incorporations confuse pkgdepend, so we
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# just create the .res file for DEP_SYNTH_PKGS directly.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# We also shouldn't have to ignore the error from pkgdepend, but
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# until at least 14110 is resolved, pkgdepend will always exit with
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota -$(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota print "Suppressing dependency resolution"; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota print "Resolving dependencies"; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota print "Removing dependency versions from $$p"; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota @print "Creating repository metadata"
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Since we create zero-length processed manifests for a graceful abort
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# from pkgmogrify, we need to detect that here and make no effort to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# publish the package.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# For all other packages, we publish them regardless of status. We
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# derive the target repository as a component of the metadata-derived
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# symlink for each package.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otapublish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Initialize the empty on-disk repositories
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)pkgsend -s file://$(@) create-repository \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# rule to process real manifests
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# To allow redistributability and package status to change, we must
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# remove not only the actual build target (the processed manifest), but
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# also the incidental ones (the metadata-derived symlinks).
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# If pkgmogrify exits cleanly but fails to create the specified output
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# file, it means that it encountered an abort directive. That means
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# that this package should not be published for this particular build
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# environment. Since we can't prune such packages from $(PKGS)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# retroactively, we need to create an empty target file to keep make
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# from trying to rebuild it every time. For these empty targets, we
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# do not create metadata symlinks.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Automatic dependency resolution to files is also done at this phase of
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# processing. The skipped packages are skipped due to existing bugs
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# in pkgdepend.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The incorporation dependency is tricky: it needs to go into all
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# current and renamed manifests (ie all incorporated packages), but we
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# don't know which those are until after we run pkgmogrify. So
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# instead of expressing it as a transform, we tack it on ex post facto.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Implementation notes:
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# - The first $(RM) must not match other manifests, or we'll run into
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# race conditions with parallel manifest processing.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# - The make macros [ie $(MACRO)] are evaluated when the makefile is
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# read in, and will result in a fixed, macro-expanded rule for each
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# target enumerated in $(PROC_PKGS).
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# - The shell variables (ie $$VAR) are assigned on the fly, as the rule
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# is executed. The results may only be referenced in the shell in
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# which they are assigned, so from the perspective of make, all code
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# that needs these variables needs to be part of the same line of
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# code. Hence the use of command separators and line continuation
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# characters.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# - The extract_metadata transforms are designed to spit out shell
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# variable assignments to stdout. Those are published to the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# .vars temporary files, and then used as input to the eval
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# statement. This is done in stages specifically so that pkgmogrify
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# can signal failure if the manifest has a syntactic or other error.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The eval statement should begin with the default values, and the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# output from pkgmogrify (if any) should be in the form of a
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# variable assignment to override those defaults.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# - When this rule completes execution, it must leave an updated
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# target file ($@) in place, or make will reprocess the package
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# every time it encounters it as a dependency. Hence the "touch"
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# statement to ensure that the target is created, even when
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# pkgmogrify encounters an abort in the publish transforms. This
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# will not cause publication failures when switching build
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# environments, because $(CLOSED_BUILD) and $(OPEN_ONLY) are
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# referenced in $(PKGMOG_DEFINES), and changes will therefore
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# trigger a rebuild for command dependency failure. (Command
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# dependency checking is turned on by .KEEP_STATE: above.)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if [ -f $(@) ]; then \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The full chain implies that there should be a .dep.res suffix rule,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# but dependency generation is done on a set of manifests, rather than
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# on a per-manifest basis. Instead, see the gendeps rule above.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if [ -s $(<) ]; then \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota print "Publishing $(@F:%.pub=%) to $$r repository"; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota -d $(PKGROOT) -d $(TOOLSROOT) -d $(SRC)/pkg/license_files \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota -d $(SRC) --fmri-in-manifest --no-index --no-catalog $(<) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# rule to build the synthetic manifests
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# This rule necessarily has PKGDEP_TYPE that changes according to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# the specific synthetic manifest. Rather than escape command
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# dependency checking for the real manifest processing, or failing to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# express the (indirect) dependency of synthetic manifests on real
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# manifests, we simply split this rule out from the one above.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The implementation notes from the previous rule are applicable
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# here, too.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota @print "Processing synthetic manifest $(@F:%.mog=%.mf)"
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(PKGDEBUG)eval REPO=redist PKGSTAT=current `$(CAT) -s $(@).vars`; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if [ -f $(@) ]; then \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota @print "Skipping dependency generation for $(@F:%.dep=%)"
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# This rule assumes that all links in the $PKGSTAT directories
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# point to valid manifests, and will fail the make run if one
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# does not contain an fmri.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# We do this in the BEGIN action instead of using pattern matching
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# because we expect the fmri to be at or near the first line of each input
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# file, and this way lets us avoid reading the rest of the file after we
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# find what we need.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# We keep track of a failure to locate an fmri, so we can fail the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# make run, but we still attempt to process each package in the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# repo/pkgstat-specific subdir, in hopes of maybe giving some
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# additional useful info.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# The protolist is used for bfu archive creation, which may be invoked
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# interactively by the user. Both protolist and PKGLISTS targets
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# depend on $(PROC_PKGS), but protolist builds them recursively.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# To avoid collisions, we insert protolist into the dependency chain
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# here. This has two somewhat subtle benefits: it allows bfu archive
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# and it ensures that a protolist file here will always correspond to the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# contents of the processed manifests, which can vary depending on build
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# environment.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota print "Generating $$r $$s package list"; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (ARGC < 2) { \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota retcode = 0; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota for (i = 1; i < ARGC; i++) { \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota e = getline f < ARGV[i]; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota } while ((e == 1) && (f !~ /name=pkg.fmri/)); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota close(ARGV[i]); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota if (e == 1) { \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota l = split(f, a, "="); \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota print "depend fmri=" a[l], \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota "type=$$(PKGDEP_TYPE)"; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota print "no fmri in " ARGV[i] >> "/dev/stderr"; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota retcode = 2; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota exit retcode; \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota }' `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# rules to validate proto area against manifests, check for safe
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# file permission modes, and generate a faux proto list
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# For the check targets, the dependencies on $(PROC_PKGS) is specified
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# as a subordinate make process in order to suppress output.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(EXCEPTIONS:%=-e $(CODEMGR_WS)/exception_lists/%) \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# This is a convenience target to allow package names to function as
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# build targets. Generally, using it is only useful when iterating on
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# development of a manifest.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# When processing a manifest, use the basename (without extension) of
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# the package. When publishing, use the basename with a ".pub"
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# extension.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Other than during manifest development, the preferred usage is to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# avoid these targets and override PKGS on the make command line and
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# use the provided all and install targets.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# This is a convenience target to resolve dependencies without publishing
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# These are convenience targets for cross-platform packaging. If you
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# want to build any of "the normal" targets for a different
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# architecture, simply use "arch/target" as your build target.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# Since the most common use case for this is "install," the architecture
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# specific install targets have been further abbreviated to elide "/install."
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP)
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# EXPORT DELETE START
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(SED) -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(SED) -e "/^# CRYPT DELETE START/,/^# CRYPT DELETE END/d" \
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota < manifests/SUNWcryptoint.mf > manifests/SUNWcryptoint.mf+
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota $(MV) manifests/SUNWcryptoint.mf+ manifests/SUNWcryptoint.mf
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota# EXPORT DELETE END