#!/bin/bash
#
# Name: compat-swsusp2-mkinitrd
# Provides: swsusp2-mkinitrd
# Requires: mkinitrd-suspend2
#
# Binary name:  /sbin/mkinitrd-swsusp
# Symlink name: /sbin/new-kernel-pkg-swsusp
#
# Default Suspend 2 version: 20107
# Default early splash:      none
#
# compability wrapper to mkinitrd-suspend2 for older kernels
# provides dependencies for people upgrading from FC3/4 without
# removing their old kernels at the moment.
#
# It is recommended to remove this package and the older kernels if
# everything is working well.
#
# 2006/03/03, Matthias Hensler: Creation

BINARY=/sbin/mkinitrd-suspend2
RARG=2

if [ "X`basename $0`" = "Xnew-kernel-pkg-swsusp" ]; then
  BINARY=/sbin/new-kernel-pkg-suspend2
  RARG=1
fi

unset BARG
GOTVER=0
pos=1

while [ $# -gt 0 ]; do
  case $1 in
     --early-splash)
       BARG[$pos]="--suspend2-userui=auto"
       pos=$(($pos+1))
       ;;

     --swsusp-version*)
       if echo $1 | grep '=' >/dev/null ; then
         VERSION=`echo $1 | sed 's/^--swsusp-version=//'`
       else
         VERSION=$2
         shift
       fi
       BARG[$pos]="--suspend2-version=$VERSION"
       pos=$(($pos+1))
       GOTVER=1
       ;;

     *)
       if [ $GOTVER -eq 0 -a $# -eq $RARG ]; then
         BARG[$pos]="--suspend2-version=20107"
         pos=$(($pos+1))
         GOTVER=1
       fi
       BARG[$pos]="$1"
       pos=$(($pos+1))
       ;;
  esac
  shift
done

$BINARY "${BARG[@]}"

