]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
xen: fix image build and kernel package for xen.
authorArne Fitzenreiter <arne_f@ipfire.org>
Wed, 18 Feb 2015 19:51:15 +0000 (20:51 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Wed, 18 Feb 2015 19:51:15 +0000 (20:51 +0100)
config/rootfiles/core/86/update.sh
config/xen-image/README
config/xen-image/xen-image-maker.sh
src/paks/linux-pae/install.sh
src/paks/linux-pae/uninstall.sh
src/paks/linux-pae/update.sh

index ab72e684e26a6268a5429ca005b2ec3743be47e6..a0bac4d64f96ca57877c015386765ce637904714 100644 (file)
 . /opt/pakfire/lib/functions.sh
 /usr/local/bin/backupctrl exclude >/dev/null 2>&1
 
 . /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
 #
 # Remove old core updates from pakfire cache to save space...
 core=86
@@ -165,23 +196,29 @@ fi
 
 case "$(uname -m)" in
        i?86)
 
 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
 esac
 
 # Force (re)install pae kernel if pae is supported
index a23491fc9ea94b45253069f3e6154dd24656820d..159b036ceb5e50a53c3d4b22fd8eea39c9eade6d 100644 (file)
@@ -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
 - 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.
 - 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"
index 4f632805e130a72379f7e0857ef263bfb04f1911..28f005d5d9c874b34f516b02c3de4fe3c98911c9 100644 (file)
@@ -116,7 +116,7 @@ mount -o loop $IMGboot $MNThdd/boot
 mount -o loop $IMGvar $MNThdd/var
 
 # Install IPFire without kernel modules
 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
 
 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 "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
                                          >> $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
 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"
 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
 
 #Remove root / fstab check
 rm -rf $MNThdd/etc/rc.d/rcsysinit.d/S19checkfstab
index 3d59d70c00c3aacdd4042f7736e8007ef966704a..c980a0136bfd81732965bfda823522846531895d 100644 (file)
 ############################################################################
 #
 . /opt/pakfire/lib/functions.sh
 ############################################################################
 #
 . /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
 
 #
 # 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  
 
 #
 /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
 
 # request a reboot if pae is supported
 if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then
index 443328b24d98a438fb2c834402e53ae19dd71be5..03a4b6112040d4652f1a36b7f67dafb88f91a61c 100644 (file)
 ############################################################################
 #
 . /opt/pakfire/lib/functions.sh
 ############################################################################
 #
 . /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
 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
 grub-mkconfig > /boot/grub/grub.cfg
 sync && sync
index 00a3c78720ba2d5257e4ca6b4435dd797a23baba..7df354de3cf8b0bf8fbfc08ead57e9d1e775c333 100644 (file)
 ############################################################################
 #
 . /opt/pakfire/lib/functions.sh
 ############################################################################
 #
 . /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
 ./install.sh