python/elasticsearch: update to 8.16.0
[oi-userland.git] / make-rules / environment.mk
blobbfe4fc7f2376afa4c652ad758acfe40e26c5396c
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
23 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
24 # Copyright (c) 2020, Adam Stevko
27 PFEXEC = /usr/bin/pfexec
29 ZONE = $(WS_TOOLS)/userland-zone
31 define separator-line
32 @$(PYTHON) -c 'l="="*int(40-len("$1")/2); print("%s%s%s" % (l, "$1", l))'
33 endef
35 component-environment-check::
36 $(call separator-line,Workspace)
37 @echo " Path: $(WS_TOP)"
38 @echo " Branch: $$(git rev-parse --abbrev-ref HEAD)"
39 @echo " Changeset: $$(git rev-parse HEAD)"
40 $(call separator-line,System)
41 @/usr/bin/uname -a
42 @echo "Zone: $$(/usr/bin/zonename)"
43 @echo "Zone IP type: $$(/usr/bin/zonename -t)"
44 @/usr/sbin/psrinfo -vp
45 @/usr/sbin/ipadm show-addr
46 $(call separator-line,Required Packages)
47 @/usr/bin/pkg list -vH $(USERLAND_REQUIRED_PACKAGES:%=/%) $(REQUIRED_PACKAGES:%=/%)
48 $(call separator-line)
50 component-environment-prep::
51 @/usr/bin/pkg list -vH $(USERLAND_REQUIRED_PACKAGES:%=/%) $(REQUIRED_PACKAGES:%=/%) >/dev/null || \
52 { echo "Adding required packages to build environment..."; \
53 while true ; do \
54 $(PFEXEC) /usr/bin/pkg install --accept -v $(USERLAND_REQUIRED_PACKAGES:%=/%) $(REQUIRED_PACKAGES:%=/%) ; \
55 RETVAL=$$? ; \
56 [ $$RETVAL -eq 0 ] && break; \
57 [ $$RETVAL -eq 4 ] && break; \
58 [ $$RETVAL -ne 7 ] && echo "pkg install returned $$RETVAL" && exit 1; \
59 sleep 10; \
60 done; }
62 component-test-environment-check:: component-environment-check
63 $(call separator-line,Required Additional Packages Needed for Testing Only)
64 @[ -z "$(strip $(USERLAND_TEST_REQUIRED_PACKAGES))$(strip $(TEST_REQUIRED_PACKAGES))" ] || \
65 /usr/bin/pkg list -vH $(USERLAND_TEST_REQUIRED_PACKAGES:%=/%) $(TEST_REQUIRED_PACKAGES:%=/%)
66 @C=0 ; \
67 for p in $(TEST_CONFLICTING_PACKAGES) ; do \
68 /usr/bin/pkg list -q /$$p && echo "Conflicting package $$p found" && C=1 ; \
69 done ; \
70 exit $$C
71 $(call separator-line)
73 component-test-environment-prep::
74 @[ -z "$(strip $(USERLAND_TEST_REQUIRED_PACKAGES))$(strip $(TEST_REQUIRED_PACKAGES))" ] || \
75 /usr/bin/pkg list -vH $(USERLAND_TEST_REQUIRED_PACKAGES:%=/%) $(TEST_REQUIRED_PACKAGES:%=/%) >/dev/null || \
76 { echo "Adding required packages to testing environment..."; \
77 while true ; do \
78 $(PFEXEC) /usr/bin/pkg install --accept -v $(USERLAND_TEST_REQUIRED_PACKAGES:%=/%) $(TEST_REQUIRED_PACKAGES:%=/%) ; \
79 RETVAL=$$? ; \
80 [ $$RETVAL -eq 0 ] && break; \
81 [ $$RETVAL -eq 4 ] && break; \
82 [ $$RETVAL -ne 7 ] && echo "pkg install returned $$RETVAL" && exit 1; \
83 sleep 10; \
84 done; }
85 @for p in $(TEST_CONFLICTING_PACKAGES) ; do \
86 /usr/bin/pkg list -q /$$p || continue ; \
87 echo "Removing conflicting packages from testing environment..." ; \
88 while true ; do \
89 $(PFEXEC) /usr/bin/pkg uninstall -v --deny-new-be --ignore-missing $(TEST_CONFLICTING_PACKAGES:%=/%) ; \
90 RETVAL=$$? ; \
91 [ $$RETVAL -eq 0 ] && exit 0 ; \
92 [ $$RETVAL -ne 7 ] && echo "pkg uninstall returned $$RETVAL" && exit 1 ; \
93 sleep 10 ; \
94 done ; \
95 done
97 ZONENAME_PREFIX = bz
98 ZONENAME_ID = $(shell echo "$(WS_TOP)" | sha1sum | cut -c0-7)-$(COMPONENT_NAME)
99 ZONENAME = $(ZONENAME_PREFIX)-$(ZONENAME_ID)
101 component-zone-template:
102 $(call separator-line)
103 $(call separator-line,Create template zone)
104 USER_ID=$$(id -u) && \
105 $(PFEXEC) $(ZONE) --prefix $(ZONENAME_PREFIX) create-template -u $${USER} -i $${USER_ID}
107 component-zone-build:
108 $(call separator-line)
109 $(call separator-line,Create $(ZONENAME))
110 $(PFEXEC) $(ZONE) --prefix $(ZONENAME_PREFIX) spawn-zone --id $(ZONENAME_ID)
111 $(call separator-line,Boot $(ZONENAME))
112 @while $$(true); do \
113 echo "Waiting for zone $(ZONENAME) to boot..."; \
114 $(PFEXEC) /usr/sbin/zlogin -l $${USER} $(ZONENAME) \
115 /bin/true >/dev/null 2>&1 && break; \
116 sleep 10; \
117 done
118 # FIXME:
119 # - remove once we figure out a better way how to enable zoneproxy-client inside the nlipkg brand
120 @while $$(true); do \
121 echo "Waiting for $(ZONENAME) config repository.."; \
122 $(PFEXEC) /usr/bin/svcs -z $(ZONENAME) -a >/dev/null 2>&1 && break; \
123 sleep 10; \
124 done
125 # We need to create door inside after zone-proxy-client is running
126 $(call separator-line,Configure IPS for $(ZONENAME))
127 $(PFEXEC) /usr/lib/zones/zoneproxy-adm $(ZONENAME)
128 @while $$(true); do \
129 echo "Waiting for zoneproxyd to be ready.."; \
130 PROXY_PID=$$(/usr/bin/svcs -p svc:/application/pkg/zones-proxyd:default | \
131 nawk '$$0 ~ /zoneproxyd/ {print $$2}') && \
132 $(PFEXEC) /usr/bin/pfiles $${PROXY_PID} | \
133 $(GNU_GREP) $(ZONENAME) >/dev/null 2>&1 && break; \
134 sleep 10; \
135 done
136 $(PFEXEC) /usr/sbin/svcadm -z $(ZONENAME) \
137 enable svc:/application/pkg/zones-proxy-client:default
138 ZONEROOT="$$(/usr/sbin/zoneadm -z $(ZONENAME) list -p | cut -d: -f4)/root" && \
139 $(PFEXEC) /usr/bin/pkg -R $${ZONEROOT} set-property use-system-repo True && \
140 while $$(true); do \
141 echo "Waiting for sysrepo to be ready..." && \
142 $(PFEXEC) /usr/bin/pkg -R $${ZONEROOT} publisher | \
143 $(GNU_GREP) syspub >/dev/null 2>&1 && break; \
144 sleep 10; \
145 done
146 $(call separator-line,Build in $(ZONENAME))
147 $(PFEXEC) /usr/sbin/zlogin -l $${USER} $(ZONENAME) \
148 "cd $(COMPONENT_DIR); gmake install"
149 $(call separator-line)
151 component-zone-cleanup:
152 $(PFEXEC) $(ZONE) destroy-zone --id $(ZONENAME_ID)
154 # Short aliases for user convenience
155 env-check:: component-environment-check
156 env-prep:: component-environment-prep
157 test-env-check:: component-test-environment-check
158 test-env-prep:: component-test-environment-prep