-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pi/common: add buildimage command to create .img
Signed-off-by: Luis Banuelos <[email protected]> Reviewed-by: Christian Stewart <[email protected]>
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
format Format a SD card and install bootloader. | ||
install Installs to a formatted SD card. | ||
buildimage Builds an image using a loopback device. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
if [ $EUID != 0 ]; then | ||
echo "This script requires sudo, so it might not work." | ||
fi | ||
|
||
set -e | ||
|
||
if [ -z "$PI_IMAGE" ]; then | ||
echo "Please set PI_IMAGE and try agian." | ||
exit 1 | ||
fi | ||
|
||
if [[ "$PI_IMAGE" != /* ]]; then | ||
PI_IMAGE=$WORKSPACE_DIR/$PI_IMAGE | ||
fi | ||
|
||
echo "Allocating image..." | ||
dd if=/dev/zero of=$PI_IMAGE bs=1GB count=1 | ||
|
||
echo "Setting up loopback device..." | ||
PI_SD=$(sudo losetup --show -fP $PI_IMAGE) | ||
|
||
# Setup no interactive since we know its a brand new file. | ||
export SKIFF_NO_INTERACTIVE=1 | ||
|
||
$SKIFF_CURRENT_CONF_DIR/scripts/format_sd.sh | ||
$SKIFF_CURRENT_CONF_DIR/scripts/install_sd.sh | ||
|
||
echo "Removing loopback device..." | ||
sudo losetup -d $PI_SD |