From d6bdd04494c4e675673d1720574fbd8990405e06 Mon Sep 17 00:00:00 2001 From: Andri Joos <andri@joos.io> Date: Thu, 9 Jan 2025 16:44:34 +0100 Subject: [PATCH] add jan appimage --- helper_scripts/packages.sh | 33 +++++++++++ install.sh | 31 +--------- .../appimage_installation.yaml | 27 +++++++++ tasks/general_templates/wget_file.yaml | 9 +++ tasks/general_templates/wget_install.yaml | 14 ++--- tasks/raw_packages.yaml | 58 +++++++++++++++++++ variables/editable_variables.yaml | 2 +- 7 files changed, 135 insertions(+), 39 deletions(-) create mode 100644 tasks/general_templates/appimage_installation.yaml create mode 100644 tasks/general_templates/wget_file.yaml diff --git a/helper_scripts/packages.sh b/helper_scripts/packages.sh index 0b639d4..3d67695 100644 --- a/helper_scripts/packages.sh +++ b/helper_scripts/packages.sh @@ -60,9 +60,11 @@ FLATPAK_REMMINA_PACKAGE_DISPLAY_NAME="Remmina" # Raw packages RAW_GITEXTENSIONS_PACKAGE="$RAW_IDENTIFIER:gitextensions" RAW_K3D_PACKAGE="$RAW_IDENTIFIER:k3d" +RAW_JAN_PACKAGE="$RAW_IDENTIFIER:jan" RAW_GITEXTENSIONS_PACKAGE_DISPLAY_NAME="GitExtensions" RAW_K3D_PACKAGE_DISPLAY_NAME="k3d" +RAW_JAN_PACKAGE_DISPLAY_NAME="Jan Local AI Assistant" # Mainline kernel MAINLINE_KERNEL_PACKAGE="$MAINLINE_KERNEL_IDENTIFIER" @@ -98,4 +100,35 @@ PACKAGES=( ["$SNAP_FIREFOX_PACKAGE"]="$SNAP_FIREFOX_PACKAGE_DISPLAY_NAME" ["$MAINLINE_KERNEL_PACKAGE"]="$MAINLINE_KERNEL_PACKAGE_DISPLAY_NAME" ["$APT_DCONF_EDITOR"]="$APT_DCONF_EDITOR_DISPLAY_NAME" + ["$RAW_JAN_PACKAGE"]="$RAW_JAN_PACKAGE_DISPLAY_NAME" +) + +ORDERED_PACKAGES=( # Needed when order matters + "$SNAP_VSCODE_PACKAGE" + "$FLATPAK_IDEA_COMMUNITY_PACKAGE" + "$SNAP_RIDER_PACKAGE" + "$FLATPAK_WEBSTORM_PACKAGE" + "$FLATPAK_ANDROID_STUDIO_PACKAGE" + "$APT_GIT_PACKAGE" + "$RAW_GITEXTENSIONS_PACKAGE" + "$APT_DOCKER_CE_PACKAGE" + "$RAW_K3D_PACKAGE" + "$SNAP_KUBECTL_PACKAGE" + "$SNAP_FIREFOX_PACKAGE" + "$FLATPAK_OBSIDIAN_PACKAGE" + "$FLATPAK_SPOTIFY_PACKAGE" + "$FLATPAK_GIMP_PACKAGE" + "$APT_VIRTUALBOX_PACKAGE" + "$APT_VLC_PACKAGE" + "$APT_NET_TOOLS_PACKAGE" + "$FLATPAK_FLAMESHOT_PACKAGE" + "$APT_DL_DRIVER_PACKAGE" + "$FLATPAK_NEXTCLOUD_CLIENT_PACKAGE" + "$APT_PROTONVPN_PACKAGE" + "$APT_WIREGUARDVPN_PACKAGE" + "$FLATPAK_FLATSEAL_PACKAGE" + "$FLATPAK_REMMINA_PACKAGE" + "$APT_DCONF_EDITOR" + "$RAW_JAN_PACKAGE" + "$MAINLINE_KERNEL_PACKAGE" ) diff --git a/install.sh b/install.sh index e354149..40d7c38 100644 --- a/install.sh +++ b/install.sh @@ -5,41 +5,13 @@ HELPER_SCRIPTS_DIR="$INSTALLER_DIR/helper_scripts" source "$HELPER_SCRIPTS_DIR/packages.sh" -ORDERED_PACKAGES=( # Needed when order matters - "$SNAP_VSCODE_PACKAGE" - "$FLATPAK_IDEA_COMMUNITY_PACKAGE" - "$SNAP_RIDER_PACKAGE" - "$FLATPAK_WEBSTORM_PACKAGE" - "$FLATPAK_ANDROID_STUDIO_PACKAGE" - "$APT_GIT_PACKAGE" - "$RAW_GITEXTENSIONS_PACKAGE" - "$APT_DOCKER_CE_PACKAGE" - "$RAW_K3D_PACKAGE" - "$SNAP_KUBECTL_PACKAGE" - "$SNAP_FIREFOX_PACKAGE" - "$FLATPAK_OBSIDIAN_PACKAGE" - "$FLATPAK_SPOTIFY_PACKAGE" - "$FLATPAK_GIMP_PACKAGE" - "$APT_VIRTUALBOX_PACKAGE" - "$APT_VLC_PACKAGE" - "$APT_NET_TOOLS_PACKAGE" - "$FLATPAK_FLAMESHOT_PACKAGE" - "$APT_DL_DRIVER_PACKAGE" - "$FLATPAK_NEXTCLOUD_CLIENT_PACKAGE" - "$APT_PROTONVPN_PACKAGE" - "$APT_WIREGUARDVPN_PACKAGE" - "$FLATPAK_FLATSEAL_PACKAGE" - "$FLATPAK_REMMINA_PACKAGE" - "$APT_DCONF_EDITOR" - "$MAINLINE_KERNEL_PACKAGE" -) - declare -A NEEDS_VERSION NEEDS_VERSION=( ["$APT_VIRTUALBOX_PACKAGE"]="https://www.virtualbox.org/wiki/Linux_Downloads|${PACKAGES["$APT_VIRTUALBOX_PACKAGE"]} version (e.g. 7.1)" ["$RAW_GITEXTENSIONS_PACKAGE"]="https://github.com/gitextensions/gitextensions/releases|${PACKAGES["$RAW_GITEXTENSIONS_PACKAGE"]} version (e.g. 2.51.05)" ["$APT_PROTONVPN_PACKAGE"]="https://protonvpn.com/support/official-linux-vpn-ubuntu|${PACKAGES["$APT_PROTONVPN_PACKAGE"]} Repository version (e.g. 1.0.6)" ["$MAINLINE_KERNEL_PACKAGE"]="https://kernel.ubuntu.com/mainline/|Kernel versions, comma separated (e.g. 6.11.10)" + ["$RAW_JAN_PACKAGE"]="https://github.com/janhq/jan/releases|${PACKAGES["$RAW_JAN_PACKAGE"]} version (e.g. 0.5.13)" ) PACKAGES_WITH_GROUP=( @@ -72,6 +44,7 @@ CAN_AUTOSTART=( "$APT_PROTONVPN_PACKAGE" "$FLATPAK_FLATSEAL_PACKAGE" "$SNAP_FIREFOX_PACKAGE" + "$RAW_JAN_PACKAGE" # "$FLATPAK_REMMINA_PACKAGE" # Adds itself to autostart ) diff --git a/tasks/general_templates/appimage_installation.yaml b/tasks/general_templates/appimage_installation.yaml new file mode 100644 index 0000000..524fcf8 --- /dev/null +++ b/tasks/general_templates/appimage_installation.yaml @@ -0,0 +1,27 @@ +- name: Install AppImage + block: + - name: Copy AppImage + copy: + src: "{{ installation_file }}" + dest: "{{ destination }}" + + - name: Install libfuse + include_tasks: ../apt_templates/install_apt_package.yaml + vars: + app: libfuse2 + + - name: Setting AppImage permissions + file: + path: "{{ destination }}" + mode: '0775' + state: file + + - name: Extract Icon + when: "extract_icon | default (false)" + vars: + squashfs_path: "squashfs-root" + shell: | + chmod +x "{{ installation_file }}" + "{{ installation_file }}" --appimage-extract + cp "{{ squashfs_path }}/{{ appimage_icon_subpath }}" "{{ icon_destination }}" + rm -r "{{ squashfs_path }}" diff --git a/tasks/general_templates/wget_file.yaml b/tasks/general_templates/wget_file.yaml new file mode 100644 index 0000000..6512049 --- /dev/null +++ b/tasks/general_templates/wget_file.yaml @@ -0,0 +1,9 @@ +- name: wget File + block: + - name: Install wget + include_tasks: ../apt_templates/install_apt_package.yaml + vars: + app: wget + + - name: Download File + shell: wget -q "{{ url }}" -O "{{ output_path }}" diff --git a/tasks/general_templates/wget_install.yaml b/tasks/general_templates/wget_install.yaml index 852e37a..f3aeddd 100644 --- a/tasks/general_templates/wget_install.yaml +++ b/tasks/general_templates/wget_install.yaml @@ -1,21 +1,17 @@ -- name: wget File +- name: wget and install File vars: output_path: "{{ temporary_downloads_path }}/{{ wget_output_file }}" block: - - name: Install wget - include_tasks: ../apt_templates/install_apt_package.yaml - vars: - app: wget - - - name: Download File - shell: wget -q "{{ url }}" -O "{{ output_path }}" + - name: wget File + include_tasks: wget_file.yaml - name: Install File include_tasks: "{{ installation_task }}" vars: installation_file: "{{ output_path }}" + download_path: "{{ temporary_downloads_path }}" - name: wget Cleanup file: - path: "{{ temporary_downloads_path }}/{{ wget_output_file }}" + path: "{{ output_path }}" state: absent diff --git a/tasks/raw_packages.yaml b/tasks/raw_packages.yaml index 049d903..f0003f6 100644 --- a/tasks/raw_packages.yaml +++ b/tasks/raw_packages.yaml @@ -68,3 +68,61 @@ wget_output_file: k3d.sh installation_task: bash_installation.yaml when: "'k3d' in raw_packages" + +- name: Install Jan (Raw) + vars: + jan_path: "{{ portable_programs_path }}/Jan" + jan_filename: "jan.AppImage" + jan_appimage_path: "{{ jan_path }}/{{ jan_filename }}" + desktop_filename: jan + desktop_app_name: Jan + desktop_description: Jan - Local AI Assistant + desktop_icon_path: "{{ jan_path }}/icon.png" + when: raw_packages is search('jan:') + block: + - name: Remove old Jan Installation + file: + path: "{{ jan_path }}" + state: absent + + - name: Ensure Jan directory + include_tasks: general_templates/make_dir.yaml + vars: + path: "{{ jan_path }}" + + - name: Install Jan (Raw) + include_tasks: general_templates/wget_install.yaml + vars: + version: "{{ raw_packages | regex_search('jan:([^\\s]+)', '\\1') | first | trim }}" + url: https://github.com/janhq/jan/releases/download/v{{ version }}/jan-linux-x86_64-{{ version }}.AppImage + wget_output_file: "{{ jan_filename }}" + installation_task: appimage_installation.yaml + destination: "{{ jan_appimage_path }}" + extract_icon: true + icon_destination: "{{ desktop_icon_path }}" + appimage_icon_subpath: usr/share/icons/hicolor/512x512/apps/jan.png + + # - name: Download Jan Icon + # include_tasks: general_templates/wget_file.yaml + # vars: + # url: https://avatars.githubusercontent.com/u/102363196?s=200&v=4 + # output_path: "{{ desktop_icon_path }}" + + - name: Create Application Entry + include_tasks: general_templates/create_desktop_file.yaml + vars: + dir: "{{ applications_directory }}" + filename: "{{ desktop_filename }}" + app_name: "{{ desktop_app_name }}" + description: "{{ desktop_description }}" + executable: "{{ jan_appimage_path }}" + icon_path: "{{ desktop_icon_path }}" + + - name: Create Autostart Entry + include_tasks: general_templates/create_desktop_file.yaml + vars: + filename: "{{ desktop_filename }}" + app_name: "{{ desktop_app_name }}" + description: "{{ desktop_description }}" + executable: "{{ jan_appimage_path }}" + when: "'jan' in autostart_applications" diff --git a/variables/editable_variables.yaml b/variables/editable_variables.yaml index 9211f2b..9329b2a 100644 --- a/variables/editable_variables.yaml +++ b/variables/editable_variables.yaml @@ -1,2 +1,2 @@ portable_programs_path: "{{ ansible_env.HOME }}/Programs" -temporary_downloads_path: "." +temporary_downloads_path: "{{ '.' | realpath }}" -- GitLab