[DEV] zip data for windows and create a zip package for final output
This commit is contained in:
parent
092843cd02
commit
71e0f242bf
@ -780,6 +780,7 @@ class Target:
|
||||
## @param[in] static The package is build in static mode
|
||||
##
|
||||
def make_package(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
|
||||
debug.debug("make_package [START]")
|
||||
#The package generated depend of the type of the element:
|
||||
end_point_module_name = heritage_list.list_heritage[-1].name
|
||||
module = self.get_module(end_point_module_name)
|
||||
@ -801,6 +802,7 @@ class Target:
|
||||
if module.get_type() == 'PACKAGE':
|
||||
debug.info("Can not create package for package");
|
||||
return
|
||||
debug.debug("make_package [STOP]")
|
||||
return
|
||||
|
||||
##
|
||||
@ -813,6 +815,7 @@ class Target:
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def make_package_binary_data(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
debug.debug("make_package_binary_data [START]")
|
||||
target_shared_path = os.path.join(path_package, self.pkg_path_data)
|
||||
if static == True:
|
||||
path_package_data = os.path.join(target_shared_path, pkg_name)
|
||||
@ -847,6 +850,7 @@ class Target:
|
||||
ret_copy = tools.copy_list(copy_list)
|
||||
# remove unneded files (NOT folder ...)
|
||||
ret_remove = tools.clean_directory(target_shared_path, copy_list)
|
||||
debug.debug("make_package_binary_data [STOP]")
|
||||
return ret_copy or ret_remove
|
||||
|
||||
##
|
||||
@ -859,6 +863,7 @@ class Target:
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def make_package_binary_bin(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
debug.debug("make_package_binary_bin [START]")
|
||||
copy_list={}
|
||||
path_package_bin = os.path.join(path_package, self.pkg_path_bin)
|
||||
tools.create_directory_of_file(path_package_bin)
|
||||
@ -874,6 +879,7 @@ class Target:
|
||||
if self.pkg_path_bin != "":
|
||||
# remove unneded files (NOT folder ...)
|
||||
ret_remove = tools.clean_directory(path_package_bin, copy_list)
|
||||
debug.debug("make_package_binary_bin [STOP]")
|
||||
return ret_copy or ret_remove
|
||||
|
||||
##
|
||||
@ -886,6 +892,7 @@ class Target:
|
||||
## @return False Nothing has been copied
|
||||
##
|
||||
def make_package_binary_lib(self, path_package, pkg_name, base_pkg_path, heritage_list, static):
|
||||
debug.debug("make_package_binary_lib [START]")
|
||||
copy_list={}
|
||||
path_package_lib = os.path.join(path_package, self.pkg_path_lib)
|
||||
if static == False:
|
||||
@ -909,10 +916,12 @@ class Target:
|
||||
if self.pkg_path_lib != "":
|
||||
# remove unneded files (NOT folder ...)
|
||||
ret_remove = tools.clean_directory(path_package_lib, copy_list)
|
||||
debug.debug("make_package_binary_lib [STOP]")
|
||||
return ret_copy or ret_remove
|
||||
|
||||
|
||||
def make_package_generic_files(self, path_package, pkg_properties, pkg_name, base_pkg_path, heritage_list, static):
|
||||
debug.debug("make_package_generic_files [START]")
|
||||
## Create version file:
|
||||
ret_version = tools.file_write_data(os.path.join(path_package, self.pkg_path_version_file),
|
||||
tools.version_to_string(pkg_properties["VERSION"]),
|
||||
@ -973,6 +982,7 @@ class Target:
|
||||
ret_changelog = tools.file_write_data(change_log_file_dest,
|
||||
"No changelog data " + pkg_name + "\n",
|
||||
only_if_new=True)
|
||||
debug.debug("make_package_generic_files [STOP]")
|
||||
return ret_version \
|
||||
or ret_maintainer \
|
||||
or ret_appl_name \
|
||||
|
@ -63,16 +63,28 @@ class Target(lutinTarget_Linux.Target):
|
||||
tools.create_directory_of_file(target_outpath)
|
||||
|
||||
## Create share datas:
|
||||
self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_share = self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## copy binary files:
|
||||
self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_bin = self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create libraries:
|
||||
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_lib = self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_file = self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## end of the package generation
|
||||
build_package_path_done = os.path.join(self.get_build_path(pkg_name), "generatePackageDone.txt")
|
||||
#Check date between the current file "list of action to generate package and the end of package generation
|
||||
need_generate_package = depend.need_re_package(build_package_path_done, [__file__], True)
|
||||
|
||||
## create the package:
|
||||
if ret_share \
|
||||
or ret_bin \
|
||||
or ret_lib \
|
||||
or ret_file \
|
||||
or need_generate_package:
|
||||
"""
|
||||
## create the package:
|
||||
debug.debug("package : " + self.get_staging_path(pkg_name) + "/" + pkg_name + ".app.pkg")
|
||||
@ -158,6 +170,9 @@ class Target(lutinTarget_Linux.Target):
|
||||
tools.create_directory_of_file(self.get_final_path())
|
||||
tools.copy_file(self.get_staging_path("") + "/" + pkg_name + self.suffix_package, self.get_final_path() + "/" + pkg_name + self.suffix_package)
|
||||
|
||||
# package is done corectly ...
|
||||
tools.file_write_data(build_package_path_done, "done...")
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
debug.info("Install package '" + pkg_name + "'")
|
||||
|
@ -105,17 +105,28 @@ class Target(target.Target):
|
||||
tools.create_directory_of_file(target_outpath)
|
||||
|
||||
## Create share datas:
|
||||
self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_share = self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## copy binary files:
|
||||
self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_bin = self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create libraries:
|
||||
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_lib = self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_file = self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## end of the package generation
|
||||
build_package_path_done = os.path.join(self.get_build_path(pkg_name), "generatePackageDone.txt")
|
||||
#Check date between the current file "list of action to generate package and the end of package generation
|
||||
need_generate_package = depend.need_re_package(build_package_path_done, [__file__], True)
|
||||
|
||||
## create the package:
|
||||
if ret_share \
|
||||
or ret_bin \
|
||||
or ret_lib \
|
||||
or ret_file \
|
||||
or need_generate_package:
|
||||
## Create icon:
|
||||
if "ICON" in pkg_properties.keys() \
|
||||
and pkg_properties["ICON"] != "":
|
||||
@ -362,6 +373,8 @@ class Target(target.Target):
|
||||
cmdLine += ' --entitlements ' + os.path.join(self.get_build_path(pkg_name), pkg_name + ".xcent")
|
||||
cmdLine += ' ' + os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app")
|
||||
multiprocess.run_command(cmdLine)
|
||||
# package is done corectly ...
|
||||
tools.file_write_data(build_package_path_done, "done...")
|
||||
|
||||
def create_random_number(self, len):
|
||||
out = ""
|
||||
|
@ -103,16 +103,24 @@ class Target(target.Target):
|
||||
## Create generic files:
|
||||
ret_file = self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## end of the package generation
|
||||
build_package_path_done = os.path.join(self.get_build_path(pkg_name), "generatePackageDone.txt")
|
||||
#Check date between the current file "list of action to generate package and the end of package generation
|
||||
need_generate_package = depend.need_re_package(build_package_path_done, [__file__], True)
|
||||
|
||||
## create the package:
|
||||
if ret_share \
|
||||
or ret_bin \
|
||||
or ret_lib \
|
||||
or ret_file:
|
||||
or ret_file \
|
||||
or need_generate_package:
|
||||
debug.debug("package : " + os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app.pkg"))
|
||||
os.system("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
|
||||
#multiprocess.run_command("cd " + self.get_staging_path(pkg_name) + " ; tar -czf " + pkg_name + ".app.tar.gz " + pkg_name + ".app")
|
||||
tools.create_directory_of_file(self.get_final_path())
|
||||
tools.copy_file(os.path.join(self.get_staging_path(pkg_name), pkg_name + ".app.tar.gz"), os.path.join(self.get_final_path(), pkg_name + ".app.gpkg"))
|
||||
# package is done corectly ...
|
||||
tools.file_write_data(build_package_path_done, "done...")
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
@ -71,16 +71,28 @@ class Target(target.Target):
|
||||
tools.create_directory_of_file(target_outpath)
|
||||
|
||||
## Create share datas:
|
||||
self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_share = self.make_package_binary_data(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## copy binary files:
|
||||
self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_bin = self.make_package_binary_bin(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create libraries:
|
||||
self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_lib = self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create generic files:
|
||||
self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_file = self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## end of the package generation
|
||||
build_package_path_done = os.path.join(self.get_build_path(pkg_name), "generatePackageDone.txt")
|
||||
#Check date between the current file "list of action to generate package and the end of package generation
|
||||
need_generate_package = depend.need_re_package(build_package_path_done, [__file__], True)
|
||||
|
||||
## create the package:
|
||||
if ret_share \
|
||||
or ret_bin \
|
||||
or ret_lib \
|
||||
or ret_file \
|
||||
or need_generate_package:
|
||||
|
||||
## Create icon (no convertion ==> TODO: must test if png is now supported):
|
||||
if "ICON" in pkg_properties.keys() \
|
||||
@ -138,6 +150,7 @@ class Target(target.Target):
|
||||
## user information:
|
||||
#debug.info("You can have an shell interface by executing : ")
|
||||
#debug.info(" sudo cp " + shell_file_name + " /usr/local/bin")
|
||||
tools.file_write_data(build_package_path_done, "done...")
|
||||
|
||||
def install_package(self, pkg_name):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
@ -12,6 +12,7 @@ from lutin import debug
|
||||
from lutin import target
|
||||
from lutin import tools
|
||||
from lutin import host
|
||||
from lutin import depend
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
@ -71,8 +72,8 @@ class Target(target.Target):
|
||||
self.support_dynamic_link = False
|
||||
|
||||
|
||||
def get_staging_path_data(self, binary_name, heritage_list):
|
||||
return self.get_staging_path(binary_name) + self.path_data
|
||||
def get_staging_path_data(self, binary_name):
|
||||
return os.path.join(self.get_staging_path(binary_name), binary_name + ".app", self.pkg_path_data)
|
||||
|
||||
def make_package_binary(self, pkg_name, pkg_properties, base_pkg_path, heritage_list, static):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
@ -92,14 +93,34 @@ class Target(target.Target):
|
||||
ret_lib = self.make_package_binary_lib(target_outpath, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
## Create generic files:
|
||||
ret_file = self.make_package_generic_files(target_outpath, pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
ret_file = self.make_package_generic_files(target_outpath+"/pkg", pkg_properties, pkg_name, base_pkg_path, heritage_list, static)
|
||||
|
||||
build_package_path_done = os.path.join(self.get_build_path(pkg_name), "generatePackageDone.txt")
|
||||
#Check date between the current file "list of action to generate package and the end of package generation
|
||||
need_generate_package = depend.need_re_package(build_package_path_done, [__file__], True)
|
||||
## create the package:
|
||||
if ret_share \
|
||||
or ret_bin \
|
||||
or ret_lib \
|
||||
or ret_file:
|
||||
debug.info("TODO: create a windows pkg ...")
|
||||
or ret_file \
|
||||
or need_generate_package:
|
||||
# Zip the data
|
||||
debug.print_element("zip", "data.zip", "<==", self.get_staging_path_data(pkg_name) + "/*")
|
||||
zip_path = os.path.join(self.get_staging_path(pkg_name), "data.zip")
|
||||
zip.create_zip([
|
||||
self.get_staging_path_data(pkg_name),
|
||||
target_outpath+"/pkg"
|
||||
], zip_path)
|
||||
zip_path_final = os.path.join(self.get_final_path(), pkg_name + ".zip")
|
||||
# generate deployed zip (for user)
|
||||
debug.print_element("zip", pkg_name + ".zip", "<==", self.get_staging_path(pkg_name))
|
||||
zip.create_zip_file([
|
||||
zip_path,
|
||||
os.path.join(target_outpath, pkg_name + self.suffix_binary)
|
||||
],
|
||||
zip_path_final)
|
||||
|
||||
tools.file_write_data(build_package_path_done, "done...")
|
||||
|
||||
def make_package_single_file(self, pkg_name, pkg_properties, base_pkg_path, heritage_list):
|
||||
debug.debug("------------------------------------------------------------------------")
|
||||
|
24
lutin/zip.py
24
lutin/zip.py
@ -18,15 +18,31 @@ from . import tools
|
||||
|
||||
def create_zip(path, outputFile):
|
||||
debug.debug("Create Zip : '" + outputFile + "'")
|
||||
debug.debug(" from '" + path + "'")
|
||||
basePathlen = len(path)
|
||||
tools.create_directory_of_file(outputFile)
|
||||
debug.debug(" from '" + str(path) + "'")
|
||||
if tools.get_type_string(path) == "string":
|
||||
path = [path]
|
||||
zf = zipfile.ZipFile(outputFile, mode='w')
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
for elem in path:
|
||||
basePathlen = len(elem)
|
||||
for root, dirnames, filenames in os.walk(elem):
|
||||
# List all files :
|
||||
for filename in filenames:
|
||||
file = os.path.join(root, filename)
|
||||
debug.verbose(" ADD zip = " + str(file))
|
||||
debug.verbose(" ADD zip = " + str(file) + " ==> " +file[basePathlen:])
|
||||
zf.write(file, file[basePathlen:])
|
||||
zf.close()
|
||||
|
||||
def create_zip_file(files, outputFile):
|
||||
debug.debug("Create Zip : '" + outputFile + "'")
|
||||
tools.create_directory_of_file(outputFile)
|
||||
debug.debug(" from '" + str(files) + "'")
|
||||
if tools.get_type_string(files) == "string":
|
||||
files = [files]
|
||||
zf = zipfile.ZipFile(outputFile, mode='w')
|
||||
for elem in files:
|
||||
debug.verbose(" ADD zip = " + str(elem) + " ==> " + elem[len(os.path.dirname(elem)):])
|
||||
zf.write(elem, elem[len(os.path.dirname(elem)):])
|
||||
zf.close()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user