- Use config.json to provide the docker image for building
images
- Use config-<IMG>.json to provide the docker the image
to be used for pkg installation during install time
- Added a key "photon_docker_image" in ks_config.txt
- For imagebuilding, docker image provided by config-<Img>.json
is preffered over cmdline param or config.json value
- if docker image not provided by config-<Img>.json then
cmdline param value is preferred over config.json
- Default docker image is "photon:latest"
- $ sudo make iso THREADS=32 PHOTON_DOCKER_IMAGE=photon:3.0
Change-Id: Ic4f6df870e56c4bb4b37f752214baba2a8046aeb
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/11706
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Tested-by: Anish Swaminathan <anishs@vmware.com>
... | ... |
@@ -511,8 +511,13 @@ class RpmBuildTarget: |
511 | 511 |
check_prerequesite["ostree-repo"]=True |
512 | 512 |
if not check_prerequesite["start-docker"]: |
513 | 513 |
CheckTools.start_docker() |
514 |
+ if constants.currentArch == "x86_64": |
|
515 |
+ photon_docker_image = "vmware/photon-build:rpm-ostree-3.0" |
|
516 |
+ else: |
|
517 |
+ photon_docker_image = "vmware/photon-build:rpm-ostree-aarch64-3.0" |
|
514 | 518 |
if not os.path.isfile(os.path.join(Build_Config.stagePath, "ostree-repo.tar.gz")): |
515 |
- process = subprocess.Popen([curDir + "/support/image-builder/ostree-tools/make-ostree-image.sh", curDir, Build_Config.stagePath]) |
|
519 |
+ process = subprocess.Popen([curDir + "/support/image-builder/ostree-tools/make-ostree-image.sh", curDir, Build_Config.stagePath, |
|
520 |
+ photon_docker_image]) |
|
516 | 521 |
|
517 | 522 |
retval = process.wait() |
518 | 523 |
if retval != 0: |
... | ... |
@@ -742,6 +747,7 @@ class BuildImage: |
742 | 742 |
self.rpm_path = constants.rpmPath |
743 | 743 |
self.srpm_path = constants.sourceRpmPath |
744 | 744 |
self.pkg_to_rpm_map_file = os.path.join(Build_Config.stagePath, "pkg_info.json") |
745 |
+ self.photon_docker_image = configdict["photon-build-param"]["photon-docker-image"] |
|
745 | 746 |
|
746 | 747 |
def set_Iso_Parameters(self, imgName): |
747 | 748 |
self.generated_data_path = Build_Config.stagePath + "/common/data" |
... | ... |
@@ -1045,6 +1051,8 @@ def main(): |
1045 | 1045 |
if 'DOCKER_ENV' in os.environ: |
1046 | 1046 |
Build_Config.setDockerEnv(os.environ['DOCKER_ENV']) |
1047 | 1047 |
|
1048 |
+ if 'PHOTON_DOCKER_IMAGE' in os.environ: |
|
1049 |
+ configdict['photon-build-param']['photon-docker-image'] = os.environ['PHOTON_DOCKER_IMAGE'] |
|
1048 | 1050 |
|
1049 | 1051 |
initialize_constants() |
1050 | 1052 |
|
... | ... |
@@ -66,6 +66,7 @@ class Installer(object): |
66 | 66 |
'postinstall', |
67 | 67 |
'postinstallscripts', |
68 | 68 |
'public_key', |
69 |
+ 'photon_docker_image', |
|
69 | 70 |
'search_path', |
70 | 71 |
'setup_grub_script', |
71 | 72 |
'shadow_password', |
... | ... |
@@ -242,6 +243,10 @@ class Installer(object): |
242 | 242 |
|
243 | 243 |
install_config['install_linux_esx'] = False |
244 | 244 |
|
245 |
+ # Default Photon docker image |
|
246 |
+ if 'photon_docker_image' not in install_config: |
|
247 |
+ install_config['photon_docker_image'] = "photon:latest" |
|
248 |
+ |
|
245 | 249 |
def _check_install_config(self, install_config): |
246 | 250 |
""" |
247 | 251 |
Sanity check of install_config before its execution. |
... | ... |
@@ -643,7 +648,7 @@ class Installer(object): |
643 | 643 |
retval = self.cmd.run(['docker', 'run', |
644 | 644 |
'-v', self.rpm_cache_dir+':'+self.rpm_cache_dir, |
645 | 645 |
'-v', self.working_directory+':'+self.working_directory, |
646 |
- 'photon:3.0', '/bin/sh', '-c', tdnf_cmd]) |
|
646 |
+ self.install_config['photon_docker_image'], '/bin/sh', '-c', tdnf_cmd]) |
|
647 | 647 |
if retval != 0: |
648 | 648 |
self.logger.error("Failed to install filesystem rpm") |
649 | 649 |
self.exit_gracefully() |
... | ... |
@@ -931,7 +936,7 @@ class Installer(object): |
931 | 931 |
retval = self.cmd.run(['docker', 'run', |
932 | 932 |
'-v', self.rpm_cache_dir+':'+self.rpm_cache_dir, |
933 | 933 |
'-v', self.working_directory+':'+self.working_directory, |
934 |
- 'photon:3.0', '/bin/sh', '-c', tdnf_cmd]) |
|
934 |
+ self.install_config['photon_docker_image'], '/bin/sh', '-c', tdnf_cmd]) |
|
935 | 935 |
|
936 | 936 |
# 0 : succeed; 137 : package already installed; 65 : package not found in repo. |
937 | 937 |
if retval != 0 and retval != 137: |
... | ... |
@@ -241,4 +241,11 @@ Kickstart config file is a json format with following possible parameters: |
241 | 241 |
Acceptable values are: "linux", "linux-esx", "linux-rt", "linux-aws", and "linux-secure" |
242 | 242 |
Example: { "linux_flavor": "linux-esx" } |
243 | 243 |
|
244 |
+"photon_docker_image" (optional) |
|
245 |
+ Contains the docker image <name:tag> |
|
246 |
+ are present in "packages" or "packagelist_file" |
|
247 |
+ Acceptable values are: "photon:1.0", "photon:2.0", "photon:3.0", "photon" etc. |
|
248 |
+ Default value: "photon:latest" |
|
249 |
+ Example: { "photon_docker_image": "photon:3.0" } |
|
250 |
+ |
|
244 | 251 |
For reference, look at "sample_ks.cfg" file |
... | ... |
@@ -128,7 +128,8 @@ def createIso(options): |
128 | 128 |
working_directory, options.iso_path, |
129 | 129 |
options.rpm_path, options.package_list_file, |
130 | 130 |
rpm_list, options.stage_path, files_to_copy, |
131 |
- options.generated_data_path, initrd_pkgs]) |
|
131 |
+ options.generated_data_path, initrd_pkgs, |
|
132 |
+ options.photon_docker_image]) |
|
132 | 133 |
|
133 | 134 |
if retval: |
134 | 135 |
raise Exception("Unable to create install ISO") |
... | ... |
@@ -228,6 +229,11 @@ def createImage(options): |
228 | 228 |
os.path.abspath(script_dir), |
229 | 229 |
] |
230 | 230 |
|
231 |
+ # if 'photon_docker_image' is defined in config_<img>.json then ignore |
|
232 |
+ # commandline param 'PHOTON_DOCKER_IMAGE' and 'config.json' value |
|
233 |
+ if 'photon_docker_image' not in install_config: |
|
234 |
+ install_config['photon_docker_image'] = options.photon_docker_image |
|
235 |
+ |
|
231 | 236 |
if 'size' in config and 'disks' in config: |
232 | 237 |
raise Exception("Both 'size' and 'disks' key should not be defined together.Please use 'disks' for defining multidisks only.") |
233 | 238 |
elif 'size' in config: |
... | ... |
@@ -305,6 +311,7 @@ if __name__ == '__main__': |
305 | 305 |
parser.add_argument("-p", "--package-list-file", dest="package_list_file", default="../../common/data/build_install_options_all.json") |
306 | 306 |
parser.add_argument("-d", "--pkg-to-rpm-map-file", dest="pkg_to_rpm_map_file", default="../../stage/pkg_info.json") |
307 | 307 |
parser.add_argument("-z", "--pkg-to-be-copied-conf-file", dest="pkg_to_be_copied_conf_file") |
308 |
+ parser.add_argument("-q", "--photon-docker-image", dest="photon_docker_image", default="photon:latest") |
|
308 | 309 |
|
309 | 310 |
options = parser.parse_args() |
310 | 311 |
if options.config_file and options.config_file != '': |
... | ... |
@@ -17,6 +17,8 @@ def createOutputArtifact(raw_image_path, config, src_root, tools_bin_path): |
17 | 17 |
photon_build_num = os.environ['PHOTON_BUILD_NUM'] |
18 | 18 |
image_name = config.get('image_name', 'photon-' + config['image_type'] |
19 | 19 |
+ '-' + photon_release_ver + '-' + photon_build_num) |
20 |
+ photon_docker_image = config['installer'].get('photon_docker_image', |
|
21 |
+ 'photon:latest') |
|
20 | 22 |
new_name = [] |
21 | 23 |
if type(raw_image_path) is not list: |
22 | 24 |
raw_image_path = [raw_image_path] |
... | ... |
@@ -53,8 +55,8 @@ def createOutputArtifact(raw_image_path, config, src_root, tools_bin_path): |
53 | 53 |
|
54 | 54 |
cmd = "tdnf install -y qemu-img > /dev/null 2>&1; qemu-img info -f raw --output json {}" |
55 | 55 |
if not dockerenv: |
56 |
- cmd = "docker run -v {}:/mnt:rw photon:{} /bin/bash -c '" + cmd + "'" |
|
57 |
- cmd = cmd.format(src_root, 3.0, '/mnt/' + relrawpath) |
|
56 |
+ cmd = "docker run -v {}:/mnt:rw {} /bin/bash -c '" + cmd + "'" |
|
57 |
+ cmd = cmd.format(src_root, photon_docker_image, '/mnt/' + relrawpath) |
|
58 | 58 |
else: |
59 | 59 |
cmd = cmd.format(raw_image[0]) |
60 | 60 |
info_output = Utils.runshellcommand(cmd) |
... | ... |
@@ -64,8 +66,8 @@ def createOutputArtifact(raw_image_path, config, src_root, tools_bin_path): |
64 | 64 |
|
65 | 65 |
cmd = "tdnf install -y qemu-img > /dev/null 2>&1; qemu-img resize -f raw {} {}" |
66 | 66 |
if not dockerenv: |
67 |
- cmd = "docker run -v {}:/mnt:rw photon:{} /bin/bash -c '" + cmd + "'" |
|
68 |
- cmd = cmd.format(src_root, 3.0, '/mnt/' + relrawpath, mbroundedsize) |
|
67 |
+ cmd = "docker run -v {}:/mnt:rw {} /bin/bash -c '" + cmd + "'" |
|
68 |
+ cmd = cmd.format(src_root, photon_docker_image, '/mnt/' + relrawpath, mbroundedsize) |
|
69 | 69 |
else: |
70 | 70 |
cmd = cmd.format(raw_image[0], mbroundedsize) |
71 | 71 |
Utils.runshellcommand(cmd) |
... | ... |
@@ -73,8 +75,8 @@ def createOutputArtifact(raw_image_path, config, src_root, tools_bin_path): |
73 | 73 |
cmd = "tdnf install -y qemu-img > /dev/null 2>&1; qemu-img convert {} -O " + \ |
74 | 74 |
"vpc -o subformat=fixed,force_size {}" |
75 | 75 |
if not dockerenv: |
76 |
- cmd = "docker run -v {}:/mnt:rw photon:{} /bin/bash -c '" + cmd + "'" |
|
77 |
- cmd = cmd.format(src_root, 3.0, '/mnt/' + relrawpath, '/mnt/' |
|
76 |
+ cmd = "docker run -v {}:/mnt:rw {} /bin/bash -c '" + cmd + "'" |
|
77 |
+ cmd = cmd.format(src_root, photon_docker_image, '/mnt/' + relrawpath, '/mnt/' |
|
78 | 78 |
+ os.path.dirname(relrawpath) + vhdname) |
79 | 79 |
else: |
80 | 80 |
cmd = cmd.format(raw_image[0], os.path.dirname(raw_image[0]) + vhdname) |
... | ... |
@@ -31,6 +31,7 @@ PHOTON_COMMON_DIR=$(dirname "${PACKAGE_LIST_FILE}") |
31 | 31 |
PACKAGE_LIST_FILE_BASE_NAME=$(basename "${PACKAGE_LIST_FILE}") |
32 | 32 |
INITRD=${WORKINGDIR}/photon-chroot |
33 | 33 |
PACKAGES=$8 |
34 |
+PHOTON_DOCKER_IMAGE=$9 |
|
34 | 35 |
|
35 | 36 |
rm -rf $WORKINGDIR/* |
36 | 37 |
mkdir -p $INITRD |
... | ... |
@@ -62,8 +63,8 @@ rpm --root $INITRD --initdb --dbpath /var/lib/rpm |
62 | 62 |
|
63 | 63 |
TDNF_CMD="tdnf install -y --installroot $INITRD --rpmverbosity 10 -c ${WORKINGDIR}/tdnf.conf -q $PACKAGES" |
64 | 64 |
|
65 |
-# run host's tdnf, if fails - try one from photon:3.0 docker image |
|
66 |
-$TDNF_CMD || docker run -v $RPMS_PATH:$RPMS_PATH -v $WORKINGDIR:$WORKINGDIR photon:3.0 $TDNF_CMD |
|
65 |
+# run host's tdnf, if fails - try one from photon:latest docker image |
|
66 |
+$TDNF_CMD || docker run -v $RPMS_PATH:$RPMS_PATH -v $WORKINGDIR:$WORKINGDIR $PHOTON_DOCKER_IMAGE $TDNF_CMD |
|
67 | 67 |
|
68 | 68 |
rm -f ${WORKINGDIR}/photon-local.repo ${WORKINGDIR}/tdnf.conf |
69 | 69 |
|
... | ... |
@@ -11,7 +11,7 @@ fi |
11 | 11 |
PROGRAM=$0 |
12 | 12 |
SRCROOT=$1 |
13 | 13 |
STAGE_DIR=$2 |
14 |
-DOCK_ARCH=`uname -m` |
|
14 |
+PHOTON_DOCKER_IMAGE=$3 |
|
15 | 15 |
|
16 | 16 |
cat > ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh << EOF |
17 | 17 |
#!/bin/bash |
... | ... |
@@ -31,13 +31,7 @@ echo "baseurl=file:///RPMS" >> ${SRCROOT}/support/image-builder/ostree-tools/pho |
31 | 31 |
rm -rf ${STAGE_DIR}/ostree-repo |
32 | 32 |
mkdir -p ${STAGE_DIR}/ostree-repo |
33 | 33 |
|
34 |
-if [ $DOCK_ARCH == "x86_64" ] |
|
35 |
-then |
|
36 |
- sudo docker run --privileged -v ${SRCROOT}:/photon -v ${STAGE_DIR}/RPMS:/RPMS -v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" vmware/photon-build:rpm-ostree-3.0 ./mk-ostree-server.sh / |
|
37 |
-elif [ $DOCK_ARCH == "aarch64" ] |
|
38 |
-then |
|
39 |
- sudo docker run --privileged -v ${SRCROOT}:/photon -v ${STAGE_DIR}/RPMS:/RPMS -v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" vmware/photon-build:rpm-ostree-aarch64-3.0 ./mk-ostree-server.sh / |
|
40 |
-fi |
|
34 |
+sudo docker run --privileged -v ${SRCROOT}:/photon -v ${STAGE_DIR}/RPMS:/RPMS -v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" ${PHOTON_DOCKER_IMAGE} ./mk-ostree-server.sh / |
|
41 | 35 |
|
42 | 36 |
REPODIR=${STAGE_DIR}/ostree-repo/repo |
43 | 37 |
if [ -d "$REPODIR" ]; then |