home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / sbin / mkinitramfs-kpkg < prev    next >
Encoding:
Text File  |  2006-12-21  |  1.8 KB  |  99 lines

  1. #!/bin/sh
  2. set -eu
  3.  
  4. STATEDIR=/var/lib/initramfs-tools
  5. supported_host_version=""
  6. supported_target_version=""
  7. outfile=""
  8.  
  9. usage()
  10. {
  11.     cat >&2 << EOF
  12.  
  13. Usage: ${0} <-o outfile> [version]
  14.  
  15. Please use update-initramfs(8):
  16. ${0} exists for compatibility by kernel-package(5) calls.
  17. See mkinitramfs-kpkg(8) for further details.
  18. EOF
  19.     exit 1
  20. }
  21.  
  22. OPTIONS=`getopt -o m:o: --long supported-host-version:,supported-target-version: -n "$0" -- "$@"`
  23. # Check for non-GNU getopt
  24. if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
  25.  
  26. eval set -- "$OPTIONS"
  27.  
  28. while true; do
  29.     case "$1" in
  30.     -m)
  31.         # ignore
  32.         shift 2
  33.         ;;
  34.     -o)
  35.         touch $2
  36.         outfile="$(readlink -f "$2")"
  37.         shift 2
  38.         ;;
  39.     --supported-host-version)
  40.         supported_host_version="$2"
  41.         shift 2
  42.         ;;
  43.     --supported-target-version)
  44.         supported_target_version="$2"
  45.         shift 2
  46.         ;;
  47.     --)
  48.         shift
  49.         break
  50.         ;;
  51.     *)
  52.         echo "Internal error!" >&2
  53.         exit 1
  54.         ;;
  55.     esac
  56. done
  57.  
  58. if [ -n "$supported_host_version" ] || [ -n "$supported_target_version" ]; then
  59.     if [ -n "$supported_host_version" ]; then
  60.         host_upstream_version="${supported_host_version%%-*}"
  61.     fi
  62.     if [ -n "$supported_target_version" ]; then
  63.         target_upstream_version="${supported_target_version%%-*}"
  64.         if dpkg --compare-versions "$target_upstream_version" lt "2.6.12"; then
  65.             exit 2
  66.         fi
  67.     fi
  68.     exit 0
  69. fi
  70.  
  71.  
  72. if [ -z "${outfile}" ]; then
  73.     usage
  74. fi
  75.  
  76. # And by "version" we really mean path to kernel modules
  77. # This is braindead, and exists to preserve the interface with mkinitrd
  78. version="${1}"
  79.  
  80. case "${version}" in
  81. /lib/modules/*/[!/]*)
  82.     ;;
  83. /lib/modules/[!/]*)
  84.     version="${version#/lib/modules/}"
  85.     version="${version%%/*}"
  86.     ;;
  87. esac
  88.  
  89. case "${version}" in
  90. */*)
  91.     echo "$PROG: ${version} is not a valid kernel version" >&2
  92.     exit 1
  93.     ;;
  94. esac
  95.  
  96. # linux-image installs latest version
  97. mkinitramfs -o ${outfile} ${version}
  98. sha1sum "${outfile}" | sed -e 's/\.new//' > "${STATEDIR}/${version}"
  99.