7059188 simplify and mogrify X meta-package synthesis
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Mon, 27 Jun 2011 13:58:10 -0700
changeset 1153 912dd58dfc72
parent 1152 6cf0f98f6d5f
child 1154 941fbafb8c39
7059188 simplify and mogrify X meta-package synthesis
pkg/Makefile
pkg/X-incorporation.p5m
pkg/X-redistributable.p5m
pkg/manifests/developer-opensolaris-X.p5m
pkg/transforms/extract_metadata
pkg/transforms/synthetic
--- a/pkg/Makefile	Thu Jun 23 20:28:56 2011 -0700
+++ b/pkg/Makefile	Mon Jun 27 13:58:10 2011 -0700
@@ -109,32 +109,6 @@
 SYNTH_PKGS= X-incorporation X-redistributable
 SYNTH_MANIFESTS = $(SYNTH_PKGS:%=%.p5m)
 
-# Any given package list may be empty, but we can only determine that 
-# dynamically, so we always generate all lists.
-#
-# The meanings of each package status are as follows:
-#
-# 	PKGSTAT		meaning
-# 	----------	----------------------------------------------------
-# 	noincorp	Do not include in incorporation or group package
-# 	grouponly	Include in group package, but not incorporation
-#	obsolete	Include in incorporation, but not group package
-#	renamed		Include in incorporation, but not group package
-#	current		Include in incorporation and group package
-#
-# Since the semantics of the "noincorp" package status dictate that
-# such packages are not included in the incorporation or group packages,
-# there is no need to build noincorp package lists.
-#
-# Since packages depend on their incorporation, noincorp necessarily
-# implies nodepend, or it would inadvertently pull in other packages.
-#
-PKGLISTS= \
-	$(PDIR)/packages.current \
-	$(PDIR)/packages.grouponly \
-	$(PDIR)/packages.renamed \
-	$(PDIR)/packages.obsolete
-
 # Manifests are in either manifests or legacy directory - merge in $(PDIR)
 $(PDIR)/%.p5m: manifests/%.p5m
 	$(PKGDEBUG)$(LN) -s ../$< $@
@@ -149,6 +123,10 @@
 manifests: $(PMANIFESTS)
 $(PMANIFESTS): $(PDIR)
 
+SMANIFESTS = $(SYNTH_MANIFESTS:%=$(PDIR)/%)
+manifests: $(SMANIFESTS)
+$(SMANIFESTS): $(PDIR)
+
 ### Additional metadata generation
 
 # This should eventually move into pkg publication
@@ -220,21 +198,19 @@
 PYTHON_PKG_VERSION_CMD = print $(PYTHON_VERSION) | tr -d '.'
 PKGMOG_DEFINES += PYTHON_PKG_VERSION=$(PYTHON_PKG_VERSION_CMD:sh)
 
+PROC_PKGS = $(PKGS:%=$(PDIR)/%.mog)
+PROC_CURRENT_PKGS = $(CURRENT_MANIFESTS:%.p5m=$(PDIR)/%.mog)
+PROC_LEGACY_PKGS = $(LEGACY_MANIFESTS:%.p5m=$(PDIR)/%.mog)
+PROC_SYNTH_PKGS = $(SYNTH_MANIFESTS:%.p5m=$(PDIR)/%.mog)
 
 # Default transformations to apply
 PM_TRANSFORMS = $(PKG_BRANDING_TRANSFORMS) \
 		common_actions publish restart_fmri facets \
-		licenses $(PDIR)/versions extract_metadata
+		licenses $(PDIR)/versions
 PM_INC = transforms
 
