git » linux-armlfs.git » main » tree

[main] / chromebook.install

flash_kernel() {
  major=$(mountpoint -d / | cut -f 1 -d ':')
  root_minor=$(mountpoint -d / | cut -f 2 -d ':')
  krnl_minor=$(expr $root_minor - 1)
  device=$(cat /proc/partitions | awk {'if ($1 == "'${major}'" && $2 == "'${krnl_minor}'") print $4 '})
  device="/dev/$device"
  if [ ! -b "${device}" ]; then
    echo "Kernel partition not found. Cannot write kernel."
    echo "WRITE THE KERNEL TO THE APPROPRIATE PARTITION MANUALLY."
    echo "# dd if=/boot/vmlinux.kpart of=${device}"
    return
  fi

  kpart_size=$(cat /sys/dev/block/$major:$krnl_minor/size)
  if [ "$kpart_size" != "32768" ]; then
    echo "Unexpected kernel partition size. Aborting kernel write."
    echo "WRITE THE KERNEL TO THE APPROPRIATE PARTITION MANUALLY."
    echo "# dd if=/boot/vmlinux.kpart of=${device}"
    return
  fi

  echo "Writing new kernel onto ${device}."
  dd bs=1M if=/boot/vmlinux.kpart of=${device}
  sync
  echo "Done."
}

post_install () {
  flash_kernel
}

post_upgrade() {
  flash_kernel
}