Skip to content

Commit 329145d

Browse files
author
Jonathan Perkin
committed
Add support for specifying a version number to installed images.
Rather than adding more positional arguments, convert install-base to a proper getopts implementation. Substitute the version number in the appropriate places to the installed system.
1 parent a1c23e8 commit 329145d

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ the uuid of the seed image):
7373

7474
Then we can apply the `2013Q2-sngl` configuration to the VM with:
7575

76-
$ ./install-base 2013Q2-sngl c374c4bc-2395-4848-b28d-0c18937e7775
76+
$ ./install-base -c 2013Q2-sngl -r 13.2.0 -z c374c4bc-2395-4848-b28d-0c18937e7775
77+
78+
This uses the `2013Q2-sngl` configuration, sets the version number to `13.2.0`
79+
and installs to the specified zone.
7780

7881
The final part of this script runs `sm-prepare-image` which does some final
7982
image cleanup and shutdown, after which you can simply generate the finished

install-base

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,31 @@
44
#
55

66

7-
if [ $# -eq 2 ]; then
8-
config=$1; shift
9-
zone=$1; shift
10-
else
11-
echo "usage: $0 <config> <zone>" >&2
12-
exit 2
13-
fi
7+
usage()
8+
{
9+
echo "usage: install-base [-hv] -c <config> -r <release> -z <zone>" >&2
10+
exit 1
11+
}
12+
13+
while getopts c:hr:vz: flag; do
14+
case "${flag}" in
15+
c) config=$OPTARG ;;
16+
r) release=$OPTARG ;;
17+
v) verbose=1 ;;
18+
z) zone=$OPTARG ;;
19+
*) usage ;;
20+
esac
21+
done
1422

1523
#
1624
# Sanity checks.
1725
#
26+
for var in config release zone; do
27+
if [ -z "${!var}" ]; then
28+
echo "ERROR: ${var} not set" >&2
29+
usage
30+
fi
31+
done
1832
if [[ ! "${config}" =~ ^([0-9]{4}Q[0-9]|trunk)-(i386|x86_64|sngl|multiarch) ]]; then
1933
echo "ERROR: Unsupported configuration: ${config}" >&2
2034
exit 1
@@ -84,6 +98,7 @@ IMAGE_PRODUCT="Joyent Instance"
8498
IMAGE_SHORTPRODUCT="Instance"
8599
IMAGE_BRANCH="${config%-*}"
86100
IMAGE_ARCH="${config##*-}"
101+
IMAGE_VERSION="${release}"
87102

88103
IMAGE_CSHPATH=$(echo ${IMAGE_PATH} | sed -e 's,:, ,g')
89104
IMAGE_PACKAGES=$(echo ${IMAGE_PACKAGES} | tr '\n' ' ')
@@ -100,7 +115,7 @@ fi
100115
for var in CRLE_DPATH_32 CRLE_DPATH_64 CRLE_TPATH_32 CRLE_TPATH_64 \
101116
IMAGE_PATH IMAGE_CSHPATH IMAGE_MANDIRS \
102117
IMAGE_PREFIX IMAGE_SYSCONFDIR \
103-
IMAGE_PRODUCT IMAGE_SHORTPRODUCT \
118+
IMAGE_PRODUCT IMAGE_SHORTPRODUCT IMAGE_VERSION \
104119
IMAGE_BRANCH IMAGE_ARCH IMAGE_DOC IMAGE_PACKAGES
105120
do
106121
sedsubst="${sedsubst} s!@${var}@!${!var}!g;"

overlay/etc/motd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
_| |_ | .-. . . .-. :--. |-
33
|_ _| ;| || |(.-' | | |
44
|__| `--' `-' `;-| `-' ' ' `-'
5-
/ ; @IMAGE_SHORTPRODUCT@ (@IMAGE_ARCH@ @IMAGE_BRANCH@)
5+
/ ; @IMAGE_SHORTPRODUCT@ (@IMAGE_ARCH@ @IMAGE_VERSION@)
66
`-' @IMAGE_DOC@
77

overlay/root/customize

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ IMAGE_SYSCONFDIR="@IMAGE_SYSCONFDIR@"
3030
IMAGE_PRODUCT="@IMAGE_PRODUCT@"
3131
IMAGE_BRANCH="@IMAGE_BRANCH@"
3232
IMAGE_ARCH="@IMAGE_ARCH@"
33+
IMAGE_VERSION="@IMAGE_VERSION@"
3334
IMAGE_PRODUCT="@IMAGE_PRODUCT@"
3435
IMAGE_DOC="@IMAGE_DOC@"
3536
IMAGE_PACKAGES="@IMAGE_PACKAGES@"

0 commit comments

Comments
 (0)