[arch-releng] [RFC] [PATCH] [archiso] Add checksum= boot param
Gerardo Exequiel Pozzi
vmlinuz386 at yahoo.com.ar
Thu Aug 11 23:26:36 EDT 2011
NOTE 1: Needs md5sum, not added here.
Option 1: Use md5sum from coreutils.
Option 2: Use md5sum from mkinitcpio-busybox (currently is not builded).
NOTE 2: This is a draft without testing, but should works.
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386 at yahoo.com.ar>
---
README | 4 ++++
archiso/hooks/archiso | 15 +++++++++++++++
archiso/mkarchiso | 15 +++++++++++++++
configs/baseline/build.sh | 1 +
configs/releng/build.sh | 2 ++
5 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/README b/README
index 09765fb..26be787 100644
--- a/README
+++ b/README
@@ -31,6 +31,10 @@ INDEX
* copytoram= If set to "y" or just "copytoram" without arguments,
all SquashFS are copied to "RAM".
Default: (unset)
+* checksum= If set to "y" or just "checksum" without arguments,
+ performs a self-test of all files inside ${install_dir},
+ and continue booting if ok.
+ Default: (unset)
* cowspace_size= Set the size of tmpfs /cowspace. This space is used for
Copy-On-Write files of dm-snapshot.
(directory not visible outside initramfs)
diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso
index 66dbafd..fb817b2 100644
--- a/archiso/hooks/archiso
+++ b/archiso/hooks/archiso
@@ -135,6 +135,21 @@ archiso_mount_handler() {
launch_interactive_shell
fi
+ if [[ "${checksum}" == "y" ]]; then
+ if [[ -f "/bootmnt/${archisobasedir}/checksum.md5" ]]; then
+ echo ":: Self-test requested, please wait..."
+ if md5sum -c "/bootmnt/${archisobasedir}/checksum.md5" > /checksum.log 2>&1; then
+ echo "done. Checksum is OK, continue booting."
+ else
+ echo "ERROR: one or more files are wrong, see /checksum.log for details"
+ launch_interactive_shell
+ fi
+ else
+ echo "ERROR: checksum=y option specified but checksum.md5 not found"
+ launch_interactive_shell
+ fi
+ fi
+
if [[ "${copytoram}" == "y" ]]; then
msg -n ":: Mounting /copytoram (tmpfs) filesystem, size=${copytoram_size}..."
mount -t tmpfs -o "size=${copytoram_size}",mode=0755 copytoram /copytoram
diff --git a/archiso/mkarchiso b/archiso/mkarchiso
index 12d8936..e4a85eb 100755
--- a/archiso/mkarchiso
+++ b/archiso/mkarchiso
@@ -112,6 +112,8 @@ _usage ()
echo " includes all specified packages"
echo " prepare <dir>"
echo " build all images"
+ echo " checksum <dir>"
+ echo " make a checksum.md5 for self-test"
echo " iso <dir> <image name>"
echo " build an iso image from the working dir"
exit ${1}
@@ -134,6 +136,8 @@ _show_config () {
;;
prepare)
;;
+ checksum)
+ ;;
iso)
_msg_info " Image name: ${img_name}"
_msg_info " Disk label: ${iso_label}"
@@ -286,6 +290,14 @@ _mkfs () {
_umount_fs "${work_dir}/mnt/${_src}"
}
+command_checksum () {
+ _show_config checksum
+
+ _msg_info "Creating checksum file for self-test"
+ find "${work_dir}/iso/${install_dir}" -print0 | xargs -0 md5sum > "${work_dir}/iso/${install_dir}/checksum.md5"
+ _msg_info "Done!"
+}
+
# Create an ISO9660 filesystem from "iso" directory.
command_iso () {
if [[ ! -f "${work_dir}/iso/isolinux/isolinux.bin" ]]; then
@@ -428,6 +440,9 @@ case "${command_name}" in
prepare)
command_prepare
;;
+ checksum)
+ command_checksum
+ ;;
iso)
if [[ $# -lt 3 ]]; then
_msg_error "No image specified" 0
diff --git a/configs/baseline/build.sh b/configs/baseline/build.sh
index a07599c..eabe21f 100755
--- a/configs/baseline/build.sh
+++ b/configs/baseline/build.sh
@@ -86,6 +86,7 @@ make_prepare() {
# Build ISO
make_iso() {
+ mkarchiso ${verbose} checksum "${work_dir}"
mkarchiso ${verbose} -D "${install_dir}" -L "${iso_label}" iso "${work_dir}" "${name}-${version}-${arch}.iso"
}
diff --git a/configs/releng/build.sh b/configs/releng/build.sh
index 284ab76..22229ce 100755
--- a/configs/releng/build.sh
+++ b/configs/releng/build.sh
@@ -163,6 +163,7 @@ make_prepare() {
# args: $1 (core | netinstall)
make_iso() {
local _iso_type=${1}
+ mkarchiso ${verbose} checksum "${work_dir}"
mkarchiso ${verbose} -D "${install_dir}" -L "${iso_label}" iso "${work_dir}" "${name}-${version}-${_iso_type}-${arch}.iso"
}
@@ -206,6 +207,7 @@ make_dual() {
sed "s|%ARCHISO_LABEL%|${iso_label}|g;
s|%INSTALL_DIR%|${install_dir}|g" ${_cfg} > ${work_dir}/dual/iso/${install_dir}/boot/syslinux/${_cfg##*/}
done
+ mkarchiso ${verbose} checksum "${work_dir}/dual"
mkarchiso ${verbose} -D "${install_dir}" -L "${iso_label}" iso "${work_dir}/dual" "${name}-${version}-${_iso_type}-dual.iso"
: > ${work_dir}/dual/build.${FUNCNAME}_${_iso_type}
fi
--
1.7.6
More information about the arch-releng
mailing list