Skip to content

Commit

Permalink
Added fix for generating the json files for cloud images
Browse files Browse the repository at this point in the history
  • Loading branch information
harishspqr authored and sjohngeorge committed Aug 15, 2015
1 parent 8d282b9 commit 94cdb4d
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 17 deletions.
53 changes: 38 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ PHOTON_MICRO_DEPLIST := micro-dep-list
PHOTON_FULL_DEPLIST := full-dep-list
PREPARE_OUT_DATADIR := prepare-out-datadir

MINIMAL_PACKAGE_LIST_FILE := build_install_options_minimal.json
MICRO_PACKAGE_LIST_FILE := build_install_options_micro.json
FULL_PACKAGE_LIST_FILE := build_install_options_all.json
CLOUDALL_PACKAGE_LIST_FILE := build_install_options_cloudall.json

ifdef PHOTON_PUBLISH_RPMS_PATH
PHOTON_PUBLISH_RPMS := publish-rpms-cached
else
Expand Down Expand Up @@ -61,7 +66,8 @@ micro-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MICRO) $(PHOTON_MICRO_DEPLIST
-w $(PHOTON_STAGE)/photon_iso \
-l $(PHOTON_STAGE)/LOGS \
-r $(PHOTON_STAGE)/RPMS \
-p $(PHOTON_DATA_DIR)/build_install_options_micro.json \
-p $(PHOTON_DATA_DIR)/$(MICRO_PACKAGE_LIST_FILE) \
-o $(PHOTON_STAGE)/common/data \
-f > \
$(PHOTON_LOGS_DIR)/installer.log 2>&1

Expand All @@ -71,15 +77,15 @@ $(PHOTON_MICRO_DEPLIST): check $(PREPARE_OUT_DATADIR)
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
--input-type=json --file packages_micro.json -d json -t $(PHOTON_STAGE) -a $(PHOTON_DATA_DIR)
--input-type=json --file $(MICRO_PACKAGE_LIST_FILE) -d json -t $(PHOTON_STAGE) -a $(PHOTON_DATA_DIR)
@echo "generated the json file with all dependencies for micro installation"

deptree-micro:
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
-i json -f packages_micro.json -a $(PHOTON_DATA_DIR)
-i json -f $(MICRO_PACKAGE_LIST_FILE) -a $(PHOTON_DATA_DIR)

packages-micro: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
@echo "Building all Micro RPMS..."
Expand All @@ -91,7 +97,7 @@ packages-micro: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
-b $(PHOTON_CHROOT_PATH) \
-l $(PHOTON_LOGS_DIR) \
-p $(PHOTON_PUBLISH_RPMS_DIR) \
-j $(PHOTON_DATA_DIR)/build_install_options_micro.json \
-j $(PHOTON_DATA_DIR)/$(MICRO_PACKAGE_LIST_FILE) \
-c $(PHOTON_BINTRAY_CONFIG) \
-d $(PHOTON_DIST_TAG) \
-t ${THREADS}
Expand All @@ -104,7 +110,7 @@ deptree-minimal:
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
-i json -f packages_minimal.json -a $(PHOTON_DATA_DIR)
-i json -f $(MINIMAL_PACKAGE_LIST_FILE) -a $(PHOTON_DATA_DIR)

minimal-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) $(PHOTON_MINIMAL_DEPLIST)
@echo "Building Photon Minimal ISO..."
Expand All @@ -113,7 +119,8 @@ minimal-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) $(PHOTON_MINIMAL_D
-w $(PHOTON_STAGE)/photon_iso \
-l $(PHOTON_STAGE)/LOGS \
-r $(PHOTON_STAGE)/RPMS \
-p $(PHOTON_DATA_DIR)/build_install_options_minimal.json \
-p $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) \
-o $(PHOTON_STAGE)/common/data \
-f > \
$(PHOTON_LOGS_DIR)/installer.log 2>&1

Expand All @@ -125,6 +132,7 @@ ostree-host-iso: check $(PHOTON_STAGE) ostree-repo
-l $(PHOTON_STAGE)/LOGS \
-r $(PHOTON_STAGE)/RPMS \
-p $(PHOTON_DATA_DIR)/build_install_options_ostreehost.json \
-o $(PHOTON_STAGE)/common/data \
-f > \
$(PHOTON_LOGS_DIR)/installer.log 2>&1

