make-asahi-installer-package: also generate installer_data.json

This commit is contained in:
Davide Cavalca 2022-11-04 21:46:46 +00:00
parent 9321c14ba3
commit 91b6472ee8

View File

@ -15,9 +15,9 @@ requireCommands() {
done
}
[ "$#" -ne 2 ] && fail "usage: $0 <image> <package>"
image="$1"
package="$2"
date=$(date +%Y%m%d)
image="${1:-outdir/Fedora-Asahi-Remix.aarch64-0.0.0.raw}"
package="${2:-fedora-rawhide-${date}}"
if [ ! -r "$image" ]; then
fail "$image does not exist or cannot be read!"
@ -37,9 +37,9 @@ imagename="$(basename "$image")"
imagedir="$(dirname "$image")"
# extract filesystems from disk image
pushd "$imagedir"
pushd "$imagedir" > /dev/null
eval "$(sfdisk -ql "$imagename" | awk "NR>=2 { printf \"dd if=${imagename} of=${workdir}/%s skip=%s count=%s\\n\", \$1, \$2, \$4 }")"
popd
popd > /dev/null
# build package
mkdir -p "${workdir}/package/esp"
@ -47,6 +47,47 @@ fatcat "${workdir}/${imagename}1" -x "${workdir}/package/esp"
mv "${workdir}/${imagename}2" "${workdir}/package/boot.img"
mv "${workdir}/${imagename}3" "${workdir}/package/root.img"
pushd "${workdir}/package"
pushd "${workdir}/package" > /dev/null
zip -r "${basedir}/${package}" .
popd
popd > /dev/null
volume_id="$(file "${workdir}/${imagename}1" | awk -v 'RS=,' '/serial number/ { print $3 }')"
cat > installer_data.json <<EOF
{
"os_list": [
{
"name": "Fedora Rawide",
"default_os_name": "Fedora Rawhide",
"boot_object": "m1n1.bin",
"next_object": "m1n1/boot.bin",
"package": "${package}.zip",
"supported_fw": ["12.3", "12.4"],
"partitions": [
{
"name": "EFI",
"type": "EFI",
"size": "500MB",
"format": "fat",
"volume_id": "${volume_id}",
"copy_firmware": true,
"copy_installer_data": true,
"source": "esp"
},
{
"name": "Boot",
"type": "Linux",
"size": "1GB",
"image": "boot.img"
},
{
"name": "Root",
"type": "Linux",
"size": "15GB",
"expand": true,
"image": "root.img"
}
]
}
]
}
EOF