#!/bin/sh # # mkinitrd - emulate mkinitrd with yaird for kernel-image installs. # # Copyright (C) 2001-2003 Herbert Xu # Copyright (C) 2005 Erik van Konijnenburg # - ripped out everything but the options. # # 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 2 of the License, or # (at your option) any later version. # # This program 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 program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # PROG=mkinitrd.yaird outfile='' TEMP=`getopt -o cd:k:m:o:r:u --long supported-host-version:,supported-target-version: -n "$PROG" -- "$@"` # Check for non-GNU getopt if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi eval set -- "$TEMP" while true ; do case "$1" in -c) # ignore shift 1 ;; -d) echo "$PROG: $1 unsupported" >&2 exit 1 ;; -k) VERSION="$2" shift 2 ;; -m) # ignore shift 2 ;; -o) outfile="$2" shift 2 ;; -r) echo "$PROG: $1 unsupported" >&2 exit 1 ;; -u) # ignore shift 1 ;; --supported-host-version) supported_host_version="$2" shift 2 ;; --supported-target-version) supported_target_version="$2" shift 2 ;; --) shift break ;; *) echo "Internal error!" >&2 exit 1 ;; esac done if [ -n "$supported_host_version" ] || [ -n "$supported_target_version" ]; then if [ -n "$supported_host_version" ]; then host_upstream_version="${supported_host_version%%-*}" if dpkg --compare-versions "$host_upstream_version" lt "2.6.8"; then exit 2 fi fi if [ -n "$supported_target_version" ]; then target_upstream_version="${supported_target_version%%-*}" if dpkg --compare-versions "$target_upstream_version" lt "2.6.8"; then exit 2 fi fi exit 0 fi if [ "$VERSION" = "" ]; then VERSION="$1" fi if [ "$outfile" = "" ]; then outfile=/boot/initrd.img-$VERSION fi if [ $# -gt 1 ]; then echo "$PROG: extra arguments found" >&2 exit 1 fi # Note that version may be a pathname; # this is used by the installer for Debian kernel image packages. [ $# -gt 0 ] || unset VERSION case "$VERSION" in /lib/modules/*/[!/]*) ;; /lib/modules/[!/]*) VERSION="${VERSION#/lib/modules/}" VERSION="${VERSION%%/*}" ;; esac case $VERSION in */*) echo "$PROG: $VERSION is not a valid kernel version" >&2 exit 1 ;; esac VERSION="${VERSION-$(uname -r)}" if [ -f $outfile ]; then rm $outfile fi exec /usr/sbin/yaird --output "$outfile" "$VERSION"