-PKGDEP_INCORP = depend fmri=pkg:/consolidation/X/X-incorporation type=require
-
-PROC_PKGS = $(PKGS:%=$(PDIR)/%.mog)
-PROC_SYNTH_PKGS = $(SYNTH_PKGS:%=$(PDIR)/%.mog)
-PROC_CURRENT_PKGS = $(CURRENT_MANIFESTS:%.p5m=$(PDIR)/%.mog)
-
-# Extra transforms for non-legacy packages
-$(PROC_CURRENT_PKGS):= EXTRA_TRANSFORMS = defaults
+# Additional transforms for specific types of packages
+$(PROC_CURRENT_PKGS) $(PROC_SYNTH_PKGS) := EXTRA_TRANSFORMS = defaults
 
 mogrify: $(PROC_PKGS)
 $(PROC_PKGS): $(PDIR)/versions
@@ -251,57 +227,13 @@
 
 $(PDIR)/%.mog: $(PDIR)/%.p5m $(PDIR)/%.attr
 	@print "## Processing manifest $(@F:.mog=.p5m)"
-	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) $(@:%.mog=%.nodepend) \
-		$(@:%.mog=%.metadata.*) $(@).vars
+	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%) \
+		$(@:%.mog=%.metadata.*) $(@:%.mog=%.synth)
 	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
