pax_global_header00006660000000000000000000000064122444375610014522gustar00rootroot0000000000000052 comment=853a2b7d26e075e481a03bed4e01acc13b6b424f kboot-utils-0.4/000077500000000000000000000000001224443756100136415ustar00rootroot00000000000000kboot-utils-0.4/ChangeLog000066400000000000000000000042461224443756100154210ustar00rootroot000000000000002013-11-24 18:58:08 +0100 Antonio Ospite * Install kboot-mkconfig_lib under /usr/share/kboot (HEAD, master) 2013-11-19 15:06:27 +0100 Antonio Ospite * ChangeLog: update for v0.3 release (tag: v0.3) 2013-11-19 15:01:50 +0100 Antonio Ospite * kboot-mkconfig: fix a typo (origin/master, origin/HEAD) 2013-11-19 14:57:50 +0100 Antonio Ospite * Makefile: fix directory creation 2013-11-19 14:04:31 +0100 Antonio Ospite * README: strip trailing spaces 2011-09-30 23:45:35 +0200 Antonio Ospite * Release v0.2 as the first actually working release (tag: v0.2) 2011-09-30 22:49:38 +0200 Antonio Ospite * Fix several problems in linux_find_root_device 2011-09-23 13:27:44 +0200 Antonio Ospite * Release a new version with a ChangeLog file (tag: v0.1a) 2011-09-23 13:14:41 +0200 Antonio Ospite * Makefile: add a rule to generate a GNU style ChangeLog 2011-09-23 12:06:40 +0200 Antonio Ospite * README: adjust wording and add links to kboot.conf format 2011-09-22 13:03:09 +0200 Antonio Ospite * Remove the debian/ dir from the master branch (tag: v0.1) 2011-09-13 15:16:38 +0200 Antonio Ospite * Add an alternative way to find the root device 2011-09-13 12:57:43 +0200 Antonio Ospite * Fix a typo: the 10_linux we ispire from is from grub 2011-09-13 12:56:26 +0200 Antonio Ospite * Put "set -e" after the license header 2011-09-13 12:01:55 +0200 Antonio Ospite * Cleanup debian/postinst and debian/postrm scripts 2011-09-13 11:19:02 +0200 Antonio Ospite * No need to be a native debian package 2011-04-15 21:39:42 +0200 Antonio Ospite * Handle the case when links like /dev/root are returned 2011-04-14 23:43:58 +0200 Antonio Ospite * Initial import kboot-utils-0.4/Makefile000066400000000000000000000007621224443756100153060ustar00rootroot00000000000000prefix ?= /usr sysconfdir ?= /etc all: clean: install: install -d $(DESTDIR)$(prefix)/share/kboot/ install -m 0644 kboot-mkconfig_lib $(DESTDIR)$(prefix)/share/kboot/kboot-mkconfig_lib install -d $(DESTDIR)$(prefix)/sbin install -m 0755 kboot-mkconfig $(DESTDIR)$(prefix)/sbin/kboot-mkconfig install -d $(DESTDIR)$(sysconfdir)/default install -m 0644 default.kboot $(DESTDIR)$(sysconfdir)/default/kboot changelog: git log --pretty="format:%ai %aN <%aE>%n%n%x09* %s%d%n" > ChangeLog kboot-utils-0.4/README000066400000000000000000000011511224443756100145170ustar00rootroot00000000000000kboot-utils provides helper tools to automatically generate a kboot.conf file from entries in /boot. kboot.conf is used for instance by the petitboot bootloader, which is used on the Sony PlayStation 3 in OtherOS mode; petitboot reads the file from the root filesystem in order to list kernels to boot. A description of the kboot.conf file format can be found at: http://www.kernel.org/pub/linux/kernel/people/geoff/cell/ps3-linux-docs/ps3-linux-docs-latest/mini-boot-conf.txt mirrored at: http://ring.nict.go.jp/pub/linux/kernel.org/kernel/people/geoff/cell/ps3-linux-docs/ps3-linux-docs-latest/mini-boot-conf.txt kboot-utils-0.4/TODO000066400000000000000000000012361224443756100143330ustar00rootroot00000000000000Make 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}"` kboot-utils-0.4/default.kboot000066400000000000000000000011541224443756100163260ustar00rootroot00000000000000# 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" kboot-utils-0.4/doc/000077500000000000000000000000001224443756100144065ustar00rootroot00000000000000kboot-utils-0.4/doc/kboot.conf.sample000066400000000000000000000001611224443756100176510ustar00rootroot00000000000000timeout=5 default=linux linux='/boot/vmlinux initrd=/boot/initrd.img root=/dev/ps3da1 video=ps3fb:mode:3 quiet' kboot-utils-0.4/kboot-mkconfig000077500000000000000000000066421224443756100165100ustar00rootroot00000000000000#! /bin/sh # Generate kboot.conf by inspecting /boot contents. # Copyright (C) 2011 Antonio Ospite # # Inspired by grub-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 . set -e PACKAGE_NAME=kboot-mkconfig PACKAGE_VERSION=0.4 prefix=/usr exec_prefix=${prefix} sbindir=${exec_prefix}/sbin bindir=${exec_prefix}/bin 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 } 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 . ${datadir}/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 kboot-utils-0.4/kboot-mkconfig_lib000066400000000000000000000124371224443756100173320ustar00rootroot00000000000000# kboot-mkconfig helper script. # Copyright (C) 2011 Antonio Ospite # # Inspired by the 10_linux script from grub # # 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 . prefix=/usr exec_prefix=${prefix} bindir=${exec_prefix}/bin libdir=${exec_prefix}/lib # TODO: remove this if the following find_linux_root_device() # is found to be reliable enough #LINUX_ROOT_DEVICE="$(readlink -f $(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_find_root_device() { ROOT_DEVICE=$(mountpoint -d /) for devnode in $(find /dev); do # Get major and minor in decimal CURRENT_DEVICE=$(printf "%d:%d" $(stat --printf="0x%t 0x%T" "$devnode")) if [ $CURRENT_DEVICE = $ROOT_DEVICE ]; then ROOT_NODE="$devnode" break fi done echo "$ROOT_NODE" } 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"` # TODO: remove this too #linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" linux_root_device_thisversion=`linux_find_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 } kboot-utils-0.4/man/000077500000000000000000000000001224443756100144145ustar00rootroot00000000000000kboot-utils-0.4/man/kboot-mkconfig.8000066400000000000000000000011721224443756100174170ustar00rootroot00000000000000.\" 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 .