Expand All @@ -136,6 +144,7 @@ live-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) minimal-iso
-l $(PHOTON_STAGE)/LOGS \
-r $(PHOTON_STAGE)/RPMS \
-p $(PHOTON_GENERATED_DATA_DIR)/build_install_options_livecd.json \
-o $(PHOTON_STAGE)/common/data \
-f > \
$(PHOTON_LOGS_DIR)/installer.log 2>&1

Expand All @@ -145,7 +154,7 @@ $(PHOTON_MINIMAL_DEPLIST): $(PREPARE_OUT_DATADIR)
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
--input-type=json --file packages_minimal.json -d json -a $(PHOTON_DATA_DIR)
--input-type=json --file $(MINIMAL_PACKAGE_LIST_FILE) -d json -a $(PHOTON_DATA_DIR)
@echo "generated the json file with all dependencies for minimal installation"

packages-minimal: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
Expand All @@ -158,7 +167,7 @@ packages-minimal: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES)
-b $(PHOTON_CHROOT_PATH) \
-l $(PHOTON_LOGS_DIR) \
-p $(PHOTON_PUBLISH_RPMS_DIR) \
-j $(PHOTON_DATA_DIR)/build_install_options_minimal.json \
-j $(PHOTON_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) \
-c $(PHOTON_BINTRAY_CONFIG) \
-d $(PHOTON_DIST_TAG) \
-t ${THREADS}
Expand All @@ -170,8 +179,8 @@ iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES) ostree-repo $(PHOTON_FULL_DEPLIST)
-w $(PHOTON_STAGE)/photon_iso \
-l $(PHOTON_STAGE)/LOGS \
-r $(PHOTON_STAGE)/RPMS \
-p $(PHOTON_DATA_DIR)/build_install_options_all.json \
-o $(PHOTON_STAGE)/common/data \
-p $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
-o $(PHOTON_STAGE)/common/data \
-f > \
$(PHOTON_LOGS_DIR)/installer.log 2>&1

Expand All @@ -181,15 +190,15 @@ $(PHOTON_FULL_DEPLIST): $(PHOTON_MINIMAL_DEPLIST)
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
--input-type=json --file packages_full.json -d json -a $(PHOTON_DATA_DIR)
--input-type=json --file $(FULL_PACKAGE_LIST_FILE) -d json -a $(PHOTON_DATA_DIR)
@echo "generated the json file with all dependencies for full installation"

deptree-full:
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
-i json -f packages_full.json -a $(PHOTON_DATA_DIR)
-i json -f $(FULL_PACKAGE_LIST_FILE) -a $(PHOTON_DATA_DIR)

