Added a new key as photon_release_version in installer.py.
This key is set in imagebuilder.py for building cloud images and
ova. For iso this key is passed as a command line argument to
the binary.
Change-Id: I84f26a0dd9fe0ad42f055a94b59699a53cbd5b69
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/12496
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Tested-by: Anish Swaminathan <anishs@vmware.com>
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
Summary: Photon OS Installer |
3 | 3 |
Name: photon-os-installer |
4 | 4 |
Version: 1.0 |
5 |
-Release: 4%{?dist} |
|
5 |
+Release: 5%{?dist} |
|
6 | 6 |
License: Apache 2.0 and GPL 2.0 |
7 | 7 |
Group: System Environment/Base |
8 | 8 |
URL: https://github.com/vmware/photon-os-installer |
... | ... |
@@ -10,6 +10,7 @@ Source0: %{name}-%{version}.tar.gz |
10 | 10 |
Patch0: support_insecure_installation.patch |
11 | 11 |
Patch1: insecure_randomness.patch |
12 | 12 |
Patch2: list_block_devices.patch |
13 |
+Patch3: releasever_tdnf_install.patch |
|
13 | 14 |
Vendor: VMware, Inc. |
14 | 15 |
Distribution: Photon |
15 | 16 |
%define sha1 %{name}=cc86d22b7ef8495164fec1fb7d96bb97a2fb82c6 |
... | ... |
@@ -29,6 +30,7 @@ This is to create rpm for installer code |
29 | 29 |
%patch0 -p1 |
30 | 30 |
%patch1 -p1 |
31 | 31 |
%patch2 -p1 |
32 |
+%patch3 -p1 |
|
32 | 33 |
|
33 | 34 |
%build |
34 | 35 |
pyinstaller --onefile photon-installer.spec |
... | ... |
@@ -45,6 +47,8 @@ rm -rf $RPM_BUILD_ROOT |
45 | 45 |
%{_bindir}/photon-installer |
46 | 46 |
|
47 | 47 |
%changelog |
48 |
+* Tue Feb 23 2021 Piyush Gupta <gpiyush@vmware.com> 1.0-5 |
|
49 |
+- Added --releasever to tdnf install command |
|
48 | 50 |
* Fri Feb 19 2021 Piyush Gupta <gpiyush@vmware.com> 1.0-4 |
49 | 51 |
- Listing block devices after user accepts license. |
50 | 52 |
* Fri Jan 15 2021 Piyush Gupta <gpiyush@vmware.com> 1.0-3 |
51 | 53 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,120 @@ |
0 |
+From cbef434149f9a1733ae438d6c27fe875c8f22efe Mon Sep 17 00:00:00 2001 |
|
1 |
+From: Piyush Gupta <gpiyush@vmware.com> |
|
2 |
+Date: Tue, 23 Feb 2021 09:19:28 +0000 |
|
3 |
+Subject: [PATCH] installer.py: Adding releasever to tdnf.conf |
|
4 |
+ |
|
5 |
+Change-Id: Ifaa4e7c2910e3572543c34dbac181f515346550f |
|
6 |
+--- |
|
7 |
+ photon-installer.py | 1 + |
|
8 |
+ photon_installer/installer.py | 18 ++++++++++++++---- |
|
9 |
+ photon_installer/isoInstaller.py | 5 +++++ |
|
10 |
+ photon_installer/ks_config.txt | 4 ++++ |
|
11 |
+ 4 files changed, 24 insertions(+), 4 deletions(-) |
|
12 |
+ |
|
13 |
+diff --git a/photon-installer.py b/photon-installer.py |
|
14 |
+index 3c43a30..4f0ea56 100644 |
|
15 |
+--- a/photon-installer.py |
|
16 |
+@@ -18,6 +18,7 @@ if __name__ == '__main__': |
|
17 |
+ parser.add_argument("-l", "--log-path", dest="log_path") |
|
18 |
+ parser.add_argument("-e", "--eula-file", dest="eula_file_path", default=None) |
|
19 |
+ parser.add_argument("-t", "--license-title", dest="license_display_title", default=None) |
|
20 |
++ parser.add_argument("-v", "--photon-release-version", dest="photon_release_version") |
|
21 |
+ |
|
22 |
+ options = parser.parse_args() |
|
23 |
+ |
|
24 |
+diff --git a/photon_installer/installer.py b/photon_installer/installer.py |
|
25 |
+index 2501fca..686d5e2 100755 |
|
26 |
+--- a/photon_installer/installer.py |
|
27 |
+@@ -66,6 +66,7 @@ class Installer(object): |
|
28 |
+ 'packagelist_file', |
|
29 |
+ 'partition_type', |
|
30 |
+ 'partitions', |
|
31 |
++ 'photon_release_version', |
|
32 |
+ 'network', |
|
33 |
+ 'password', |
|
34 |
+ 'postinstall', |
|
35 |
+@@ -118,6 +119,10 @@ class Installer(object): |
|
36 |
+ def configure(self, install_config, ui_config = None): |
|
37 |
+ if install_config and 'insecure_installation' in install_config: |
|
38 |
+ insecure_installation = install_config.pop('insecure_installation') |
|
39 |
++ |
|
40 |
++ if install_config and 'photon_release_version' in install_config: |
|
41 |
++ photon_release_version = install_config.pop('photon_release_version') |
|
42 |
++ |
|
43 |
+ # Initialize logger and cmd first |
|
44 |
+ if not install_config: |
|
45 |
+ # UI installation |
|
46 |
+@@ -138,6 +143,9 @@ class Installer(object): |
|
47 |
+ |
|
48 |
+ if 'insecure_installation' in locals(): |
|
49 |
+ install_config['insecure_installation'] = insecure_installation |
|
50 |
++ |
|
51 |
++ if 'photon_release_version' in locals(): |
|
52 |
++ install_config['photon_release_version'] = photon_release_version |
|
53 |
+ self._add_defaults(install_config) |
|
54 |
+ |
|
55 |
+ issue = self._check_install_config(install_config) |
|
56 |
+@@ -653,8 +661,9 @@ class Installer(object): |
|
57 |
+ self.exit_gracefully() |
|
58 |
+ |
|
59 |
+ # Install filesystem rpm |
|
60 |
+- tdnf_cmd = "tdnf install filesystem --installroot {0} --assumeyes -c {1}".format(self.photon_root, |
|
61 |
+- self.tdnf_conf_path) |
|
62 |
++ tdnf_cmd = "tdnf install filesystem --releasever {0} --installroot {1} --assumeyes -c {2}".format( |
|
63 |
++ self.install_config['photon_release_version'], self.photon_root, |
|
64 |
++ self.tdnf_conf_path) |
|
65 |
+ retval = self.cmd.run(tdnf_cmd) |
|
66 |
+ if retval != 0: |
|
67 |
+ retval = self.cmd.run(['docker', 'run', |
|
68 |
+@@ -894,8 +903,9 @@ class Installer(object): |
|
69 |
+ packages_to_install = {} |
|
70 |
+ total_size = 0 |
|
71 |
+ stderr = None |
|
72 |
+- tdnf_cmd = "tdnf install --installroot {0} --assumeyes -c {1} {2}".format(self.photon_root, |
|
73 |
+- self.tdnf_conf_path, " ".join(selected_packages)) |
|
74 |
++ tdnf_cmd = "tdnf install --releasever {0} --installroot {1} --assumeyes -c {2} {3}".format( |
|
75 |
++ self.install_config['photon_release_version'], self.photon_root, |
|
76 |
++ self.tdnf_conf_path, " ".join(selected_packages)) |
|
77 |
+ self.logger.debug(tdnf_cmd) |
|
78 |
+ |
|
79 |
+ # run in shell to do not throw exception if tdnf not found |
|
80 |
+diff --git a/photon_installer/isoInstaller.py b/photon_installer/isoInstaller.py |
|
81 |
+index 8babe5c..bc02b60 100755 |
|
82 |
+--- a/photon_installer/isoInstaller.py |
|
83 |
+@@ -59,12 +59,17 @@ class IsoInstaller(object): |
|
84 |
+ if ks_path: |
|
85 |
+ install_config = self._load_ks_config(ks_path) |
|
86 |
+ |
|
87 |
++ |
|
88 |
+ # insecure_installation flag added through commandline overrides that of ks_config |
|
89 |
+ if self.insecure_installation: |
|
90 |
+ if not install_config: |
|
91 |
+ install_config = {} |
|
92 |
+ install_config['insecure_installation'] = self.insecure_installation |
|
93 |
+ |
|
94 |
++ if not install_config: |
|
95 |
++ install_config = {} |
|
96 |
++ install_config['photon_release_version'] = options.photon_release_version |
|
97 |
++ |
|
98 |
+ if options.ui_config_file: |
|
99 |
+ ui_config = (JsonWrapper(options.ui_config_file)).read() |
|
100 |
+ else: |
|
101 |
+diff --git a/photon_installer/ks_config.txt b/photon_installer/ks_config.txt |
|
102 |
+index ce8fcb8..b7ed03b 100644 |
|
103 |
+--- a/photon_installer/ks_config.txt |
|
104 |
+@@ -259,4 +259,8 @@ Kickstart config file is a json format with following possible parameters: |
|
105 |
+ Default value: "photon:latest" |
|
106 |
+ Example: { "photon_docker_image": "photon:3.0" } |
|
107 |
+ |
|
108 |
++"photon_release_version" |
|
109 |
++ Contains the photon release version |
|
110 |
++ Acceptable values are: "4.0" |
|
111 |
++ Example: {"photon_release_version": "4.0"} |
|
112 |
+ For reference, look at "sample_ks.cfg" file |
|
113 |
+-- |
|
114 |
+2.23.0 |
|
115 |
+ |
... | ... |
@@ -746,6 +746,7 @@ class BuildImage: |
746 | 746 |
self.pkg_to_rpm_map_file = os.path.join(Build_Config.stagePath, "pkg_info.json") |
747 | 747 |
self.ph_docker_image = configdict["photon-build-param"]["photon-docker-image"] |
748 | 748 |
self.ova_cloud_images = ["ami", "gce", "azure", "ova_uefi", "ova"] |
749 |
+ self.photon_release_version = constants.releaseVersion |
|
749 | 750 |
|
750 | 751 |
def set_Iso_Parameters(self, imgName): |
751 | 752 |
self.generated_data_path = Build_Config.stagePath + "/common/data" |
... | ... |
@@ -200,6 +200,7 @@ def createImage(options): |
200 | 200 |
|
201 | 201 |
install_config = config['installer'] |
202 | 202 |
|
203 |
+ install_config['photon_release_version'] = options.photon_release_version |
|
203 | 204 |
image_type = config['image_type'] |
204 | 205 |
image_name = config.get('image_name', 'photon-' + image_type) |
205 | 206 |
workingDir = os.path.abspath(options.stage_path + "/" + image_type) |
... | ... |
@@ -311,6 +312,7 @@ if __name__ == '__main__': |
311 | 311 |
parser.add_argument("-d", "--pkg-to-rpm-map-file", dest="pkg_to_rpm_map_file", default="../../stage/pkg_info.json") |
312 | 312 |
parser.add_argument("-z", "--pkg-to-be-copied-conf-file", dest="pkg_to_be_copied_conf_file") |
313 | 313 |
parser.add_argument("-q", "--photon-docker-image", dest="ph_docker_image", default="photon:latest") |
314 |
+ parser.add_argument("-v", "--photon-release-version", dest="photon_release_version") |
|
314 | 315 |
|
315 | 316 |
options = parser.parse_args() |
316 | 317 |
if options.config_file and options.config_file != '': |
... | ... |
@@ -60,7 +60,7 @@ EOF |
60 | 60 |
|
61 | 61 |
rpm --root $INITRD --initdb --dbpath /var/lib/rpm |
62 | 62 |
|
63 |
-TDNF_CMD="tdnf install -y --installroot $INITRD --rpmverbosity 10 -c ${WORKINGDIR}/tdnf.conf -q $PACKAGES" |
|
63 |
+TDNF_CMD="tdnf install -y --releasever $PHOTON_RELEASE_VER --installroot $INITRD --rpmverbosity 10 -c ${WORKINGDIR}/tdnf.conf -q $PACKAGES" |
|
64 | 64 |
|
65 | 65 |
# run host's tdnf, if fails - try one from photon:latest docker image |
66 | 66 |
$TDNF_CMD || docker run -v $RPMS_PATH:$RPMS_PATH -v $WORKINGDIR:$WORKINGDIR $PHOTON_DOCKER_IMAGE $TDNF_CMD |
... | ... |
@@ -143,7 +143,7 @@ cd /installer |
143 | 143 |
ACTIVE_CONSOLE="\$(< /sys/devices/virtual/tty/console/active)" |
144 | 144 |
|
145 | 145 |
install() { |
146 |
- LANG=en_US.UTF-8 photon-installer -i iso -o $PACKAGE_LIST_FILE_BASE_NAME -e EULA.txt -t "VMWARE 4.0 LICENSE AGREEMENT" && shutdown -r now |
|
146 |
+ LANG=en_US.UTF-8 photon-installer -i iso -o $PACKAGE_LIST_FILE_BASE_NAME -e EULA.txt -t "VMWARE 4.0 LICENSE AGREEMENT" -v $PHOTON_RELEASE_VER && shutdown -r now |
|
147 | 147 |
} |
148 | 148 |
|
149 | 149 |
try_run_installer() { |