Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
nl6720
arch-boxes
Commits
382b86bb
Commit
382b86bb
authored
Jan 31, 2021
by
Kristian Klausen
🎉
Browse files
Make disk size configurable per image
parent
4000e324
Changes
5
Hide whitespace changes
Inline
Side-by-side
build-inside-vm.sh
View file @
382b86bb
...
...
@@ -5,7 +5,7 @@
# errexit: "Exit immediately if [...] command exits with a non-zero status."
set
-o
nounset
-o
errexit
shopt
-s
extglob
readonly
DISK_SIZE
=
"20G"
readonly
DEFAULT_
DISK_SIZE
=
"20G"
readonly
IMAGE
=
"image.img"
# shellcheck disable=SC2016
readonly
MIRROR
=
'https://mirror.pkgbuild.com/$repo/os/$arch'
...
...
@@ -43,7 +43,7 @@ trap cleanup EXIT
# Create the disk, partitions it, format the partition and mount the filesystem
function
setup_disk
()
{
truncate
-s
"
${
DISK_SIZE
}
"
"
${
IMAGE
}
"
truncate
-s
"
${
DEFAULT_
DISK_SIZE
}
"
"
${
IMAGE
}
"
sgdisk
--clear
\
--new
1::+1M
--typecode
=
1:ef02
\
--new
2::-0
--typecode
=
2:8300
\
...
...
@@ -126,12 +126,6 @@ function unmount_image() {
LOOPDEV
=
""
}
# Copy image and mount the copied image
function
copy_and_mount_image
()
{
cp
-a
"
${
IMAGE
}
"
"
${
1
}
"
mount_image
"
${
1
}
"
}
# Compute SHA256, adjust owner to $SUDO_UID:$SUDO_UID and move to output/
function
mv_to_output
()
{
sha256sum
"
${
1
}
"
>
"
${
1
}
.SHA256"
...
...
@@ -148,7 +142,19 @@ function mv_to_output() {
function
create_image
()
{
local
tmp_image
tmp_image
=
"
$(
basename
"
$(
mktemp
-u
)
"
)
"
copy_and_mount_image
"
${
tmp_image
}
"
cp
-a
"
${
IMAGE
}
"
"
${
tmp_image
}
"
if
[
-n
"
${
DISK_SIZE
}
"
]
;
then
truncate
-s
"
${
DISK_SIZE
}
"
"
${
tmp_image
}
"
sgdisk
--delete
2
"
${
tmp_image
}
"
sgdisk
--move-second-header
\
--new
2::-0
--typecode
=
2:8300
\
"
${
tmp_image
}
"
fi
mount_image
"
${
tmp_image
}
"
if
[
-n
"
${
DISK_SIZE
}
"
]
;
then
btrfs filesystem resize max
"
${
MOUNT
}
"
fi
if
[
0
-lt
"
${#
PACKAGES
[@]
}
"
]
;
then
arch-chroot
"
${
MOUNT
}
"
/usr/bin/pacman
-S
--noconfirm
"
${
PACKAGES
[@]
}
"
fi
...
...
images/basic.sh
View file @
382b86bb
#!/bin/bash
# shellcheck disable=SC2034,SC2154
IMAGE_NAME
=
"Arch-Linux-x86_64-basic-
${
build_version
}
.qcow2"
DISK_SIZE
=
""
PACKAGES
=()
SERVICES
=()
...
...
images/cloud-image.sh
View file @
382b86bb
#!/bin/bash
# shellcheck disable=SC2034,SC2154
IMAGE_NAME
=
"Arch-Linux-x86_64-cloudimg-
${
build_version
}
.qcow2"
DISK_SIZE
=
""
# The growpart module[1] requires the growpart program, provided by the
# cloud-guest-utils package
# [1] https://cloudinit.readthedocs.io/en/latest/topics/modules.html#growpart
...
...
images/vagrant-libvirt.sh
View file @
382b86bb
#!/bin/bash
# shellcheck disable=SC2034,SC2154
IMAGE_NAME
=
"Arch-Linux-x86_64-libvirt-
${
build_version
}
.box"
DISK_SIZE
=
""
PACKAGES
=()
SERVICES
=()
...
...
images/vagrant-virtualbox.sh
View file @
382b86bb
#!/bin/bash
# shellcheck disable=SC2034,SC2154
IMAGE_NAME
=
"Arch-Linux-x86_64-virtualbox-
${
build_version
}
.box"
DISK_SIZE
=
""
PACKAGES
=(
virtualbox-guest-utils-nox
)
SERVICES
=(
vboxservice
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment