change from ext2 image to vfat, brings back reproducibility :)

This commit is contained in:
Tobias Powalowski 2022-09-20 16:17:19 +02:00
parent 94c324978a
commit cc535d968b
5 changed files with 29 additions and 53 deletions

View file

@ -6,7 +6,6 @@
_parameters "$@" _parameters "$@"
_root_check _root_check
_riscv64_check _riscv64_check
_loop_check
[[ "${_GENERATE}" == "1" ]] || _usage [[ "${_GENERATE}" == "1" ]] || _usage
_config _config
echo "Starting Image creation ..." echo "Starting Image creation ..."
@ -14,7 +13,7 @@ _fix_mkinitcpio
_prepare_kernel_initramfs_files_RISCV64 || exit 1 _prepare_kernel_initramfs_files_RISCV64 || exit 1
_prepare_extlinux_conf || exit 1 _prepare_extlinux_conf || exit 1
_reproducibility _reproducibility
_prepare_extlinux_image || exit 1 _prepare_uboot_image || exit 1
_create_cksum || exit 1 _create_cksum || exit 1
_cleanup_iso || exit 1 _cleanup_iso || exit 1
echo "Finished Image creation." echo "Finished Image creation."

View file

@ -6,7 +6,6 @@ _ARCHBOOT="archboot-riscv"
. /usr/lib/archboot/release.sh . /usr/lib/archboot/release.sh
[[ -z "${1}" ]] && _usage [[ -z "${1}" ]] && _usage
_root_check _root_check
_loop_check
echo "Start release creation in $1 ..." echo "Start release creation in $1 ..."
_create_iso "$@" || exit 1 _create_iso "$@" || exit 1
_create_boot || exit 1 _create_boot || exit 1

View file

@ -47,14 +47,6 @@ _riscv64_check() {
fi fi
} }
_loop_check() {
if ! [[ -b /dev/loop0 ]]; then
modprobe loop > /dev/null 2>&1
losetup -f > /dev/null 2>&1
! [[ -b /dev/loop0 ]] && (echo "ERROR: No /dev/loop0 available. Aborting..."; exit 1)
fi
}
### check for tpowa's build server ### check for tpowa's build server
_buildserver_check() { _buildserver_check() {
if [[ ! "$(cat /etc/hostname)" == "T-POWA-LX" ]]; then if [[ ! "$(cat /etc/hostname)" == "T-POWA-LX" ]]; then

View file

@ -88,7 +88,7 @@ _prepare_kernel_initramfs_files() {
# https://sourceware.org/bugzilla/show_bug.cgi?id=29009 # https://sourceware.org/bugzilla/show_bug.cgi?id=29009
# - only left option is extlinux support in u-boot loader # - only left option is extlinux support in u-boot loader
_prepare_kernel_initramfs_files_RISCV64() { _prepare_kernel_initramfs_files_RISCV64() {
echo "Prepare RISCV64 extlinux ..." echo "Prepare RISCV64 u-boot ..."
source "${_PRESET}" source "${_PRESET}"
mkdir -p ${_ISODIR}/boot/extlinux mkdir -p ${_ISODIR}/boot/extlinux
install -m644 "${ALL_kver}" "${_ISODIR}/boot/vmlinuz_${_RUNNING_ARCH}" install -m644 "${ALL_kver}" "${_ISODIR}/boot/vmlinuz_${_RUNNING_ARCH}"
@ -181,20 +181,14 @@ _prepare_uefi_image() {
## get size of boot files ## get size of boot files
BOOTSIZE=$(du -bc "${_ISODIR}"/EFI | grep total | cut -f1) BOOTSIZE=$(du -bc "${_ISODIR}"/EFI | grep total | cut -f1)
IMGSZ=$(((BOOTSIZE*102)/100/1024 + 1)) # image size in sectors IMGSZ=$(((BOOTSIZE*102)/100/1024 + 1)) # image size in sectors
## Create efi.img
dd if=/dev/zero of="${_ISODIR}"/efi.img bs="${IMGSZ}" count=1024 status=none
VFAT_IMAGE="${_ISODIR}/efi.img" VFAT_IMAGE="${_ISODIR}/efi.img"
## Create efi.img
dd if=/dev/zero of="${VFAT_IMAGE}" bs="${IMGSZ}" count=1024 status=none
mkfs.vfat --invariant "${VFAT_IMAGE}" >/dev/null mkfs.vfat --invariant "${VFAT_IMAGE}" >/dev/null
## Copy all files to UEFI vfat image ## Copy all files to UEFI vfat image
mcopy -m -i "${VFAT_IMAGE}" -s "${_ISODIR}"/EFI ::/ mcopy -m -i "${VFAT_IMAGE}" -s "${_ISODIR}"/EFI ::/
} }
# https://github.com/CoelacanthusHex/archriscv-scriptlet/blob/master/mkimg
# https://checkmk.com/linux-knowledge/mounting-partition-loop-device
# calculate mountpoint offset: sector*start
# 512*2048=1048576
# https://reproducible-builds.org/docs/system-images/
# mkfs.ext4 does not allow reproducibility
_prepare_extlinux_conf() { _prepare_extlinux_conf() {
echo "Prepare extlinux.conf ..." echo "Prepare extlinux.conf ..."
cat << EOF >> "${_ISODIR}/boot/extlinux/extlinux.conf" cat << EOF >> "${_ISODIR}/boot/extlinux/extlinux.conf"
@ -209,28 +203,30 @@ label linux
EOF EOF
} }
_prepare_extlinux_image() { # https://github.com/CoelacanthusHex/archriscv-scriptlet/blob/master/mkimg
echo "Prepare extlinux image ..." # https://checkmk.com/linux-knowledge/mounting-partition-loop-device
# calculate mountpoint offset: sector*start
# 512*2048=1048576
# https://reproducible-builds.org/docs/system-images/
# mkfs.ext4 does not allow reproducibility
_prepare_uboot_image() {
echo "Prepare u-boot image ..."
## get size of boot files ## get size of boot files
BOOTSIZE=$(du -bc "${_ISODIR}"/boot | grep total | cut -f1) BOOTSIZE=$(du -bc "${_ISODIR}"/boot | grep total | cut -f1)
IMGSZ=$(((BOOTSIZE*110)/100/1024)) # image size in sectors IMGSZ=$(((BOOTSIZE*102)/100/1024)) # image size in sectors
## Create extlinux.img VFAT_IMAGE="${_ISODIR}/extlinux.img"
dd if=/dev/zero of="${_ISODIR}"/extlinux.img bs="${IMGSZ}" count=1024 status=none ## Create efi.img
EXT_IMAGE="${_ISODIR}/extlinux.img" dd if=/dev/zero of="${VFAT_IMAGE}" bs="${IMGSZ}" count=1024 status=none
sfdisk "${_ISODIR}/extlinux.img" >/dev/null 2>&1 <<EOF sfdisk "${VFAT_IMAGE}" >/dev/null 2>&1 <<EOF
label: dos label: dos
label-id: 0x12345678 label-id: 0x12345678
device: "${_ISODIR}/extlinux.img" device: "${VFAT_IMAGE}"
unit: sectors unit: sectors
"${_ISODIR}/extlinux.img"1 : start= 2048, type=83, bootable "${VFAT_IMAGE}"1 : start= 2048, type=83, bootable
EOF EOF
mkfs.ext2 -E offset=1048576 -U clear "${_ISODIR}/extlinux.img" >/dev/null 2>&1 || exit 1 mkfs.vfat --invariant "${VFAT_IMAGE}" >/dev/null
mkdir ${_ISODIR}/mount ## Copy all files to UEFI vfat image
mount -o loop,offset=1048576 "${_ISODIR}/extlinux.img" "${_ISODIR}/mount" || exit 1 mcopy -m -i "${VFAT_IMAGE}" -s "${_ISODIR}"/EFI ::/
cp -r "${_ISODIR}/boot" "${_ISODIR}/mount"
chmod 644 "${_ISODIR}"/mount/boot/*
umount "${_ISODIR}"/mount
mv "${_ISODIR}"/extlinux.img "${_IMAGENAME}.img"
} }
_grub_mkrescue() { _grub_mkrescue() {

View file

@ -31,8 +31,6 @@ _usage () {
_create_iso() { _create_iso() {
mkdir -p "${1}" mkdir -p "${1}"
cd "${1}" || exit 1 cd "${1}" || exit 1
_BIND_LOOP=""
[[ "${_ARCH}" == "riscv64" ]] && _BIND_LOOP="--bind /dev/loop0"
# create container # create container
archboot-"${_ARCH}"-create-container.sh "${_W_DIR}" -cc --install-source="${2}" || exit 1 archboot-"${_ARCH}"-create-container.sh "${_W_DIR}" -cc --install-source="${2}" || exit 1
_create_archboot_db "${_W_DIR}"/var/cache/pacman/pkg _create_archboot_db "${_W_DIR}"/var/cache/pacman/pkg
@ -45,19 +43,19 @@ _create_iso() {
# generate latest tarball in container # generate latest tarball in container
echo "Generate local ISO ..." echo "Generate local ISO ..."
# generate local iso in container # generate local iso in container
systemd-nspawn ${_BIND_LOOP} -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;rm -rf /tmp/*; archboot-${_ARCH}-iso.sh -g -p=${_PRESET_LOCAL} \ systemd-nspawn -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;rm -rf /tmp/*; archboot-${_ARCH}-iso.sh -g -p=${_PRESET_LOCAL} \
-i=${_ISONAME}-local-${_ARCH}" || exit 1 -i=${_ISONAME}-local-${_ARCH}" || exit 1
rm -rf "${_W_DIR}"/var/cache/pacman/pkg/* rm -rf "${_W_DIR}"/var/cache/pacman/pkg/*
echo "Generate latest ISO ..." echo "Generate latest ISO ..."
# generate latest iso in container # generate latest iso in container
systemd-nspawn ${_BIND_LOOP} -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;rm -rf /tmp/*;archboot-${_ARCH}-iso.sh -g -p=${_PRESET_LATEST} \ systemd-nspawn -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;rm -rf /tmp/*;archboot-${_ARCH}-iso.sh -g -p=${_PRESET_LATEST} \
-i=${_ISONAME}-latest-${_ARCH}" || exit 1 -i=${_ISONAME}-latest-${_ARCH}" || exit 1
echo "Install lvm2 to container ${_W_DIR} ..." echo "Install lvm2 to container ${_W_DIR} ..."
systemd-nspawn -D "${_W_DIR}" /bin/bash -c "pacman -Sy lvm2 --noconfirm" >/dev/null 2>&1 systemd-nspawn -D "${_W_DIR}" /bin/bash -c "pacman -Sy lvm2 --noconfirm" >/dev/null 2>&1
fi fi
echo "Generate normal ISO ..." echo "Generate normal ISO ..."
# generate iso in container # generate iso in container
systemd-nspawn ${_BIND_LOOP} -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;archboot-${_ARCH}-iso.sh -g \ systemd-nspawn -q -D "${_W_DIR}" /bin/bash -c "umount /tmp;archboot-${_ARCH}-iso.sh -g \
-i=${_ISONAME}-${_ARCH}" || exit 1 -i=${_ISONAME}-${_ARCH}" || exit 1
# create Release.txt with included main archlinux packages # create Release.txt with included main archlinux packages
echo "Generate Release.txt ..." echo "Generate Release.txt ..."
@ -84,24 +82,16 @@ _create_boot() {
echo "Create boot directory ..." echo "Create boot directory ..."
if [[ "${_ARCH}" == "riscv64" ]]; then if [[ "${_ARCH}" == "riscv64" ]]; then
mkdir -p boot/ mkdir -p boot/
_MP="$(mktemp -d archboot-mount.XXX)"
for i in *.img; do for i in *.img; do
if echo "${i}" | grep -v local | grep -vq latest; then if echo "${i}" | grep -v local | grep -vq latest; then
mount -o loop,offset=1048576 "${i}" "${_MP}" || exit 1 mcopy -i "${i}"@@1048576 ::/"${_KERNEL}" ./boot/"${_KERNEL_ARCHBOOT}"
cp "${_MP}/${_KERNEL}" "${_KERNEL_ARCHBOOT}" mcopy -i "${i}"@@1048576 ::/"${_INITRAMFS}" ./boot/"${_INITRAMFS}"
cp "${_MP}/${_INITRAMFS}" "${_INITRAMFS}"
umount "${_MP}"
elif echo "${i}" | grep -q latest; then elif echo "${i}" | grep -q latest; then
mount -o loop,offset=1048576 "${i}" "${_MP}" || exit 1 mcopy -i "${i}"@@1048576 ::/"${_INITRAMFS}" ./boot/"${_INITRAMFS_LATEST}"
cp "${_MP}/${_INITRAMFS}" "${_INITRAMFS_LATEST}"
umount "${_MP}"
elif echo "${i}" | grep -q local; then elif echo "${i}" | grep -q local; then
mount -o loop,offset=1048576 "${i}" "${_MP}" || exit 1 mcopy -i "${i}"@@1048576 ::/"${_INITRAMFS}" ./boot/"${_INITRAMFS_LOCAL}"
cp "${_MP}/${_INITRAMFS}" "${_INITRAMFS_LOCAL}"
umount "${_MP}"
fi fi
done done
rm -r "${_MP}"
else else
mkdir -p boot/licenses/amd-ucode mkdir -p boot/licenses/amd-ucode
[[ "${_ARCH}" == "aarch64" ]] || mkdir -p boot/licenses/intel-ucode [[ "${_ARCH}" == "aarch64" ]] || mkdir -p boot/licenses/intel-ucode