From ec4812e873655051d85e4acd39123df270f4fea7 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 28 Aug 2023 10:39:54 +0200 Subject: [PATCH 1/4] #113 fix inkscape install for other linux distros (non ubuntu) --- inkscape-setup-action/action.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/inkscape-setup-action/action.yml b/inkscape-setup-action/action.yml index d465f71..fc76eb1 100644 --- a/inkscape-setup-action/action.yml +++ b/inkscape-setup-action/action.yml @@ -11,6 +11,8 @@ runs: win_prefix = "C:\\Program Files\\Inkscape\\bin" + platform_name = "Ubuntu" if 'ubuntu' in platform.version().lower() else platform.system() + cmds = { "Darwin": [ "HOMEBREW_CASK_OPTS='--no-quarantine' brew install --cask inkscape", "inkscape --version" ], "Windows": [ @@ -18,13 +20,19 @@ runs: "echo {}>> {}".format(win_prefix, os.environ["GITHUB_PATH"]), "\"{}\\inkscape\" --version".format(win_prefix) ], - "Linux": [ + "Ubuntu": [ "sudo add-apt-repository ppa:inkscape.dev/stable", "sudo apt update", "sudo apt install inkscape", + "which inkscape", + "inkscape --version" + ], + "Linux": [ + "wget https://inkscape.org/gallery/item/42330/Inkscape-0e150ed-x86_64.AppImage -O /usr/local/bin/inkscape", + "sudo chmod +x /usr/local/bin/inkscape", "inkscape --version" ] - }.get(platform.system(), [ "echo \"Unsupported platform: {}\"".format(platform.system()), "exit 1" ]) + }.get(platform_name, [ "echo \"Unsupported platform: {}\"".format(platform_name), "exit 1" ]) for cmd in cmds: if os.system(cmd) != 0: From 3f7b7db0ea965a6fcc09e3f7564462ee2be97892 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 28 Aug 2023 11:38:37 +0200 Subject: [PATCH 2/4] Add ppa:inkscape.dev/stable for ubuntu only repos in docker-gem-install --- docker-gem-install/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-gem-install/action.yml b/docker-gem-install/action.yml index 60b414b..4dc6526 100644 --- a/docker-gem-install/action.yml +++ b/docker-gem-install/action.yml @@ -8,7 +8,9 @@ runs: using: "composite" steps: - run: | - add-apt-repository ppa:inkscape.dev/stable + if uname -a | grep -qi ubuntu; then + add-apt-repository ppa:inkscape.dev/stable + fi apt-get update -y && apt-get install -y gcc g++ ruby-dev shell: bash From 517087dc9230a917680b86abbc8ece977ef2119f Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 28 Aug 2023 14:32:03 +0200 Subject: [PATCH 3/4] #113 Debian can use Ubuntu's kernel, check actual os via /etc/os-release --- docker-gem-install/action.yml | 3 ++- inkscape-setup-action/action.yml | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docker-gem-install/action.yml b/docker-gem-install/action.yml index 4dc6526..fea2f37 100644 --- a/docker-gem-install/action.yml +++ b/docker-gem-install/action.yml @@ -8,7 +8,8 @@ runs: using: "composite" steps: - run: | - if uname -a | grep -qi ubuntu; then + source /etc/os-release + if [ "$ID" == "ubuntu" ]; then add-apt-repository ppa:inkscape.dev/stable fi apt-get update -y && apt-get install -y gcc g++ ruby-dev diff --git a/inkscape-setup-action/action.yml b/inkscape-setup-action/action.yml index fc76eb1..cfac063 100644 --- a/inkscape-setup-action/action.yml +++ b/inkscape-setup-action/action.yml @@ -11,7 +11,14 @@ runs: win_prefix = "C:\\Program Files\\Inkscape\\bin" - platform_name = "Ubuntu" if 'ubuntu' in platform.version().lower() else platform.system() + def get_platform_name(): + try: + os_release_id = platform.freedesktop_os_release()["ID"] + return "Ubuntu" if os_release_id == "Ubuntu" else platform.system() + except AttributeError: + return platform.system() + + platform_name = get_platform_name() cmds = { "Darwin": [ "HOMEBREW_CASK_OPTS='--no-quarantine' brew install --cask inkscape", "inkscape --version" ], From 0f7fac92b5f7d15cb376d385728e1a3c9ebc5e30 Mon Sep 17 00:00:00 2001 From: Alexande B Date: Mon, 28 Aug 2023 15:02:22 +0200 Subject: [PATCH 4/4] #113 implement fallback code if executed on python2 --- inkscape-setup-action/action.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/inkscape-setup-action/action.yml b/inkscape-setup-action/action.yml index cfac063..d12ef06 100644 --- a/inkscape-setup-action/action.yml +++ b/inkscape-setup-action/action.yml @@ -11,14 +11,27 @@ runs: win_prefix = "C:\\Program Files\\Inkscape\\bin" - def get_platform_name(): + def os_release(): try: - os_release_id = platform.freedesktop_os_release()["ID"] - return "Ubuntu" if os_release_id == "Ubuntu" else platform.system() + return platform.freedesktop_os_release() except AttributeError: - return platform.system() + properties = {} + try: + with open("/etc/os-release", "r") as file: + for line in file: + line = line.strip() + if line and not line.startswith("#"): + key, value = line.split("=", 1) + properties[key] = value.strip('"') + except: + pass + return properties - platform_name = get_platform_name() + os_release_dict = os_release() + + print(os_release_dict) + + platform_name = "Ubuntu" if os_release_dict.get("ID", None) == "ubuntu" else platform.system() cmds = { "Darwin": [ "HOMEBREW_CASK_OPTS='--no-quarantine' brew install --cask inkscape", "inkscape --version" ],