Skip to content

Commit 5099dea

Browse files
oliverkurthGitHub Enterprise
authored andcommitted
Merge pull request vmware#37 from vcf/topic/okurth/partition-label-and-no-fs
add partition label, allow no fs and no mountpoint, and mount_by option
2 parents 3065562 + 824771e commit 5099dea

File tree

8 files changed

+64
-38
lines changed

8 files changed

+64
-38
lines changed

examples/iso/iso.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ initrd_pkgs_list_file: packages_installer_initrd.json
1010
#boot_cmdline_param: ks=minimal_ks.yaml
1111

1212
repo_paths:
13-
- https://packages.vmware.com/photon/$releasever/photon_updates_$releasever_$basearch
13+
- https://packages-prod.broadcom.com/photon/$releasever/photon_updates_$releasever_$basearch
1414
- /poi
1515

1616
iso_files:

examples/ova/gitlab-runner_ks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ partitions:
2020
repos:
2121
photon:
2222
name: "Photon 5.0"
23-
baseurl: !param photon_repo_url=https://packages.vmware.com/photon/$releasever/photon_updates_$releasever_$basearch/
23+
baseurl: !param photon_repo_url=https://packages-prod.broadcom.com/photon/$releasever/photon_updates_$releasever_$basearch/
2424
enabled: 1
2525
gpgcheck: 0
2626

examples/ova/minimal_ks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ partitions:
2323
repos:
2424
photon:
2525
name: "Photon"
26-
baseurl: !param photon_repo_url=https://packages.vmware.com/photon/$releasever/photon_updates_$releasever_$basearch
26+
baseurl: !param photon_repo_url=https://packages-prod.broadcom.com/photon/$releasever/photon_updates_$releasever_$basearch
2727
enabled: 1
2828
gpgcheck: 0
2929

examples/ova/minimal_lvm_ks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ partitions:
2121
repos:
2222
photon:
2323
name: "Photon"
24-
baseurl: !param photon_repo_url=https://packages.vmware.com/photon/$releasever/photon_updates_$releasever_$basearch
24+
baseurl: !param photon_repo_url=https://packages-prod.broadcom.com/photon/$releasever/photon_updates_$releasever_$basearch
2525
enabled: 1
2626
gpgcheck: 0
2727

examples/ova/minimal_secure_ks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ partitions:
2525
repos:
2626
photon:
2727
name: "Photon"
28-
baseurl: !param photon_repo_url=https://packages.vmware.com/photon/$releasever/photon_updates_$releasever_$basearch
28+
baseurl: !param photon_repo_url=https://packages-prod.broadcom.com/photon/$releasever/photon_updates_$releasever_$basearch
2929
enabled: 1
3030
gpgcheck: 0
3131

photon_installer/generate_initrd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ def clean_up(self):
186186
self.cmd_util.remove_files(files_to_remove)
187187

188188
def install_initrd_packages(self):
189-
tdnf_args = ["install"] + self.initrd_pkgs
189+
# nogpgcheck to work around installing locally built packages, like photon-os-installer
190+
tdnf_args = ["--nogpgcheck", "install"] + self.initrd_pkgs
190191
# mount_dirs = []
191192
if self.ostree_iso:
192193
self.tdnf.config_file = None

photon_installer/installer.py

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ def _unmount_all(self):
10201020
# only fstrim fs types that are supported to avoid error messages
10211021
# instead of filtering for the fs type we could use '--quiet-unsupported',
10221022
# but this is not implemented in older fstrim versions in Photon 3.0
1023-
if p['filesystem'] in ['ext4', 'btrfs', 'xfs']:
1023+
if p['filesystem'] in ['ext4', 'btrfs', 'xfs'] and p['mountpoint'] is not None:
10241024
mntpoint = os.path.join(self.photon_root, p['mountpoint'].strip('/'))
10251025
retval = self.cmd.run(["fstrim", mntpoint])
10261026

@@ -1148,31 +1148,36 @@ def _create_fstab(self, fstab_path=None):
11481148
else:
11491149
mountpoint = partition['mountpoint']
11501150

