Skip to content

Commit ebda131

Browse files
committed
Repackage base boxes, used by rspec tests
1 parent ffde1b2 commit ebda131

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

TESTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ 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+
109+
```sh
110+
./bin/repackage_base_boxes.sh
111+
```
112+
113+
will iterate over `spec/vagrantfiles/Vagrantfile.*`, spin up a VM, drop you
114+
into an interactive shell and then give you the option to repackage afterwards.
115+
It will skip any boxes that already exist in the project root, similar to
116+
behavior of the rspec suite.
117+
118+
After repackaging, use `./bin/publish_laptopped_boxes.sh` to publish to aws.
119+
102120
## Creating new base boxes to test a new release
103121

104122
1. Download a 64 bit minimal server ISO

bin/publish_laptopped_boxes.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22
check_for_aws() {
3-
if ! command -v aws &>/dev/null; then
3+
if ! command -v aws >/dev/null; then
44
failure_message 'You must install aws-cli to publish boxes'
55
exit 1
66
fi
@@ -34,10 +34,10 @@ publish_box(){
3434
}
3535

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

40-
[ "$local_size" -ne "$remote_size" ]
40+
[ "$local_size" != "$remote_size" ]
4141
}
4242

4343
###################################

bin/repackage_base_boxes.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env 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)