deptree:
@cd $(PHOTON_SPECDEPS_DIR) && \
Expand All @@ -209,7 +218,7 @@ packages: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN)
-b $(PHOTON_CHROOT_PATH) \
-l $(PHOTON_LOGS_DIR) \
-p $(PHOTON_PUBLISH_RPMS_DIR) \
-j $(PHOTON_DATA_DIR)/build_install_options_all.json \
-j $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
-c $(PHOTON_BINTRAY_CONFIG) \
-d $(PHOTON_DIST_TAG) \
-t ${THREADS}
Expand All @@ -224,7 +233,7 @@ tool-chain-stage1: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN)
-b $(PHOTON_CHROOT_PATH) \
-l $(PHOTON_LOGS_DIR) \
-p $(PHOTON_PUBLISH_RPMS_DIR) \
-j $(PHOTON_DATA_DIR)/build_install_options_all.json \
-j $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
-t ${THREADS} \
-c $(PHOTON_BINTRAY_CONFIG) \
-d $(PHOTON_DIST_TAG) \
Expand All @@ -240,7 +249,7 @@ tool-chain-stage2: check $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN)
-b $(PHOTON_CHROOT_PATH) \
-l $(PHOTON_LOGS_DIR) \
-p $(PHOTON_PUBLISH_RPMS_DIR) \
-j $(PHOTON_DATA_DIR)/build_install_options_all.json \
-j $(PHOTON_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
-t ${THREADS} \
-c $(PHOTON_BINTRAY_CONFIG) \
-d $(PHOTON_DIST_TAG) \
Expand Down Expand Up @@ -371,6 +380,13 @@ photon-vagrant-local: check-packer check-vagrant
fi

cloud-image: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso
@echo "Generating the install time dependency list for "$(IMG_NAME)
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
--input-type=json --file build_install_options_$(IMG_NAME).json -d json -a $(PHOTON_DATA_DIR)
@echo "generated the json file with all dependencies for "$(IMG_NAME)
@echo "Building cloud image $(IMG_NAME)..."
@cd $(PHOTON_CLOUD_IMAGE_BUILDER_DIR)
@if [ -e $(PHOTON_STAGE)/photon.iso ]; then \
Expand All @@ -383,6 +399,13 @@ cloud-image: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso


cloud-image-all: $(PHOTON_STAGE) $(PHOTON_ISO_PATH) iso
@echo "Generating the install time dependency list for full installation"
@cd $(PHOTON_SPECDEPS_DIR) && \
$(PHOTON_SPECDEPS) \
-s $(PHOTON_SPECS_DIR) \
-t $(PHOTON_STAGE) \
--input-type=json --file $(CLOUDALL_PACKAGE_LIST_FILE) -d json -a $(PHOTON_DATA_DIR)
@echo "generated the json file with all dependencies for full installation"
@echo "Building cloud images - gce, ami, azure and ova..."
@cd $(PHOTON_CLOUD_IMAGE_BUILDER_DIR)
@if [ -e $(PHOTON_STAGE)/photon.iso ]; then \
Expand Down
38 changes: 38 additions & 0 deletions common/data/build_install_options_cloudall.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"iso" : {
"title" : "ISO Packages",
"file" : "packages_iso.json",
"visible" : false,
"include" : []
},
"minimal" : {
"title" : "Photon Minimal",
"file" : "packages_minimal.json",
"visible" : true,
"include" : []
},
"ami" : {
"title" : "Photon AMI packages",
"file" : "packages_ami.json",
"visible" : false,
"include" : ["minimal"]
},
"azure" : {
"title" : "Photon Azure packages",
"file" : "packages_azure.json",
"visible" : false,
"include" : ["minimal"]
},
"gce" : {
"title" : "Photon GCE packages",
"file" : "packages_gce.json",
"visible" : false,
"include" : ["minimal"]
},
"minimal_ova" : {
"title" : "Photon Minimal",
"file" : "packages_minimal_ova.json",
"visible" : false,
"include" : []
}
}
17 changes: 15 additions & 2 deletions support/SpecDeps/SpecDeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sys
import os
from optparse import OptionParser
from jsonwrapper import JsonWrapper

DEFAULT_INPUT_TYPE = "pkg"
DEFAULT_DISPLAY_OPTION = "tree"
Expand All @@ -26,8 +27,14 @@ def main():
parser.add_option("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR)
parser.add_option("-t", "--stage-dir", dest="stage_dir", default="../../stage")
parser.add_option("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/")

(options, args) = parser.parse_args()


if(False == options.input_data_dir.endswith('/')):
options.input_data_dir += '/'



specDeps = SerializedSpecObjects(options.input_data_dir, options.stage_dir)
displayOption = options.display_option
abs_path = os.path.abspath(__file__)
Expand All @@ -39,7 +46,13 @@ def main():
elif(options.input_type == "json"):
targetName = options.json_file

specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, targetName, displayOption)
# Generate the package dependencies based on package_list_file
json_wrapper_option_list = JsonWrapper(options.input_data_dir + options.json_file)
option_list_json = json_wrapper_option_list.read()
options_sorted = option_list_json.items()
for install_option in options_sorted:
if install_option[1]["file"] != "iso":
specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, install_option[1]["file"], displayOption)

sys.exit(0)

Expand Down
25 changes: 25 additions & 0 deletions support/SpecDeps/jsonwrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/python2
#
# Copyright (C) 2015 vmware inc.
#
# Author: Sharath George <sharathg@vmware.com>


import json
import collections

class JsonWrapper(object):

def __init__(self, filename):
self.filename = filename

def read(self):
json_data = open(self.filename)
self.data = json.load(json_data, object_pairs_hook=collections.OrderedDict)
json_data.close()
return self.data

def write(self, data):
self.data = data
outfile = open(self.filename, 'wb')
json.dump(data, outfile)

0 comments on commit 94cdb4d

Please sign in to comment.