Browse code

installer: remove shell scripts

..except mk-setup-grub.sh.

Extras:
- use PARTUUID/UUID in fstab. It is most flexible and will
allow imagebuilder to use fstab creator from installer
instead its own implementation.
- Renamed /boot/esp ESP mountpoint to /boot/efi.
- Updated installer/README.txt to reflect previous lvm change.
- Fixed UI config for skipping inactive screens.

Change-Id: I5df3044a42b8deb748c87278dee137081ed60079
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/8231
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Alexey Makhalov authored on 2019/10/11 08:05:12
Showing 20 changed files
... ...
@@ -5,7 +5,7 @@ This repository contains signed binaries: bootx64.efi and bootaa64.efi
5 5
 # # mv shimx64.efi bootx64.efi
6 6
 
7 7
 # grubx64.efi is generated on Photon OS by using grub2-efi-2.02-12:
8
-# # grub2-mkimage -o grubx64.efi -p /boot/grub2 -O x86_64-efi  fat iso9660 part_gpt part_msdos  normal boot linux configfile loopback chain  efifwsetup efi_gop efi_uga  ls search search_label search_fs_uuid search_fs_file  gfxterm gfxterm_background gfxterm_menu test all_video loadenv  exfat ext2 udf halt gfxmenu png tga lsefi help probe echo
8
+# # grub2-mkimage -o grubx64.efi -p /boot/grub2 -O x86_64-efi fat iso9660 part_gpt part_msdos normal boot linux configfile loopback chain efifwsetup efi_gop efi_uga ls search search_label search_fs_uuid search_fs_file gfxterm gfxterm_background gfxterm_menu test all_video loadenv exfat ext2 udf halt gfxmenu png tga lsefi help probe echo lvm
9 9
 
10 10
 # grubaa64.efi is generated on Photon OS (aarch64) by using grub2-efi >= 2.02-11:
11 11
 # cat > /tmp/grub-embed-config.cfg << EOF
... ...
@@ -11,7 +11,8 @@ class CommandUtils(object):
11 11
 
12 12
     def run(self, cmd):
13 13
         self.logger.debug(cmd)
