--- /dev/null
+PREFIX ?= /usr
+SYSCONFDIR ?= /etc
+
+all:
+
+install:
+ echo ${DESTDIR}
+ install -m 0755 -d $(DESTDIR)$(PREFIX)/lib/kboot/
+ install -m 0644 kboot-mkconfig_lib $(DESTDIR)$(PREFIX)/lib/kboot/kboot-mkconfig_lib
+ install -m 0755 kboot-mkconfig $(DESTDIR)$(PREFIX)/sbin/kboot-mkconfig
+ install -m 0644 default.kboot $(DESTDIR)$(SYSCONFDIR)/default/kboot
--- /dev/null
+Helper tools to automatically generate a kboot.conf from entries in /boot
+
+The kboot.conf file can be read by the petitboot bootloader which is used for
+instance on the Sony Playstation 3 in OtherOS mode in order to list kernels to
+boot.
--- /dev/null
+Make the script more portable:
+
+grub.mkconfig is built from gub-mkconfig.in with something like this:
+
+grub-mkconfig: util/grub-mkconfig.in $(top_builddir)/config.status
+ $(top_builddir)/config.status --file=-:$< | sed -e 's,@pkglib_DATA@,$(pkglib_DATA),g' > $@
+ chmod a+x grub-mkconfig
+
+autotools do the substitutions of placeholders used in grub-mkconfig.in
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+sbindir=@sbindir@
+bindir=@bindir@
+libdir=@libdir@
+sysconfdir=@sysconfdir@
+PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_VERSION=@PACKAGE_VERSION@
+host_os=@host_os@
+datarootdir=@datarootdir@
+datadir=@datadir@
+pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
--- /dev/null
+kboot-utils (0.1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Antonio Ospite <ospite@studenti.unina.it> Thu, 14 Apr 2011 23:34:56 +0200
--- /dev/null
+Source: kboot-utils
+Section: admin
+Priority: extra
+Maintainer: Antonio Ospite <ospite@studenti.unina.it>
+Build-Depends: debhelper (>= 7.0.50~)
+Standards-Version: 3.9.1
+Homepage: http://git.ao2.it/kboot-utils.git
+Vcs-Git: git://git.ao2.it/kboot-utils.git
+Vcs-Browser: http://git.ao2.it/kboot-utils.git
+
+Package: kboot-utils
+Architecture: all
+Depends: ${misc:Depends}
+Description: Helper tools to generate a kboot.conf file
+ Helper tools to automatically generate a kboot.conf from entries in /boot
+ .
+ The kboot.conf file can be read by the petitboot bootloader which is used
+ for instance on the Sony Playstation 3 in OtherOS mode in order to list
+ kernels to boot.
--- /dev/null
+Format: http://dep.debian.net/deps/dep5
+Upstream-Name: kboot-utils
+Source: http://git.ao2.it/kboot-utils.git
+
+Files: *
+Copyright: 2011 Antonio Ospite <ospite@studenti.unina.it>
+License: GPL-3.0+
+
+Files: debian/*
+Copyright: 2011 Antonio Ospite <ospite@studenti.unina.it>
+License: GPL-3.0+
+
+License: GPL-3.0+
+ On Debian systems the full text of the GNU General Public
+ License can be found in the `/usr/share/common-licenses/GPL'
+ file.
--- /dev/null
+/etc/default
+/usr/sbin
--- /dev/null
+README
+doc/kboot.conf.sample
--- /dev/null
+debian/update-kboot usr/sbin
+debian/kernel/zz-update-kboot etc/kernel/postinst.d
+debian/kernel/zz-update-kboot etc/kernel/postrm.d
--- /dev/null
+#! /bin/sh
+set -e
+
+which update-kboot >/dev/null 2>&1 || exit 0
+
+set -- $DEB_MAINT_PARAMS
+mode="${1#\'}"
+mode="${mode%\'}"
+case $0:$mode in
+ # Only run on postinst configure and postrm remove, to avoid wasting
+ # time by calling update-grub multiple times on upgrade and removal.
+ # Also run if we have no DEB_MAINT_PARAMS, in order to work with old
+ # kernel packages.
+ */postinst.d/*:|*/postinst.d/*:configure|*/postrm.d/*:|*/postrm.d/*:remove)
+ exec update-kboot
+ ;;
+esac
+
+exit 0
--- /dev/null
+man/kboot-mkconfig.8
+debian/update-kboot.8
--- /dev/null
+#!/bin/sh
+# postinst script for kboot-utils
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <postinst> `abort-remove'
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ configure)
+ # Update the kboot.conf on install
+ update-kboot 3>&-
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
--- /dev/null
+#!/bin/bash
+set -e
+
+case "$1" in
+ purge)
+ rm -f /etc/kboot.conf
+ ;;
+ remove|upgrade|failed-upgrade|abort-upgrade|abort-install)
+ ;;
+ *)
+ echo "postrm called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+%:
+ dh $@
--- /dev/null
+3.0 (native)
--- /dev/null
+#!/bin/sh
+set -e
+exec kboot-mkconfig -o /etc/kboot.conf "$@"
--- /dev/null
+.\" Copyright 2011 Antonio Ospite
+.\" Lincensed under GPL3+
+.TH UPDATE-KBOOT "8" "April 2011"
+.SH NAME
+update-kboot \- stub for kboot-mkconfig
+.SH SYNOPSIS
+.B update-kboot
+.SH DESCRIPTION
+.B update-kboot
+is a stub for running
+.B kboot-mkconfig -o /etc/kboot.cfg
+to generate a kboot config file.
+.SH "SEE ALSO"
+.BR kboot-mkconfig (8)
--- /dev/null
+# If you change this file, run 'update-kboot' afterwards to update
+# /etc/kboot.conf.
+# For full documentation of the options in this file, see:
+# man 8 update-kboot
+
+KBOOT_TIMEOUT=5
+KBOOT_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
+
+# 480i = ps3fb:mode:1
+# 576i = ps3fb:mode:6
+# 720p = ps3fb:mode:3
+# 1080i = ps3fb:mode:4
+# 1080p = ps3fb:mode:5
+
+# This entry is NOT used on RECOVERY kernels
+KBOOT_CMDLINE_LINUX_DEFAULT="quiet"
+# This entry is used for all kernels
+KBOOT_CMDLINE_LINUX="video=ps3fb:mode:6"
+
+# Uncomment to disable generation of recovery mode menu entries
+#KBOOT_DISABLE_RECOVERY="true"
--- /dev/null
+timeout=5
+default=linux
+
+linux='/boot/vmlinux initrd=/boot/initrd.img root=/dev/ps3da1 video=ps3fb:mode:3 quiet'
--- /dev/null
+#! /bin/sh
+set -e
+
+# Generate kboot.conf by inspecting /boot contents.
+# Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it>
+#
+# Inspired by kboot-mkconfig
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This progra, is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this software. If not, see <http://www.gnu.org/licenses/>.
+
+PACKAGE_NAME=kboot-mkconfig
+PACKAGE_VERSION=0.1
+
+prefix=/usr
+exec_prefix=${prefix}
+sbindir=${exec_prefix}/sbin
+bindir=${exec_prefix}/bin
+libdir=${exec_prefix}/lib
+sysconfdir=/etc
+host_os=linux-gnu
+datarootdir=${prefix}/share
+datadir=${datarootdir}
+pkgdatadir=${datadir}/kboot
+kboot_conf=""
+
+self=`basename $0`
+
+# Usage: usage
+# Print the usage.
+usage () {
+ cat <<EOF
+Usage: $self [OPTION]
+Generate a kboot config file
+
+ -o, --output=FILE output generated config to FILE [default=stdout]
+ -h, --help print this message and exit
+ -v, --version print the version information and exit
+
+Report bugs to <bug-kboot@gnu.org>.
+EOF
+}
+
+argument () {
+ opt=$1
+ shift
+
+ if test $# -eq 0; then
+ echo "$0: option requires an argument -- '$opt'" 1>&2
+ exit 1
+ fi
+ echo $1
+}
+
+# Check the arguments.
+while test $# -gt 0
+do
+ option=$1
+ shift
+
+ case "$option" in
+ -h | --help)
+ usage
+ exit 0 ;;
+ -v | --version)
+ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
+ exit 0 ;;
+ -o | --output)
+ kboot_conf=`argument $option "$@"`; shift;;
+ --output=*)
+ kboot_conf=`echo "$option" | sed 's/--output=//'`
+ ;;
+ -*)
+ echo "Unrecognized option \`$option'" 1>&2
+ usage
+ exit 1
+ ;;
+ # Explicitly ignore non-option arguments, for compatibility.
+ esac
+done
+
+. ${libdir}/kboot/kboot-mkconfig_lib
+
+if [ "x$EUID" = "x" ] ; then
+ EUID=`id -u`
+fi
+
+if [ "$EUID" != 0 ] ; then
+ root=f
+ case "`uname 2>/dev/null`" in
+ CYGWIN*)
+ # Cygwin: Assume root if member of admin group
+ for g in `id -G 2>/dev/null` ; do
+ case $g in
+ 0|544) root=t ;;
+ esac
+ done ;;
+ esac
+ if [ $root != t ] ; then
+ echo "$self: You must run this as root" >&2
+ exit 1
+ fi
+fi
+
+
+if test -f ${sysconfdir}/default/kboot ; then
+ . ${sysconfdir}/default/kboot
+fi
+
+# Default values
+if [ "x${KBOOT_TIMEOUT}" = "x" ] ; then KBOOT_TIMEOUT=5 ; fi
+
+if [ "x${KBOOT_DISTRIBUTOR}" = "x" ] ; then
+ OS=GNU/Linux
+else
+ OS="${KBOOT_DISTRIBUTOR} GNU/Linux"
+fi
+
+# These are optional, user-defined variables.
+export KBOOT_TIMEOUT \
+ KBOOT_DISTRIBUTOR \
+ KBOOT_CMDLINE_LINUX \
+ KBOOT_CMDLINE_LINUX_DEFAULT \
+ KBOOT_DISABLE_RECOVERY
+
+if test "x${kboot_conf}" != "x"; then
+ rm -f ${kboot_conf}.new
+ exec > ${kboot_conf}.new
+fi
+echo "Generating kboot.conf ..." >&2
+
+cat << EOF
+#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by $self
+# with settings from ${sysconfdir}/default/kboot
+#
+
+timeout=${KBOOT_TIMEOUT}
+
+EOF
+
+echo "### BEGIN list of kernels ###"
+list_kernels
+echo "### END list of kernels ###"
+
+if test "x${kboot_conf}" != "x" ; then
+ # none of the children aborted with error, install the new kboot.cfg
+ mv -f ${kboot_conf}.new ${kboot_conf}
+fi
+
+echo "done" >&2
--- /dev/null
+# kboot-mkconfig helper script.
+# Copyright (C) 2011 Antonio Ospite <ospite@studenti.unina.it>
+#
+# Inspired by the 10_linux script from kboot
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This progra, is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this software. If not, see <http://www.gnu.org/licenses/>.
+
+prefix=/usr
+exec_prefix=${prefix}
+bindir=${exec_prefix}/bin
+libdir=${exec_prefix}/lib
+
+LINUX_ROOT_DEVICE="$(mount | grep ' / ' | cut -d ' ' -f 1)"
+
+if $(which gettext >/dev/null 2>/dev/null) ; then
+ gettext="gettext"
+else
+ gettext="echo"
+fi
+
+# One layer of quotation is eaten by "", the second by sed, and the third by
+# printf; so this turns ' into \'. Note that you must use the output of
+# this function in a printf format string.
+gettext_quoted () {
+ $gettext "$@" | sed "s/'/'\\\\\\\\''/g"
+}
+
+# Run the first argument through gettext_quoted, and then pass that and all
+# remaining arguments to printf. This is a useful abbreviation and tends to
+# be easier to type.
+gettext_printf () {
+ local format="$1"
+ shift
+ printf "$(gettext_quoted "$format")" "$@"
+}
+
+kboot_file_is_not_garbage ()
+{
+ if test -f "$1" ; then
+ case "$1" in
+ *.dpkg-*) return 1 ;; # debian dpkg
+ README*) return 1 ;; # documentation
+ esac
+ else
+ return 1
+ fi
+ return 0
+}
+
+version_test_gt ()
+{
+ local sedexp="s/[^-]*-//;s/[._-]\(pre\|rc\|test\|git\|old\|trunk\)/~\1/g"
+ local a=`echo $1 | sed -e "$sedexp"`
+ local b=`echo $2 | sed -e "$sedexp"`
+ local cmp=gt
+ if [ "x$b" = "x" ] ; then
+ return 0
+ fi
+ case $a:$b in
+ *.old:*.old) ;;
+ *.old:*) a=`echo -n $a | sed -e s/\.old$//` ; cmp=gt ;;
+ *:*.old) b=`echo -n $b | sed -e s/\.old$//` ; cmp=ge ;;
+ esac
+ dpkg --compare-versions "$a" $cmp "$b"
+ return $?
+}
+
+version_find_latest ()
+{
+ local a=""
+ for i in $@ ; do
+ if version_test_gt "$i" "$a" ; then
+ a="$i"
+ fi
+ done
+ echo "$a"
+}
+
+linux_entry ()
+{
+ os="$1"
+ version="$2"
+ recovery="$3"
+ args="$4"
+ if ${recovery} ; then
+ title="$(gettext_quoted "%s, with Linux %s (recovery mode)")"
+ else
+ title="$(gettext_quoted "%s, with Linux %s")"
+ fi
+ label="$(printf "${title}" "${os}" "${version}")"
+ echo -n "'${label}'='${dirname}/${basename} "
+ if test -n "${initrd}" ; then
+ echo -n "initrd=${dirname}/${initrd}"
+ fi
+ echo " root=${linux_root_device_thisversion} ro ${args}'"
+}
+
+list_kernels ()
+{
+ list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* ; do
+ if kboot_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
+ done`
+ prepare_boot_cache=
+
+ while [ "x$list" != "x" ] ; do
+ linux=`version_find_latest $list`
+ echo "Found linux image: $linux" >&2
+ basename=`basename $linux`
+ dirname=`dirname $linux`
+
+ # XXX: this relies on a binary shipped by GRUB, we just use ${dirname} for
+ # now, check the ${dirname} entries if we need something like that later
+ #rel_dirname=`make_system_path_relative_to_its_root $dirname`
+
+ version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
+ alt_version=`echo $version | sed -e "s,\.old$,,g"`
+ linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
+
+ initrd=
+ for i in "initrd.img-${version}" "initrd-${version}.img" \
+ "initrd-${version}" "initramfs-${version}.img" \
+ "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
+ "initrd-${alt_version}" "initramfs-${alt_version}.img"; do
+ if test -e "${dirname}/${i}" ; then
+ initrd="$i"
+ break
+ fi
+ done
+
+ initramfs=
+ for i in "config-${version}" "config-${alt_version}"; do
+ if test -e "${dirname}/${i}" ; then
+ initramfs=`grep CONFIG_INITRAMFS_SOURCE= "${dirname}/${i}" | cut -f2 -d= | tr -d \"`
+ break
+ fi
+ done
+
+ if test -n "${initrd}" ; then
+ echo "Found initrd image: ${dirname}/${initrd}" >&2
+ elif test -z "${initramfs}" ; then
+ # "UUID=" magic is parsed by initrd or initramfs. Since there's
+ # no initrd or builtin initramfs, it can't work here.
+ linux_root_device_thisversion=${KBOOT_DEVICE}
+ fi
+
+ linux_entry "${OS}" "${version}" false \
+ "${KBOOT_CMDLINE_LINUX} ${KBOOT_CMDLINE_LINUX_DEFAULT}"
+ if [ "x${KBOOT_DISABLE_RECOVERY}" != "xtrue" ]; then
+ linux_entry "${OS}" "${version}" true \
+ "single ${KBOOT_CMDLINE_LINUX}"
+ fi
+
+ list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+ done
+}
--- /dev/null
+.\" Copyright 2011 Antonio Ospite
+.\" Lincensed under GPL3+
+.\" Copyed from the grub-mkconfig man page
+.TH KBOOT-MKCONFIG "8" "April 2011" "kboot-mkconfig 0.1" "System Administration Utilities"
+.SH NAME
+kboot-mkconfig \- generate a kboot configuration file
+.SH SYNOPSIS
+.B kboot-mkconfig
+[\fIOPTION\fR]
+.SH DESCRIPTION
+Generate a kboot config file
+.TP
+\fB\-o\fR, \fB\-\-output\fR=\fIFILE\fR
+output generated config to FILE [default=stdout]
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+print this message and exit
+.TP
+\fB\-v\fR, \fB\-\-version\fR
+print the version information and exit
+.SH "REPORTING BUGS"
+Report bugs to <ospite@studenti.unina.it>.