summaryrefslogtreecommitdiff
path: root/kernels/xen/09_xen
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2014-06-13 00:49:50 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2014-06-13 00:49:50 -0300
commit4b04ad93cdb9aa776b68b7de7d2e36e275670822 (patch)
tree925af60d74e38ee4b7d3704353c575ff017f40d9 /kernels/xen/09_xen
parent56d756a6b388c5f06fe2b27d3bb5eee72feac2aa (diff)
xen-4.4.0-4: updating version
Diffstat (limited to 'kernels/xen/09_xen')
-rw-r--r--kernels/xen/09_xen322
1 files changed, 206 insertions, 116 deletions
diff --git a/kernels/xen/09_xen b/kernels/xen/09_xen
index ddb20696f..c00d1ab96 100644
--- a/kernels/xen/09_xen
+++ b/kernels/xen/09_xen
@@ -1,141 +1,231 @@
-#! /bin/sh -e
+#!/usr/bin/env bash
+
+##
+## grub-mkconfig helper script specific to Parabola GNU/Linux-libre
+## Contributed by "Keshav Amburay" <the ddoott ridikulus ddoott rat aatt geemmayil ddoott ccoomm>
+## Rebranded for Parabola by "André Silva" <emulatorman@parabola.nu>
+## Updated on 08 February 2014
+##
+## Script based on do_grub_config() function in Arch Archboot ISO Installer/Setup script
+## Some parts taken from /etc/grub.d/10_linux script shipped by GRUB(2) upstream
+##
+## This script can be freely distributed and/or modified
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This script 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.
+##
+
+## Adapted for use with the xen package, to ensure feature comparity
+## Modified by "David Sutton" <kantras - gmail com>
+
+_FUNC_GRUB_FILE_PRESENT() {
+
+ [[ -z "${GRUB_PLATFORM}" ]] && GRUB_PLATFORM="x86"
+
+ if [[ "${GRUB_PLATFORM}" == "x86" ]]; then
+ check="--is-x86-linux32"
+ elif [[ "${GRUB_PLATFORM}" == "i386-xen-pae" ]]; then
+ check="--is-i386-xen-pae-domu"
+ elif [[ "${GRUB_PLATFORM}" == "x86_64-xen" ]]; then
+ check="--is-x86_64-xen-domu"
+ else
+ check="--is-${GRUB_PLATFORM}-linux"
+ fi
+
+ case "${GRUB_PLATFORM}" in
+ x86)
+ list="$(for i in "${GRUB_ROOT}"/boot/vmlinuz-linux* ; do
+ if grub_file_is_not_garbage "${i}" && "${grub_file}" ${check} "${i}" ; then echo -n "${i} " ; fi
+ done)" ;;
+ *)
+ list="$(for i in "${GRUB_ROOT}"/boot/vmlinuz-linux* ; do
+ if grub_file_is_not_garbage "${i}" && "${grub_file}" ${check} "${i}" ; then echo -n "${i} " ; fi
+ done)" ;;
+ esac
+}
-if [ -f /usr/share/grub/grub-mkconfig_lib ]; then
- . /usr/share/grub/grub-mkconfig_lib
-else
- # no grub file, so we notify and exit gracefully
- echo "Cannot find grub config file, exiting." >&2
- exit 0
-fi
+set -e
-XEN_HYPERVISOR_CMDLINE="xsave=1"
-XEN_LINUX_CMDLINE="console=tty0"
-[ -r /etc/xen/grub.conf ] && . /etc/xen/grub.conf
+prefix="/usr"
+exec_prefix="${prefix}"
+datarootdir="/usr/share"
+datadir="${datarootdir}"
+sysconfdir="/etc"
-CLASS="--class gnu-linux --class gnu --class os"
+. "${datarootdir}/grub/grub-mkconfig_lib"
-if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
- OS=GNU/Linux
-else
- if [ "${GRUB_DISTRIBUTOR}" = "Parabola" ] ; then
- OS="${GRUB_DISTRIBUTOR} GNU/Linux-libre"
- elif [ "${GRUB_DISTRIBUTOR}" = "parabola" ] ; then
- OS="${GRUB_DISTRIBUTOR} GNU/Linux-libre"
- elif [ "${GRUB_DISTRIBUTOR}" = "Blag" ] ; then
- OS="${GRUB_DISTRIBUTOR} Linux and GNU"
- elif [ "${GRUB_DISTRIBUTOR}" = "blag" ] ; then
- OS="${GRUB_DISTRIBUTOR} Linux and GNU"
- elif [ "${GRUB_DISTRIBUTOR}" = "Musix" ] ; then
- OS="${GRUB_DISTRIBUTOR} GNU+Linux"
- elif [ "${GRUB_DISTRIBUTOR}" = "musix" ] ; then
- OS="${GRUB_DISTRIBUTOR} GNU+Linux"
- elif [ "${GRUB_DISTRIBUTOR}" = "Dragora" ] ; then
- OS="${GRUB_DISTRIBUTOR} GNU/Linux-libre"
- elif [ "${GRUB_DISTRIBUTOR}" = "dragora" ] ; then
- OS="${GRUB_DISTRIBUTOR} GNU/Linux-libre"
- else
- OS="${GRUB_DISTRIBUTOR} GNU/Linux"
- fi
- CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
+. "${sysconfdir}/default/grub"
+
+export XEN_HYPERVISOR_CMDLINE="xsave=1"
+export XEN_LINUX_CMDLINE="console=tty0"
+
+[[ -r "${sysconfdir}/xen/grub.conf" ]] && . "${sysconfdir}/xen/grub.conf"
+
+[[ -z "${XEN_LINUX_CMDLINE_OVERRIDE}" ]] && XEN_LINUX_CMDLINE_OVERRIDE="0"
+
+export TEXTDOMAIN="grub"
+export TEXTDOMAINDIR="${datarootdir}/locale"
+
+CLASS="--class xen --class parabola --class gnu-linux --class gnu --class os"
+
+[[ "${grub_file}" != "" ]] && _FUNC_GRUB_FILE_PRESENT
+
+BOOT_PART_FS_UUID="$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null)"
+BOOT_PART_HINTS_STRING="$(${grub_probe} --target="hints_string" "/boot" 2>/dev/null || true)"
+BOOT_PART_FS="$(${grub_probe} --target="fs" "/boot" 2>/dev/null)"
+
+ROOT_PART_GRUB_DEVICE="$(${grub_probe} --target=device / || true)"
+ROOT_PART_FS="$(${grub_probe} --device ${ROOT_PART_GRUB_DEVICE} --target=fs 2> /dev/null || echo "unknown")"
+
+if [[ "${GRUB_LINUX_ROOT_DEVICE}" == "" ]]; then
+
+ case "${ROOT_PART_FS}" in
+ btrfs)
+ rootsubvol="$(make_system_path_relative_to_its_root /)"
+ rootsubvol="${rootsubvol#/}"
+ if [[ "${rootsubvol}" != "" ]]; then
+ GRUB_LINUX_ROOT_DEVICE="subvol=${rootsubvol}"
+ fi
+ ;;
+ zfs)
+ rpool="$(${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true)"
+ bootfs="$(make_system_path_relative_to_its_root / | sed -e "s,@$,,")"
+ GRUB_LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
+ ;;
+ esac
+
+ if [[ "${GRUB_DEVICE_UUID}" == "" ]] || \
+ [[ "${GRUB_DISABLE_LINUX_UUID}" == "true" ]] || \
+ [[ ! -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ]] || \
+ uses_abstraction "${GRUB_DEVICE}" lvm ; then
+ GRUB_LINUX_ROOT_DEVICE="${GRUB_DEVICE}"
+ else
+ GRUB_LINUX_ROOT_DEVICE="UUID=${GRUB_DEVICE_UUID}"
+ fi
fi
-# loop-AES arranges things so that /dev/loop/X can be our root device, but
-# the initrds that Linux uses don't like that.
-case ${GRUB_DEVICE} in
- /dev/loop/*|/dev/loop[0-9])
- GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
- ;;
-esac
-
-if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
- || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
- || [ "`grub-probe -t abstraction --device ${GRUB_DEVICE} | sed -e 's,.*\(lvm\).*,\1,'`" = "lvm" ] ; then
- LINUX_ROOT_DEVICE=${GRUB_DEVICE}
+[[ "${GRUB_LINUX_PARAMS}" == "" ]] && GRUB_LINUX_PARAMS="${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
+if [[ "${XEN_LINUX_CMDLINE_OVERRIDE}" == "0" ]]; then
+ GRUB_LINUX_PARAMS="${GRUB_LINUX_PARAMS} ${XEN_LINUX_CMDLINE}"
else
- LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
+ GRUB_LINUX_PARAMS="${XEN_LINUX_CMDLINE}"
fi
-xen_entry ()
-{
- os="$1"
- xen_version="$2"
- version="$3"
- xen_args="$4"
- args="$5"
- printf "menuentry 'Xen %s / %s, with Linux %s' --class xen ${CLASS} {\n" "${xen_version}" "${os}" "${version}"
- save_default_entry | sed -e "s/^/\t/"
-
- if [ -z "${prepare_boot_cache}" ]; then
- prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
- fi
- printf '%s\n' "${prepare_boot_cache}"
- cat << EOF
- echo '$(printf "Loading Xen %s ..." ${xen_version})'
- multiboot ${rel_dirname}/${xen_basename} ${rel_dirname}/${xen_basename} ${xen_args}
- echo $(printf "$(gettext "Loading Linux %s ...")" ${version})
- module ${rel_dirname}/${basename} ${rel_dirname}/${basename} root=${linux_root_device_thisversion} rw ${args}
-EOF
- if test -n "${initrd}" ; then
- cat << EOF
- echo "Loading initial ramdisk ..."
- module ${rel_dirname}/${initrd}
-EOF
- fi
- cat << EOF
-}
-EOF
-}
-
xen_list=`for i in /boot/xen-*.gz /xen-*.gz ; do
if grub_file_is_not_garbage "$i" ; then echo -n "$i "; fi
done`
-prepare_boot_cache=
while [ "x$xen_list" != "x" ] ; do
xen=`version_find_latest $xen_list`
echo "Found Xen hypervisor image: $xen" >&2
- xen_basename=`basename $xen`
- xen_dirname=`dirname $xen`
- rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
- xen_version=`echo $xen_basename | sed -e "s,^[^0-9]*-,,g" | sed -e "s,.gz,,g"`
- alt_xen_version=`echo $xen_version | sed -e "s,\.old$,,g"`
+ XEN_BASENAME=`basename $xen`
+ XEN_VERSION=`echo $XEN_BASENAME | sed -e "s,^[^0-9]*-,,g" | sed -e "s,.gz,,g"`
+
+ for _KERNEL_ in ${list} ; do
+
+ echo "Found linux image: ${_KERNEL_}" >&2
+
+ basename="$(basename "${_KERNEL_}")"
+ dirname="$(dirname "${_KERNEL_}")"
+ REAL_DIR="$(make_system_path_relative_to_its_root "${dirname}")"
+
+ _KERNEL_FILE_="$(echo ${_KERNEL_} | sed 's,/boot/,,g')"
+ _KERNEL_PKG_="pkg-$(echo ${_KERNEL_FILE_} | sed 's,vmlinuz-,,g')"
+
+ _INITRAMFS_="${_KERNEL_FILE_/vmlinuz-/initramfs-}.img"
+
+ if [[ -e "/boot/${_INITRAMFS_}" ]]; then
+
+ echo "Found initramfs image: /boot/${_INITRAMFS_}" >&2
+
+ cat << EOF
+
+menuentry "Xen ${XEN_VERSION} / Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel" ${CLASS} {
+ $(save_default_entry)
+ if [ x\$feature_all_video_module = xy ]; then
+ insmod all_video
+ fi
+ set gfxpayload=keep
+ insmod ${BOOT_PART_FS}
+ if [ x\$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_HINTS_STRING} ${BOOT_PART_FS_UUID}
+ else
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_FS_UUID}
+ fi
+ echo '$(printf "Loading Xen %s ..." ${XEN_VERSION})'
+ multiboot ${REAL_DIR}/${XEN_BASENAME} ${REAL_DIR}/${XEN_BASENAME} ${XEN_HYPERVISOR_CMDLINE}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel ...'
+ module ${REAL_DIR}/${_KERNEL_FILE_} ${REAL_DIR}/${_KERNEL_FILE_} root=${GRUB_LINUX_ROOT_DEVICE} rw ${GRUB_LINUX_PARAMS}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel initramfs ...'
+ module ${REAL_DIR}/${_INITRAMFS_}
+}
- list=`for i in /boot/vmlinuz-* /vmlinuz-*; do
- if grub_file_is_not_garbage "$i" ; then echo -n "$i "; fi
- done`
-
- while [ "x$list" != "x" ] ; do
- linux=`version_find_latest $list`
- echo -e "\tFound linux image: $linux" >&2
- basename=`basename $linux`
- dirname=`dirname $linux`
- rel_dirname=`make_system_path_relative_to_its_root $dirname`
- version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
- base_init=`echo $basename | sed -e "s,vmlinuz,initramfs,g"`
- alt_version="${base_init}-fallback"
- linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
- initrd=
-
- for i in "${base_init}.img"; do
- if test -e "${dirname}/${i}" ; then
- initrd="$i"
- break
- fi
- done
- if test -n "${initrd}" ; then
- echo -e "\tFound initrd image: ${dirname}/${initrd}" >&2
- else
- # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here.
- linux_root_device_thisversion=${GRUB_DEVICE}
+EOF
fi
+
+ _INITRAMFS_FALLBACK_="${_KERNEL_FILE_/vmlinuz-/initramfs-}-fallback.img"
+
+ if [[ -e "/boot/${_INITRAMFS_FALLBACK_}" ]]; then
+
+ echo "Found fallback initramfs image: /boot/${_INITRAMFS_FALLBACK_}" >&2
+
+ cat << EOF
+
+menuentry "Xen ${XEN_VERSION} / Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel (fallback initramfs)" ${CLASS} {
+ $(save_default_entry)
+ if [ x\$feature_all_video_module = xy ]; then
+ insmod all_video
+ fi
+ set gfxpayload=keep
+ insmod ${BOOT_PART_FS}
+ if [ x\$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_HINTS_STRING} ${BOOT_PART_FS_UUID}
+ else
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_FS_UUID}
+ fi
+ echo '$(printf "Loading Xen %s ..." ${XEN_VERSION})'
+ multiboot ${REAL_DIR}/${XEN_BASENAME} ${REAL_DIR}/${XEN_BASENAME} ${XEN_HYPERVISOR_CMDLINE}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel ...'
+ module ${REAL_DIR}/${_KERNEL_FILE_} ${REAL_DIR}/${_KERNEL_FILE_} root=${GRUB_LINUX_ROOT_DEVICE} rw ${GRUB_LINUX_PARAMS}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel fallback initramfs ...'
+ module ${REAL_DIR}/${_INITRAMFS_FALLBACK_}
+}
- xen_entry "${OS}" "${xen_version}" "${version}" \
- "${XEN_HYPERVISOR_CMDLINE}" \
- "${XEN_LINUX_CMDLINE}"
+EOF
+ fi
+
+ if [[ ! -e "/boot/${_INITRAMFS_}" ]] && [[ ! -e "/boot/${_INITRAMFS_FALLBACK_}" ]]; then
+ cat << EOF
+
+menuentry "Xen ${XEN_VERSION} / Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel (no initramfs)" ${CLASS} {
+ $(save_default_entry)
+ if [ x\$feature_all_video_module = xy ]; then
+ insmod all_video
+ fi
+ set gfxpayload=keep
+ insmod ${BOOT_PART_FS}
+ if [ x\$feature_platform_search_hint = xy ]; then
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_HINTS_STRING} ${BOOT_PART_FS_UUID}
+ else
+ search --no-floppy --fs-uuid --set=root ${BOOT_PART_FS_UUID}
+ fi
+ echo '$(printf "Loading Xen %s ..." ${XEN_VERSION})'
+ multiboot ${REAL_DIR}/${XEN_BASENAME} ${REAL_DIR}/${XEN_BASENAME} ${XEN_HYPERVISOR_CMDLINE}
+ echo 'Loading Parabola GNU/Linux-libre ${_KERNEL_PKG_} kernel ...'
+ module ${REAL_DIR}/${_KERNEL_FILE_} ${REAL_DIR}/${_KERNEL_FILE_} root=${GRUB_LINUX_ROOT_DEVICE} rw ${GRUB_LINUX_PARAMS}
+}
- list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
+EOF
+ fi
+
done
xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $xen | tr '\n' ' '`
done
+