Package: debirf
Severity: wishlist

I love debirf, its so handy! However, the handiness is offset by the
less than handy process of having to build these images and ship them
off to my machines that I want debirf on. The fact that I want debirf
installed on every physical mcahine I have, and setup automatically in
grub2 make me sad that there is no package I can just install.

I propose building a package that installs pre-built images into
/boot/debirf and the following (tested!) /etc/grub.d/21_debirf to fill
out the grub menu:

#!/bin/sh
set -e

prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
. ${libdir}/grub/grub-mkconfig_lib

DEBIRF_CMDLINE="root=/dev/ram0 rw panic=15 $GRUB_CMDLINE_LINUX"

# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
  /dev/loop/*|/dev/loop[0-9])
    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
  ;;
esac

if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = 
"xtrue" ] \
    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
    || uses_abstraction "${GRUB_DEVICE}" lvm; then
  LINUX_ROOT_DEVICE=${GRUB_DEVICE}
else
  LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
fi

prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed 
-e "s/^/\t/")"

list=`for i in /boot/debirf/vmlinuz-* ; do
        if is_path_readable_by_grub "$i" && grub_file_is_not_garbage "$i" ;
           then echo -n "$i " ; fi
        done`

while [ "x$list" != "x" ] ; do
  debirf_linux=`version_find_latest $list`
  echo "Found debirf image: $debirf_linux" >&2
  basename=`basename $debirf_linux`
  dirname=`dirname $debirf_linux`
  rel_dirname=`make_system_path_relative_to_its_root $dirname`
  version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`

  debirf_initrd=
  for i in "debirf-rescue_${version}.cgz" "debirf-minimal_${version}.cgz" \
      "debirf-kiosk_${version}.cgz"; do
    if test -e "${dirname}/${i}" ; then
      debirf_initrd="$i"
      break
    fi
  done

  if test -n "${debirf_initrd}" ; then
    echo "Found debirf initrd image: ${dirname}/${debirf_initrd}" >&2
  else
    echo "No debirf initrd images found"
  fi

  cat <<EOF
menuentry "debirf ${version}" --users su {
EOF
  printf '%s\n' "${prepare_boot_cache}"

  cat <<EOF
        linux ${rel_dirname}/${basename} 
        initrd ${rel_dirname}/${debirf_initrd}
}
EOF
 
  list=`echo $list | tr ' ' '\n' | grep -vx $debirf_linux | tr '\n' ' '`
done

-- 

Attachment: pgpKpkaOPxj84.pgp
Description: PGP signature

Reply via email to