From da9662533a8c0f961a0e2a0c190b06c6c2e5417b Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sun, 22 Dec 2024 20:29:09 +0100 Subject: [PATCH] fix(editor_vscode): use the packaged version of VSCode Signed-off-by: Matej Focko --- .../files/code-url-handler.desktop | 12 ------- roles/editor_vscode/files/code.desktop | 18 ---------- roles/editor_vscode/files/update.sh | 31 ----------------- .../editor_vscode/tasks/install_AlmaLinux.yml | 1 + roles/editor_vscode/tasks/install_CentOS.yml | 1 + roles/editor_vscode/tasks/install_Fedora.yml | 1 + roles/editor_vscode/tasks/install_Rocky.yml | 1 + roles/editor_vscode/tasks/install_rhel.yml | 12 +++++++ roles/editor_vscode/tasks/main.yml | 33 +++---------------- 9 files changed, 21 insertions(+), 89 deletions(-) delete mode 100644 roles/editor_vscode/files/code-url-handler.desktop delete mode 100644 roles/editor_vscode/files/code.desktop delete mode 100644 roles/editor_vscode/files/update.sh create mode 120000 roles/editor_vscode/tasks/install_AlmaLinux.yml create mode 120000 roles/editor_vscode/tasks/install_CentOS.yml create mode 120000 roles/editor_vscode/tasks/install_Fedora.yml create mode 120000 roles/editor_vscode/tasks/install_Rocky.yml create mode 100644 roles/editor_vscode/tasks/install_rhel.yml diff --git a/roles/editor_vscode/files/code-url-handler.desktop b/roles/editor_vscode/files/code-url-handler.desktop deleted file mode 100644 index c750536..0000000 --- a/roles/editor_vscode/files/code-url-handler.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Name=Visual Studio Code - URL Handler -Comment=Code Editing. Redefined. -GenericName=Text Editor -Exec=/opt/VSCode-linux-x64/bin/code-insiders --no-sandbox --open-url %U -Icon=/opt/VSCode-linux-x64/resources/app/resources/linux/code.png -Type=Application -NoDisplay=true -StartupNotify=true -Categories=Utility;TextEditor;Development;IDE; -MimeType=x-scheme-handler/vscode-insiders; -Keywords=vscode; diff --git a/roles/editor_vscode/files/code.desktop b/roles/editor_vscode/files/code.desktop deleted file mode 100644 index d4cf29e..0000000 --- a/roles/editor_vscode/files/code.desktop +++ /dev/null @@ -1,18 +0,0 @@ -[Desktop Entry] -Name=Visual Studio Code Insiders -Comment=Code Editing. Refined. -GenericName=Text Editor -Exec=/opt/VSCode-linux-x64/bin/code-insiders --no-sandbox --unity-launch %F -Icon=/opt/VSCode-linux-x64/resources/app/resources/linux/code.png -Type=Application -StartupNotify=false -StartupWMClass=code - insiders -Categories=Utility;TextEditor;Development;IDE; -MimeType=text/plain;inode/directory; -Actions=new-empty-window; -Keywords=vscode; - -[Desktop Action new-empty-window] -Name=New Empty Window -Exec=/opt/VSCode-linux-x64/bin/code-insiders --no-sandbox --new-window %F -Icon=/opt/VSCode-linux-x64/resources/app/resources/linux/code.png diff --git a/roles/editor_vscode/files/update.sh b/roles/editor_vscode/files/update.sh deleted file mode 100644 index dba9dee..0000000 --- a/roles/editor_vscode/files/update.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# for upstream -URL='https://code.visualstudio.com/sha/download?build=insider&os=linux-x64' - -# for local -# URL='https://maxwell.mfocko.xyz/code-insiders.tar.gz' - -# for local over VPN (also use --no-check-certificate) -# URL='https://172.16.0.2/code-insiders.tar.gz' - -echo ">>> Downloading"; -wget $URL -O /tmp/code.tar.gz - -echo ">>> Removing and extracting"; -rm -rf /opt/VSCode-linux-x64 -tar xvaf /tmp/code.tar.gz -C /opt/ - -# Check for binaries -if ! [ -x /usr/local/bin/code-insiders ]; then - echo ">>> Linking binaries"; - ln -s /opt/VSCode-linux-x64/bin/code-insiders /usr/local/bin/ - ln -s /opt/VSCode-linux-x64/bin/code-insiders /usr/local/bin/code -fi - -# Check for *.desktop -if ! ls /usr/share/applications | grep visual-studio-code; then - echo ">>> Installing desktop files"; - PATH_TO_APPS=/home/mfocko/.local/share/visual-studio-code-insiders - sudo cp $PATH_TO_APPS{,-url-handler}.desktop /usr/share/applications/; -fi diff --git a/roles/editor_vscode/tasks/install_AlmaLinux.yml b/roles/editor_vscode/tasks/install_AlmaLinux.yml new file mode 120000 index 0000000..c10604b --- /dev/null +++ b/roles/editor_vscode/tasks/install_AlmaLinux.yml @@ -0,0 +1 @@ +install_rhel.yml \ No newline at end of file diff --git a/roles/editor_vscode/tasks/install_CentOS.yml b/roles/editor_vscode/tasks/install_CentOS.yml new file mode 120000 index 0000000..c10604b --- /dev/null +++ b/roles/editor_vscode/tasks/install_CentOS.yml @@ -0,0 +1 @@ +install_rhel.yml \ No newline at end of file diff --git a/roles/editor_vscode/tasks/install_Fedora.yml b/roles/editor_vscode/tasks/install_Fedora.yml new file mode 120000 index 0000000..c10604b --- /dev/null +++ b/roles/editor_vscode/tasks/install_Fedora.yml @@ -0,0 +1 @@ +install_rhel.yml \ No newline at end of file diff --git a/roles/editor_vscode/tasks/install_Rocky.yml b/roles/editor_vscode/tasks/install_Rocky.yml new file mode 120000 index 0000000..c10604b --- /dev/null +++ b/roles/editor_vscode/tasks/install_Rocky.yml @@ -0,0 +1 @@ +install_rhel.yml \ No newline at end of file diff --git a/roles/editor_vscode/tasks/install_rhel.yml b/roles/editor_vscode/tasks/install_rhel.yml new file mode 100644 index 0000000..ddd8085 --- /dev/null +++ b/roles/editor_vscode/tasks/install_rhel.yml @@ -0,0 +1,12 @@ +--- +- name: Resolve URL to the VSCode RPM + ansible.builtin.uri: + url: https://code.visualstudio.com/sha/download?build=insider&os=linux-rpm-x64 + register: _vscode_rpm_response + +- name: Install VSCode via RPM + ansible.builtin.dnf: + name: "{{ _vscode_rpm_response.url }}" + disable_gpg_check: true + state: present + become: true diff --git a/roles/editor_vscode/tasks/main.yml b/roles/editor_vscode/tasks/main.yml index a2a50d1..efb2aed 100644 --- a/roles/editor_vscode/tasks/main.yml +++ b/roles/editor_vscode/tasks/main.yml @@ -1,28 +1,13 @@ --- +- name: Install VSCode + ansible.builtin.include_tasks: "install_{{ ansible_distribution }}.yml" + tags: install + - name: Create directories for VSCode ansible.builtin.file: - path: "{{ item }}" + path: "$HOME/.config/Code - Insiders/User" state: directory mode: 0740 - loop: - - ~/.local/bin - - ~/.local/share - - "$HOME/.config/Code - Insiders/User" - -- name: Install VSCode script - ansible.builtin.copy: - src: files/update.sh - dest: ~/.local/bin/code-update.sh - mode: 0640 - -- name: Create app info for VSCode - ansible.builtin.copy: - src: files/code{{ item }}.desktop - dest: ~/.local/share/applications/visual-studio-code-insiders{{ item }}.desktop - mode: 0640 - loop: - - "" - - "-url-handler" - name: Install VSCode configuration ansible.builtin.copy: @@ -32,11 +17,3 @@ loop: - settings - keybindings - -- name: Install VSCode - ansible.builtin.command: - cmd: bash /home/{{ target_user }}/.local/bin/code-update.sh - creates: /opt/VSCode-linux-x64 - become: true - when: false - tags: install