mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
xen: fix image build and kernel package for xen.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,49 +22,29 @@
|
||||
############################################################################
|
||||
#
|
||||
. /opt/pakfire/lib/functions.sh
|
||||
|
||||
|
||||
function find_partition() {
|
||||
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
|
||||
echo ${root}
|
||||
return 0
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#Check if the system use serial console...
|
||||
if [ "$(grep "^serial" /boot/grub/grub.conf)" == "" ]; then
|
||||
console=""
|
||||
else
|
||||
console=" console=ttyS0,115200n8"
|
||||
fi
|
||||
|
||||
#
|
||||
# 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
|
||||
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user