1151-
# Use PARTUUID/UUID instead of bare path.
1152-
# Prefer PARTUUID over UUID as it is supported by kernel
1153-
# and UUID only by initrd.
11541151
path = partition['path']
1155-
mnt_src = None
1156-
partuuid = self._get_partuuid(path)
1157-
if partuuid != '':
1158-
mnt_src = f"PARTUUID={partuuid}"
1152+
if partition.get('mount_by') is None:
1153+
# Use PARTUUID/UUID instead of bare path.
1154+
# Prefer PARTUUID over UUID as it is supported by kernel
1155+
# and UUID only by initrd.
1156+
mnt_src = None
1157+
partuuid = self._get_partuuid(path)
1158+
if partuuid != '':
1159+
mnt_src = f"PARTUUID={partuuid}"
1160+
else:
1161+
uuid = self._get_uuid(path)
1162+
if uuid != '':
1163+
mnt_src = f"UUID={uuid}"
11591164
else:
1160-
uuid = self._get_uuid(path)
1161-
if uuid != '':
1162-
mnt_src = f"UUID={uuid}"
1165+
mount_by = partition['mount_by']
1166+
if mount_by == "partuuid":
1167+
mnt_src = "PARTUUID=" + self._get_partuuid(path)
1168+
elif mount_by == "uuid":
1169+
mnt_src = "UUID=" + self._get_uuid(path)
1170+
elif mount_by == "partlabel":
1171+
mnt_src = "PARTLABEL=" + partition.get('partlabel')
1172+
elif mount_by == "label":
1173+
mnt_src = "LABEL=" + partition.get('label')
1174+
else:
1175+
raise InstallerConfigError(f"unsupported 'mount_by' '{mount_by}'")
1176+
11631177
if not mnt_src:
1164-
raise RuntimeError(f"Cannot get PARTUUID/UUID of: {path}")
1165-
1166-
fstab_file.write(
1167-
"{}\t{}\t{}\t{}\t{}\t{}\n".format(
1168-
mnt_src,
1169-
mountpoint,
1170-
partition['filesystem'],
1171-
options,
1172-
dump,
1173-
fsck,
1174-
)
1175-
)
1178+
raise RuntimeError(f"Cannot get mount source for: {path}")
1179+
1180+
fstab_file.write(f"{mnt_src}\t{mountpoint}\t{partition['filesystem']}\t{options}\t{dump}\t{fsck}\n")
11761181

11771182
if partition.get('filesystem', '') == "btrfs" and "btrfs" in partition and "subvols" in partition["btrfs"]:
11781183
self._add_btrfs_subvolume_to_fstab(mnt_src, fstab_file, partition["btrfs"])
@@ -1247,6 +1252,8 @@ def _mount_partitions(self):
12471252
continue
12481253
if partition.get('shadow', False):
12491254
continue
1255+
if partition['mountpoint'] is None:
1256+
continue
12501257

12511258
mntpoint = os.path.join(self.photon_root, partition['mountpoint'].strip('/'))
12521259
if not partition.get('no_build_mount', False):
@@ -2116,13 +2123,19 @@ def _partition_disks(self):
21162123
else:
21172124
l2['partition']['path'] = self._get_partition_path(device, part_idx)
21182125

2126+
this_cmd = partition_cmd
21192127
if l2['size'] == 0:
21202128
last_partition = []
2121-
last_partition.extend([f'-n{part_idx}'])
2122-
last_partition.extend([f"-t{part_idx}:{l2['type']}"])
2129+
this_cmd = last_partition
2130+
this_cmd.append(f'-n{part_idx}')
21232131
else:
2124-
partition_cmd.extend([f"-n{part_idx}::+{l2['size']}M"])
2125-
partition_cmd.extend([f"-t{part_idx}:{l2['type']}"])
2132+
this_cmd.append(f"-n{part_idx}::+{l2['size']}M")
2133+
2134+
this_cmd.append(f"-t{part_idx}:{l2['type']}")
2135+
2136+
if 'partition' in l2 and l2['partition'].get('partlabel') is not None:
2137+
this_cmd.append(f"-c{part_idx}:{l2['partition']['partlabel']}")
2138+
21262139
part_idx += 1
21272140

21282141
# if extensible partition present, add it to the end of the disk
@@ -2188,23 +2201,35 @@ def _format_partitions(self):
21882201

21892202
# Format the filesystem
21902203
for partition in partitions:
2204+
# unformatted partition
2205+
if partition['filesystem'] is None:
2206+
continue
2207+
21912208
ptype = self._get_partition_type(partition)
21922209
# Do not format BIOS boot partition
21932210
if ptype == PartitionType.BIOS:
21942211
continue
21952212
if ptype == PartitionType.SWAP:
2196-
mkfs_cmd = ['mkswap']
2213+
mkfs_cmd = ["mkswap"]
21972214
else:
2198-
mkfs_cmd = ['mkfs', '-t', partition['filesystem']]
2215+
mkfs_cmd = ["mkfs", "-t", partition['filesystem']]
21992216

22002217
# Add force option to mkfs to override previously created partition
22012218
if partition["filesystem"] in ["btrfs", "xfs"]:
2202-
mkfs_cmd.extend(['-f'])
2219+
mkfs_cmd.append("-f")
22032220

22042221
if 'mkfs_options' in partition:
22052222
options = partition['mkfs_options'].split()
22062223
mkfs_cmd.extend(options)
22072224

2225+
# fs level label
2226+
if partition.get('label') is not None:
2227+
# label options are "-L" for all supqported filesystems including swap, except for vfat
2228+
if partition["filesystem"] == "vfat":
2229+
mkfs_cmd.extend(["-n", partition['label']])
2230+
else:
2231+
mkfs_cmd.extend(["-L", partition['label']])
2232+
22082233
mkfs_cmd.extend([partition['path']])
22092234
retval = self.cmd.run(mkfs_cmd)
22102235

photon_installer/isoBuilder.py

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ def downloadPkgs(self):
226226
self.logger.info("downloading packages...")
227227
retval = self.tdnf.run(
228228
[
229+
"--nogpgcheck", # work around for installing locally built packages, like photon-os-installer
229230
"--alldeps",
230231
"--downloadonly",
231-
"--downloaddir",
232-
self.rpms_path,
232+
"--downloaddir", self.rpms_path,
233233
"install",
234234
]
235235
+ self.pkg_list,

0 commit comments

Comments
 (0)