From 741fa41c6ce99a23662ed90b174e6752732d91ad Mon Sep 17 00:00:00 2001 From: Arne Fitzenreiter Date: Wed, 18 Feb 2015 20:51:15 +0100 Subject: [PATCH] xen: fix image build and kernel package for xen. --- config/rootfiles/core/86/update.sh | 69 ++++++++++++++++++------ config/xen-image/README | 4 +- config/xen-image/xen-image-maker.sh | 17 +++--- src/paks/linux-pae/install.sh | 83 ++++++++++++++--------------- src/paks/linux-pae/uninstall.sh | 8 +-- src/paks/linux-pae/update.sh | 8 ++- 6 files changed, 116 insertions(+), 73 deletions(-) diff --git a/config/rootfiles/core/86/update.sh b/config/rootfiles/core/86/update.sh index ab72e684e2..a0bac4d64f 100644 --- a/config/rootfiles/core/86/update.sh +++ b/config/rootfiles/core/86/update.sh @@ -24,6 +24,37 @@ . /opt/pakfire/lib/functions.sh /usr/local/bin/backupctrl exclude >/dev/null 2>&1 + +function find_device() { + local mountpoint="${1}" + + local root + local dev mp fs flags rest + while read -r dev mp fs flags rest; do + # Skip unwanted entries + [ "${dev}" = "rootfs" ] && continue + + if [ "${mp}" = "${mountpoint}" ] && [ -b "${dev}" ]; then + root="$(basename "${dev}")" + break + fi + done < /proc/mounts + + # Get the actual device from the partition that holds / + while [ -n "${root}" ]; do + if [ -e "/sys/block/${root}" ]; then + echo "${root}" + return 0 + fi + + # Remove last character + root="${root::-1}" + done + + return 1 +} + + # # Remove old core updates from pakfire cache to save space... core=86 @@ -165,23 +196,29 @@ fi case "$(uname -m)" in i?86) - # - # Update to GRUB2 - # - echo - echo Update grub configuration ... - if grep -qE "^serial" /boot/old-grub-config; then - sed -i /etc/default/grub \ - -e "s|panic=10|& console=ttyS0,115200n8|g" - echo "GRUB_TERMINAL=\"serial\"" >> /etc/default/grub - echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub - fi + case "$(find_device "/")" in + xvd* ) + echo Skip bootloader update on xen. + ;; + * ) + # + # Update to GRUB2 + # + echo + echo Update grub configuration ... + if grep -qE "^serial" /boot/old-grub-config; then + sed -i /etc/default/grub \ + -e "s|panic=10|& console=ttyS0,115200n8|g" + echo "GRUB_TERMINAL=\"serial\"" >> /etc/default/grub + echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=115200\"" >> /etc/default/grub + fi - if ! /usr/local/bin/update-bootloader; then - logger -p syslog.emerg -t ipfire \ - "Could not update the bootloader!" - fi - ;; + if ! /usr/local/bin/update-bootloader; then + logger -p syslog.emerg -t ipfire \ + "Could not update the bootloader!" + fi + ;; + esac esac # Force (re)install pae kernel if pae is supported diff --git a/config/xen-image/README b/config/xen-image/README index a23491fc9e..159b036ceb 100644 --- a/config/xen-image/README +++ b/config/xen-image/README @@ -20,6 +20,6 @@ other usefull commands from the Dom0: - look what is going on: "xm top" or "xm list" This script can also build a Citrix XenCenter xva image. (Need xz-aware -xen version. Tested with Citrix Xen Server 6.2.5 beta) +xen version. Tested with Citrix Xen Server 6.5) - run "XEN_IMG_TYPE=xva bash xen-image-maker.sh" to build an xva image. -- import the vm with "xe vm-import file=ipfire.xva" +- import the vm with "xe vm-import filename=ipfire.xva" diff --git a/config/xen-image/xen-image-maker.sh b/config/xen-image/xen-image-maker.sh index 4f632805e1..28f005d5d9 100644 --- a/config/xen-image/xen-image-maker.sh +++ b/config/xen-image/xen-image-maker.sh @@ -116,7 +116,7 @@ mount -o loop $IMGboot $MNThdd/boot mount -o loop $IMGvar $MNThdd/var # Install IPFire without kernel modules -xz -d < $ISODIR/$SNAME-$VERSION.tlz > $TMPDIR/$SNAME-$VERSION.tar +xz -d < $ISODIR/distro.img > $TMPDIR/$SNAME-$VERSION.tar tar -C $MNThdd/ -xvf $TMPDIR/$SNAME-$VERSION.tar \ --exclude=lib/modules* --exclude=boot* --numeric-owner @@ -130,9 +130,9 @@ mkdir $MNThdd/boot/grub echo "timeout 10" > $MNThdd/boot/grub/grub.conf echo "default 0" >> $MNThdd/boot/grub/grub.conf echo "title IPFire ($KERN_TYPE-kernel)" >> $MNThdd/boot/grub/grub.conf -echo " kernel /vmlinuz-$KVER-ipfire-$KERN_TYPE root=/dev/$P3 rootdelay=10 panic=10 console=$CONSOLE ro" \ +echo " kernel /vmlinuz-$KVER-ipfire-$KERN_TYPE root=/dev/$P3 rootdelay=10 panic=10 console=$CONSOLE" \ >> $MNThdd/boot/grub/grub.conf -echo " initrd /ipfirerd-$KVER-$KERN_TYPE.img" >> $MNThdd/boot/grub/grub.conf +echo " initrd /initramfs-$KVER-ipfire-$KERN_TYPE.img" >> $MNThdd/boot/grub/grub.conf echo "# savedefault 0" >> $MNThdd/boot/grub/grub.conf ln -s grub.conf $MNThdd/boot/grub/menu.lst @@ -159,12 +159,13 @@ mount --bind /proc $MNThdd/proc mount --bind /dev $MNThdd/dev mount --bind /sys $MNThdd/sys chroot $MNThdd /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang" -sed -i -e "s|DEVICE1|/dev/$P1|g" $MNThdd/etc/fstab -sed -i -e "s|DEVICE2|/dev/$P2|g" $MNThdd/etc/fstab -sed -i -e "s|DEVICE3|/dev/$P3|g" $MNThdd/etc/fstab -sed -i -e "s|DEVICE4|/dev/$P4|g" $MNThdd/etc/fstab -sed -i -e "s|FSTYPE|$FSTYPE|g" $MNThdd/etc/fstab +# create fstab +echo "/dev/$P1 /boot auto defaults 1 3" > $MNThdd/etc/fstab +echo "/dev/$P2 swap swap defaults 0 0" >> $MNThdd/etc/fstab +echo "/dev/$P3 / auto defaults 1 1" >> $MNThdd/etc/fstab +echo "/dev/$P4 /var auto defaults 1 2" >> $MNThdd/etc/fstab + #Remove root / fstab check rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S19checkfstab diff --git a/src/paks/linux-pae/install.sh b/src/paks/linux-pae/install.sh index 3d59d70c00..c980a0136b 100644 --- a/src/paks/linux-pae/install.sh +++ b/src/paks/linux-pae/install.sh @@ -22,49 +22,29 @@ ############################################################################ # . /opt/pakfire/lib/functions.sh -extract_files -# -KVER=xxxKVERxxx -ROOT=`mount | grep " / " | cut -d" " -f1` -ROOTUUID=`blkid -c /dev/null -sUUID $ROOT | cut -d'"' -f2` -if [ ! -z $ROOTUUID ]; then - ROOT="UUID=$ROOTUUID" -fi -if [ -f /boot/grub/grub.conf ]; then -MOUNT=`grep "kernel" /boot/grub/grub.conf | tail -n 1` -# Nur den letzten Parameter verwenden -echo $MOUNT > /dev/null -MOUNT=$_ -if [ ! $MOUNT == "rw" ]; then - MOUNT="ro" -fi -ENTRY=`grep "savedefault" /boot/grub/grub.conf | tail -n 1` -# Nur den letzten Parameter verwenden -echo $ENTRY > /dev/null -let ENTRY=$_+1 +function find_partition() { + local mountpoint="${1}" -#Check if the system use serial console... -if [ "$(grep "^serial" /boot/grub/grub.conf)" == "" ]; then - console="" -else - console=" console=ttyS0,115200n8" -fi + local root + local dev mp fs flags rest + while read -r dev mp fs flags rest; do + # Skip unwanted entries + [ "${dev}" = "rootfs" ] && continue + if [ "${mp}" = "${mountpoint}" ] && [ -b "${dev}" ]; then + root="$(basename "${dev}")" + break + fi + done < /proc/mounts + echo ${root} + return 0 +} + +extract_files # -# backup grub.conf -# -cp /boot/grub/grub.conf /boot/grub/grub-backup-$KVER-pae_install.conf -# -# Add new Entry to grub.conf -# -echo "" >> /boot/grub/grub.conf -echo "title IPFire (PAE-Kernel)" >> /boot/grub/grub.conf -echo " kernel /vmlinuz-$KVER-ipfire-pae root=$ROOT panic=10$console $MOUNT" >> /boot/grub/grub.conf -echo " initrd /ipfirerd-$KVER-pae.img" >> /boot/grub/grub.conf -echo " savedefault $ENTRY" >> /boot/grub/grub.conf -fi +KVER=xxxKVERxxx # # Create new module depency @@ -75,10 +55,29 @@ depmod -a $KVER-ipfire-pae # /usr/bin/dracut --force --xz /boot/initramfs-$KVER-ipfire-pae.img $KVER-ipfire-pae -# -# Update grub2 config -# -grub-mkconfig > /boot/grub/grub.cfg + +ROOT="$(find_partition "/")" +case $ROOT in + xvd* ) + # + # We are on XEN so create new grub.conf / menu.lst for pygrub + # + echo "timeout 10" > /boot/grub/grub.conf + echo "default 0" >> /boot/grub/grub.conf + echo "title IPFire (pae-kernel)" >> /boot/grub/grub.conf + echo " kernel /vmlinuz-$KVER-ipfire-pae root=/dev/$ROOT rootdelay=10 panic=10 console=hvc0" \ + >> /boot/grub/grub.conf + echo " initrd /initramfs-$KVER-ipfire-pae.img" >> /boot/grub/grub.conf + echo "# savedefault 0" >> /boot/grub/grub.conf + ln -s grub.conf $MNThdd/boot/grub/menu.lst + ;; + * ) + # + # Update grub2 config + # + grub-mkconfig > /boot/grub/grub.cfg + ;; +esac # request a reboot if pae is supported if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then diff --git a/src/paks/linux-pae/uninstall.sh b/src/paks/linux-pae/uninstall.sh index 443328b24d..03a4b61120 100644 --- a/src/paks/linux-pae/uninstall.sh +++ b/src/paks/linux-pae/uninstall.sh @@ -22,13 +22,13 @@ ############################################################################ # . /opt/pakfire/lib/functions.sh +if [ -f /boot/grub/grub.conf ]; then + echo "Error! Connot remove linux-pae because we are on XEN." + exit 1 +fi remove_files rm -rf /boot/initramfs-*-pae.img rm -rf /boot/vmlinuz-*-pae rm -rf /lib/modules/*-ipfire-pae -if [ -f /boot/grub/grub.conf ]; then - cp /boot/grub/grub.conf /boot/grub/grub-backup-pae_uninstall.conf - sed -i "/title IPFire (PAE-Kernel)/,+3d" /boot/grub/grub.conf -fi grub-mkconfig > /boot/grub/grub.cfg sync && sync diff --git a/src/paks/linux-pae/update.sh b/src/paks/linux-pae/update.sh index 00a3c78720..7df354de3c 100644 --- a/src/paks/linux-pae/update.sh +++ b/src/paks/linux-pae/update.sh @@ -22,5 +22,11 @@ ############################################################################ # . /opt/pakfire/lib/functions.sh -./uninstall.sh +remove_files +rm -rf /boot/initramfs-*-pae.img +rm -rf /boot/vmlinuz-*-pae +rm -rf /lib/modules/*-ipfire-pae +if [ ! -f /boot/grub/grub.conf ]; then + grub-mkconfig > /boot/grub/grub.cfg +fi ./install.sh -- 2.39.2