+def bin_products_archives(config, logger, only_vcs):
+ '''Prepare binary packages for all products
+ :param config Config: The global configuration.
+ :return: the error status
+ :rtype: bool
+ '''
+
+ logger.write("Make %s binary archives\n" % config.VARS.dist)
+ # Get the default directory where to put the packages
+ binpackage_path = os.path.join(config.APPLICATION.workdir, "PACKAGE", "products")
+ src.ensure_path_exists(binpackage_path)
+ # Get the list of product installation to add to the archive
+ l_products_name = sorted(config.APPLICATION.products.keys())
+ l_product_info = src.product.get_products_infos(l_products_name,
+ config)
+ # first loop on products : filter products, analyse properties,
+ # and store the information that will be used to create the archive in the second loop
+ l_not_installed=[] # store not installed products for warning at the end
+ for prod_name, prod_info in l_product_info:
+ # ignore the native and fixed products for install directories
+ if (src.get_property_in_product_cfg(prod_info, "not_in_package") == "yes"
+ or src.product.product_is_native(prod_info)
+ or src.product.product_is_fixed(prod_info)
+ or not src.product.product_compiles(prod_info)):
+ continue
+ if only_vcs and not src.product.product_is_vcs(prod_info):
+ continue
+ if not src.product.check_installation(config, prod_info):
+ l_not_installed.append(prod_name)
+ continue # product is not installed, we skip it
+ # prepare call to make_bin_archive
+ path_targz_prod = os.path.join(binpackage_path, prod_name + '-' + prod_info.version + "-" + config.VARS.dist + PACKAGE_EXT)
+ targz_prod = tarfile.open(path_targz_prod, mode='w:gz')
+ bin_path = prod_info.install_dir
+ targz_prod.add(bin_path)
+ targz_prod.close()
+ # Python program to find MD5 hash value of a file
+ import hashlib
+ with open(path_targz_prod,"rb") as f:
+ bytes = f.read() # read file as bytes
+ readable_hash = hashlib.md5(bytes).hexdigest();
+ with open(path_targz_prod+".md5", "w") as md5sum:
+ md5sum.write("%s %s" % (readable_hash, os.path.basename(path_targz_prod)))
+ logger.write(" archive : %s (md5sum = %s)\n" % (path_targz_prod, readable_hash))
+
+ return 0
+