Merge ~cgrabowski/maas:tweaks_to_custom_image_script into maas:master

Proposed by Christian Grabowski
Status: Merged
Approved by: Christian Grabowski
Approved revision: 607cbd1e22d28c7ce64dc87d98cdfb0533222808
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~cgrabowski/maas:tweaks_to_custom_image_script
Merge into: maas:master
Diff against target: 80 lines (+17/-6)
1 file modified
utilities/build_custom_ubuntu_image (+17/-6)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Alberto Donato (community) Approve
Review via email: mp+408254@code.launchpad.net

Commit message

teardown cleanly every time

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b tweaks_to_custom_image_script lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/10907/console
COMMIT: dd9c10d53b32305711ab9aae3ee9962115e53599

review: Needs Fixing
Revision history for this message
Alberto Donato (ack) wrote :

nice, +1

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b tweaks_to_custom_image_script lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/10910/console
COMMIT: 753ef48137b7574a1c195c61828e02bcce1f253e

review: Needs Fixing
607cbd1... by Christian Grabowski

create curtin dir

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b tweaks_to_custom_image_script lp:~cgrabowski/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 607cbd1e22d28c7ce64dc87d98cdfb0533222808

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/utilities/build_custom_ubuntu_image b/utilities/build_custom_ubuntu_image
2index 40e1dd5..82bfee6 100755
3--- a/utilities/build_custom_ubuntu_image
4+++ b/utilities/build_custom_ubuntu_image
5@@ -6,12 +6,13 @@ set -e
6 set -o pipefail
7
8 PWD="$(pwd)"
9+WORK_DIR="$(mktemp -d ./tmp-XXXX)"
10 OS="${OS:-ubuntu}"
11 OS_VERSION="${OS_VERSION:-20.04.2}"
12 IMAGE_TYPE="${IMAGE_TYPE:-live-server}"
13 OS_ARCH="${OS_ARCH:-amd64}"
14 BASE_IMAGE_FILE="${BASE_IMAGE_FILE:-${OS}-${OS_VERSION}-${IMAGE_TYPE}-${OS_ARCH}.iso}"
15-BASE_IMAGE_PATH="${BASE_IMAGE_PATH:-${PWD}/tmp/${BASE_IMAGE_FILE}}"
16+BASE_IMAGE_PATH="${BASE_IMAGE_PATH:-/tmp/${BASE_IMAGE_FILE}}"
17 BASE_IMAGE_URL="${BASE_IMAGE_URL:-https://releases.ubuntu.com/${OS_VERSION}/${BASE_IMAGE_FILE}}"
18 BASE_IMAGE_CHECKSUM="${BASE_IMAGE_CHECKSUM:-d1f2bf834bbe9bb43faf16f9be992a6f3935e65be0edece1dee2aa6eb1767423}"
19 OUTPUT_FILE="custom-${OS}-${OS_VERSION}-${OS_ARCH}.img"
20@@ -22,7 +23,7 @@ pull_image () {
21 if [ "${DOWNLOAD_BASE_IMAGE}" -eq "1" ]; then
22 echo "Downloading Base Ubuntu Image..."
23 curl -L -o "${BASE_IMAGE_PATH}" "${BASE_IMAGE_URL}"
24- echo "${BASE_IMAGE_CHECKSUM} ./tmp/${BASE_IMAGE_FILE}" | shasum -c
25+ echo "${BASE_IMAGE_CHECKSUM} /tmp/${BASE_IMAGE_FILE}" | shasum -c
26 fi
27 }
28
29@@ -48,6 +49,17 @@ autoinstall:
30 hostname: ubuntu-server
31 password: "$(mkpasswd --method=SHA-512 --rounds=4096)"
32 username: ubuntu
33+ ssh:
34+ install-server: true
35+ storage:
36+ swap:
37+ size: 0
38+ layout:
39+ name: lvm
40+ late-commands:
41+ - mkdir -p /target/curtin
42+ - touch /target/curtin/curtin-hooks
43+ - chmod 750 /target/curtin/curtin-hooks
44 EOF
45
46 touch meta-data
47@@ -65,7 +77,7 @@ build () {
48 echo "running build VM"
49 kvm -no-reboot -m 2048\
50 -nographic\
51- -drive file="${OUTPUT_DIR}/tmp_image.img",format=raw,cache=none,if=virtio\
52+ -drive file="${OUTPUT_DIR}/${OUTPUT_FILE}",format=raw,cache=none,if=virtio\
53 -cdrom "${BASE_IMAGE_PATH}"\
54 -kernel "/mnt/${OS}-${OS_VERSION}/casper/vmlinuz"\
55 -initrd "/mnt/${OS}-${OS_VERSION}/casper/initrd"\
56@@ -76,7 +88,7 @@ teardown () {
57 echo "tearing down workspace"
58 kill %1
59 umount "/mnt/${OS}-${OS_VERSION}"
60- rm -rf ./tmp/www/
61+ rm -rf "${WORK_DIR}"
62 }
63
64 main () {
65@@ -85,7 +97,7 @@ main () {
66 exit 1
67 fi
68
69- WORK_DIR=$(mktemp -d ./tmp-XXXX)
70+ trap teardown EXIT
71 pull_image
72 mount_resources
73 mkdir -p "${WORK_DIR}/www/"
74@@ -95,7 +107,6 @@ main () {
75 cd ..
76 create_output_file
77 build
78- teardown
79 echo "created image can be found at: ${OUTPUT_DIR}/${OUTPUT_FILE}"
80 }
81

Subscribers

People subscribed via source and target branches