Browse code

AWS AMI: Remove hardcoded replacement of linux with linux-aws in the installer

Generalize the logic for replacing selected packages by adding a
'remove' field in the json file, and use this in the installer to
replace the linux kernel package with linux-aws for AMI builds.

Also, while at it, add linux-aws to the list of packages to skip for
ARM64 builds.

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

Srivatsa S. Bhat authored on 2018/03/16 10:28:25
Showing 5 changed files
... ...
@@ -9,6 +9,7 @@
9 9
         "title" : "Photon AMI packages",
10 10
         "file" : "packages_ami.json",
11 11
         "visible" : false,
12
-        "include" : ["minimal"]
12
+        "include" : ["minimal"],
13
+        "remove" : ["linux"]
13 14
     }
14 15
 }
... ...
@@ -1,3 +1,3 @@
1 1
 {
2
-    "packages":["sudo", "gawk", "cloud-utils", "gptfdisk", "tar"]
2
+    "packages":["sudo", "gawk", "cloud-utils", "gptfdisk", "tar", "linux-aws"]
3 3
 }
... ...
@@ -38,6 +38,11 @@ class PackageSelector(object):
38 38
                 json_wrapper_package_list = JsonWrapper(os.path.join(output_data_path, install_option[1]["file"]))
39 39
                 package_list_json = json_wrapper_package_list.read()
40 40
                 package_list = package_list + package_list_json["packages"]
41
+
42
+                if "remove" in install_option[1]:
43
+                    for package in install_option[1]["remove"]:
44
+                        package_list.remove(package)
45
+
41 46
                 break
42 47
         return package_list
43 48
 
... ...
@@ -244,11 +244,6 @@ if __name__ == '__main__':
244 244
         packages = []
245 245
         packages = PackageSelector.get_packages_to_install(options_sorted, config['type'], options.output_data_path)
246 246
 
247
-	# Use the optimized linux-aws kernel for AMI images.
248
-	if options.vmdk_path and config['type'] == 'ami':
249
-		packages.remove('linux')
250
-		packages.append('linux-aws')
251
-
252 247
         config['packages'] = packages
253 248
 
254 249
         if (os.path.isdir(options.working_directory)):
... ...
@@ -363,6 +363,7 @@ class constants(object):
363 363
             # only generic linux is for arm64
364 364
             "linux-esx.spec",
365 365
             "linux-secure.spec",
366
+            "linux-aws.spec",
366 367
             # only linux-secure supports aufs
367 368
             "aufs-util.spec",
368 369
             # open-vm-tools does not support aarch64