Skip to content

Commit 78a7e0e

Browse files
committed
scripts/build-aci: improve the script
- fix path for bash - check for common errors
1 parent e109836 commit 78a7e0e

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

scripts/build-aci

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,53 @@
1-
#!/usr/bin/bash
1+
#!/bin/bash
22

3-
if [ ! -d rootfs ]; then
4-
mkdir -p rootfs
5-
mv * rootfs
3+
# A non-installed actool can be used, for example:
4+
# ACTOOL=../../appc/spec/bin/actool
5+
ACTOOL=${ACTOOL:-actool}
6+
7+
IMAGEDIR=${IMAGEDIR:-bin/image-aci}
8+
9+
VERSION=$1
10+
11+
if [ ! -x "$ACTOOL" ] ; then
12+
echo "actool ($ACTOOL) is not executable"
13+
exit 1
14+
fi
15+
16+
if [ ! -x bin/etcd ] ; then
17+
echo "bin/etcd not found. Is it compiled?"
18+
exit 1
19+
fi
20+
21+
if [ -z "$VERSION" ] ; then
22+
echo "Usage: scripts/build-aci VERSION"
23+
exit 1
24+
fi
25+
26+
mkdir -p $IMAGEDIR/rootfs
27+
if [ ! -d $IMAGEDIR/rootfs -o ! -x $IMAGEDIR/rootfs ]; then
28+
echo "$IMAGEDIR/rootfs is not a writeable directory"
29+
exit 1
630
fi
731

8-
cat <<DF > manifest
32+
if [ -n "$(ls -A $IMAGEDIR/rootfs)" ]; then
33+
echo "$IMAGEDIR/rootfs is not empty"
34+
exit 1
35+
fi
36+
37+
cp bin/etcd bin/etcdctl $IMAGEDIR/rootfs/
38+
cp README.md $IMAGEDIR/rootfs/
39+
cp etcdctl/README.md $IMAGEDIR/rootfs/README-etcdctl.md
40+
cp -r Documentation $IMAGEDIR/rootfs/
41+
42+
cat <<DF > $IMAGEDIR/manifest
943
{
1044
"acVersion": "0.1.1",
1145
"acKind": "ImageManifest",
1246
"name": "coreos.com/etcd",
1347
"labels": [
1448
{"name": "os", "value": "linux"},
1549
{"name": "arch", "value": "amd64"},
16-
{"name": "version", "value": "${1}"}
50+
{"name": "version", "value": "${VERSION}"}
1751
],
1852
"app": {
1953
"exec": [
@@ -25,9 +59,9 @@ cat <<DF > manifest
2559
}
2660
DF
2761

28-
mkdir -p rootfs/etc/
29-
cat <<DF > rootfs/etc/hosts
62+
mkdir -p $IMAGEDIR/rootfs/etc/
63+
cat <<DF > $IMAGEDIR/rootfs/etc/hosts
3064
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
3165
DF
3266

33-
actool build -overwrite=true . ../etcd-${1}-linux-amd64.aci
67+
$ACTOOL build -overwrite=true $IMAGEDIR bin/etcd-${1}-linux-amd64.aci

0 commit comments

Comments
 (0)