-		$(PKGMOG_DEFINES:%=-D %) -P $(@).vars -O $(@) \
-		$(@:.mog=.p5m) $(@:.mog=.attr) \
-		$(PM_TRANSFORMS) $(EXTRA_TRANSFORMS) 
-	$(PKGDEBUG)if [[ -f $(@) ]]; then \
-		eval PKGSTAT=current NODEPEND="$(SUPPRESSPKGDEP)" \
-			$$(cat -s $(@).vars) ; \
-		if [[ "$$NODEPEND" != "false" || "$$PKGSTAT" = "noincorp" ]]; \
-		then \
-			$(TOUCH) $(@:%.mog=%.nodepend); \
-		fi; \
-		$(LN) -s $(@F) \
-			$(PDIR)/$(@F:%.mog=%).metadata.$$PKGSTAT ; \
-		if [[ "$$PKGSTAT" = "current" || "$$PKGSTAT" = "renamed"  ]]; \
-		then \
-			print $(PKGDEP_INCORP) >> $(@); \
-		fi; \
-	else \
-		$(TOUCH) $(@); \
-	fi
-	$(PKGDEBUG)$(RM) $(@).vars
-
-# make the package lists from the real manifests for the synthetic manifests
-$(PKGLISTS): $(PROC_PKGS)
-	@print "## Generating $(@F:packages.%=%) package list"
-	$(PKGDEBUG)$(PERL) -nl -w -Mdiagnostics \
-	 -e 'if ($$_ =~ m{name=pkg.fmri value=(\S+)}) {' \
-	 -e '   printf "depend fmri=$$1 type=\$$(PKGDEP_TYPE)\n";' \
-	 -e '   close ARGV; ' \
-	 -e '}' $(PDIR)/*.metadata.$(@F:packages.%=%) > $(@).new
-	$(PKGDEBUG) mv -f $(@).new $(@)
-
-pkglists: $(PKGLISTS)
-
-# The package lists are generated with $(PKGDEP_TYPE) as their
-# dependency types, so that they can be included by either an
-# incorporation or a group package.
-#
-$(PDIR)/X-redistributable.mog:= PKGDEP_TYPE= require
-$(PDIR)/X-incorporation.mog:= PKGDEP_TYPE= incorporate
-
-# rule to build the synthetic manifests
-$(PROC_SYNTH_PKGS): $(PKGLISTS) $$(@F:%.mog=%.p5m)
-	@print "## Processing synthetic manifest $(@F:%.mog=%.p5m)"
-	$(PKGDEBUG)$(RM) $(@) $(@:%.mog=%).metadata.*
-	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) -I transforms -I $(PDIR) \
-		$(PKGMOG_DEFINES:%=-D %) -D PKGDEP_TYPE=$(PKGDEP_TYPE) \
-		-O $(@) $(@F:%.mog=%.p5m) \
-		$(PM_TRANSFORMS) defaults synthetic
+		$(PKGMOG_DEFINES:%=-D %) -O $(@) \
+		$(@:%.mog=%.p5m) $(@:%.mog=%.attr) \
+		$(PM_TRANSFORMS) $(EXTRA_TRANSFORMS)
+	$(PKGDEBUG)$(TOUCH) $(@)
 
 ### Dependency detection
 DEP_PKGS= $(PKGS:%=$(PDIR)/%.dep)
@@ -325,7 +257,7 @@
 $(PDIR)/%.dep: $(PDIR)/%.mog
 	@print "## Generating dependencies for $(<F)"
 	$(PKGDEBUG)$(RM) $(@)
-	$(PKGDEBUG)if [[ ! -f $(@:%.dep=%.nodepend) ]]; then \
+	$(PKGDEBUG)if [[ "$(SUPPRESSPKGDEP)" != "true" ]]; then \
 		pkgdepend generate -m $(PKGDEP_TOKENS:%=-D %) $(<) \
 			$(PKGROOT) > $(@); \
 	else \
@@ -374,14 +306,30 @@
 	$(PKGDEBUG)$(CP) $(@:%.dep.res=%.dep) $(@)
 
 # Post-processing of manifests after dependency resolution
+RES_PKGS = $(PKGS:%=$(PDIR)/%.res)
+RES_CURRENT_PKGS = $(CURRENT_MANIFESTS:%.p5m=$(PDIR)/%.res)
+RES_LEGACY_PKGS = $(LEGACY_MANIFESTS:%.p5m=$(PDIR)/%.res)
+RES_SYNTH_PKGS = $(SYNTH_MANIFESTS:%.p5m=$(PDIR)/%.res)
+
+POST_TRANSFORMS = post-pkgdepend extract_metadata
 $(PDIR)/%.res: $(PDIR)/%.dep.res
+	@print "## Post-processing manifest for $(@F:%.res=%)"
 	$(PKGDEBUG)if [[ -s $< ]] ; then \
 		$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
-			-O $@ $< post-pkgdepend ; \
+		 -O $@ -P $(@:%.res=%.synth) $< $(POST_TRANSFORMS) ; \
 	else \
 		$(CP) $< $@ ; \
 	fi
 
+# Generate info for synthetic manifests
+$(RES_SYNTH_PKGS): $(RES_PKGS) $$(@:%.res=%.dep.res)
+	@print "## Gathering package lists for synthetic package $(@F:%.res=%)"
+	$(PKGDEBUG)$(PKGMOGRIFY) $(PKGMOG_VERBOSE) $(PM_INC:%= -I %) \
+		-O $(@) -P $(@:%.res=%.synth.sed) \
+		$(@:%.res=%.dep.res) synthetic
+	$(PKGDEBUG)$(SED) -n -f $(@:%.res=%.synth.sed) $(PDIR)/*.synth >> $(@)
+
+
 ### pkglint checking (pre-publication)
 
 PKGLINT = pkglint
--- a/pkg/X-incorporation.p5m	Thu Jun 23 20:28:56 2011 -0700
+++ b/pkg/X-incorporation.p5m	Mon Jun 27 13:58:10 2011 -0700
@@ -28,6 +28,3 @@
 set name=pkg.summary value="X consolidation incorporation"
 set name=info.classification \
     value="org.opensolaris.category.2008:Meta Packages/Incorporations"
-<include packages.current>
-<include packages.renamed>
-<include packages.obsolete>
--- a/pkg/X-redistributable.p5m	Thu Jun 23 20:28:56 2011 -0700
+++ b/pkg/X-redistributable.p5m	Mon Jun 27 13:58:10 2011 -0700
@@ -27,5 +27,3 @@
 set name=pkg.summary value="X consolidation group package"
 set name=info.classification \
     value="org.opensolaris.category.2008:Meta Packages/Group Packages"
-<include packages.current>
-<include packages.grouponly>
--- a/pkg/manifests/developer-opensolaris-X.p5m	Thu Jun 23 20:28:56 2011 -0700
+++ b/pkg/manifests/developer-opensolaris-X.p5m	Mon Jun 27 13:58:10 2011 -0700
@@ -28,9 +28,7 @@
 # We don't want this package to be part of the X incorporation so that you
 # can install it to bootstrap the consolidation build for a later build
 # without having to uninstall all the X packages first.
-# We do want it to be part of the X-redistributable group, so it gets
-# included in the WOS correctly.
-set name=org.opensolaris.grouponly value=true
+set name=org.opensolaris.noincorp value=true
 
 # Workaround for https://defect.opensolaris.org/bz/show_bug.cgi?id=15809
 depend fmri=pkg:/compatibility/ucb type=require
--- a/pkg/transforms/extract_metadata	Thu Jun 23 20:28:56 2011 -0700
+++ b/pkg/transforms/extract_metadata	Mon Jun 27 13:58:10 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -21,17 +21,29 @@
 # DEALINGS IN THE SOFTWARE.
 #
 
-#
-# Ordering is important here, and the last line wins.
-#
-# The default of "current" is provided by the calling environment,
-# rather than a print operation.
+<transform pkg -> default pkg.obsolete false>
+<transform pkg -> default pkg.renamed false>
+
+# 
+# Non-obsolete packages should be included in the consolidation 
+# incorporation, unless marked otherwise
 #
-<transform set name=pkg.renamed value=true -> print PKGSTAT=renamed>
-<transform set name=pkg.obsolete value=true -> print PKGSTAT=obsolete>
-<transform set name=org.opensolaris.grouponly value=true -> print PKGSTAT=grouponly>
-<transform set name=org.opensolaris.grouponly -> drop>
-<transform set name=org.opensolaris.nodepend value=true -> print NODEPEND=true>
-<transform set name=org.opensolaris.nodepend -> drop>
-<transform set name=org.opensolaris.noincorp value=true -> print PKGSTAT=noincorp>
+<transform pkg -> default org.opensolaris.noincorp false>
+<transform pkg -> default org.opensolaris.incorporation \
+    pkg:/consolidation/X/X-incorporation>
+<transform pkg pkg.obsolete=false org.opensolaris.noincorp=false -> print \
+    %(org.opensolaris.incorporation): depend fmri=%{pkg.fmri} type=incorporate>
+<transform pkg pkg.obsolete=false org.opensolaris.noincorp=false -> emit \
+    depend fmri=%(org.opensolaris.incorporation) type=require>
 <transform set name=org.opensolaris.noincorp -> drop>
+<transform set name=org.opensolaris.incorporation -> drop>
+
+# 
+# Packages that are neither obsolete nor renamed should be included in
+# the X-redistributable group package, unless marked otherwise
+#
+<transform pkg -> default org.opensolaris.nogroup false>
+<transform pkg pkg.renamed=false pkg.obsolete=false \
+    org.opensolaris.nogroup=false pkg.fmri=^(.*)@.* -> print \
+    pkg:/consolidation/X/X-redistributable: depend fmri=%<1> type=require>
+<transform set name=org.opensolaris.nogroup -> drop>
--- a/pkg/transforms/synthetic	Thu Jun 23 20:28:56 2011 -0700
+++ b/pkg/transforms/synthetic	Mon Jun 27 13:58:10 2011 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -21,10 +21,7 @@
 # DEALINGS IN THE SOFTWARE.
 #
 
-#
-# When we process the synthetic manifests, we don't know if a "make
-# clobber" was done or not.  This keeps us from having silly,
-# self-referential dependencies in 'em, even when they make it into
-# the package lists.
-#
-<transform depend fmri=pkg:/consolidation/X/X-incorporation@.+ -> drop>
+# Generate the sed command used to extract the metadata for this synthetic
+# package from the *.synth files for the other packages
+
+<transform pkg pkg.fmri=^(.*)@.* -> print s|^%<1>: ||p>