Skip to content

Commit 85dfc9e

Browse files
committed
Honor APP_ROOT when installing locally built vminit image.
- Closes #1185. - Rework `install-init.sh` to accept a `-a` argument to set the app root.
1 parent adb3c44 commit 85dfc9e

2 files changed

Lines changed: 45 additions & 5 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CODESIGN_OPTS ?= --force --sign - --timestamp=none
3636
ifeq ($(strip $(APP_ROOT)),)
3737
SYSTEM_START_OPTS :=
3838
else
39-
SYSTEM_START_OPTS := --app-root "$(strip $(APP_ROOT))"
39+
SYSTEM_START_OPTS := -a "$(strip $(APP_ROOT))"
4040
endif
4141

4242
MACOS_VERSION := $(shell sw_vers -productVersion)
@@ -77,7 +77,7 @@ release: all
7777

7878
.PHONY: init-block
7979
init-block:
80-
@scripts/install-init.sh
80+
scripts/install-init.sh $(SYSTEM_START_OPTS)
8181

8282
.PHONY: install
8383
install: installer-pkg

scripts/install-init.sh

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,43 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
usage() {
17+
cat <<EOF
18+
Usage: $(basename "$0") [-a APP_ROOT] [-h]
19+
20+
Install the init image for container system.
21+
22+
Options:
23+
-a APP_ROOT Install the init image under the APP_ROOT path
24+
-h Show this help message
25+
26+
EOF
27+
exit 0
28+
}
29+
30+
# Parse command line options
31+
APP_ROOT=""
32+
while getopts "a:h" opt; do
33+
case $opt in
34+
a)
35+
APP_ROOT="$OPTARG"
36+
;;
37+
h)
38+
usage
39+
;;
40+
\?)
41+
echo "Invalid option: -$OPTARG" >&2
42+
usage
43+
;;
44+
:)
45+
echo "Option -$OPTARG requires an argument." >&2
46+
usage
47+
;;
48+
esac
49+
done
50+
1651
SWIFT="/usr/bin/swift"
1752
IMAGE_NAME="vminit:latest"
18-
DEST_DIR="${1:-$(git rev-parse --show-toplevel)/bin}"
19-
mkdir -p "${DEST_DIR}"
2053

2154
CONTAINERIZATION_VERSION="$(${SWIFT} package show-dependencies --format json | jq -r '.dependencies[] | select(.identity == "containerization") | .version')"
2255
if [ "${CONTAINERIZATION_VERSION}" == "unspecified" ] ; then
@@ -28,8 +61,15 @@ if [ "${CONTAINERIZATION_VERSION}" == "unspecified" ] ; then
2861
echo "Creating InitImage"
2962
make -C ${CONTAINERIZATION_PATH} init
3063
${CONTAINERIZATION_PATH}/bin/cctl images save -o /tmp/init.tar ${IMAGE_NAME}
64+
3165
# Sleep because commands after stop and start are racy.
32-
bin/container system stop && sleep 3 && bin/container system start && sleep 3
66+
bin/container system stop && sleep 3
67+
if [ -n "$APP_ROOT" ]; then
68+
bin/container system start --app-root "$APP_ROOT"
69+
else
70+
bin/container system start
71+
fi
72+
sleep 3
3373
bin/container i load -i /tmp/init.tar
3474
rm /tmp/init.tar
3575
fi

0 commit comments

Comments
 (0)