Don't use lsb_release

Using lsb_release to figure out what distro and release an image is
is redundant, as the same information is available in DIB_ vars.
Further, it causes errors when creating new rhel7/centos7 images
like this: http://paste.openstack.org/show/144729/

Change-Id: I213ee581b8abfe119ffe3b783e6a3236e58e3e47
This commit is contained in:
Abel Lopez 2014-12-04 09:35:21 -08:00
parent f1c90ae72a
commit acccfaf181

View File

@ -118,22 +118,21 @@ function install_grub2 {
GRUB_CFG=/boot/grub/grub.cfg GRUB_CFG=/boot/grub/grub.cfg
fi fi
DIST=`lsb_release -is`
[ -n "$DIST" ]
echo 'GRUB_TERMINAL="serial console"' >>/etc/default/grub echo 'GRUB_TERMINAL="serial console"' >>/etc/default/grub
echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub echo 'GRUB_GFXPAYLOAD_LINUX=text' >>/etc/default/grub
echo 'GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200"' >>/etc/default/grub echo 'GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,115200"' >>/etc/default/grub
echo 'GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' >>/etc/default/grub echo 'GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' >>/etc/default/grub
GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG" GRUB_MKCONFIG="grub2-mkconfig -o $GRUB_CFG"
case $DIST in DISTRO_NAME=${DISTRO_NAME:-}
'Ubuntu'|'Debian') case $DISTRO_NAME in
'ubuntu'|'debian')
sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub
GRUB_MKCONFIG=update-grub GRUB_MKCONFIG=update-grub
;; ;;
'Fedora'|'CentOS') 'fedora'|'centos7')
echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub echo 'GRUB_CMDLINE_LINUX="nofb nomodeset vga=normal"' >>/etc/default/grub
;; ;;
'openSUSE project') 'opensuse')
sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub sed -i -e 's/\(^GRUB_CMDLINE_LINUX.*\)"$/\1 nofb nomodeset vga=normal"/' /etc/default/grub
;; ;;
esac esac
@ -155,11 +154,10 @@ function install_grub2 {
sed -i '$d' /etc/default/grub sed -i '$d' /etc/default/grub
fi fi
RELEASE=`lsb_release -cs`
[ -n "$RELEASE" ]
# grub-mkconfig generates a config with the device in it, # grub-mkconfig generates a config with the device in it,
# This shouldn't be needed, but old code has bugs # This shouldn't be needed, but old code has bugs
if [ $RELEASE = 'precise' ] || [ $RELEASE = 'wheezy' ]; then DIB_RELEASE=${DIB_RELEASE:-}
if [ $DIB_RELEASE = 'precise' ] || [ $DIB_RELEASE = 'wheezy' ]; then
sed -i "s%search --no.*%%" $GRUB_CFG sed -i "s%search --no.*%%" $GRUB_CFG
sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG sed -i "s%set root=.*%set root=(hd0,1)%" $GRUB_CFG
fi fi
@ -169,8 +167,8 @@ function install_grub2 {
sed -i "s%$PART_DEV%LABEL=${DIB_ROOT_LABEL}%" $GRUB_CFG sed -i "s%$PART_DEV%LABEL=${DIB_ROOT_LABEL}%" $GRUB_CFG
sed -i "s%search --no-floppy --fs-uuid --set=root .*$%search --no-floppy --set=root --label ${DIB_ROOT_LABEL}%" $GRUB_CFG sed -i "s%search --no-floppy --fs-uuid --set=root .*$%search --no-floppy --set=root --label ${DIB_ROOT_LABEL}%" $GRUB_CFG
sed -i "s%root=UUID=[A-Za-z0-9\-]*%root=LABEL=${DIB_ROOT_LABEL}%" $GRUB_CFG sed -i "s%root=UUID=[A-Za-z0-9\-]*%root=LABEL=${DIB_ROOT_LABEL}%" $GRUB_CFG
if [ "$DIST" = 'Fedora' ] ; then if [ "$DISTRO_NAME" = 'fedora' ] ; then
if [ $(lsb_release -rs) = '19' ]; then if [ $DIB_RELEASE = '19' ]; then
sed -i "s%UUID=[A-Za-z0-9\-]*%LABEL=${DIB_ROOT_LABEL}%" /etc/fstab sed -i "s%UUID=[A-Za-z0-9\-]*%LABEL=${DIB_ROOT_LABEL}%" /etc/fstab
fi fi
# Fix efi specific instructions in grub config file # Fix efi specific instructions in grub config file