Change-Id: I2b34857285a1d30383b6e3f58cfe3164c9ae0895
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1691
Reviewed-by: suezzelur <anishs@vmware.com>
Tested-by: suezzelur <anishs@vmware.com>
| ... | ... |
@@ -44,10 +44,6 @@ if [[ $IMG_NAME == ova* ]] |
| 44 | 44 |
then |
| 45 | 45 |
command -v ovftool >/dev/null 2>&1 || { echo "Ovftool not installed. Aborting." >&2; exit 1; }
|
| 46 | 46 |
fi |
| 47 |
-if [[ $IMG_NAME != ova* ]] |
|
| 48 |
- then |
|
| 49 |
- cp ${BUILD_SCRIPTS_PATH}/mk-setup-grub.sh .
|
|
| 50 |
-fi |
|
| 51 | 47 |
|
| 52 | 48 |
if [ -e ${BUILD_SCRIPTS_PATH}/${IMG_NAME}/mk-setup-grub.sh ]
|
| 53 | 49 |
then |
| ... | ... |
@@ -63,7 +63,8 @@ fi |
| 63 | 63 |
# |
| 64 | 64 |
# Install grub2. |
| 65 | 65 |
# |
| 66 |
-UUID=$(blkid -s UUID -o value $ROOT_PARTITION_PATH) |
|
| 66 |
+UUID_VAL=$(blkid -s UUID -o value $ROOT_PARTITION_PATH) |
|
| 67 |
+PARTUUID_VAL=$(blkid -s PARTUUID -o value $ROOT_PARTITION_PATH) |
|
| 67 | 68 |
BOOT_UUID=$(blkid -s UUID -o value $BOOT_PARTITION_PATH) |
| 68 | 69 |
echo "Changing boot loader to MBR type on raw disk" |
| 69 | 70 |
|
| ... | ... |
@@ -93,7 +94,7 @@ if [ "$BOOTMODE" == "efi" ]; then |
| 93 | 93 |
grub_efi_install |
| 94 | 94 |
fi |
| 95 | 95 |
|
| 96 |
-cat > "$BUILDROOT"/boot/grub2/grub.cfg << "EOF" |
|
| 96 |
+cat > ${BUILDROOT}/boot/grub2/grub.cfg <<EOF
|
|
| 97 | 97 |
# Begin /boot/grub2/grub.cfg |
| 98 | 98 |
# |
| 99 | 99 |
# DO NOT EDIT THIS FILE |
| ... | ... |
@@ -103,12 +104,12 @@ cat > "$BUILDROOT"/boot/grub2/grub.cfg << "EOF" |
| 103 | 103 |
# |
| 104 | 104 |
|
| 105 | 105 |
### BEGIN /etc/grub.d/00_header ### |
| 106 |
-if [ -s $prefix/grubenv ]; then |
|
| 106 |
+if [ -s \$prefix/grubenv ]; then |
|
| 107 | 107 |
load_env |
| 108 | 108 |
fi |
| 109 | 109 |
set default="0" |
| 110 | 110 |
|
| 111 |
-if [ x"${feature_menuentry_id}" = xy ]; then
|
|
| 111 |
+if [ x"\${feature_menuentry_id}" = xy ]; then
|
|
| 112 | 112 |
menuentry_id_option="--id" |
| 113 | 113 |
else |
| 114 | 114 |
menuentry_id_option="" |
| ... | ... |
@@ -116,9 +117,10 @@ fi |
| 116 | 116 |
|
| 117 | 117 |
export menuentry_id_option |
| 118 | 118 |
load_env -f "$BOOT_DIRECTORY"photon.cfg |
| 119 |
+set rootpartition=PARTUUID=$PARTUUID_VAL |
|
| 119 | 120 |
|
| 120 |
-if [ "${prev_saved_entry}" ]; then
|
|
| 121 |
- set saved_entry="${prev_saved_entry}"
|
|
| 121 |
+if [ "\${prev_saved_entry}" ]; then
|
|
| 122 |
+ set saved_entry="\${prev_saved_entry}"
|
|
| 122 | 123 |
save_env saved_entry |
| 123 | 124 |
set prev_saved_entry= |
| 124 | 125 |
save_env prev_saved_entry |
| ... | ... |
@@ -126,14 +128,14 @@ if [ "${prev_saved_entry}" ]; then
|
| 126 | 126 |
fi |
| 127 | 127 |
|
| 128 | 128 |
function savedefault {
|
| 129 |
- if [ -z "${boot_once}" ]; then
|
|
| 130 |
- saved_entry="${chosen}"
|
|
| 129 |
+ if [ -z "\${boot_once}" ]; then
|
|
| 130 |
+ saved_entry="\${chosen}"
|
|
| 131 | 131 |
save_env saved_entry |
| 132 | 132 |
fi |
| 133 | 133 |
} |
| 134 | 134 |
|
| 135 | 135 |
function load_video {
|
| 136 |
- if [ x$feature_all_video_module = xy ]; then |
|
| 136 |
+ if [ x\$feature_all_video_module = xy ]; then |
|
| 137 | 137 |
insmod all_video |
| 138 | 138 |
else |
| 139 | 139 |
insmod efi_gop |
| ... | ... |
@@ -153,51 +155,51 @@ set timeout=5 |
| 153 | 153 |
### END /etc/grub.d/00_header ### |
| 154 | 154 |
|
| 155 | 155 |
### BEGIN /etc/grub.d/10_linux ### |
| 156 |
-menuentry 'GNU/Linux' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-UUID_PLACEHOLDER' {
|
|
| 156 |
+menuentry 'GNU/Linux' --class gnu-linux --class gnu --class os \$menuentry_id_option 'gnulinux-simple-UUID_PLACEHOLDER' {
|
|
| 157 | 157 |
load_video |
| 158 | 158 |
set gfxpayload=keep |
| 159 | 159 |
insmod gzio |
| 160 | 160 |
insmod part_msdos |
| 161 | 161 |
insmod ext2 |
| 162 | 162 |
set root='hd0,msdos2' |
| 163 |
- if [ x$feature_platform_search_hint = xy ]; then |
|
| 163 |
+ if [ x\$feature_platform_search_hint = xy ]; then |
|
| 164 | 164 |
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 UUID_PLACEHOLDER |
| 165 | 165 |
else |
| 166 | 166 |
search --no-floppy --fs-uuid --set=root UUID_PLACEHOLDER |
| 167 | 167 |
fi |
| 168 |
- echo 'Loading Linux $photon_linux ...' |
|
| 169 |
- linux "$BOOT_DIRECTORY"\$photon_linux root=UUID_PLACEHOLDER ro console=ttyS0,38400n8 |
|
| 168 |
+ echo 'Loading Linux \$photon_linux ...' |
|
| 169 |
+ linux "$BOOT_DIRECTORY"\$photon_linux root=/dev/sda2 ro console=ttyS0,38400n8 |
|
| 170 | 170 |
} |
| 171 |
-submenu 'Advanced options for GNU/Linux' $menuentry_id_option 'gnulinux-advanced-UUID_PLACEHOLDER' {
|
|
| 172 |
- menuentry 'GNU/Linux, with Linux $photon_linux' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-$photon_linux-advanced-UUID_PLACEHOLDER' {
|
|
| 171 |
+submenu 'Advanced options for GNU/Linux' \$menuentry_id_option 'gnulinux-advanced-UUID_PLACEHOLDER' {
|
|
| 172 |
+ menuentry 'GNU/Linux, with Linux \$photon_linux' --class gnu-linux --class gnu --class os \$menuentry_id_option 'gnulinux-\$photon_linux-advanced-UUID_PLACEHOLDER' {
|
|
| 173 | 173 |
load_video |
| 174 | 174 |
set gfxpayload=keep |
| 175 | 175 |
insmod gzio |
| 176 | 176 |
insmod part_msdos |
| 177 | 177 |
insmod ext2 |
| 178 | 178 |
set root='hd0,msdos2' |
| 179 |
- if [ x$feature_platform_search_hint = xy ]; then |
|
| 179 |
+ if [ x\$feature_platform_search_hint = xy ]; then |
|
| 180 | 180 |
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 UUID_PLACEHOLDER |
| 181 | 181 |
else |
| 182 | 182 |
search --no-floppy --fs-uuid --set=root UUID_PLACEHOLDER |
| 183 | 183 |
fi |
| 184 |
- echo 'Loading Linux $photon_linux ...' |
|
| 185 |
- linux "$BOOT_DIRECTORY"\$photon_linux root=UUID_PLACEHOLDER ro console=ttyS0,38400n8 |
|
| 184 |
+ echo 'Loading Linux \$photon_linux ...' |
|
| 185 |
+ linux "$BOOT_DIRECTORY"\$photon_linux root=/dev/sda2 ro console=ttyS0,38400n8 |
|
| 186 | 186 |
} |
| 187 |
- menuentry 'GNU/Linux, with Linux $photon_linux (recovery mode)' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-$photon_linux-recovery-UUID_PLACEHOLDER' {
|
|
| 187 |
+ menuentry 'GNU/Linux, with Linux \$photon_linux (recovery mode)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'gnulinux-\$photon_linux-recovery-UUID_PLACEHOLDER' {
|
|
| 188 | 188 |
load_video |
| 189 | 189 |
set gfxpayload=keep |
| 190 | 190 |
insmod gzio |
| 191 | 191 |
insmod part_msdos |
| 192 | 192 |
insmod ext2 |
| 193 | 193 |
set root='hd0,msdos2' |
| 194 |
- if [ x$feature_platform_search_hint = xy ]; then |
|
| 194 |
+ if [ x\$feature_platform_search_hint = xy ]; then |
|
| 195 | 195 |
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 UUID_PLACEHOLDER |
| 196 | 196 |
else |
| 197 | 197 |
search --no-floppy --fs-uuid --set=root UUID_PLACEHOLDER |
| 198 | 198 |
fi |
| 199 |
- echo 'Loading Linux $photon_linux ...' |
|
| 200 |
- linux "$BOOT_DIRECTORY"\$photon_linux root=/UUID_PLACEHOLDER ro single console=ttyS0,38400n8 |
|
| 199 |
+ echo 'Loading Linux \$photon_linux ...' |
|
| 200 |
+ linux "$BOOT_DIRECTORY"\$photon_linux root=/dev/sda2 ro single console=ttyS0,38400n8 |
|
| 201 | 201 |
} |
| 202 | 202 |
} |
| 203 | 203 |
|
| ... | ... |
@@ -217,17 +219,17 @@ submenu 'Advanced options for GNU/Linux' $menuentry_id_option 'gnulinux-advanced |
| 217 | 217 |
### END /etc/grub.d/40_custom ### |
| 218 | 218 |
|
| 219 | 219 |
### BEGIN /etc/grub.d/41_custom ### |
| 220 |
-if [ -f ${config_directory}/custom.cfg ]; then
|
|
| 221 |
- source ${config_directory}/custom.cfg
|
|
| 222 |
-elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
|
|
| 223 |
- source $prefix/custom.cfg; |
|
| 220 |
+if [ -f \${config_directory}/custom.cfg ]; then
|
|
| 221 |
+ source \${config_directory}/custom.cfg
|
|
| 222 |
+elif [ -z "\${config_directory}" -a -f \$prefix/custom.cfg ]; then
|
|
| 223 |
+ source \$prefix/custom.cfg; |
|
| 224 | 224 |
fi |
| 225 | 225 |
### END /etc/grub.d/41_custom ### |
| 226 | 226 |
|
| 227 | 227 |
# End /boot/grub2/grub.cfg |
| 228 | 228 |
EOF |
| 229 | 229 |
|
| 230 |
-sed -i "s/UUID_PLACEHOLDER/$UUID/" "$BUILDROOT"/boot/grub2/grub.cfg > ${LOGFILE}
|
|
| 230 |
+sed -i "s/UUID_PLACEHOLDER/$UUID_VAL/" "$BUILDROOT"/boot/grub2/grub.cfg > ${LOGFILE}
|
|
| 231 | 231 |
|
| 232 | 232 |
#Cleanup the workspace directory |
| 233 | 233 |
#find "$BUILDROOT"/{,usr/}{lib,bin,sbin} -type f -exec strip --strip-debug --strip-unneeded '{}' ';' > /dev/null 2>&1
|