14
-        process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
14
+        use_shell = not isinstance(cmd, list)
15
+        process = subprocess.Popen(cmd, shell=use_shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
15 16
         out,err = process.communicate()
16 17
         retval = process.returncode
17 18
         if out != b'':
... ...
@@ -22,6 +23,17 @@ class CommandUtils(object):
22 22
             self.logger.error(err.decode())
23 23
         return retval
24 24
 
25
+    def run_in_chroot(self, chroot_path, cmd):
26
+        # Use short command here. Initial version was:
27
+        # chroot "${BUILDROOT}" \
28
+        #   /usr/bin/env -i \
29
+        #   HOME=/root \
30
+        #   TERM="$TERM" \
31
+        #   PS1='\u:\w\$ ' \
32
+        #   PATH=/bin:/usr/bin:/sbin:/usr/sbin \
33
+        #   /usr/bin/bash --login +h -c "cd installer;$*"
34
+        return self.run(['chroot', chroot_path, '/bin/bash', '-c', cmd])
35
+
25 36
     @staticmethod
26 37
     def is_vmware_virtualization():
27 38
         """Detect vmware vm"""
... ...
@@ -13,6 +13,7 @@ import glob
13 13
 import modules.commons
14 14
 import random
15 15
 import curses
16
+import stat
16 17
 from logger import Logger
17 18
 from commandutils import CommandUtils
18 19
 from jsonwrapper import JsonWrapper
... ...
@@ -38,12 +39,14 @@ class Installer(object):
38 38
     known_keys = {
39 39
         'additional_packages',
40 40
         'additional_rpms_path',
41
+        'arch',
41 42
         'autopartition',
42 43
         'bootmode',
43 44
         'disk',
44 45
         'eject_cdrom',
45 46
         'hostname',
46 47
         'install_linux_esx',
48
+        'live',
47 49
         'log_level',
48 50
         'ostree',
49 51
         'packages',
... ...
@@ -59,11 +62,6 @@ class Installer(object):
59 59
         'ui'
60 60
     }
61 61
 
62
-    mount_command = os.path.dirname(__file__)+"/mk-mount-disk.sh"
63
-    prepare_command = os.path.dirname(__file__)+"/mk-prepare-system.sh"
64
-    finalize_command = "./mk-finalize-system.sh"
65
-    chroot_command = os.path.dirname(__file__)+"/mk-run-chroot.sh"
66
-    unmount_disk_command = os.path.dirname(__file__)+"/mk-unmount-disk.sh"
67 62
     default_partitions = [{"mountpoint": "/", "size": 0, "filesystem": "ext4"}]
68 63
 
69 64
     def __init__(self, working_directory="/mnt/photon-root",
... ...
@@ -158,14 +156,23 @@ class Installer(object):
158 158
         else:
159 159
             install_config['packages'] = packages
160 160
 
161
+        # set arch to host's one if not defined
162
+        arch = subprocess.check_output(['uname', '-m'], universal_newlines=True).rstrip('\n')
163
+        if 'arch' not in install_config:
164
+            install_config['arch'] = arch
165
+
161 166
         # 'bootmode' mode
162 167
         if 'bootmode' not in install_config:
163
-            arch = subprocess.check_output(['uname', '-m'], universal_newlines=True)
164 168
             if "x86_64" in arch:
165 169
                 install_config['bootmode'] = 'dualboot'
166 170
             else:
167 171
                 install_config['bootmode'] = 'efi'
168 172
 
173
+        # live means online system. When you create an image for
174
+        # target system, live should be set to false.
175
+        if 'live' not in install_config:
176
+            install_config['live'] = 'loop' not in install_config['disk']
177
+
169 178
         # default partition
170 179
         if 'partitions' not in install_config:
171 180
             install_config['partitions'] = Installer.default_partitions
... ...
@@ -232,6 +239,13 @@ class Installer(object):
232 232
         if not has_root:
233 233
             return "There is no partition assigned to root '/'"
234 234
 
235
+        if install_config['arch'] not in ["aarch64", 'x86_64']:
236
+            return "Unsupported target architecture {}".format(install_config['arch'])
237
+
238
+        # No BIOS for aarch64
239
+        if install_config['arch'] == 'aarch64' and install_config['bootmode'] in ['dualboot', 'bios']:
240
+            return "Aarch64 targets do not support BIOS boot. Set 'bootmode' to 'efi'."
241
+
235 242
         return None
236 243
 
237 244
     def _install(self, stdscreen=None):
... ...
@@ -295,6 +309,7 @@ class Installer(object):
295 295
         else:
296 296
             self._setup_install_repo()
297 297
             self._initialize_system()
298
+            self._mount_special_folders()
298 299
             self._install_packages()
299 300
             self._install_additional_rpms()
300 301
             self._enable_network_in_chroot()
... ...
@@ -304,7 +319,7 @@ class Installer(object):
304 304
             self._create_fstab()
305 305
         self._execute_modules(modules.commons.POST_INSTALL)
306 306
         self._disable_network_in_chroot()
307
-        self._unmount_partitions()
307
+        self._unmount_all()
308 308
 
309 309
     def exit_gracefully(self, signal1=None, frame1=None):
310 310
         """
... ...
@@ -313,7 +328,7 @@ class Installer(object):
313 313
         """
314 314
         del signal1
315 315
         del frame1
316
-        if not self.exiting:
316
+        if not self.exiting and self.install_config:
317 317
             self.exiting = True
318 318
             if self.install_config['ui']:
319 319
                 self.progress_bar.hide()
... ...
@@ -322,18 +337,26 @@ class Installer(object):
322 322
                 self.window.content_window().getch()
323 323
 
324 324
             self._cleanup_install_repo()
325
-            self._unmount_partitions()
325
+            self._unmount_all()
326 326
         sys.exit(1)
327 327
 
328
-    def _unmount_partitions(self):
328
+    def _unmount_all(self):
329 329
         """
330
-        Unmount partitions
330
+        Unmount partitions and special folders
331 331
         """
332
-        command = [Installer.unmount_disk_command, '-w', self.photon_root]
333
-        command.extend(self._generate_partitions_param(reverse=True))
334
-        retval = self.cmd.run(command)
335
-        if retval != 0:
336
-            self.logger.error("Failed to unmount disks")
332
+        for d in ["/run", "/sys", "/dev/pts", "/dev", "/proc"]:
333
+            retval = self.cmd.run(['umount', '-l', self.photon_root + d])
334
+            if retval != 0:
335
+                self.logger.error("Failed to unmount {}".format(d))
336
+
337
+        for partition in self.install_config['partitions'][::-1]:
338
+            if self._get_partition_type(partition) in [PartitionType.BIOS, PartitionType.SWAP]:
339
+                continue
340
+            mountpoint = self.photon_root + partition["mountpoint"]
341
+            retval = self.cmd.run(['umount', '-l', mountpoint])
342
+            if retval != 0:
343
+                self.logger.error("Failed to unmount partition {}".format(mountpoint))
344
+
337 345
         # need to call it twice, because of internal bind mounts
338 346
         if 'ostree' in self.install_config:
339 347
             retval = self.cmd.run(['umount', '-R', self.photon_root])
... ...
@@ -341,6 +364,7 @@ class Installer(object):
341 341
             if retval != 0:
342 342
                 self.logger.error("Failed to unmount disks in photon root")
343 343
 
344
+        self.cmd.run(['sync'])
344 345
         shutil.rmtree(self.photon_root)
345 346
 
346 347
         # Deactivate LVM VGs
... ...
@@ -411,6 +435,21 @@ class Installer(object):
411 411
                 self.cmd.run(['rm', '-rf', self.rpm_cache_dir]) != 0):
412 412
             self.logger.error("Fail to unbind cache rpms")
413 413
 
414
+    def _get_partuuid(self, path):
415
+        partuuid = subprocess.check_output(['blkid', '-s', 'PARTUUID', '-o', 'value', path],
416
+                                       universal_newlines=True).rstrip('\n')
417
+        # Backup way to get uuid/partuuid. Leave it here for later use.
418
+        #if partuuidval == '':
419
+        #    sgdiskout = Utils.runshellcommand(
420
+        #        "sgdisk -i 2 {} ".format(disk_device))
421
+        #    partuuidval = (re.findall(r'Partition unique GUID.*',
422
+        #                          sgdiskout))[0].split(':')[1].strip(' ').lower()
423
+        return partuuid
424
+
425
+    def _get_uuid(self, path):
426
+        return subprocess.check_output(['blkid', '-s', 'UUID', '-o', 'value', path],
427
+                                       universal_newlines=True).rstrip('\n')
428
+
414 429
     def _create_fstab(self, fstab_path = None):
415 430
         """
416 431
         update fstab
... ...
@@ -440,8 +479,23 @@ class Installer(object):
440 440
                 else:
441 441
                     mountpoint = partition['mountpoint']
442 442
 
443
+                # Use PARTUUID/UUID instead of bare path.
444
+                # Prefer PARTUUID over UUID as it is supported by kernel
445
+                # and UUID only by initrd.
446
+                path = partition['path']
447
+                mnt_src = None
448
+                partuuid = self._get_partuuid(path)
449
+                if partuuid != '':
450
+                    mnt_src = "PARTUUID={}".format(partuuid)
451
+                else:
452
+                    uuid = self._get_uuid(path)
453
+                    if uuid != '':
454
+                        mnt_src = "UUID={}".format(uuid)
455
+                if not mnt_src:
456
+                    raise RuntimeError("Cannot get PARTUUID/UUID of: {}".format(path))
457
+
443 458
                 fstab_file.write("{}\t{}\t{}\t{}\t{}\t{}\n".format(
444
-                    partition['path'],
459
+                    mnt_src,
445 460
                     mountpoint,
446 461
                     partition['filesystem'],
447 462
                     options,
... ...
@@ -468,13 +522,15 @@ class Installer(object):
468 468
         return params
469 469
 
470 470
     def _mount_partitions(self):
471
-        command = [Installer.mount_command, '-w', self.photon_root]
472
-        command.extend(self._generate_partitions_param())
473
-        retval = self.cmd.run(command)
474
-        if retval != 0:
475
-            self.logger.info("Failed to mount partitions for installation")
476
-            self.exit_gracefully()
477
-
471
+        for partition in self.install_config['partitions'][::1]:
472
+            if self._get_partition_type(partition) in [PartitionType.BIOS, PartitionType.SWAP]:
473
+                continue
474
+            mountpoint = self.photon_root + partition["mountpoint"]
475
+            self.cmd.run(['mkdir', '-p', mountpoint])
476
+            retval = self.cmd.run(['mount', '-v', partition["path"], mountpoint])
477
+            if retval != 0:
478
+                self.logger.error("Failed to mount partition {}".format(partition["path"]))
479
+                self.exit_gracefully()
478 480
 
479 481
     def _initialize_system(self):
480 482
         """
... ...
@@ -484,10 +540,48 @@ class Installer(object):
484 484
             self.progress_bar.update_message('Initializing system...')
485 485
         self._bind_installer()
486 486
         self._bind_repo_dir()
487
-        retval = self.cmd.run([Installer.prepare_command, '-w', self.photon_root,
488
-                               self.working_directory, self.rpm_cache_dir])
487
+
488
+        # Initialize rpm DB
489
+        self.cmd.run(['mkdir', '-p', os.path.join(self.photon_root, "var/lib/rpm")])
490
+        retval = self.cmd.run(['rpm', '--root', self.photon_root, '--initdb',
491
+                               '--dbpath', '/var/lib/rpm'])
492
+        if retval != 0:
493
+            self.logger.error("Failed to initialize rpm DB")
494
+            self.exit_gracefully()
495
+
496
+        # Install filesystem rpm
497
+        tdnf_cmd = "tdnf install filesystem --installroot {0} --assumeyes -c {1}".format(self.photon_root,
498
+                        self.tdnf_conf_path)
499
+        retval = self.cmd.run(tdnf_cmd)
500
+        if retval != 0:
501
+            retval = self.cmd.run(['docker', 'run',
502
+                                   '-v', self.rpm_cache_dir+':'+self.rpm_cache_dir,
503
+                                   '-v', self.working_directory+':'+self.working_directory,
504
+                                   'photon:3.0', '/bin/sh', '-c', tdnf_cmd])
505
+            if retval != 0:
506
+                self.logger.error("Failed to install filesystem rpm")
507
+                self.exit_gracefully()
508
+
509
+        # Create special devices (TODO: really need it?)
510
+        devices = {
511
+            'console': (600, stat.S_IFCHR, 5, 1),
512
+            'null': (666, stat.S_IFCHR, 1, 3),
513
+            'random': (444, stat.S_IFCHR, 1, 8),
514
+            'urandom': (444, stat.S_IFCHR, 1, 9)
515
+        }
516
+        for device, (mode, dev_type, major, minor) in devices.items():
517
+            os.mknod(os.path.join(self.photon_root, "dev", device),
518
+                    mode | dev_type, os.makedev(major, minor))
519
+
520
+    def _mount_special_folders(self):
521
+        for d in ["/proc", "/dev", "/dev/pts", "/sys"]:
522
+            retval = self.cmd.run(['mount', '-o', 'bind', d, self.photon_root + d])
523
+            if retval != 0:
524
+                self.logger.error("Failed to bind mount {}".format(d))
525
+                self.exit_gracefully()
526
+        retval = self.cmd.run(['mount', '-t', 'tmpfs', 'tmpfs', self.photon_root + "/run"])
489 527
         if retval != 0:
490
-            self.logger.info("Failed to bind the installer and repo needed by tdnf")
528
+            self.logger.error("Failed to bind mount {}".format(d))
491 529
             self.exit_gracefully()
492 530
 
493 531
     def _finalize_system(self):
... ...
@@ -497,10 +591,17 @@ class Installer(object):
497 497
         if self.install_config['ui']:
498 498
             self.progress_bar.show_loading('Finalizing installation')
499 499
 
500
-        retval = self.cmd.run([Installer.chroot_command, '-w', self.photon_root,
501
-                                    Installer.finalize_command, '-w', self.photon_root])
502
-        if retval != 0:
503
-            self.logger.error("Fail to setup the target system after the installation")
500
+        self.cmd.run_in_chroot(self.photon_root, "/sbin/ldconfig")
501
+        self.cmd.run_in_chroot(self.photon_root, "/bin/systemd-machine-id-setup")
502
+        # Importing the pubkey
503
+        self.cmd.run_in_chroot(self.photon_root, "rpm --import /etc/pki/rpm-gpg/*")
504
+        # Set locale
505
+        with open(os.path.join(self.photon_root, "etc/locale.conf"), "w") as locale_conf:
506
+            locale_conf.write("LANG=en_US.UTF-8\n")
507
+        #locale-gen.sh needs /usr/share/locale/locale.alias which is shipped with
508
+        #  glibc-lang rpm, in some photon installations glibc-lang rpm is not installed
509
+        #  by default. Call localedef directly here to define locale environment.
510
+        self.cmd.run_in_chroot(self.photon_root, "/usr/bin/localedef -c -i en_US -f UTF-8 en_US.UTF-8")
504 511
 
505 512
     def _cleanup_install_repo(self):
506 513
         self._unbind_installer()
... ...
@@ -513,10 +614,59 @@ class Installer(object):
513 513
         os.remove(self.tdnf_repo_path)
514 514
 
515 515
     def _setup_grub(self):
516
+        bootmode = self.install_config['bootmode']
517
+
518
+        self.cmd.run(['mkdir', '-p', self.photon_root + '/boot/grub2'])
519
+        self.cmd.run(['ln', '-sfv', 'grub2', self.photon_root + '/boot/grub'])
520
+
521
+        # Setup bios grub
522
+        if bootmode == 'dualboot' or bootmode == 'bios':
523
+            retval = self.cmd.run(['grub2-install', '--target=i386-pc', '--force',
524
+                                   '--boot-directory={}'.format(self.photon_root + "/boot"),
525
+                                   self.install_config['disk']])
526
+            if retval != 0:
527
+                retval = self.cmd.run(['grub-install', '--target=i386-pc', '--force',
528
+                                   '--boot-directory={}'.format(self.photon_root + "/boot"),
529
+                                   self.install_config['disk']])
530
+                if retval != 0:
531
+                    raise Exception("Unable to setup grub")
532
+
533
+        # Setup efi grub
534
+        if bootmode == 'dualboot' or bootmode == 'efi':
535
+            esp_pn = '1'
536
+            if bootmode == 'dualboot':
537
+                esp_pn = '2'
538
+
539
+            self.cmd.run(['mkdir', '-p', self.photon_root + '/boot/efi/EFI/BOOT'])
540
+            if self.install_config['arch'] == 'aarch64':
541
+                shutil.copy(self.installer_path + '/EFI_aarch64/BOOT/bootaa64.efi', self.photon_root + '/boot/efi/EFI/BOOT')
542
+                exe_name='bootaa64.efi'
543
+            if self.install_config['arch'] == 'x86_64':
544
+                shutil.copy(self.installer_path + '/EFI_x86_64/BOOT/bootx64.efi', self.photon_root + '/boot/efi/EFI/BOOT')
545
+                shutil.copy(self.installer_path + '/EFI_x86_64/BOOT/grubx64.efi', self.photon_root + '/boot/efi/EFI/BOOT')
546
+                exe_name='bootx64.efi'
547
+
548
+            self.cmd.run(['mkdir', '-p', self.photon_root + '/boot/efi/boot/grub2'])
549
+            with open(os.path.join(self.photon_root, 'boot/efi/boot/grub2/grub.cfg'), "w") as grub_cfg:
550
+                grub_cfg.write("search -n -u {} -s\n".format(self._get_uuid(self.install_config['partitions_data']['boot'])))
551
+                grub_cfg.write("configfile {}grub2/grub.cfg\n".format(self.install_config['partitions_data']['bootdirectory']))
552
+
553
+            if self.install_config['live']:
554
+                # Some platforms do not support adding boot entry. Thus, ignore failures
555
+                self.cmd.run(['efibootmgr', '--create', '--remove-dups', '--disk', self.install_config['disk'],
556
+                              '--part', esp_pn, '--loader', '/EFI/BOOT/' + exe_name, '--label', 'Photon'])
557
+
558
+        # Copy grub theme files
559
+        shutil.copy(self.installer_path + '/boot/ascii.pf2', self.photon_root + '/boot/grub2')
560
+        self.cmd.run(['mkdir', '-p', self.photon_root + '/boot/grub2/themes/photon'])
561
+        shutil.copy(self.installer_path + '/boot/splash.png', self.photon_root + '/boot/grub2/themes/photon/photon.png')
562
+        shutil.copy(self.installer_path + '/boot/theme.txt', self.photon_root + '/boot/grub2/themes/photon')
563
+        for f in glob.glob(os.path.abspath(self.installer_path) + '/boot/terminal_*.tga'):
564
+            shutil.copy(f, self.photon_root + '/boot/grub2/themes/photon')
565
+
566
+        # Create custom grub.cfg
516 567
         retval = self.cmd.run(
517
-            [self.setup_grub_command, '-w', self.photon_root,
518
-             self.install_config.get('bootmode', 'bios'),
519
-             self.install_config['disk'],
568
+            [self.setup_grub_command, self.photon_root,
520 569
              self.install_config['partitions_data']['root'],
521 570
              self.install_config['partitions_data']['boot'],
522 571
              self.install_config['partitions_data']['bootdirectory']])
... ...
@@ -726,7 +876,7 @@ class Installer(object):
726 726
             return PartitionType.BIOS
727 727
         if partition['filesystem'] == 'swap':
728 728
             return PartitionType.SWAP
729
-        if partition.get('mountpoint', '') == '/boot/esp' and partition['filesystem'] == 'vfat':
729
+        if partition.get('mountpoint', '') == '/boot/efi' and partition['filesystem'] == 'vfat':
730 730
             return PartitionType.ESP
731 731
         if partition.get('lvm', None):
732 732
             return PartitionType.LVM
... ...
@@ -875,7 +1025,7 @@ class Installer(object):
875 875
 
876 876
         # Insert efi special partition
877 877
         if not esp_found and (bootmode == 'dualboot' or bootmode == 'efi'):
878
-            efi_partition = { 'size': 8, 'filesystem': 'vfat', 'mountpoint': '/boot/esp' }
878
+            efi_partition = { 'size': 8, 'filesystem': 'vfat', 'mountpoint': '/boot/efi' }
879 879
             self.install_config['partitions'].insert(0, efi_partition)
880 880
 
881 881
         # Insert bios partition last to be very first
... ...
@@ -145,13 +145,21 @@ class IsoConfig(object):
145 145
 
146 146
         items = self.add_ui_pages(install_config, ui_config, maxy, maxx)
147 147
         index = 0
148
+        # Used to continue direction if some screen was skipped
149
+        go_next=True
150
+
151
+        # UI screens showing
148 152
         while True:
149
-            result = items[index][0]()
150
-            if result.success:
153
+            ar = items[index][0]()
154
+            # Skip inactive window and continue previos direction.
155
+            if ar.result and ar.result.get('inactive_screen', False):
156
+                ar.success = go_next
157
+            go_next = ar.success
158
+            if ar.success:
151 159
                 index += 1
152 160
                 if index == len(items):
153 161
                     # confirm window
154
-                    if result.result['yes']:
162
+                    if ar.result['yes']:
155 163
                         break
156 164
                     else:
157 165
                         exit(0)
... ...
@@ -6,6 +6,14 @@ Kickstart config file is a json format with following possible parameters:
6 6
 	Provide a path containing additional RPMS that are to be bundled into
7 7
 	the image.
8 8
 
9
+"arch" (optional)
10
+	Target system architecture. Should be set if target architecture is
11
+	different from host one, for instance x86_64 machine building RPi
12
+	image.
13
+	Acceptible values are: "x86_64", "aarch64"
14
+	Defatult value: autodetected host architecture
15
+	Example: { "arch": "aarch64" }
16
+
9 17
 "bootmode" (optional)
10 18
 	Sets the boot type to suppot: EFI, BIOS or both.
11 19
 	Acceptible values are: "bios", "efi", "dualboot"
... ...
@@ -105,7 +113,7 @@ Kickstart config file is a json format with following possible parameters:
105 105
 				 }
106 106
 			},
