Compile script: Allow creating only Tar files

This commit is contained in:
Orsiris de Jong 2024-09-03 00:23:13 +02:00
parent 8cf3db3533
commit b74958001a

View file

@ -7,8 +7,8 @@ __intname__ = "npbackup.compile"
__author__ = "Orsiris de Jong" __author__ = "Orsiris de Jong"
__copyright__ = "Copyright (C) 2023-2024 NetInvent" __copyright__ = "Copyright (C) 2023-2024 NetInvent"
__license__ = "GPL-3.0-only" __license__ = "GPL-3.0-only"
__build__ = "2024052201" __build__ = "2024090301"
__version__ = "2.0.0" __version__ = "2.0.1"
""" """
@ -177,12 +177,13 @@ def have_nuitka_commercial():
return False return False
def compile(arch: str, audience: str, build_type: str, onefile: bool): def compile(arch: str, audience: str, build_type: str, onefile: bool, create_tar_only: bool):
if build_type not in BUILD_TYPES: if build_type not in BUILD_TYPES:
print("CANNOT BUILD BOGUS BUILD TYPE") print("CANNOT BUILD BOGUS BUILD TYPE")
sys.exit(1) sys.exit(1)
source_program = "bin/npbackup-{}".format(build_type) source_program = "bin/npbackup-{}".format(build_type)
if onefile: if onefile:
suffix = "-{}-{}".format(build_type, arch) suffix = "-{}-{}".format(build_type, arch)
@ -226,6 +227,7 @@ def compile(arch: str, audience: str, build_type: str, onefile: bool):
# npbackup compilation # npbackup compilation
# Strip possible version suffixes '-dev' # Strip possible version suffixes '-dev'
print(npbackup_version)
_npbackup_version = npbackup_version.split("-")[0] _npbackup_version = npbackup_version.split("-")[0]
PRODUCT_VERSION = _npbackup_version + ".0" PRODUCT_VERSION = _npbackup_version + ".0"
FILE_VERSION = _npbackup_version + ".0" FILE_VERSION = _npbackup_version + ".0"
@ -311,18 +313,20 @@ def compile(arch: str, audience: str, build_type: str, onefile: bool):
source_program, source_program,
) )
print(CMD)
errors = False errors = False
exit_code, output = command_runner(CMD, timeout=0, live_output=True) if not create_tar_only:
if exit_code != 0: print(CMD)
errors = True exit_code, output = command_runner(CMD, timeout=0, live_output=True)
if exit_code != 0:
errors = True
## Create version file
with open(
os.path.join(BUILDS_DIR, audience, "VERSION"), "w", encoding="utf-8"
) as fh:
fh.write(npbackup_version)
print(f"COMPILED {'WITH SUCCESS' if not errors else 'WITH ERRORS'}")
## Create version file
with open(
os.path.join(BUILDS_DIR, audience, "VERSION"), "w", encoding="utf-8"
) as fh:
fh.write(npbackup_version)
print(f"COMPILED {'WITH SUCCESS' if not errors else 'WITH ERRORS'}")
if not onefile: if not onefile:
if not create_archive( if not create_archive(
platform=platform, platform=platform,
@ -413,6 +417,14 @@ if __name__ == "__main__":
help="Build single file executable (more prone to AV detection)", help="Build single file executable (more prone to AV detection)",
) )
parser.add_argument(
"--create-tar-only",
action="store_true",
default=False,
required=False,
help="Only create tar files, shortcut when we need to package signed binaries"
)
args = parser.parse_args() args = parser.parse_args()
# Make sure we get out dev environment back when compilation ends / fails # Make sure we get out dev environment back when compilation ends / fails
@ -420,6 +432,7 @@ if __name__ == "__main__":
move_audience_files, move_audience_files,
"private", "private",
) )
try: try:
errors = False errors = False
if args.audience.lower() == "all": if args.audience.lower() == "all":
@ -435,42 +448,47 @@ if __name__ == "__main__":
else: else:
build_types = BUILD_TYPES build_types = BUILD_TYPES
for audience in audiences: create_tar_only = args.create_tar_only
move_audience_files(audience)
npbackup_version = get_metadata(os.path.join(BASEDIR, "__version__.py"))[
"version"
]
private_build = check_private_build(audience) for audience in audiences:
if private_build and audience != "private": npbackup_version = get_metadata(os.path.join(BASEDIR, "__version__.py"))[
print("ERROR: Requested public build but private data available") "version"
errors = True ]
continue if not create_tar_only:
elif not private_build and audience != "public": move_audience_files(audience)
print("ERROR: Requested private build but no private data available")
errors = True private_build = check_private_build(audience)
continue if private_build and audience != "private":
print("ERROR: Requested public build but private data available")
errors = True
continue
elif not private_build and audience != "public":
print("ERROR: Requested private build but no private data available")
errors = True
continue
for build_type in build_types: for build_type in build_types:
result = compile( result = compile(
arch=python_arch(), arch=python_arch(),
audience=audience, audience=audience,
build_type=build_type, build_type=build_type,
onefile=args.onefile, onefile=args.onefile,
create_tar_only=create_tar_only
) )
audience_build = "private" if private_build else "public" if not create_tar_only:
if result: audience_build = "private" if private_build else "public"
print( if result:
"SUCCESS: MADE {} build for audience {}".format( print(
audience_build, audience "SUCCESS: MADE {} build for audience {}".format(
audience_build, audience
)
) )
) else:
else: print(
print( "ERROR: Failed making {} build for audience {}".format(
"ERROR: Failed making {} build for audience {}".format( audience_build, audience
audience_build, audience )
) )
) errors = True
errors = True
if errors: if errors:
print("ERRORS IN BUILD PROCESS") print("ERRORS IN BUILD PROCESS")
else: else: