Browse code

Dyname bootloder install.

Change-Id: I9cfd20a5591249d3dddd7f15713afa33c5995d4f
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/2156
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
Tested-by: gerrit-photon <photon-checkins@vmware.com>

xiaolin-vmware authored on 2017/03/21 06:09:56
Showing 7 changed files
... ...
@@ -5,5 +5,5 @@
5 5
                   "libffi","expat","linux","cpio","Linux-PAM","attr","libcap", "systemd","dbus",
6 6
                   "gzip", "sqlite-autoconf","nspr","nss","popt","lua","rpm","gptfdisk","tar", "librepo",
7 7
                   "hawkey", "python2","python2-libs","pcre","glib", "tdnf", "python-requests",
8
-                  "grub2","dracut", "curl", "ostree"]
8
+                  "grub2", "grub2-efi", "efibootmgr", "efivar","dracut", "curl", "ostree", "dosfstools"]
9 9
 }
10 10
deleted file mode 100644
11 11
Binary files a/installer/efi/bootx64.efi and /dev/null differ
... ...
@@ -145,6 +145,8 @@ class Installer(object):
145 145
             # Execute post installation modules
146 146
             self.execute_modules(modules.commons.POST_INSTALL)
147 147
 
148
+            if self.iso_installer and os.path.isdir("/sys/firmware/efi"):
149
+                self.install_config['boot'] = 'efi'
148 150
             # install grub
149 151
             try:
150 152
                 if self.install_config['boot'] == 'bios':
... ...
@@ -48,6 +48,8 @@ run_command "# 5" "cp boot/terminal_*.tga ${WORKINGDIR}/boot/grub2/themes/photon
48 48
 run_command "# 6" "cp boot/theme.txt ${WORKINGDIR}/boot/grub2/themes/photon/" "${LOGFILE}"
49 49
 run_command "echo : ${WORKINGDIR}" "echo ${WORKINGDIR}" "${LOGFILE}"
50 50
 cp BUILD_DVD/isolinux/splash.png ${BUILDROOT}/installer/boot/.
51
+mkdir -p ${BUILDROOT}/installer/EFI/BOOT
52
+cp EFI/BOOT/bootx64.efi ${BUILDROOT}/installer/EFI/BOOT/bootx64.efi
51 53
 
52 54
 if [ "$LIVE_CD" = true ] ; then
53 55
     mv ${WORKINGDIR}/isolinux/live-menu.cfg ${WORKINGDIR}/isolinux/menu.cfg
... ...
@@ -15,7 +15,7 @@
15 15
 
16 16
 grub_efi_install()
17 17
 {
18
-    mkdir $BUILDROOT/boot/efi
18
+    mkdir -p $BUILDROOT/boot/efi
19 19
     #
20 20
     # if it is a loop device then we should mount the dev mapped boot partition
21 21
     #
... ...
@@ -23,14 +23,16 @@ grub_efi_install()
23 23
     then
24 24
          BOOT_PARTITION=/dev/mapper/`basename ${HDD}`p1
25 25
     else
26
-         BOOT_PARTITION=${HDD}1
26
+         BOOT_PARTITION=${HDD}2
27 27
     fi
28 28
     mkfs.vfat $BOOT_PARTITION
29 29
     mount -t vfat $BOOT_PARTITION $BUILDROOT/boot/efi
30 30
     cp boot/unifont.pf2 /usr/share/grub/
31 31
     grub2-efi-install --target=x86_64-efi --efi-directory=$BUILDROOT/boot/efi --bootloader-id=Boot --root-directory=$BUILDROOT --recheck
32 32
     rm $BUILDROOT/boot/efi/EFI/Boot/grubx64.efi
33
-    cp efi/bootx64.efi $BUILDROOT/boot/efi/EFI/Boot/bootx64.efi
33
+    cp EFI/BOOT/bootx64.efi $BUILDROOT/boot/efi/EFI/Boot/bootx64.efi
34
+    mkdir -p $BUILDROOT/boot/efi/boot/grub2
35
+    echo "configfile (hd0,gpt1)/boot/grub2/grub.cfg" > $BUILDROOT/boot/efi/boot/grub2/grub.cfg
34 36
     umount $BUILDROOT/boot/efi
35 37
 }
36 38
 
... ...
@@ -71,12 +73,12 @@ mkdir -p $BUILDROOT/boot/grub2
71 71
 ln -sfv grub2 $BUILDROOT/boot/grub
72 72
 command -v grub-install >/dev/null 2>&1 && grubInstallCmd="grub-install" && { echo >&2 "Found grub-install"; }
73 73
 command -v grub2-install >/dev/null 2>&1 && grubInstallCmd="grub2-install" && { echo >&2 "Found grub2-install"; }
74
-if [ -z $grubInstallCmd ]; then
75
-echo "Unable to find grub install command"
76
-exit 1
77
-fi
78 74
 
79
-if [ "$BOOTMODE" == "bios" ]; then 
75
+if [ "$BOOTMODE" == "bios" ]; then
76
+    if [ -z $grubInstallCmd ]; then
77
+        echo "Unable to find grub install command"
78
+        exit 1
79
+    fi
80 80
     grub_mbr_install
81 81
 fi
82 82
 if [ "$BOOTMODE" == "efi" ]; then 
... ...
@@ -76,7 +76,11 @@ def partition_disk(disk, partitions):
76 76
         return None
77 77
 
78 78
     # Add the grub flags
79
-    process = subprocess.Popen(['sgdisk', '-t' + `partitions_count + 1` + ':ef02', disk], stdout = output)
79
+    grub_flag = ':ef02'
80
+    if os.path.isdir("/sys/firmware/efi"):
81
+        grub_flag = ':ef00'
82
+
83
+    process = subprocess.Popen(['sgdisk', '-t' + `partitions_count + 1` + grub_flag, disk], stdout = output)
80 84
     retval = process.wait()
81 85
     if retval != 0:
82 86
         log(LOG_ERROR, "Failed to setup grub partition")
... ...
@@ -39,33 +39,6 @@ def query_yes_no(question, default="no"):
39 39
             sys.stdout.write("Please respond with 'yes' or 'no' "
40 40
                              "(or 'y' or 'n').\n")
41 41
 
42
-def partition_disk(disk):
43
-    partitions_data = {}
44
-    partitions_data['disk'] = disk
45
-    partitions_data['root'] = disk + '2'
46
-    partitions_data['swap'] = disk + '3'
47
-
48
-    # Clear the disk
49
-    process = subprocess.Popen(['sgdisk', '-z', partitions_data['disk']])
50
-    retval = process.wait()
51
-
52
-    # 1: grub, 2: swap, 3: filesystem
53
-    process = subprocess.Popen(['sgdisk', '-n', '1::+2M', '-n', '3:-3G:', '-n', '2:', '-p', partitions_data['disk']])
54
-    retval = process.wait()
55
-
56
-    # Add the grub flags
57
-    process = subprocess.Popen(['sgdisk', '-t1:ef02', partitions_data['disk']])
58
-    retval = process.wait()
59
-
60
-    # format the swap
61
-    process = subprocess.Popen(['mkswap', partitions_data['swap']])
62
-    retval = process.wait()
63
-
64
-    # format the file system
65
-    process = subprocess.Popen(['mkfs', '-t', 'ext4', partitions_data['root']])
66
-    retval = process.wait()
67
-    return partitions_data
68
-
69 42
 def create_vmdk_and_partition(config, vmdk_path):
70 43
     partitions_data = {}
71 44