make-rules/environment.mk
changeset 3817 30b42c38bbc4
child 5682 94c0ca64c022
equal deleted inserted replaced
3814:60344306d223 3817:30b42c38bbc4
       
     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 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
       
    22 #
       
    23 SUDO =		/usr/bin/sudo
       
    24 
       
    25 define separator-line
       
    26 	@$(PYTHON) -c 'l="="*(40-len("$1")/2); print("%s%s%s" % (l, "$1", l))'
       
    27 endef
       
    28 
       
    29 component-environment-check::
       
    30 	$(call separator-line,Workspace)
       
    31 	@echo " Path:        $(WS_TOP)"
       
    32 	@echo " Branch:      $$(hg identify -b)"
       
    33 	@echo " Changeset:   $$(hg identify -n)($$(hg identify -i))"
       
    34 	$(call separator-line,System)
       
    35 	@/usr/bin/uname -a
       
    36 	@echo "Zone:  $$(/usr/sbin/zonename)"
       
    37 	@/usr/sbin/psrinfo -vp
       
    38 	@/usr/sbin/ipadm show-addr
       
    39 	$(call separator-line,Required Packages)
       
    40 	@/usr/bin/pkg list -vH $(REQUIRED_PACKAGES:%=/%)
       
    41 	$(call separator-line)
       
    42 
       
    43 component-environment-prep::
       
    44 	@echo "Adding required packages to build environment..."
       
    45 	@-echo $(REQUIRED_PACKAGES:%=/%) | xargs \
       
    46 		$(SUDO) /usr/bin/pkg install --accept -v
       
    47 
       
    48 
       
    49 #
       
    50 # For building in a constructed zone.  Currently this assumes a template zone
       
    51 # with /ws (tools mountpoint) and /builds (workspace mountpoint) mounted
       
    52 # in the same place as in the global zone.  It also assumes the current
       
    53 # $USER account is replicated in the template zone.
       
    54 #
       
    55 ZONENAME=bz-$(shell echo "$(WS_TOP)" | md5sum | cut -c0-7)-$(COMPONENT_NAME)
       
    56 
       
    57 $(BUILD_DIR)/packages.xml:	Makefile	$(BUILD_DIR)
       
    58 	@echo "$(REQUIRED_PACKAGES:%=\t\t<name>pkg:/%</name>\n)" >$(@)
       
    59 
       
    60 $(BUILD_DIR)/ai_manifest.xml:	$(WS_TOOLS)/zone_default.xml $(BUILD_DIR)
       
    61 	$(CP) $< $(@)
       
    62 
       
    63 $(BUILD_DIR)/sc_profile.xml:	$(WS_TOOLS)/sc_profile.xml $(BUILD_DIR)
       
    64 	$(GSED) -e "s/XXX_USER_XXX/$${USER}/g" -e "s/XXX_UID_XXX/$$(id -u)/g" $< >$(@)
       
    65 
       
    66 component-zone-build:	$(BUILD_DIR)/ai_manifest.xml $(BUILD_DIR)/packages.xml \
       
    67 			$(BUILD_DIR)/sc_profile.xml download
       
    68 	$(call separator-line)
       
    69 	$(call separator-line,Create $(ZONENAME))
       
    70 	$(SUDO) /usr/sbin/zonecfg -z $(ZONENAME) create -t template
       
    71 	#@$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) clone template 
       
    72 	$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) install \
       
    73 		-m $(BUILD_DIR)/ai_manifest.xml \
       
    74 		-c $(BUILD_DIR)/sc_profile.xml
       
    75 	$(call separator-line,Boot $(ZONENAME))
       
    76 	$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) boot
       
    77 	@while $$(true) ; do \
       
    78 		echo "waiting for zone ..." ; \
       
    79 		$(SUDO) /usr/sbin/zlogin -l $${USER} $(ZONENAME) \
       
    80 				/bin/true >/dev/null 2>&1 && break ; \
       
    81 		sleep 10 ; \
       
    82 	done
       
    83 	#$(call separator-line,Prep $(ZONENAME))
       
    84 	#@$(SUDO) /usr/sbin/zlogin -S $(ZONENAME) \
       
    85 	#	"cd $(COMPONENT_DIR) ; gmake component-be-prep"
       
    86 	$(call separator-line,Build in $(ZONENAME))
       
    87 	$(SUDO) /usr/sbin/zlogin -l $${USER} $(ZONENAME) \
       
    88 		"cd $(COMPONENT_DIR) ; gmake component-be-check install"
       
    89 	#	"cd $(COMPONENT_DIR) ; gmake component-be-check publish PKGLINT=/bin/true"
       
    90 	$(call separator-line,Halt $(ZONENAME))
       
    91 	$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) halt
       
    92 	$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) uninstall -F
       
    93 	$(SUDO) /usr/sbin/zonecfg -z $(ZONENAME) delete -F
       
    94 	$(call separator-line)
       
    95 
       
    96 component-zone-cleanup::
       
    97 	-$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) halt
       
    98 	-$(SUDO) /usr/sbin/zoneadm -z $(ZONENAME) uninstall -F
       
    99 	-$(SUDO) /usr/sbin/zonecfg -z $(ZONENAME) delete -F