-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-image.sh
executable file
·38 lines (28 loc) · 999 Bytes
/
build-image.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
# -----------------------------------------------------------------------------
# Utilities
# -----------------------------------------------------------------------------
die() {
# **
# Prints a message to stderr & exits script with non-successful code "1"
# *
printf '%s\n' "$@" >&2
exit 1
}
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
# Build the image
printf 'Attempting to build the image...\n\n'
image=$(guix system image -t qcow2 --volatile 'config.scm') \
|| die 'Could not create image.'
release_tag=$(date +"%Y%m%d%H%M")
target_file=./guix-live-${release_tag}.qcow2
cp "${image}" "${target_file}" ||
die 'An error occurred while copying.'
# Make sure the image is writable for local testing
chmod +w $target_file
printf 'Image was succesfully built: %s\n' "${image}"
# cleanup
unset -f die
unset -v image release_tag