1# 2# CDDL HEADER START 3# 4# The contents of this file are subject to the terms of the 5# Common Development and Distribution License (the "License"). 6# You may not use this file except in compliance with the License. 7# 8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9# or http://www.opensolaris.org/os/licensing. 10# See the License for the specific language governing permissions 11# and limitations under the License. 12# 13# When distributing Covered Code, include this CDDL HEADER in each 14# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15# If applicable, add the following below this CDDL HEADER, with the 16# fields enclosed by brackets "[]" replaced with your own identifying 17# information: Portions Copyright [yyyy] [name of copyright owner] 18# 19# CDDL HEADER END 20# 21 22# 23# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. 25# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com> 26# Copyright 2016 RackTop Systems. 27# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 28# 29 30include $(SRC)/Makefile.master 31include $(SRC)/Makefile.buildnum 32 33# 34# Make sure we're getting a consistent execution environment for the 35# embedded scripts. 36# 37SHELL= /usr/bin/ksh93 38 39# 40# To suppress package dependency generation on any system, regardless 41# of how it was installed, set SUPPRESSPKGDEP=true in the build 42# environment. 43# 44SUPPRESSPKGDEP= false 45 46# 47# Comment this line out or set "PKGDEBUG=" in your build environment 48# to get more verbose output from the make processes in usr/src/pkg 49# 50PKGDEBUG= @ 51 52# 53# Cross platform packaging notes 54# 55# By default, we package the proto area from the same architecture as 56# the packaging build. In other words, if you're running nightly or 57# bldenv on an x86 platform, it will take objects from the x86 proto 58# area and use them to create x86 repositories. 59# 60# If you want to create repositories for an architecture that's 61# different from $(uname -p), you do so by setting PKGMACH in your 62# build environment. 63# 64# For this to work correctly, the following must all happen: 65# 66# 1. You need the desired proto area, which you can get either by 67# doing a gatekeeper-style build with the -U option to 68# nightly(1), or by using rsync. If you don't do this, you will 69# get packaging failures building all packages, because pkgsend 70# is unable to find the required binaries. 71# 2. You need the desired tools proto area, which you can get in the 72# same ways as the normal proto area. If you don't do this, you 73# will get packaging failures building onbld, because pkgsend is 74# unable to find the tools binaries. 75# 3. The remainder of this Makefile should never refer directly to 76# $(MACH). Instead, $(PKGMACH) should be used whenever an 77# architecture-specific path or token is needed. If this is done 78# incorrectly, then packaging will fail, and you will see the 79# value of $(uname -p) instead of the value of $(PKGMACH) in the 80# commands that fail. 81# 4. Each time a rule in this Makefile invokes $(MAKE), it should 82# pass PKGMACH=$(PKGMACH) explicitly on the command line. If 83# this is done incorrectly, then packaging will fail, and you 84# will see the value of $(uname -p) instead of the value of 85# $(PKGMACH) in the commands that fail. 86# 87# Refer also to the convenience targets defined later in this 88# Makefile. 89# 90PKGMACH= $(MACH) 91 92# 93# ROOT, TOOLS_PROTO, and PKGARCHIVE should be set by nightly or 94# bldenv. These macros translate them into terms of $PKGMACH, instead 95# of $ARCH. 96# 97PKGROOT.cmd= print $(ROOT) | sed -e s:/root_$(MACH):/root_$(PKGMACH): 98PKGROOT= $(PKGROOT.cmd:sh) 99TOOLSROOT.cmd= print $(TOOLS_PROTO) | sed -e s:/root_$(MACH):/root_$(PKGMACH): 100TOOLSROOT= $(TOOLSROOT.cmd:sh) 101PKGDEST.cmd= print $(PKGARCHIVE) | sed -e s:/$(MACH)/:/$(PKGMACH)/: 102PKGDEST= $(PKGDEST.cmd:sh) 103 104EXCEPTIONS= packaging 105 106PKGMOGRIFY= pkgmogrify 107 108# 109# Always build the redistributable repository, but only build the 110# nonredistributable bits if we have access to closed source. 111# 112# Some objects that result from the closed build are still 113# redistributable, and should be packaged as part of an open-only 114# build. Access to those objects is provided via the closed-bins 115# tarball. See usr/src/tools/scripts/bindrop.sh for details. 116# 117REPOS= redist 118 119# 120# The packages directory will contain the processed manifests as 121# direct build targets and subdirectories for package metadata extracted 122# incidentally during manifest processing. 123# 124# Nothing underneath $(PDIR) should ever be managed by SCM. 125# 126PDIR= packages.$(PKGMACH) 127 128# 129# The tools proto must be specified for dependency generation. 130# Publication from the tools proto area is managed in the 131# publication rule. 132# 133$(PDIR)/developer-build-onbld.dep:= PKGROOT= $(TOOLSROOT) 134 135PKGPUBLISHER= $(PKGPUBLISHER_REDIST) 136 137# 138# To get these defaults, manifests should simply refer to $(PKGVERS). 139# 140PKGVERS_COMPONENT= 0.$(RELEASE) 141PKGVERS_BUILTON= $(RELEASE) 142PKGVERS_BRANCH= 0.$(ONNV_BUILDNUM) 143PKGVERS= $(PKGVERS_COMPONENT),$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH) 144 145# 146# The ARCH32 and ARCH64 macros are used in the manifests to express 147# architecture-specific subdirectories in the installation paths 148# for isaexec'd commands. 149# 150# We can't simply use $(MACH32) and $(MACH64) here, because they're 151# only defined for the build architecture. To do cross-platform 152# packaging, we need both values. 153# 154i386_ARCH32= i86 155sparc_ARCH32= sparcv7 156i386_ARCH64= amd64 157sparc_ARCH64= sparcv9 158 159# 160# macros and transforms needed by pkgmogrify 161# 162# If you append to this list using target-specific assignments (:=), 163# be very careful that the targets are of the form $(PDIR)/pkgname. If 164# you use a higher level target, or a package list, you'll trigger a 165# complete reprocessing of all manifests because they'll fail command 166# dependency checking. 167# 168PM_TRANSFORMS= common_actions publish restart_fmri facets defaults \ 169 extract_metadata 170PM_FINAL_TRANSFORMS= strip_dependinfo 171PM_INC= transforms manifests 172 173JAVA_8_ONLY=$(BLD_JAVA_8) 174JAVA_7_ONLY= 175$(BLD_JAVA_8)JAVA_7_ONLY=$(POUND_SIGN) 176 177TITANIC_VERSION_MAJOR.cmd = echo $(VERSION) | sed -e 's/titanic_\([^.]*\).*/\1/' 178TITANIC_VERSION_MAJOR = $(TITANIC_VERSION_MAJOR.cmd:sh) 179TITANIC_VERSION_MAJOR_NEXT.cmd = echo $$(($(TITANIC_VERSION_MAJOR) + 1)) 180TITANIC_VERSION_MAJOR_NEXT = $(TITANIC_VERSION_MAJOR_NEXT.cmd:sh) 181 182PKGMOG_DEFINES= \ 183 i386_ONLY=$(POUND_SIGN) \ 184 sparc_ONLY=$(POUND_SIGN) \ 185 $(PKGMACH)_ONLY= \ 186 ARCH=$(PKGMACH) \ 187 ARCH32=$($(PKGMACH)_ARCH32) \ 188 ARCH64=$($(PKGMACH)_ARCH64) \ 189 PKGVERS_COMPONENT=$(PKGVERS_COMPONENT) \ 190 PKGVERS_BUILTON=$(PKGVERS_BUILTON) \ 191 PKGVERS_BRANCH=$(PKGVERS_BRANCH) \ 192 PKGVERS=$(PKGVERS) \ 193 PERL_ARCH=$(PERL_ARCH) \ 194 PERL_ARCH64=$(PERL_ARCH64) \ 195 PERL_VERSION=$(PERL_VERSION) \ 196 PERL_PKGVERS=$(PERL_PKGVERS) \ 197 BUILDPERL32=$(BUILDPERL32) \ 198 BUILDPERL64=$(BUILDPERL64) \ 199 PYTHON_VERSION=$(PYTHON_VERSION) \ 200 PYTHON3_VERSION=$(PYTHON3_VERSION) \ 201 PYTHON_PKGVERS=$(PYTHON_PKGVERS) \ 202 PYTHON3_PKGVERS=$(PYTHON3_PKGVERS) \ 203 python2_ONLY=$(BUILDPY2) \ 204 python3_ONLY=$(BUILDPY3) \ 205 python2tools_ONLY=$(BUILDPY2TOOLS) \ 206 python3tools_ONLY=$(BUILDPY3TOOLS) \ 207 JAVA_8_ONLY=$(JAVA_8_ONLY) \ 208 JAVA_7_ONLY=$(JAVA_7_ONLY) \ 209 TITANIC_VERSION_MAJOR=$(TITANIC_VERSION_MAJOR) \ 210 TITANIC_VERSION_MAJOR_NEXT=$(TITANIC_VERSION_MAJOR_NEXT) 211 212PKGDEP_TOKENS_i386= \ 213 'PLATFORM=i86hvm' \ 214 'PLATFORM=i86pc' \ 215 'PLATFORM=i86xpv' \ 216 'ISALIST=amd64' \ 217 'ISALIST=i386' 218PKGDEP_TOKENS_sparc= \ 219 'PLATFORM=sun4u' \ 220 'PLATFORM=sun4v' \ 221 'ISALIST=sparcv9' \ 222 'ISALIST=sparc' 223PKGDEP_TOKENS= $(PKGDEP_TOKENS_$(PKGMACH)) 224 225# 226# The package lists are generated with $(PKGDEP_TYPE) as their 227# dependency types, so that they can be included by either an 228# incorporation or a group package. 229# 230$(PDIR)/osnet-redist.mog := PKGDEP_TYPE= require 231$(PDIR)/osnet-incorporation.mog:= PKGDEP_TYPE= incorporate 232 233PKGDEP_INCORP= \ 234 depend fmri=consolidation/osnet/osnet-incorporation type=require 235 236# 237# All packaging build products should go into $(PDIR), so they don't 238# need to be included separately in CLOBBERFILES. 239# 240CLOBBERFILES= $(PDIR) proto_list_$(PKGMACH) install-$(PKGMACH).out \ 241 license-list 242 243# 244# By default, PKGS will list all manifests. To build and/or publish a 245# subset of packages, override this on the command line or in the 246# build environment and then reference (implicitly or explicitly) the all 247# or install targets. 248# 249# We want some manifests to optionally build based on environment options, so 250# those are excluded when generating the list of manifests and added back in if 251# necessary. We also want a relatively easy way to add files to the list of 252# manifests given special treatment. Add any other special ones to the 253# SPECIAL_MANIFESTS variable. It can contain wildcards in regexp form, i.e. 254# SUNW.* as one useful example. 255# 256SPECIAL_MANIFESTS = system-library-python-.* 257LIST_MANIFESTS_CMD = (cd manifests ; /usr/bin/ls -1 *.mf |\ 258 $(SED) $(SPECIAL_MANIFESTS:%=-e '/^%$$/d') ) 259MANIFESTS = $(LIST_MANIFESTS_CMD:sh) 260 261# Conditionally add back python modules 262$(BUILDPY2) MANIFESTS += \ 263 system-library-python-libbe-2.mf \ 264 system-library-python-solaris-2.mf \ 265 system-library-python-zfs-2.mf 266$(BUILDPY3) MANIFESTS += \ 267 system-library-python-libbe-3.mf \ 268 system-library-python-solaris-3.mf \ 269 system-library-python-zfs-3.mf 270 271PKGS= $(MANIFESTS:%.mf=%) 272DEP_PKGS= $(PKGS:%=$(PDIR)/%.dep) 273PROC_PKGS= $(PKGS:%=$(PDIR)/%.mog) 274FIN_PKGS= $(PKGS:%=$(PDIR)/%.fin) 275 276# 277# Track the synthetic manifests separately so we can properly express 278# build rules and dependencies. The synthetic and real packages use 279# different sets of transforms and macros for pkgmogrify. 280# 281SYNTH_PKGS= osnet-incorporation osnet-redist 282DEP_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.dep) 283PROC_SYNTH_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.mog) 284 285# 286# Root of pkg image to use for dependency resolution 287# Normally / on the machine used to build the binaries 288# 289PKGDEP_RESOLVE_IMAGE = / 290 291# 292# For each package, we determine the target repository based on 293# manifest-embedded metadata. Because we make that determination on 294# the fly, the publication target cannot be expressed as a 295# subdirectory inside the unknown-by-the-makefile target repository. 296# 297# In order to limit the target set to real files in known locations, 298# we use a ".pub" file in $(PDIR) for each processed manifest, regardless 299# of content or target repository. 300# 301PUB_PKGS= $(SYNTH_PKGS:%=$(PDIR)/%.pub) $(PKGS:%=$(PDIR)/%.pub) 302 303# 304# Any given repository- and status-specific package list may be empty, 305# but we can only determine that dynamically, so we always generate all 306# lists for each repository we're building. 307# 308# The meanings of each package status are as follows: 309# 310# PKGSTAT meaning 311# ---------- ---------------------------------------------------- 312# noincorp Do not include in incorporation or group package 313# obsolete Include in incorporation, but not group package 314# renamed Include in incorporation, but not group package 315# current Include in incorporation and group package 316# 317# Since the semantics of the "noincorp" package status dictate that 318# such packages are not included in the incorporation or group packages, 319# there is no need to build noincorp package lists. 320# 321PKGLISTS= \ 322 $(REPOS:%=$(PDIR)/packages.%.current) \ 323 $(REPOS:%=$(PDIR)/packages.%.renamed) \ 324 $(REPOS:%=$(PDIR)/packages.%.obsolete) 325 326.KEEP_STATE: 327 328.PARALLEL: $(PKGS) $(PROC_PKGS) $(DEP_PKGS) \ 329 $(PROC_SYNTH_PKGS) $(DEP_SYNTH_PKGS) $(FIN_PKGS) $(PUB_PKGS) 330 331# 332# For a single manifest, the dependency chain looks like this: 333# 334# raw manifest (mypkg.mf) 335# | 336# | use pkgmogrify to process raw manifest 337# | 338# processed manifest (mypkg.mog) 339# | 340# * | use pkgdepend generate to generate dependencies 341# | 342# manifest with TBD dependencies (mypkg.dep) 343# | 344# % | use pkgdepend resolve to resolve dependencies 345# | 346# manifest with dependencies resolved (mypkg.res) 347# | 348# | use pkgmogrify to apply final cleanups 349# | 350# cleaned up manifest (mypkg.fin) 351# | 352# | use pkgsend to publish the package 353# | 354# placeholder to indicate successful publication (mypkg.pub) 355# 356# * This may be suppressed via SUPPRESSPKGDEP. The resulting 357# packages will install correctly, but care must be taken to 358# install all dependencies, because pkg will not have the input 359# it needs to determine this automatically. 360# 361# % This is included in this diagram to make the picture complete, but 362# this is a point of synchronization in the build process. 363# Dependency resolution is actually done once on the entire set of 364# manifests, not on a per-package basis. 365# 366# The full dependency chain for generating everything that needs to be 367# published, without actually publishing it, looks like this: 368# 369# processed synthetic packages 370# | | 371# package lists synthetic package manifests 372# | 373# processed real packages 374# | | 375# package dir real package manifests 376# 377# Here, each item is a set of real or synthetic packages. For this 378# portion of the build, no reference is made to the proto area. It is 379# therefore suitable for the "all" target, as opposed to "install." 380# 381# Since each of these steps is expressed explicitly, "all" need only 382# depend on the head of the chain. 383# 384# From the end of manifest processing, the publication dependency 385# chain looks like this: 386# 387# repository metadata (catalogs and search indices) 388# | 389# | pkgrepo refresh 390# | 391# published packages 392# | | 393# | | pkgsend publish 394# | | 395# repositories final manifests 396# | | 397# pkgsend | | pkgmogrify final 398# create-repository | 399# | resolved dependencies 400# repo directories | 401# | pkgdepend resolve 402# | 403# generated dependencies 404# | 405# | pkgdepend 406# | 407# processed manifests 408 409ALL_TARGETS= $(PROC_SYNTH_PKGS) proto_list_$(PKGMACH) 410 411all: $(ALL_TARGETS) 412 413# 414# This will build the directory to contain the processed manifests 415# and the metadata symlinks. 416# 417$(PDIR): 418 @print "Creating $(@)" 419 $(PKGDEBUG)$(INS.dir) 420 421# 422# This rule resolves dependencies across all published manifests. 423# 424$(PDIR)/gendeps: $(DEP_SYNTH_PKGS) $(DEP_PKGS) 425 $(PKGDEBUG)if [ "$(SUPPRESSPKGDEP)" = "true" ]; then \ 426 print "Suppressing dependency resolution"; \ 427 for p in $(DEP_PKGS:%.dep=%); do \ 428 $(CP) $$p.dep $$p.res; \ 429 done; \ 430 else \ 431 print "Resolving dependencies"; \ 432 pkgdepend -R $(PKGDEP_RESOLVE_IMAGE) resolve \ 433 -m $(DEP_SYNTH_PKGS) $(DEP_PKGS); \ 434 for p in $(DEP_SYNTH_PKGS:%.dep=%) $(DEP_PKGS:%.dep=%); do \ 435 if [ "$$(print $$p.metadata.*)" = \ 436 "$$(print $$p.metadata.noincorp.*)" ]; \ 437 then \ 438 print "Removing dependency versions from $$p"; \ 439 $(PKGMOGRIFY) $(PKGMOG_VERBOSE) \ 440 -O $$p.res -I transforms \ 441 strip_versions $$p.dep.res; \ 442 $(RM) $$p.dep.res; \ 443 else \ 444 $(MV) $$p.dep.res $$p.res; \ 445 fi; \ 446 done; \ 447 fi 448 $(PKGDEBUG)$(TOUCH) $(@) 449 450install: $(ALL_TARGETS) repository-metadata 451 452repository-metadata: publish_pkgs 453 $(PKGDEBUG)for r in $(REPOS); do \ 454 pkgrepo refresh -s $(PKGDEST)/repo.$$r; \ 455 done 456 457# 458# Since we create zero-length processed manifests for a graceful abort 459# from pkgmogrify, we need to detect that here and make no effort to 460# publish the package. 461# 462# For all other packages, we publish them regardless of status. We 463# derive the target repository as a component of the metadata-derived 464# symlink for each package. 465# 466publish_pkgs: $(REPOS:%=$(PKGDEST)/repo.%) $(PDIR)/gendeps .WAIT $(PUB_PKGS) 467 468# 469# Before publishing, we want to pull the license files from $CODEMGR_WS 470# into the proto area. This allows us to NOT pass $SRC (or 471# $CODEMGR_WS) as a basedir for publication. 472# 473$(PUB_PKGS): stage-licenses 474 475# 476# Initialize the empty on-disk repositories 477# 478$(REPOS:%=$(PKGDEST)/repo.%): 479 @print "Initializing $(@F)" 480 $(PKGDEBUG)$(INS.dir) 481 $(PKGDEBUG)pkgsend -s file://$(@) create-repository \ 482 --set-property publisher.prefix=$(PKGPUBLISHER) 483 484# 485# rule to process real manifests 486# 487# To allow redistributability and package status to change, we must 488# remove not only the actual build target (the processed manifest), but 489# also the incidental ones (the metadata-derived symlinks). 490# 491# If pkgmogrify exits cleanly but fails to create the specified output 492# file, it means that it encountered an abort directive. That means 493# that this package should not be published for this particular build 494# environment. Since we can't prune such packages from $(PKGS) 495# retroactively, we need to create an empty target file to keep make 496# from trying to rebuild it every time. For these empty targets, we 497# do not create metadata symlinks. 498# 499# Automatic dependency resolution to files is also done at this phase of 500# processing. The skipped packages are skipped due to existing bugs 501# in pkgdepend. 502# 503# The incorporation dependency is tricky: it needs to go into all 504# current and renamed manifests (ie all incorporated packages), but we 505# don't know which those are until after we run pkgmogrify. So 506# instead of expressing it as a transform, we tack it on ex post facto. 507# 508# Implementation notes: 509# 510# - The first $(RM) must not match other manifests, or we'll run into 511# race conditions with parallel manifest processing. 512# 513# - The make macros [ie $(MACRO)] are evaluated when the makefile is 514# read in, and will result in a fixed, macro-expanded rule for each 515# target enumerated in $(PROC_PKGS). 516# 517# - The shell variables (ie $$VAR) are assigned on the fly, as the rule 518# is executed. The results may only be referenced in the shell in 519# which they are assigned, so from the perspective of make, all code 520# that needs these variables needs to be part of the same line of 521# code. Hence the use of command separators and line continuation 522# characters. 523# 524# - The extract_metadata transforms are designed to spit out shell 525# variable assignments to stdout. Those are published to the 526# .vars temporary files, and then used as input to the eval 527# statement. This is done in stages specifically so that pkgmogrify 528# can signal failure if the manifest has a syntactic or other error. 529# The eval statement should begin with the default values, and the 530# output from pkgmogrify (if any) should be in the form of a 531# variable assignment to override those defaults. 532# 533# - When this rule completes execution, it must leave an updated 534# target file ($@) in place, or make will reprocess the package 535# every time it encounters it as a dependency. Hence the "touch" 536# statement to ensure that the target is created, even when 537# pkgmogrify encounters an abort in the publish transforms. 538# 539 540.SUFFIXES: .mf .mog .dep .res .fin .pub 541 542$(PDIR)/%.mog: manifests/%.mf 543 @print "Processing manifest $(<F)" 544 @env PKGFMT_OUTPUT=v1 pkgfmt -c $< 545 $(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \ 546 $(@:%.mog=%.lics) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars 547 $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \ 548 $(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \ 549 $(<) $(PM_TRANSFORMS) 550 $(PKGDEBUG)eval REPO=redist PKGSTAT=current NODEPEND=$(SUPPRESSPKGDEP) \ 551 `$(CAT) -s $(@).vars`; \ 552 if [ -f $(@) ]; then \ 553 if [ "$$NODEPEND" != "false" ]; then \ 554 $(TOUCH) $(@:%.mog=%.nodepend); \ 555 fi; \ 556 $(LN) -s $(@F) \ 557 $(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \ 558 if [ \( "$$PKGSTAT" = "current" \) -o \ 559 \( "$$PKGSTAT" = "renamed" \) ]; \ 560 then print $(PKGDEP_INCORP) >> $(@); \ 561 fi; \ 562 print $$LICS > $(@:%.mog=%.lics); \ 563 else \ 564 $(TOUCH) $(@) $(@:%.mog=%.lics); \ 565 fi 566 $(PKGDEBUG)$(RM) $(@).vars 567 568$(PDIR)/%.dep: $(PDIR)/%.mog 569 @print "Generating dependencies for $(<F)" 570 $(PKGDEBUG)$(RM) $(@) 571 $(PKGDEBUG)if [ ! -f $(@:%.dep=%.nodepend) ]; then \ 572 pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \ 573 $(PKGROOT) > $(@); \ 574 else \ 575 $(CP) $(<) $(@); \ 576 fi 577 578# 579# The full chain implies that there should be a .dep.res suffix rule, 580# but dependency generation is done on a set of manifests, rather than 581# on a per-manifest basis. Instead, see the gendeps rule above. 582# 583 584$(PDIR)/%.fin: $(PDIR)/%.res 585 $(PKGDEBUG)$(RM) $(@) 586 $(PKGDEBUG)if [ -s $(<) ]; then \ 587 print "Running final transforms for $(<F)"; \ 588 $(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) -O $(@) \ 589 $(<) $(PM_FINAL_TRANSFORMS); \ 590 else \ 591 $(TOUCH) $(@); \ 592 fi 593 594$(PDIR)/%.pub: $(PDIR)/%.fin 595 $(PKGDEBUG)m=$$(basename $(@:%.pub=%).metadata.*); \ 596 r=$${m#$(@F:%.pub=%.metadata.)+(?).}; \ 597 if [ -s $(<) ]; then \ 598 print "Publishing $(@F:%.pub=%) to $$r repository"; \ 599 pkgsend -s file://$(PKGDEST)/repo.$$r publish \ 600 -d $(PKGROOT) -d $(TOOLSROOT) \ 601 -d license_files -d $(PKGROOT)/licenses \ 602 --fmri-in-manifest --no-index --no-catalog $(<) \ 603 > /dev/null; \ 604 fi; \ 605 $(TOUCH) $(@); 606 607# 608# rule to build the synthetic manifests 609# 610# This rule necessarily has PKGDEP_TYPE that changes according to 611# the specific synthetic manifest. Rather than escape command 612# dependency checking for the real manifest processing, or failing to 613# express the (indirect) dependency of synthetic manifests on real 614# manifests, we simply split this rule out from the one above. 615# 616# The implementation notes from the previous rule are applicable 617# here, too. 618# 619$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.mf) 620 @print "Processing synthetic manifest $(@F:%.mog=%.mf)" 621 $(PKGDEBUG)$(RM) $(@) $(PDIR)/$(@F:%.mog=%).metadata.* $(@).vars 622 $(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \ 623 $(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \ 624 -P $(@).vars -O $(@) $(@F:%.mog=%.mf) \ 625 $(PM_TRANSFORMS) synthetic 626 $(PKGDEBUG)eval REPO=redist PKGSTAT=current `$(CAT) -s $(@).vars`; \ 627 if [ -f $(@) ]; then \ 628 $(LN) -s $(@F) \ 629 $(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT.$$REPO; \ 630 else \ 631 $(TOUCH) $(@); \ 632 fi 633 $(PKGDEBUG)$(RM) $(@).vars 634 635$(DEP_SYNTH_PKGS): $$(@:%.dep=%.mog) 636 @print "Skipping dependency generation for $(@F:%.dep=%)" 637 $(PKGDEBUG)$(CP) $(@:%.dep=%.mog) $(@) 638 639clean: 640 641clobber: clean 642 $(RM) -r $(CLOBBERFILES) 643 644# 645# This rule assumes that all links in the $PKGSTAT directories 646# point to valid manifests, and will fail the make run if one 647# does not contain an fmri. 648# 649# We do this in the BEGIN action instead of using pattern matching 650# because we expect the fmri to be at or near the first line of each input 651# file, and this way lets us avoid reading the rest of the file after we 652# find what we need. 653# 654# We keep track of a failure to locate an fmri, so we can fail the 655# make run, but we still attempt to process each package in the 656# repo/pkgstat-specific subdir, in hopes of maybe giving some 657# additional useful info. 658# 659# The protolist is used for bfu archive creation, which may be invoked 660# interactively by the user. Both protolist and PKGLISTS targets 661# depend on $(PROC_PKGS), but protolist builds them recursively. 662# To avoid collisions, we insert protolist into the dependency chain 663# here. This has two somewhat subtle benefits: it allows bfu archive 664# creation to work correctly, even when -a was not part of NIGHTLY_OPTIONS, 665# and it ensures that a protolist file here will always correspond to the 666# contents of the processed manifests, which can vary depending on build 667# environment. 668# 669$(PKGLISTS): $(PROC_PKGS) 670 $(PKGDEBUG)sdotr=$(@F:packages.%=%); \ 671 r=$${sdotr%.+(?)}; s=$${sdotr#+(?).}; \ 672 print "Generating $$r $$s package list"; \ 673 $(RM) $(@); $(TOUCH) $(@); \ 674 $(AWK) 'BEGIN { \ 675 if (ARGC < 2) { \ 676 exit; \ 677 } \ 678 retcode = 0; \ 679 for (i = 1; i < ARGC; i++) { \ 680 do { \ 681 e = getline f < ARGV[i]; \ 682 } while ((e == 1) && (f !~ /name=pkg.fmri/)); \ 683 close(ARGV[i]); \ 684 if (e == 1) { \ 685 l = split(f, a, "="); \ 686 print "depend fmri=" a[l], \ 687 "type=$$(PKGDEP_TYPE)"; \ 688 } else { \ 689 print "no fmri in " ARGV[i] >> "/dev/stderr"; \ 690 retcode = 2; \ 691 } \ 692 } \ 693 exit retcode; \ 694 }' `find $(PDIR) -type l -a \( $(PKGS:%=-name %.metadata.$$s.$$r -o) \ 695 -name NOSUCHFILE \)` >> $(@) 696 697# 698# rules to validate proto area against manifests, check for safe 699# file permission modes, and generate a faux proto list 700# 701# For the check targets, the dependencies on $(PROC_PKGS) is specified 702# as a subordinate make process in order to suppress output. 703# 704makesilent: 705 @$(MAKE) -e $(PROC_PKGS) PKGMACH=$(PKGMACH) \ 706 SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) > /dev/null 707 708# 709# The .lics files were created during pkgmogrification, and list the 710# set of licenses to pull from $SRC for each package. Because 711# licenses may be duplicated between packages, we uniquify them as 712# well as aggregating them here. 713# 714license-list: makesilent 715 $(PKGDEBUG)( for l in `cat $(PROC_PKGS:%.mog=%.lics)`; \ 716 do print $$l; done ) | sort -u > $@ 717 718# 719# Staging the license and description files in the proto area allows 720# us to do proper unreferenced file checking of both license and 721# description files without blanket exceptions, and to pull license 722# content without reference to $CODEMGR_WS during publication. 723# 724stage-licenses: license-list FRC 725 $(PKGDEBUG)$(MAKE) -e -f Makefile.lic \ 726 PKGDEBUG=$(PKGDEBUG) LICROOT=$(PKGROOT)/licenses \ 727 `$(AWK) '{ \ 728 print "$(PKGROOT)/licenses/" $$0; \ 729 print "$(PKGROOT)/licenses/" $$0 ".descrip"; \ 730 }' license-list` > /dev/null; 731 732protocmp: makesilent 733 @validate_pkg -a $(PKGMACH) -v \ 734 $(EXCEPTIONS:%=-e $(CODEMGR_WS)/exception_lists/%) \ 735 -m $(PDIR) -p $(PKGROOT) -p $(TOOLSROOT) 736 737pmodes: makesilent 738 @validate_pkg -a $(PKGMACH) -M -m $(PDIR) \ 739 -e $(CODEMGR_WS)/exception_lists/pmodes 740 741pkglint: makesilent 742 $(PKGDEBUG)$(CP) etc/pkglintrc $(PDIR)/pkglintrc 743 $(PKGDEBUG)$(GREP) pkg:/ $(CODEMGR_WS)/exception_lists/packaging.deps \ 744 | sed 's/.*/ & \\/' >> $(PDIR)/pkglintrc 745 $(PKGDEBUG)echo " pkg:/runtime/python$(PYTHON_PKGVERS) \\" \ 746 >> $(PDIR)/pkglintrc 747 $(PKGDEBUG)echo " pkg:/runtime/python$(PYTHON3_PKGVERS) \\" \ 748 >> $(PDIR)/pkglintrc 749 $(PKGDEBUG) echo " pkg:/runtime/perl$(PERL_PKGVERS) \\" \ 750 >> $(PDIR)/pkglintrc 751 $(PKGDEBUG)echo >> $(PDIR)/pkglintrc 752 $(PKGDEBUG)$(RM) -rf $(PKGDEST)/lint.image 753 $(PKGDEBUG)for r in $(REPOS); do \ 754 pkglint \ 755 -f $(PDIR)/pkglintrc \ 756 -c $(PKGDEST)/lint.image \ 757 -r $(PKGDEST)/repo.$$r \ 758 `$(FIND) $(PDIR) -name \*.fin \! -size 0c -print`; \ 759 done 760 761check: protocmp pmodes pkglint 762 763protolist: proto_list_$(PKGMACH) 764 765proto_list_$(PKGMACH): $(PROC_PKGS) 766 @validate_pkg -a $(PKGMACH) -L -m $(PDIR) > $(@) 767 768$(PROC_PKGS): $(PDIR) 769 770# 771# This is a convenience target to allow package names to function as 772# build targets. Generally, using it is only useful when iterating on 773# development of a manifest. 774# 775# When processing a manifest, use the basename (without extension) of 776# the package. When publishing, use the basename with a ".pub" 777# extension. 778# 779# Other than during manifest development, the preferred usage is to 780# avoid these targets and override PKGS on the make command line and 781# use the provided all and install targets. 782# 783$(PKGS) $(SYNTH_PKGS): $(PDIR)/$$(@:%=%.mog) 784 785$(PKGS:%=%.pub) $(SYNTH_PKGS:%=%.pub): $(PDIR)/$$(@) 786 787# 788# This is a convenience target to resolve dependencies without publishing 789# packages. 790# 791gendeps: $(PDIR)/gendeps 792 793# 794# These are convenience targets for cross-platform packaging. If you 795# want to build any of "the normal" targets for a different 796# architecture, simply use "arch/target" as your build target. 797# 798# Since the most common use case for this is "install," the architecture 799# specific install targets have been further abbreviated to elide "/install." 800# 801i386/% sparc/%: 802 $(MAKE) -e $(@F) PKGMACH=$(@D) SUPPRESSPKGDEP=$(SUPPRESSPKGDEP) 803 804i386 sparc: $$(@)/install 805 806FRC: 807