Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2022-06-30 15:17:45 +0300
committerGhostkeeper <rubend@tutanota.com>2022-06-30 15:43:51 +0300
commitc2f3161fb6eb4bdb7a5724bbd5dac9b51990cebd (patch)
tree3c642cbddbb838cfb205a15cfd02f2ade5afda88 /packaging
parent394942e2cfe88f13d3826af7b62f1708c8999758 (diff)
Allow providing dist_path and version via command line arguments
Previously you had to call the script from the dist path specifically, using the cwd as a parameter. Now you can provide a different path, allowing you to call this script from any location. Also the version number used to be hard-coded. Now that can be provided by the caller. Contributes to issue CURA-9409.
Diffstat (limited to 'packaging')
-rw-r--r--packaging/create_appimage.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/packaging/create_appimage.py b/packaging/create_appimage.py
index c51bb4ad16..c6967398e2 100644
--- a/packaging/create_appimage.py
+++ b/packaging/create_appimage.py
@@ -1,31 +1,30 @@
# Copyright (c) 2022 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
+import argparse # Command line arguments parsing and help.
import os # Finding installation directory.
import os.path # Finding files.
import shutil # Copying files.
import stat # For setting file permissions.
import subprocess # For calling system commands.
-dist_path = os.getcwd() # TODO: Figure out where this is.
-appimage_filename = "Ultimaker-Cura_test.AppImage" # TODO: Get the proper file name.
-
-def build_appimage():
+def build_appimage(dist_path, version):
"""
Creates an AppImage file from the build artefacts created so far.
"""
- copy_metadata_files()
+ copy_metadata_files(dist_path)
+ appimage_filename = f"Ultimaker-Cura_{version}.AppImage"
try:
os.remove(os.path.join(dist_path, appimage_filename)) # Ensure any old file is removed, if it exists.
except FileNotFoundError:
pass # If it didn't exist, that's even better.
- generate_appimage()
+ generate_appimage(dist_path, appimage_filename)
- sign_appimage()
+ sign_appimage(dist_path, appimage_filename)
-def copy_metadata_files():
+def copy_metadata_files(dist_path):
"""
Copy metadata files for the metadata of the AppImage.
"""
@@ -44,14 +43,14 @@ def copy_metadata_files():
# Ensure that AppRun has the proper permissions: 755 (user reads, writes and executes, group reads and executes, world reads and executes).
os.chmod(os.path.join(dist_path, "AppRun"), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
-def generate_appimage():
+def generate_appimage(dist_path, appimage_filename):
appimage_path = os.path.join(dist_path, appimage_filename)
command = ["appimagetool", "--appimage-extract-and-run", f"{dist_path}/", appimage_path]
result = subprocess.call(command)
if result != 0:
raise RuntimeError(f"The AppImageTool command returned non-zero: {result}")
-def sign_appimage():
+def sign_appimage(dist_path, appimage_filename):
appimage_path = os.path.join(dist_path, appimage_filename)
command = ["gpg", "--yes", "--armor", "--detach-sig", appimage_path]
result = subprocess.call(command)
@@ -59,4 +58,8 @@ def sign_appimage():
raise RuntimeError(f"The GPG command returned non-zero: {result}")
if __name__ == "__main__":
- build_appimage()
+ parser = argparse.ArgumentParser(description = "Create AppImages of Cura.")
+ parser.add_argument("dist_path", type=str, help="Path to where PyInstaller installed the distribution of Cura.")
+ parser.add_argument("version", type=str, help="Full version number of Cura (e.g. '5.1.0-beta')")
+ args = parser.parse_args()
+ build_appimage(args.dist_path, args.version)