Skip to content

Commit 7e7cdcf

Browse files
committed
Repackage base boxes, used by rspec tests
1 parent fbb0d1f commit 7e7cdcf

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

TESTING.md

+16
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ given that we're dealing with an entire operating system.
9999
- Remove the box config in vagrantcloud
100100
- Update README.md
101101

102+
## Repackaging base boxes
103+
104+
You might want to repackage base boxes on occasion to make running the
105+
automated suite faster. There will be fewer updates to apply, and sometimes
106+
vendor-supplied updates do not apply cleanly in a non-interactive shell.
107+
108+
```sh
109+
./bin/repackage_base_boxes.sh
110+
```
111+
This will iterate over `spec/vagrantfiles/Vagrantfile.*`, spin up a VM, drop
112+
you into an interactive shell and then give you the option to repackage
113+
afterwards. It will skip any boxes that already exist in the project root,
114+
similar to behavior of the rspec suite.
115+
116+
After repackaging, use `./bin/publish_laptopped_boxes.sh` to publish to aws.
117+
102118
## Creating new base boxes to test a new release
103119

104120
1. Download a 64 bit minimal server ISO

bin/publish_laptopped_boxes.sh

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#!/usr/bin/env sh
1+
#!/bin/sh
2+
23
check_for_aws() {
3-
if ! command -v aws &>/dev/null; then
4+
if ! command -v aws >/dev/null; then
45
failure_message 'You must install aws-cli to publish boxes'
56
exit 1
67
fi
@@ -34,10 +35,10 @@ publish_box(){
3435
}
3536

3637
box_has_changed() {
37-
local remote_size=$(aws s3 ls "laptop-boxes/$box" | cut -f 3 -d ' ')
38+
local remote_size=$(aws s3 ls "laptop-boxes/$box" | sed "s/ / /" | cut -f 3 -d ' ')
3839
local local_size=$(stat -c %s "$box")
3940

40-
[ "$local_size" -ne "$remote_size" ]
41+
[ "$local_size" != "$remote_size" ]
4142
}
4243

4344
###################################

bin/repackage_base_boxes.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
for box in spec/vagrantfiles/Vagrantfile.*; do
4+
base_name=$(basename "$box" '.box' | sed "s/Vagrantfile\.//")
5+
box_file="${base_name}.box"
6+
7+
if [ ! -e "$box_file" ]; then
8+
ln -sf $box Vagrantfile
9+
10+
vagrant destroy
11+
vagrant up
12+
echo "You'll now be dropped into an interactive shell in $base_name."
13+
echo "Make whatever changes are necessary and when you exit we'll repackage the box."
14+
vagrant ssh
15+
16+
rm -f "$box_file"
17+
vagrant package --base "laptop-$base_name" --output "$box_file"
18+
19+
else
20+
echo "$base_name already packaged at $box_file, skipping"
21+
fi
22+
done

0 commit comments

Comments
 (0)