Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More create disk cleanup #760

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cmd-buildextend-metal
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ if [ "$arch" == "s390x" ]; then
fi
kargs="$kargs $tty ignition.platform.id=$image_type"

ostree_remote="$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin).get("ostree-remote", "NONE"))' < "$configdir/image.yaml")"
save_var_subdirs="$(python3 -c 'import sys, yaml; print(yaml.safe_load(sys.stdin).get("save-var-subdirs-for-selabel-workaround", "NONE"))' < "$configdir/image.yaml")"

if [ -z "${use_anaconda}" ]; then
qemu-img create -f ${image_format} "${path}.tmp" "$size"
# In the anaconda path, run_virtinstall dereferences in the ref_is_temp
Expand All @@ -173,8 +170,11 @@ if [ -z "${use_anaconda}" ]; then
ref_arg=${commit}
fi

runvm -drive "if=virtio,id=target,format=${image_format},file=${path}.tmp" -- /usr/lib/coreos-assembler/create_disk.sh /dev/vda "$ostree_repo" "${ref_arg}" "${ostree_remote}" /usr/lib/coreos-assembler/grub.cfg "$name" "${save_var_subdirs}" "\"$kargs\""
# Transcode to JSON so it's easier to parse from shell script
python3 -c 'import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout)' < "${configdir}/image.yaml" > tmp/image.json
runvm -drive "if=virtio,id=target,format=${image_format},file=${path}.tmp" -- /usr/lib/coreos-assembler/create_disk.sh "$ostree_repo" "${ref_arg}" "$name" "\"$kargs\""
mv "${path}.tmp" "$path"
rm tmp/image.json
echo "{}" > tmp/vm-iso-checksum.json
else
[ "${image_type}" == qemu ]
Expand Down
1 change: 1 addition & 0 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ runvm() {
set -xeuo pipefail
export PATH=/usr/sbin:$PATH
workdir=${workdir}
builddir=$(pwd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this e.g. host_pwd=$(pwd) ?

IOW, I don't think we should think of this as a builddir since we don't always have one. Whereas if we just reframe it as "make supermin command run in the same dir as where we were", that achieves the same goal and seems a less surprising behaviour than always cd'ing to the workdir.

Let's maybe also add a check that the host_pwd is under workdir and just error out otherwise? That way we ensure that we end up under the workdir mount.


# use the builder user's id, otherwise some operations like
# chmod will set ownership to root, not builder
Expand Down
17 changes: 9 additions & 8 deletions src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
# an issue and we can discuss configuration needs.
set -euo pipefail

if [ "$#" -ne 8 ]; then
echo 'create_disk <device> <ostree-repo> <ostree-ref> <ostree-remote> <grub-script> <os-name> <save-var-subdirs> <space separated kargs>'
if [ "$#" -ne 4 ]; then
echo 'create_disk <ostree-repo> <ostree-ref> <os-name> <space separated kargs>'
exit 1
fi

export PATH=$PATH:/sbin:/usr/sbin

arch="$(uname -m)"

disk="$1" && shift
disk=/dev/vda

ostree="$1" && shift
ref="$1" && shift
remote_name="$1" && shift
grub_script="$1" && shift
os_name="$1" && shift
save_var_subdirs="$1" && shift
extrakargs="$1" && shift

remote_name=$(jq -r '.["ostree-remote"]' < tmp/image.json)
save_var_subdirs=$(jq -r '.["save-var-subdirs"]' < tmp/image.json)

set -x

# Partition and create fs's. The 0...4...a...1 uuid is a sentinal used by coreos-gpt-setup
Expand Down Expand Up @@ -90,7 +91,7 @@ ostree admin deploy "${deploy_ref}" --sysroot rootfs --os "$os_name" $kargsargs
# See the equivalent code in gf-anaconda-cleanup
# /var hack: we'd like to remove all of /var, but SELinux issues prevent that.
# see https://github.com/coreos/ignition-dracut/pull/79#issuecomment-488446949
if [ "${save_var_subdirs}" != NONE ]; then
if [ "${save_var_subdirs}" != "null" ]; then
vardir=rootfs/ostree/deploy/${os_name}/var
mkdir -p ${vardir}/{home,log/journal,lib/systemd}
# And /home is the only one that doesn't have a filename transition today
Expand Down Expand Up @@ -124,7 +125,7 @@ normal
EOF

# copy the grub config and any other files we might need
cp $grub_script rootfs/boot/grub2/grub.cfg
cp /usr/lib/coreos-assembler/grub.cfg rootfs/boot/grub2/grub.cfg
else
# current zipl expects 'title' to be first line, and no blank lines in BLS file
# see https://github.com/ibm-s390-tools/s390-tools/issues/64
Expand Down
2 changes: 1 addition & 1 deletion src/supermin-init-prelude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ update-alternatives --install /etc/alternatives/iptables iptables /usr/sbin/ipta
update-alternatives --install /etc/alternatives/ip6tables ip6tables /usr/sbin/ip6tables-legacy 1

# https://github.com/koalaman/shellcheck/wiki/SC2164
cd "${workdir}" || exit
cd "${builddir}" || exit