forked from coreos/coreos-assembler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the server side required for osmet packing: coreos/coreos-installer#187 We run `osmet pack` when creating the live ISO and include the osmet binary as part of the CPIO containing the root squashfs.
- Loading branch information
Showing
2 changed files
with
77 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
if [ ! -f /etc/cosa-supermin ]; then | ||
dn=$(dirname "$0") | ||
# shellcheck source=src/cmdlib.sh | ||
. "${dn}"/cmdlib.sh | ||
|
||
img_src=$1; shift | ||
osmet_dest=$1; shift | ||
checksum=$1; shift | ||
coreinst=${1:-} | ||
|
||
workdir=$(pwd) | ||
TMPDIR=tmp/tmp-osmet-pack | ||
rm -rf "${TMPDIR}" | ||
mkdir -p "${TMPDIR}" | ||
|
||
if [[ $img_src == *.gz || $img_src == *.xz ]]; then | ||
img="$(basename "$img_src")" | ||
fatal "Cannot pack osmet from $img; not an uncompressed image" | ||
fi | ||
|
||
set -- "${TMPDIR}/osmet.bin" "${checksum}" | ||
if [ -n "${coreinst:-}" ]; then | ||
cp "${coreinst}" "${TMPDIR}/coreos-installer" | ||
set -- "$@" "${TMPDIR}/coreos-installer" | ||
fi | ||
|
||
runvm -drive "if=virtio,id=coreos,format=raw,readonly=on,file=${img_src}" -- \ | ||
/usr/lib/coreos-assembler/osmet-pack "$@" | ||
|
||
mv "${TMPDIR}/osmet.bin" "${osmet_dest}" | ||
rm -rf "${TMPDIR}" | ||
|
||
exit 0 | ||
fi | ||
|
||
# This runs inside supermin | ||
|
||
osmet_dest=$1; shift | ||
checksum=$1; shift | ||
coreinst=${1:-} | ||
|
||
set -x | ||
|
||
# we want /dev/disk symlinks for coreos-installer | ||
/usr/lib/systemd/systemd-udevd --daemon | ||
/usr/sbin/udevadm trigger --settle | ||
|
||
if [ -z "${coreinst}" ]; then | ||
mkdir -p /sysroot | ||
mount -o ro /dev/disk/by-label/root /sysroot | ||
osname=$(ls /sysroot/ostree/deploy) | ||
deploydir=$(find "/sysroot/ostree/deploy/$osname/deploy" -mindepth 1 -maxdepth 1 -type d) | ||
coreinst=${deploydir}/usr/bin/coreos-installer | ||
fi | ||
|
||
RUST_BACKTRACE=1 "${coreinst}" osmet pack /dev/vda \ | ||
--checksum "${checksum}" \ | ||
--output "${osmet_dest}" |