Skip to content

Commit f827109

Browse files
committed
scripts: replace old build-capstan-img and build-capstan-images with single build-capstan-base-image
Signed-off-by: Waldemar Kozaczuk <[email protected]>
1 parent e9d6a13 commit f827109

File tree

3 files changed

+89
-79
lines changed

3 files changed

+89
-79
lines changed

scripts/build-capstan-base-image

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
program=$(basename $0)
4+
5+
set -e
6+
7+
if [ $# -lt 2 ]; then
8+
echo "Build capstan base image"
9+
echo "Usage: $program [image-name] [(<app|module>)(,<app|module>)*] [description]"
10+
echo "Examples:"
11+
echo " ./scripts/build-capstan-base-image cloudius/osv-base empty 'OSv base image for developers'"
12+
echo " ./scripts/build-capstan-base-image cloudius/java8 openjdk8-zulu-full 'OSv base with Java 8'"
13+
echo " ./scripts/build-capstan-base-image cloudius/python3 python3x 'OSv base with Python 3'"
14+
exit 1
15+
fi
16+
17+
name=$1
18+
image=$2
19+
description=$3
20+
21+
if [ -f /etc/os-release ]; then
22+
platform=$(grep PRETTY_NAME /etc/os-release | cut -d = -f 2 | grep -o -P "[^\"]+")
23+
elif [ -f /etc/lsb-release ]; then
24+
platform=$(grep DISTRIB_DESCRIPTION /etc/lsb-release | cut -d = -f 2 | grep -o -P "[^\"]+")
25+
else
26+
platform="Unknown Linux"
27+
fi
28+
29+
OSV_VERSION=$(scripts/osv-version.sh | cut -d - -f 1 | grep -Po "[^v]*")
30+
OSV_COMMIT=$(scripts/osv-version.sh | grep -Po "\-g.*" | grep -oP "[^-g]*")
31+
32+
if [ "$OSV_COMMIT" != "" ]; then
33+
version="$OSV_VERSION-$OSV_COMMIT"
34+
fi
35+
36+
now=$(date +"%Y-%m-%dT%R:%S")
37+
38+
out=build/capstan/$name
39+
qemuimage=build/release/osv.qcow2
40+
vboximage=build/release/osv.vdi
41+
gceimage=build/release/osv.tar.gz
42+
vmwimage=build/release/osv.vmdk
43+
index=$out/index.yaml
44+
build="scripts/build image=$image"
45+
capstan_local_repository=$HOME/.capstan/repository
46+
47+
mkdir -p $out
48+
49+
echo "==> Building '$name'..."
50+
51+
echo "format_version: 1" > $index
52+
echo "version: $version" >> $index
53+
echo "created: $now" >> $index
54+
echo "description: $description" >> $index
55+
echo "build: $build" >> $index
56+
echo "platform: $platform" >> $index
57+
58+
$build
59+
60+
# Generate QEMU image
61+
scripts/convert vdi
62+
scripts/convert vmdk
63+
64+
# Generate GCE image
65+
scripts/gen-gce-tarball.sh
66+
67+
read -p "Copy base images into capstan local repository [y/N]? :" -n 1 -t 15 -s
68+
echo
69+
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
70+
mkdir -p $capstan_local_repository/$name
71+
cp $index $capstan_local_repository/$name/
72+
cp $qemuimage $capstan_local_repository/$name/$(basename $name).qemu
73+
cp $vboximage $capstan_local_repository/$name/$(basename $name).vbox
74+
cp $vmwimage $capstan_local_repository/$name/$(basename $name).vmw
75+
echo "Copied base images into $capstan_local_repository/$name/"
76+
fi
77+
78+
gzip < $qemuimage > $out/$(basename $name).qemu.gz
79+
gzip < $vboximage > $out/$(basename $name).vbox.gz
80+
gzip < $vmwimage > $out/$(basename $name).vmw.gz
81+
82+
gce_url_file=$out/$(basename $name).gce
83+
gce_tar_ball=$out/$(basename $name).gce.tar.gz
84+
echo "gs://osv/$version/$(basename $name).gce.tar.gz" > $gce_url_file
85+
gzip <$gce_url_file > $gce_url_file.gz
86+
rm -f $gce_url_file $gce_tar_ball
87+
mv -f $gceimage $gce_tar_ball
88+
89+
echo "==> '$name' image built to '$out'."

scripts/build-capstan-images

Lines changed: 0 additions & 21 deletions
This file was deleted.

scripts/build-capstan-img

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)