Skip to content

Commit

Permalink
Merge pull request #17 from sourcebots/fast-build
Browse files Browse the repository at this point in the history
Add option to build without compression
  • Loading branch information
WillB97 authored Aug 18, 2023
2 parents 0b93058 + 633badf commit b59132c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ crash.log
output-*/

# End of https://www.toptal.com/developers/gitignore/api/packer
output.img*
*-image-*.img*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Packer scripts to build SourceBots robot image

## Usage

Simply run the `./build-image.sh` script. Packer will download all needed files and save the output image to `output.img`, ready for further compression and/or distribution.
Simply run the `./build-image.sh` script. Packer will download all needed files and save the output image to `Source OS-image-<GIT-TAG/HASH>.img.xz`, ready for distribution. Running `./build-image.sh nocompress` will skip the compression step, which greatly speeds up the build process.
7 changes: 7 additions & 0 deletions build-image.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/bin/bash
if [ $1 == "nocompress" ]; then
SKIP_COMPRESSION="true"
else
SKIP_COMPRESSION="false"
fi

SB_NAME="Source OS"
SB_VERSION="$(git describe --tags --always)"

rm -f *-image-*.img.xz
rm -f *-image-*.img

docker run --rm --privileged \
-v /dev:/dev \
Expand All @@ -12,4 +18,5 @@ docker run --rm --privileged \
build \
-var "SB_NAME=${SB_NAME}" \
-var "SB_VERSION=${SB_VERSION}" \
-var "SKIP_COMPRESSION=${SKIP_COMPRESSION}" \
pi.json
9 changes: 7 additions & 2 deletions pi.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"variables": {
"SB_NAME": "",
"SB_VERSION": ""
"SB_VERSION": "",
"SKIP_COMPRESSION": "false"
},
"builders": [{
"type": "arm",
Expand Down Expand Up @@ -60,7 +61,11 @@
"post-processors": [
{
"type": "shell-local",
"inline": ["xz -vT0 \"{{user `SB_NAME`}}-image-{{user `SB_VERSION`}}.img\""]
"inline": [
"if [ \"{{user `SKIP_COMPRESSION`}}\" != \"true\" ]; then",
"xz -vT0 \"{{user `SB_NAME`}}-image-{{user `SB_VERSION`}}.img\"",
"fi"
]
}
]
}

0 comments on commit b59132c

Please sign in to comment.