107 107
 			{
108
-				"mountpoint": "/boot/esp",
108
+				"mountpoint": "/boot/efi",
109 109
 				"size": 12,
110 110
 				"filesystem": "vfat",
111 111
 				"fs_options": "-n EFI"
... ...
@@ -38,7 +38,7 @@ class LinuxSelector(object):
38 38
 
39 39
     def display(self):
40 40
         if 'ostree' in self.install_config:
41
-            return ActionResult(True, None)
41
+            return ActionResult(None, {"inactive_screen": True})
42 42
 
43 43
         self.window.addstr(0, 0, 'The installer has detected that you are installing')
44 44
         self.window.addstr(1, 0, 'Photon OS on a VMware hypervisor.')
45 45
deleted file mode 100755
... ...
@@ -1,38 +0,0 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-finalize-system              #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  mbassiouny@vmware.com           #
7
-#     Options:                                  #
8
-#################################################
9
-#   Overview
10
-#       Finalize the system after the installation
11
-#   End
12
-#
13
-set -o errexit      # exit if error...insurance ;
14
-set -o nounset      # exit if variable not initalized
15
-set +h          # disable hashall
16
-set -x
17
-SCRIPT_PATH=$(dirname $(realpath -s $0))
18
-source $SCRIPT_PATH/config.inc
19
-PRGNAME=${0##*/}    # script name minus the path
20
-[ ${EUID} -eq 0 ]   || fail "${PRGNAME}: Need to be root user: FAILURE"
21
-
22
-/sbin/ldconfig
23
-/usr/sbin/pwconv
24
-/usr/sbin/grpconv
25
-/bin/systemd-machine-id-setup
26
-/usr/bin/touch /etc/locale.conf
27
-/bin/echo "LANG=en_US.UTF-8" > /etc/locale.conf
28
-
29
-# Importing the pubkey
30
-rpm --import /etc/pki/rpm-gpg/*
31
-
32
-#locale-gen.sh needs /usr/share/locale/locale.alias which is shipped with
33
-#  glibc-lang rpm, in some photon installations glibc-lang rpm is not installed
34
-#  by default. Call localedef directly here to define locale environment.
35
-/usr/bin/localedef -c -i en_US -f UTF-8 en_US.UTF-8
36
-#/sbin/locale-gen.sh
37
-
38
-exit 0
39 1
deleted file mode 100755
... ...
@@ -1,46 +0,0 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-mount-disk                   #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  mbassiouny@vmware.com           #
7
-#     Options:                                  #
8
-#################################################
9
-#	Overview
10
-#		This mount a partition passed in arguments or a in the config.inc in root photon mount directory
11
-#	End
12
-#
13
-set -o errexit		# exit if error...insurance ;
14
-set -o nounset		# exit if variable not initalized
15
-set +h			# disable hashall
16
-set -x
17
-PRGNAME=${0##*/}	# script name minus the path
18
-SCRIPT_PATH=$(dirname $(realpath -s $0))
19
-source $SCRIPT_PATH/config.inc		#	configuration parameters
20
-source $SCRIPT_PATH/function.inc
21
-LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"	#	set log file name
22
-#LOGFILE=/dev/null		#	uncomment to disable log file
23
-[ ${EUID} -eq 0 ]	|| fail "${PRGNAME}: Need to be root user: FAILURE"
24
-> ${LOGFILE}		#	clear/initialize logfile
25
-
26
-while [[ $# > 0 ]]
27
-do
28
-    key="$1"
29
-    shift
30
- 
31
-    case $key in
32
-        -p|--partitionmountpoint)
33
-        PARTITION="$1"
34
-        MOUNTPOINT="$2"
35
-        shift 2
36
-
37
-        # make sure the directory exists
38
-        run_command "Making Directory" "mkdir -p ${BUILDROOT}${MOUNTPOINT}" "${LOGFILE}"
39
-        run_command "Mounting Partition" "mount -v ${PARTITION} ${BUILDROOT}${MOUNTPOINT}" "${LOGFILE}"
40
-    ;;
41
-    *)
42
-        # unknown option
43
-    ;;
44
-    esac
45
-done
46
-
47 1
deleted file mode 100755
... ...
@@ -1,59 +0,0 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-prepare-system               #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  mbassiouny@vmware.com           #
7
-#     Options:                                  #
8
-#################################################
9
-#   Overview
10
-#       Preparing the system to install photon
11
-#   End
12
-#
13
-set -o errexit      # exit if error...insurance ;
14
-set -o nounset      # exit if variable not initalized
15
-set +h          # disable hashall
16
-set -x
17
-SCRIPT_PATH=$(dirname $(realpath -s $0))
18
-source $SCRIPT_PATH/config.inc
19
-source $SCRIPT_PATH/function.inc
20
-PRGNAME=${0##*/}    # script name minus the path
21
-
22
-LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"    #   set log file name
23
-#LOGFILE=/dev/null      #   uncomment to disable log file
24
-
25
-[ ${EUID} -eq 0 ]   || fail "${PRGNAME}: Need to be root user: FAILURE"
26
-[ -z ${BUILDROOT} ] && fail "${PRGNAME}: Build root not set: FAILURE"
27
-
28
-WORKINGDIR=$1
29
-RPMS_PATH=$2
30
-
31
-if mountpoint ${BUILDROOT}/run  >/dev/null 2>&1; then umount ${BUILDROOT}/run; fi
32
-if mountpoint ${BUILDROOT}/sys  >/dev/null 2>&1; then umount ${BUILDROOT}/sys; fi
33
-if mountpoint ${BUILDROOT}/proc >/dev/null 2>&1; then umount ${BUILDROOT}/proc; fi
34
-if mountpoint ${BUILDROOT}/dev/pts  >/dev/null 2>&1; then umount ${BUILDROOT}/dev/pts; fi
35
-if mountpoint ${BUILDROOT}/dev  >/dev/null 2>&1; then umount ${BUILDROOT}/dev; fi
36
-
37
-mkdir -p ${BUILDROOT}/var/lib/rpm
38
-mkdir -p ${BUILDROOT}/cache/tdnf
39
-rpm --root ${BUILDROOT} --initdb --dbpath /var/lib/rpm
40
-# tdnf conf is created in working directory which is parent of buildroot
41
-tdnf install filesystem --installroot ${BUILDROOT} --assumeyes -c ${WORKINGDIR}/tdnf.conf || \
42
-    docker run -v $RPMS_PATH:$RPMS_PATH -v $WORKINGDIR:$WORKINGDIR photon:3.0 \
43
-	tdnf install filesystem --installroot ${BUILDROOT} --assumeyes -c ${WORKINGDIR}/tdnf.conf
44
- 
45
-#   Ommited in the filesystem.spec file - not needed for booting
46
-[ -e ${BUILDROOT}/dev/console ] || mknod -m 600 ${BUILDROOT}/dev/console c 5 1
47
-[ -e ${BUILDROOT}/dev/null ]    || mknod -m 666 ${BUILDROOT}/dev/null c 1 3
48
-[ -e ${BUILDROOT}/dev/random ]  || mknod -m 444 ${BUILDROOT}/dev/random c 1 8
49
-[ -e ${BUILDROOT}/dev/urandom ] || mknod -m 444 ${BUILDROOT}/dev/urandom c 1 9
50
-
51
-#   Mount kernel filesystem
52
-#
53
-if ! mountpoint ${BUILDROOT}/dev    >/dev/null 2>&1; then mount --bind /dev ${BUILDROOT}/dev; fi
54
-if ! mountpoint ${BUILDROOT}/dev/pts    >/dev/null 2>&1; then mount -t devpts devpts ${BUILDROOT}/dev/pts -o gid=5,mode=620; fi
55
-if ! mountpoint ${BUILDROOT}/proc   >/dev/null 2>&1; then mount -t proc proc ${BUILDROOT}/proc; fi
56
-if ! mountpoint ${BUILDROOT}/sys    >/dev/null 2>&1; then mount -t sysfs sysfs ${BUILDROOT}/sys; fi
57
-if ! mountpoint ${BUILDROOT}/run    >/dev/null 2>&1; then mount -t tmpfs tmpfs ${BUILDROOT}/run; fi
58
-if [ -h ${BUILDROOT}/dev/shm ];          then mkdir -pv ${BUILDROOT}/$(readlink ${BUILDROOT}/dev/shm); fi
59
-exit 0
60 1
deleted file mode 100755
... ...
@@ -1,37 +0,0 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-run-chroot                   #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  mbassiouny@vmware.com           #
7
-#     Options:                                  #
8
-#################################################
9
-#   Overview
10
-#       Run the passed command into the chroot
11
-#   End
12
-#
13
-set -o errexit      # exit if error...insurance ;
14
-set -o nounset      # exit if variable not initalized
15
-set +h          # disable hashall
16
-set -x
17
-SCRIPT_PATH=$(dirname $(realpath -s $0))
18
-source $SCRIPT_PATH/config.inc
19
-PRGNAME=${0##*/}    # script name minus the path
20
-[ ${EUID} -eq 0 ]   || fail "${PRGNAME}: Need to be root user: FAILURE"
21
-[ -z ${BUILDROOT} ] && fail "${PRGNAME}: Build root not set: FAILURE"
22
-
23
-# Remove the name of this script from our argument list
24
-#shift
25
-
26
-#
27
-#   Goto chroot and run the command specified as parameter.
28
-#
29
-chroot "${BUILDROOT}" \
30
-    /usr/bin/env -i \
31
-    HOME=/root \
32
-    TERM="$TERM" \
33
-    PS1='\u:\w\$ ' \
34
-    PATH=/bin:/usr/bin:/sbin:/usr/sbin \
35
-    /usr/bin/bash --login +h -c "cd installer;$*"
36
-
37
-exit 0
... ...
@@ -1,81 +1,15 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-setup-grub                   #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  sharathg@vmware.com             #
7
-#     Options:                                  #
8
-#################################################
9
-#    Overview
10
-#        This is a precursor for the vmware build system.
11
-#        This assumes that an empty hard disk is attached to the build VM.
12
-#        The path to this empty disk is specified in the HDD variable in config.inc
13
-#    End
14
-#
15
-
16
-grub_efi_install()
17
-{
18
-    mkdir -p $BUILDROOT/boot/efi
19
-    #
20
-    # if it is a loop device then we should mount the dev mapped boot partition
21
-    #
22
-    if [[ $HDD == *"loop"* ]]
23
-    then
24
-         BOOT_PARTITION=/dev/mapper/`basename ${HDD}`p$EFI_PARTITION_NUMBER
25
-    elif [[ $HDD == *"nvme"* || $HDD == *"mmcblk"* ]]
26
-    then
27
-         BOOT_PARTITION=${HDD}p$EFI_PARTITION_NUMBER
28
-    else
29
-         BOOT_PARTITION=${HDD}$EFI_PARTITION_NUMBER
30
-    fi
31
-    mount -t vfat $BOOT_PARTITION $BUILDROOT/boot/efi
32
-    cp $INSTALLER_PATH/boot/unifont.pf2 /usr/share/grub/
33
-    mkdir -p $BUILDROOT/boot/efi/EFI/Boot/
34
-    if [ $(uname -m) == "aarch64" ]
35
-    then
36
-        cp $INSTALLER_PATH/EFI_aarch64/BOOT/* $BUILDROOT/boot/efi/EFI/Boot/
37
-        local EXE_NAME="bootaa64.efi"
38
-    elif [ $(uname -m) == "x86_64" ]
39
-    then
40
-        cp $INSTALLER_PATH/EFI_x86_64/BOOT/* $BUILDROOT/boot/efi/EFI/Boot/
41
-        local EXE_NAME="bootx64.efi"
42
-    fi
43
-
44
-    mkdir -p $BUILDROOT/boot/efi/boot/grub2
45
-    cat > $BUILDROOT/boot/efi/boot/grub2/grub.cfg << EOF
46
-search -n -u ${BOOT_UUID} -s
47
-configfile ${BOOT_DIRECTORY}grub2/grub.cfg
48
-EOF
49
-    # Some platforms do not support adding boot entry. Thus, ignore failures.
50
-    efibootmgr --create --remove-dups --disk "$HDD" --part $EFI_PARTITION_NUMBER --loader "/EFI/Boot/$EXE_NAME" --label Photon --verbose >&2 || :
51
-    umount $BUILDROOT/boot/efi
52
-}
53
-
54
-grub_mbr_install()
55
-{
56
-    $grubInstallCmd --target=i386-pc --force --boot-directory=$BUILDROOT/boot "$HDD"
57
-}
1
+#! /bin/bash
58 2
 
59 3
 set -o errexit        # exit if error...insurance ;)
60 4
 set -o nounset        # exit if variable not initalized
61 5
 set +h            # disable hashall
62 6
 set -x
63
-PRGNAME=${0##*/}    # script name minus the path
64 7
 SCRIPT_PATH=$(dirname $(realpath -s $0))
65
-INSTALLER_PATH=$SCRIPT_PATH
66
-source $SCRIPT_PATH/config.inc        #    configuration parameters
67
-source $SCRIPT_PATH/function.inc        #    commonn functions
68
-LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"    #    set log file name
69
-ARCH=$(uname -m)    # host architecture
70
-[ ${EUID} -eq 0 ]    || fail "${PRGNAME}: Need to be root user: FAILURE"
71
-> ${LOGFILE}        #    clear/initialize logfile
72 8
 
73
-BOOTMODE=$1
74
-HDD=$2
75
-ROOT_PARTITION_PATH=$3
76
-BOOT_PARTITION_PATH=$4
77
-BOOT_DIRECTORY=$5
78
-EFI_PARTITION_NUMBER="1"
9
+BUILDROOT=$1
10
+ROOT_PARTITION_PATH=$2
11
+BOOT_PARTITION_PATH=$3
12
+BOOT_DIRECTORY=$4
79 13
 
80 14
 #
81 15
 #    Install grub2.
... ...
@@ -83,41 +17,10 @@ EFI_PARTITION_NUMBER="1"
83 83
 PARTUUID=$(blkid -s PARTUUID -o value $ROOT_PARTITION_PATH)
84 84
 BOOT_UUID=$(blkid -s UUID -o value $BOOT_PARTITION_PATH)
85 85
 
86
-grubInstallCmd=""
87
-mkdir -p $BUILDROOT/boot/grub2
88
-ln -sfv grub2 $BUILDROOT/boot/grub
89
-command -v grub-install >/dev/null 2>&1 && grubInstallCmd="grub-install" && { echo >&2 "Found grub-install"; }
90
-command -v grub2-install >/dev/null 2>&1 && grubInstallCmd="grub2-install" && { echo >&2 "Found grub2-install"; }
91
-
92
-if [ "$BOOTMODE" == "bios" ]; then
93
-    if [ -z $grubInstallCmd ]; then
94
-        echo "Unable to find grub install command"
95
-        exit 1
96
-    fi
97
-    grub_mbr_install
98
-elif [ "$BOOTMODE" == "efi" ]; then
99
-    grub_efi_install
100
-elif [ "$BOOTMODE" == "dualboot" ]; then
101
-    EFI_PARTITION_NUMBER="2"
102
-    if [ -z $grubInstallCmd ]; then
103
-        echo "Unable to find grub install command"
104
-        exit 1
105
-    fi
106
-    grub_mbr_install
107
-
108
-    grub_efi_install
109
-fi
110
-
111
-rm -rf ${BUILDROOT}/boot/grub2/fonts
112
-cp $INSTALLER_PATH/boot/ascii.pf2 ${BUILDROOT}/boot/grub2/
113
-mkdir -p ${BUILDROOT}/boot/grub2/themes/photon
114
-cp $INSTALLER_PATH/boot/splash.png ${BUILDROOT}/boot/grub2/themes/photon/photon.png
115
-cp $INSTALLER_PATH/boot/terminal_*.tga ${BUILDROOT}/boot/grub2/themes/photon/
116
-cp $INSTALLER_PATH/boot/theme.txt ${BUILDROOT}/boot/grub2/themes/photon/
117 86
 # linux-esx tries to mount rootfs even before nvme got initialized.
118 87
 # rootwait fixes this issue
119 88
 EXTRA_PARAMS=""
120
-if [[ $HDD == *"nvme"* ]]; then
89
+if [[ $ROOT_PARTITION_PATH == *"nvme"* ]]; then
121 90
     EXTRA_PARAMS=rootwait
122 91
 fi
123 92
 
124 93
deleted file mode 100755
... ...
@@ -1,51 +0,0 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-unmount-disk                 #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  mbassiouny@vmware.com           #
7
-#     Options:                                  #
8
-#################################################
9
-#   Overview
10
-#       This unmount the mounted directories after installing photon
11
-#   End
12
-#
13
-set -o errexit      # exit if error...insurance ;
14
-set -o nounset      # exit if variable not initalized
15
-set +h          # disable hashall
16
-set -x
17
-SCRIPT_PATH=$(dirname $(realpath -s $0))
18
-source $SCRIPT_PATH/config.inc
19
-PRGNAME=${0##*/}    # script name minus the path
20
-LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"    #   set log file name
21
-#LOGFILE=/dev/null      #   uncomment to disable log file
22
-[ ${EUID} -eq 0 ]   || fail "${PRGNAME}: Need to be root user: FAILURE"
23
-[ -z ${BUILDROOT} ]     && fail "${PRGNAME}: BUILDROOT not set: FAILURE"
24
-
25
-if mountpoint ${BUILDROOT}/run >/dev/null 2>&1; then umount -l ${BUILDROOT}/run; fi
26
-if mountpoint ${BUILDROOT}/sys >/dev/null 2>&1; then umount -l ${BUILDROOT}/sys; fi
27
-if mountpoint ${BUILDROOT}/proc    >/dev/null 2>&1; then umount -l ${BUILDROOT}/proc; fi
28
-if mountpoint ${BUILDROOT}/dev/pts >/dev/null 2>&1; then umount ${BUILDROOT}/dev/pts; fi
29
-if mountpoint ${BUILDROOT}/dev >/dev/null 2>&1; then umount ${BUILDROOT}/dev; fi
30
-sync
31
-while [[ $# > 0 ]]
32
-do
33
-    key="$1"
34
-    shift
35
- 
36
-    case $key in
37
-        -p|--partitionmountpoint)
38
-        PARTITION="$1"
39
-        MOUNTPOINT="$2"
40
-        shift 2
41
-
42
-        # make sure the directory exists
43
-        if mountpoint ${BUILDROOT}${MOUNTPOINT} >/dev/null 2>&1; then umount -l ${BUILDROOT}${MOUNTPOINT}; fi
44
-        sync
45
-    ;;
46
-    *)
47
-        # unknown option
48
-    ;;
49
-    esac
50
-done
51
-exit 0
... ...
@@ -19,5 +19,5 @@ def execute(installer):
19 19
         outfile.write("\n".join(script).encode())
20 20
 
21 21
     os.chmod(script_file, 0o700)
22
-    return installer.cmd.run(["./mk-run-chroot.sh", '-w', installer.photon_root,
23
-                              "/etc/tmpfiles.d/postinstall.sh"]) == 0
22
+    return installer.cmd.run_in_chroot(installer.photon_root,
23
+                                       "/etc/tmpfiles.d/postinstall.sh") == 0
... ...
@@ -24,3 +24,6 @@ def execute(installer):
24 24
         #add password hash in shadow file
25 25
         commons.replace_string_in_file(shadow_filename, "root::", "root:"+shadow_password+":")
26 26
         commons.replace_string_in_file(shadow_filename, "root:x:", "root:"+shadow_password+":")
27
+
28
+    installer.cmd.run_in_chroot(installer.photon_root, "/usr/sbin/pwconv")
29
+    installer.cmd.run_in_chroot(installer.photon_root, "/usr/sbin/grpconv")
... ...
@@ -1,98 +1,27 @@
1 1
 #!/bin/bash
2
-#################################################
3
-#       Title:  mk-setup-grub                   #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  sharathg@vmware.com             #
7
-#     Options:                                  #
8
-#################################################
9
-#   Overview
10
-#       This is a precursor for the vmware build system.
11
-#       This assumes that an empty hard disk is attached to the build VM.
12
-#       The path to this empty disk is specified in the HDD variable in config.inc
13
-#   End
14
-#
15
-grub_efi_install()
16
-{
17
-    mkdir $BUILDROOT/boot/efi
18
-    #
19
-    # if it is a loop device then we should mount the dev mapped boot partition
20
-    #
21
-    if [[ $HDD == *"loop"* ]]
22
-    then
23
-         BOOT_PARTITION=/dev/mapper/`basename ${HDD}`p1
24
-    else
25
-         BOOT_PARTITION=${HDD}1
26
-    fi
27
-    mount -t vfat $BOOT_PARTITION $BUILDROOT/boot/efi
28
-    cp $INSTALLER_PATH/boot/unifont.pf2 /usr/share/grub/
29
-    grub2-efi-install --target=x86_64-efi --efi-directory=$BUILDROOT/boot/efi --bootloader-id=Boot --root-directory=$BUILDROOT --recheck
30
-    rm $BUILDROOT/boot/efi/EFI/Boot/grubx64.efi
31
-    cp $INSTALLER_PATH/EFI_x86_64/BOOT/* $BUILDROOT/boot/efi/EFI/Boot/
32
-    mkdir -p $BUILDROOT/boot/efi/boot/grub2    
33
-    cat > $BUILDROOT/boot/efi/boot/grub2/grub.cfg << EOF
34
-search -n -u ${BOOT_UUID} -s
35
-configfile ${BOOT_DIRECTORY}grub2/grub.cfg
36
-EOF
37
-    umount $BUILDROOT/boot/efi
38
-}
39
-
40
-grub_mbr_install()
41
-{
42
-    $grubInstallCmd --force --boot-directory=$BUILDROOT/boot "$HDD"
43
-}
44 2
 
45 3
 set -o errexit      # exit if error...insurance ;)
46 4
 set -o nounset      # exit if variable not initalized
47 5
 set +h          # disable hashall
48
-PRGNAME=${0##*/}    # script name minus the path
6
+set -x
49 7
 SCRIPT_PATH=$(dirname $(realpath -s $0))
50 8
 INSTALLER_PATH=$SCRIPT_PATH/../../../installer
51
-source $INSTALLER_PATH/config.inc       #   configuration parameters
52
-source $INSTALLER_PATH/function.inc     #   commonn functions
53
-LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"    #   set log file name
54
-#LOGFILE=/dev/null      #   uncomment to disable log file
55
-ARCH=$(uname -m)    # host architecture
56
-[ ${EUID} -eq 0 ]   || fail "${PRGNAME}: Need to be root user: FAILURE"
57
-> ${LOGFILE}        #   clear/initialize logfile
58
-
59
-BOOTMODE=$1
60
-HDD=$2
61
-ROOT_PARTITION_PATH=$3
62
-BOOT_PARTITION_PATH=$4
63
-BOOT_DIRECTORY=$5
9
+
10
+BUILDROOT=$1
11
+ROOT_PARTITION_PATH=$2
12
+BOOT_PARTITION_PATH=$3
13
+BOOT_DIRECTORY=$4
64 14
 
65 15
 #
66 16
 #	Install grub2.
67 17
 #
68 18
 UUID_VAL=$(blkid -s UUID -o value $ROOT_PARTITION_PATH)
69 19
 PARTUUID=$(blkid -s PARTUUID -o value $ROOT_PARTITION_PATH)
70
-BOOT_UUID=$(blkid -s UUID -o value $BOOT_PARTITION_PATH)
71
-echo "Changing boot loader to MBR type on raw disk"
72
-
73
-sgdisk -m 1:2 "$HDD"
74
-
75
-grubInstallCmd=""
76
-mkdir -p $BUILDROOT/boot/grub2
77
-ln -sfv grub2 $BUILDROOT/boot/grub
78
-command -v grub-install >/dev/null 2>&1 && grubInstallCmd="grub-install" && { echo >&2 "Found grub-install"; }
79
-command -v grub2-install >/dev/null 2>&1 && grubInstallCmd="grub2-install" && { echo >&2 "Found grub2-install"; }
80
-if [ -z $grubInstallCmd ]; then
81
-echo "Unable to find grub install command"
82
-exit 1
83
-fi
84
-rm -rf ${BUILDROOT}/boot/grub2/fonts
85
-mkdir -p ${BUILDROOT}/boot/grub2/themes/photon
86
-cp $INSTALLER_PATH/boot/splash.png ${BUILDROOT}/boot/grub2/themes/photon/photon.png
87
-cp $INSTALLER_PATH/boot/terminal_*.tga ${BUILDROOT}/boot/grub2/themes/photon/
88
-cp $INSTALLER_PATH/boot/theme.txt ${BUILDROOT}/boot/grub2/themes/photon/
89
-
90
-if [ "$BOOTMODE" == "bios" ]; then 
91
-    grub_mbr_install
92
-fi
93
-if [ "$BOOTMODE" == "efi" ]; then 
94
-    grub_efi_install
95
-fi
20
+
21
+# TODO: check is installer._setup_grub() is enough
22
+# grub2-efi-install --target=x86_64-efi --efi-directory=$BUILDROOT/boot/efi --bootloader-id=Boot --root-directory=$BUILDROOT --recheck
23
+# rm $BUILDROOT/boot/efi/EFI/Boot/grubx64.efi
24
+# cp $INSTALLER_PATH/EFI_x86_64/BOOT/* $BUILDROOT/boot/efi/EFI/Boot/
96 25
 
97 26
 cat > ${BUILDROOT}/boot/grub2/grub.cfg <<EOF
98 27
 # Begin /boot/grub2/grub.cfg
... ...
@@ -233,4 +162,4 @@ fi
233 233
 # End /boot/grub2/grub.cfg
234 234
 EOF
235 235
 
236
-sed -i "s/UUID_PLACEHOLDER/$UUID_VAL/" "$BUILDROOT"/boot/grub2/grub.cfg > ${LOGFILE} 
236
+sed -i "s/UUID_PLACEHOLDER/$UUID_VAL/" "$BUILDROOT"/boot/grub2/grub.cfg
... ...
@@ -28,34 +28,6 @@ def cleanupMountPoints(mount_path):
28 28
     Utils.runshellcommand("sync")
29 29
     Utils.runshellcommand("umount -l {}".format(mount_path))
30 30
 
31
-def writefstabandgrub(mount_path, uuidval, partuuidval):
32
-    os.remove(mount_path + "/etc/fstab")
33
-    f = open(mount_path + "/etc/fstab", "w")
34
-    if uuidval != '':
35
-        f.write("UUID={}    /    ext4    defaults 1 1\n".format(uuidval))
36
-    else:
37
-        f.write("PARTUUID={}    /    ext4    defaults 1 1\n".format(partuuidval))
38
-    f.close()
39
-    Utils.replaceinfile(mount_path + "/boot/grub/grub.cfg",
40
-                        "rootpartition=PARTUUID=.*$",
41
-                        "rootpartition=PARTUUID={}".format(partuuidval))
42
-
43
-def generateUuid(loop_device_path):
44
-    partuuidval = (Utils.runshellcommand(
45
-        "blkid -s PARTUUID -o value {}".format(loop_device_path))).rstrip('\n')
46
-    uuidval = (Utils.runshellcommand(
47
-        "blkid -s UUID -o value {}".format(loop_device_path))).rstrip('\n')
48
-    if partuuidval == '':
49
-        sgdiskout = Utils.runshellcommand(
50
-            "sgdisk -i 2 {} ".format(disk_device))
51
-        partuuidval = (re.findall(r'Partition unique GUID.*',
52
-                                  sgdiskout))[0].split(':')[1].strip(' ').lower()
53
-
54
-    if partuuidval == '':
55
-        raise RuntimeError("Cannot generate partuuid")
56
-
57
-    return (uuidval, partuuidval)
58
-
59 31
 def customizeImage(config, mount_path):
60 32
     build_scripts_path = os.path.dirname(os.path.abspath(__file__))
61 33
     image_name = config['image_type']
... ...
@@ -183,13 +155,10 @@ def generateImage(raw_image_path, tools_bin_path, src_root, config):
183 183
     print(loop_device_path)
184 184
 
185 185
     try:
186
-        (uuidval, partuuidval) = generateUuid(loop_device_path)
187 186
         # Prep the loop device
188 187
         prepLoopDevice(loop_device_path, mount_path)
189 188
         # Clear machine-id so it gets regenerated on boot
190 189
         open(mount_path + "/etc/machine-id", "w").close()
191
-        # Write fstab
192
-        writefstabandgrub(mount_path, uuidval, partuuidval)
193 190
         # Perform additional steps defined in installer config
194 191
         customizeImage(config, mount_path)
195 192
     except Exception as e:
... ...
@@ -1,11 +1,12 @@
1 1
 {
2 2
     "installer": {
3
-        "bootmode":"efi",
3
+	"arch": "aarch64",
4
+        "bootmode": "efi",
4 5
         "hostname": "photon-machine",
5 6
         "packagelist_file": "packages_ls1012afrwy.json",
6 7
         "partition_type": "msdos",
7 8
         "partitions": [
8
-            {"mountpoint": "/boot/esp", "size": 12, "filesystem": "vfat", "fs_options": "-n EFI"},
9
+            {"mountpoint": "/boot/efi", "size": 12, "filesystem": "vfat", "fs_options": "-n EFI"},
9 10
             {"mountpoint": "/", "size": 0, "filesystem": "ext4", "fs_options": "-F -O ^huge_file -b 4096 -L rootfs"}
10 11
         ]
11 12
     },
... ...
@@ -1,59 +1,20 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-setup-grub                   #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  sharathg@vmware.com             #
7
-#     Options:                                  #
8
-#################################################
9
-#    Overview
10
-#        This is a precursor for the vmware build system.
11
-#        This assumes that an empty hard disk is attached to the build VM.
12
-#        The path to this empty disk is specified in the HDD variable in config.inc
13
-#    End
14
-#
15
-
16
-grub_efi_install()
17
-{
18
-	cp -r $SCRIPT_PATH/esp/ls1012afrwy_boot.scr $BUILDROOT/boot/esp/
19
-	cp -r $SCRIPT_PATH/esp/ls1046afrwy_boot.scr $BUILDROOT/boot/esp/
20
-	mkdir -p $BUILDROOT/boot/esp/EFI/BOOT/
21
-        cp $INSTALLER_PATH/EFI_aarch64/BOOT/bootaa64.efi $BUILDROOT/boot/esp/EFI/BOOT/
22
-}
23
-
1
+#! /bin/bash
24 2
 
25 3
 set -o errexit        # exit if error...insurance ;)
26 4
 set -o nounset        # exit if variable not initalized
27 5
 set +h            # disable hashall
28
-PRGNAME=${0##*/}    # script name minus the path
29 6
 SCRIPT_PATH=$(dirname $(realpath -s $0))
30
-INSTALLER_PATH=$SCRIPT_PATH/../../../installer
31
-source ${INSTALLER_PATH}/config.inc             #       configuration parameters
32
-source ${INSTALLER_PATH}/function.inc #    commonn functions
33
-LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"    #    set log file name
34
-ARCH=$(uname -m)    # host architecture
35
-[ ${EUID} -eq 0 ]    || fail "${PRGNAME}: Need to be root user: FAILURE"
36
-> ${LOGFILE}        #    clear/initialize logfile
37 7
 
38
-BOOTMODE=$1
39
-HDD=$2
40
-ROOT_PARTITION_PATH=$3
41
-BOOT_PARTITION_PATH=$4
42
-BOOT_DIRECTORY=$5
43
-
44
-#
45
-#    Install grub2.
46
-#
47
-BOOT_UUID=$(blkid -s UUID -o value $ROOT_PARTITION_PATH)
8
+BUILDROOT=$1
9
+ROOT_PARTITION_PATH=$2
10
+BOOT_PARTITION_PATH=$3
11
+BOOT_DIRECTORY=$4
48 12
 
49 13
 echo "$ROOT_PARTITION_PATH"
50 14
 echo "$BUILDROOT"
51 15
 
52
-mkdir -p $BUILDROOT/boot/grub2/
53
-ln -sfv grub2 $BUILDROOT/boot/grub
54
-
55
-grub_efi_install
56
-
16
+cp -r $SCRIPT_PATH/esp/ls1012afrwy_boot.scr $BUILDROOT/boot/efi/
17
+cp -r $SCRIPT_PATH/esp/ls1046afrwy_boot.scr $BUILDROOT/boot/efi/
57 18
 
58 19
 EXTRA_PARAMS="rootwait rw console=ttyS0,115200n8 console=tty0 rootfs=/dev/mmcblk0p2"
59 20
 
... ...
@@ -87,14 +48,3 @@ menuentry "Photon" {
87 87
 # End /boot/grub2/grub.cfg
88 88
 EOF
89 89
 
90
-
91
-
92
-#mkdir $BUILDROOT/boot/grub
93
-#cp -rfa $BUILDROOT/boot/grub2/* $BUILDROOT/boot/grub/
94
-
95
-#grub_efi_install
96
-
97
-#Cleanup the workspace directory
98
-rm -rf "$BUILDROOT"/tools
99
-rm -rf "$BUILDROOT"/RPMS
100
-
... ...
@@ -1,11 +1,12 @@
1 1
 {
2 2
     "installer": {
3
-        "bootmode":"efi",
3
+	"arch": "aarch64",
4
+        "bootmode": "efi",
4 5
         "hostname": "photon-machine",
5 6
         "packagelist_file": "packages_rpi3.json",
6 7
         "partition_type": "msdos",
7 8
         "partitions": [
8
-            {"mountpoint": "/boot/esp", "size": 30, "filesystem": "vfat"},
9
+            {"mountpoint": "/boot/efi", "size": 30, "filesystem": "vfat"},
9 10
             {"mountpoint": "/", "size": 0, "filesystem": "ext4"}
10 11
         ]
11 12
     },
... ...
@@ -1,71 +1,17 @@
1
-#!/bin/bash
2
-#################################################
3
-#       Title:  mk-setup-grub                   #
4
-#        Date:  2014-11-26                      #
5
-#     Version:  1.0                             #
6
-#      Author:  sharathg@vmware.com             #
7
-#     Options:                                  #
8
-#################################################
9
-#    Overview
10
-#        This is a precursor for the vmware build system.
11
-#        This assumes that an empty hard disk is attached to the build VM.
12
-#        The path to this empty disk is specified in the HDD variable in config.inc
13
-#    End
14
-#
15
-
16
-grub_efi_install()
17
-{
18
-    BOOT_PARTITION=/dev/mapper/`basename ${HDD}`p1
19
-#    mount -t vfat $BOOT_PARTITION $BUILDROOT/boot/esp
20
-    # Raspberry prorpiaetary GPU bootloader (1st stage)
21
-    cp -r $SCRIPT_PATH/esp/* $BUILDROOT/boot/esp/
22
-    # u-boot (2nd stage) was copied earlier by installer.py
23
-    # grub efi bootloader (3rd stage)
24
-    mkdir -p $BUILDROOT/boot/esp/EFI/BOOT/
25
-    cp $INSTALLER_PATH/EFI_aarch64/BOOT/* $BUILDROOT/boot/esp/EFI/BOOT/
26
-    mkdir -p $BUILDROOT/boot/esp/boot/grub2
27
-    cat > $BUILDROOT/boot/esp/boot/grub2/grub.cfg << EOF
28
-search -n -u ${BOOT_UUID} -s
29
-configfile ${BOOT_DIRECTORY}grub2/grub.cfg
30
-EOF
31
-#    umount $BUILDROOT/boot/esp
32
-}
1
+#! /bin/bash
33 2
 
34 3
 set -o errexit        # exit if error...insurance ;)
35 4
 set -o nounset        # exit if variable not initalized
36 5
 set +h            # disable hashall
37
-PRGNAME=${0##*/}    # script name minus the path
38 6
 SCRIPT_PATH=$(dirname $(realpath -s $0))
39
-INSTALLER_PATH=$SCRIPT_PATH/../../../installer
40
-source $INSTALLER_PATH/config.inc        #    configuration parameters
41
-source $INSTALLER_PATH/function.inc        #    common functions
42
-LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}"    #    set log file name
43
-ARCH=$(uname -m)    # host architecture
44
-[ ${EUID} -eq 0 ]    || fail "${PRGNAME}: Need to be root user: FAILURE"
45
-> ${LOGFILE}        #    clear/initialize logfile
46
-
47
-BOOTMODE=$1
48
-HDD=$2
49
-ROOT_PARTITION_PATH=$3
50
-BOOT_PARTITION_PATH=$4
51
-BOOT_DIRECTORY=$5
52
-
53
-#
54
-#    Install grub2.
55
-#
56
-BOOT_UUID=$(blkid -s UUID -o value $BOOT_PARTITION_PATH)
57
-
58
-mkdir -p $BUILDROOT/boot/grub2
59
-ln -sfv grub2 $BUILDROOT/boot/grub
60 7
 
61
-grub_efi_install
8
+BUILDROOT=$1
9
+ROOT_PARTITION_PATH=$2
10
+BOOT_PARTITION_PATH=$3
11
+BOOT_DIRECTORY=$4
62 12
 
63
-rm -rf ${BUILDROOT}/boot/grub2/fonts
64
-cp $INSTALLER_PATH/boot/ascii.pf2 ${BUILDROOT}/boot/grub2/
65
-mkdir -p ${BUILDROOT}/boot/grub2/themes/photon
66
-cp $INSTALLER_PATH/boot/splash.png ${BUILDROOT}/boot/grub2/themes/photon/photon.png
67
-cp $INSTALLER_PATH/boot/terminal_*.tga ${BUILDROOT}/boot/grub2/themes/photon/
68
-cp $INSTALLER_PATH/boot/theme.txt ${BUILDROOT}/boot/grub2/themes/photon/
13
+# Raspberry prorpiaetary GPU bootloader (1st stage)
14
+cp -r $SCRIPT_PATH/esp/* $BUILDROOT/boot/efi/
69 15
 
70 16
 EXTRA_PARAMS="rootwait rw console=ttyS0,115200n8 console=tty0 cma=256M"
71 17