File: update-tirfs

package info (click to toggle)
tiny-initramfs 0.1-6.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 744 kB
  • sloc: ansic: 4,097; sh: 1,529; makefile: 48
file content (77 lines) | stat: -rwxr-xr-x 1,848 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh

set -e
umask 0022

usage() {
  echo "Usage: $0 [-k version]"
  echo ""
  echo "Updates system tiny-initramfs images"
  echo ""
  echo "Options:"
  echo "    -k, --kernel-version=VERSION  The kernel version for which the initramfs"
  echo "                                  image is to be updated. (default: all)"
}

if ! OPTIONS=$(getopt -o k:h -l kernel-version:,help -n "$0" -- "$@") ; then
  usage >&2
  exit 1
fi
eval set -- "$OPTIONS"

VERSION="all"
while true; do
  case "$1" in
    -h|--help)
      usage
      exit 0
      ;;
    -k|--kernel-version)
      VERSION="$2"
      shift 2
      ;;
    --)
      shift
      break
      ;;
    *)
      echo "$0: internal error" >&2
      exit 1
      ;;
  esac
done

if [ $# -gt 0 ] ; then
  echo "$0: too many options" >&2
  usage >&2
  exit 1
fi

# Called from a maintainer script -> resort to triggers instead
if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
  echo "$0: WARNING: called from dpkg maintscript, please use triggers instead." >&2
  if dpkg-trigger --no-await update-initramfs; then
    echo "update-tirfs: deferring update (trigger activated)"
    exit 0
  fi
fi

if [ x"$VERSION" = x"all" ] ; then
  for V in /boot/vmlinu[xz]-* ; do
    if ! [ -r "${V}" ] ; then continue ; fi
    V=${V#/boot/vmlinu?-}
    mktirfs -o /boot/initrd.img-"${V}" "${V}"
    if [ -d /etc/initramfs/post-update.d ]; then
      run-parts --arg="${V}" --arg=/boot/initrd.img-"${V}" /etc/initramfs/post-update.d
    fi
  done
else
  if ! ls /boot/vmlinu[xz]-"${VERSION}" >/dev/null 2>&1 ; then
    echo "$0: kernel version ${VERSION} does not appear to be installed." >&2
    exit 1
  fi
  mktirfs -o /boot/initrd.img-"${VERSION}" "${VERSION}"
  if [ -d /etc/initramfs/post-update.d ]; then
    run-parts --arg="${VERSION}" --arg=/boot/initrd.img-"${VERSION}" /etc/initramfs/post-update.d
  fi
fi