From c9d972f25bcac1343e07389ac898bd8367db168f94fa205da9318be7a45a1105 Mon Sep 17 00:00:00 2001 From: Richard Brown Date: Thu, 23 May 2024 12:55:59 +0000 Subject: [PATCH] - Rewrite aeon-firstboot to be multi-threaded and install locales (boo#1224328, boo#1213055, boo#1208869, boo#1217466, boo#1223608) OBS-URL: https://build.opensuse.org/package/show/devel:microos:aeon/gnome-branding-Aeon?expand=0&rev=16 --- aeon-firstboot | 184 +++++++++++++++++++++++++----------- gnome-branding-Aeon.changes | 6 ++ gnome-branding-Aeon.spec | 2 +- 3 files changed, 138 insertions(+), 54 deletions(-) diff --git a/aeon-firstboot b/aeon-firstboot index f32bc69..4d09454 100644 --- a/aeon-firstboot +++ b/aeon-firstboot @@ -1,60 +1,138 @@ -#!/bin/sh -( -echo "# Waiting for Internet connection" -until /usr/bin/curl -s --max-time 5 https://flathub.org > /dev/null; do sleep 1; done -echo "10" +#!/bin/bash -echo "# Adding Flathub Repository" -/usr/bin/flatpak remote-add --user --if-not-exists flathub /usr/share/aeon/flathub.flatpakrepo -if [ "$?" != 0 ] ; then - zenity --error \ - --text="Adding Flathub Repo Failed" - exit 1 -fi -echo "20" +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Copyright 2024 SUSE LLC +# SPDX-FileCopyrightText: Copyright 2024 Richard Brown +# SPDX-FileCopyrightText: Copyright 2024 Raymond Yip -echo "# Installing Firefox" -/usr/bin/flatpak install --user --noninteractive flathub org.mozilla.firefox -if [ "$?" != 0 ] ; then - zenity --error \ - --text="Installing Firefox Failed" - exit 1 -fi +installFlatpakRepo(){ + /usr/bin/flatpak remote-add --user --if-not-exists flathub /usr/share/aeon/flathub.flatpakrepo + if [ "$?" != 0 ] ; then + zenity --error \ + --text="Adding Flathub Repo Failed" + exit 1 + fi +} -echo "40" -echo "# Installing Calculator" -/usr/bin/flatpak install --user --noninteractive flathub org.gnome.Calculator -if [ "$?" != 0 ] ; then - zenity --error \ - --text="Installing Calculator Failed" - exit 1 -fi +installFlatpakPackage(){ + /usr/bin/flatpak install --user --noninteractive flathub $1 + if [ "$?" != 0 ] ; then + zenity --error \ + --text="Installing $1 Failed" + exit 1 + fi +} -echo "60" -echo "# Installing Text Editor" -/usr/bin/flatpak install --user --noninteractive flathub org.gnome.TextEditor -if [ "$?" != 0 ] ; then - zenity --error \ - --text="Installing Text Editor Failed" - exit 1 -fi +defaultOptions() { + pkgs=("org.mozilla.firefox" "org.gnome.Calculator" "org.gnome.TextEditor") +} -echo "80" -echo "# Installing Extension Manager" -/usr/bin/flatpak install --user --noninteractive flathub com.mattjakeman.ExtensionManager -if [ "$?" != 0 ] ; then - zenity --error \ - --text="Installing Extension Manager Failed" - exit 1 -fi +customizeOptions() { + #User has decided to customize their installed flatpaks + selection=$(zenity --list --width=1000 --height=1025 --title="Choose software to install" \ + --text="Select which software you would like to install\nMore software can be found in the Software App" \ + --checklist --column="" --column="AppName" --column="Application" --column="Description" \ + --hide-column=2 \ +TRUE org.mozilla.firefox "Mozilla Firefox" "Default Web Browser" \ +TRUE org.gnome.Calculator "Calculator" "Basic Calculator" \ +TRUE org.gnome.TextEditor "Text Editor" "Basic Text Editor" \ +FALSE com.mattjakeman.ExtensionManager "Extension Manager" "Shell Extensions Manager" \ +FALSE com.github.tchx84.Flatseal "Flatseal" "Application Permissions Manager" \ +FALSE com.valvesoftware.Steam "Steam" "Steam Games Launcher" \ +FALSE org.gnome.Loupe "Image Viewer" "Basic Image Viewer" \ +FALSE org.gnome.gThumb "gThumb" "Advanced Image Viewer" \ +FALSE io.github.celluloid_player.Celluloid "Celluloid" "Basic Video Player" \ +FALSE org.videolan.VLC "VLC" "Advanced Video Player" \ +FALSE org.mozilla.Thunderbird "Thunderbird" "Mail Client" \ +FALSE org.telegram.desktop "Telegram Desktop" "Telegram Messaging Client" \ +FALSE org.libreoffice.LibreOffice "LibreOffice" "LibreOffice Office Suite" \ +FALSE org.gimp.GIMP "GNU Image Manipulation Program" "Image Editor" \ +FALSE org.gnome.Builder "Builder" "Graphical IDE" \ +FALSE io.github.dvlv.boxbuddyrs "BoxBuddy" "Distrobox Container Manager" \ +FALSE org.gnome.Boxes "Boxes" "Virtualisation" \ +FALSE org.gnome.World.PikaBackup "Pika Backup" "Basic Backup Tool" \ +FALSE org.gnome.SimpleScan "Document Scanner" "Basic Document Scanner" \ +) + #the above command outputs pipe-delimeted lists of all the flathub app names people chose..eg + #org.mozilla.firefox|org.gnome.Calculator|org.gnome.TextEditor|com.github.tchx84.Flatseal|com.valvesoftware.Steam|org.telegram.desktop + #So that could be parsed to figure out the number of apps chosen and fed into flatpak —user —noninteractive flathub and allow people to pick what they install on first boot + if [[ -z "${selection}" ]]; then + #if cancel is pressed, $custom variable is empty so we go back to use the default options + defaultOptions + else + IFS='|' read -a pkgs <<< "$selection" + fi +} -echo "100" -echo "# Cleaning up" -rm ~/.config/autostart/aeon-firstboot.desktop -) | - zenity --progress --title="Aeon Firstboot" --percentage=0 --auto-close --no-cancel --width=300 +firstMSG() { + #Insert Welcome message here + zenity --question --icon=distributor-logo-Aeon-symbolic --no-wrap --title 'Welcome to openSUSE Aeon' \ + --text 'Almost done, there is one last step\n\nWe need to download some applications to get you started\n\nYou can add more software later using the Software App' \ + --width 300 --height 300 \ + --ok-label OK \ + --cancel-label Customise + option=$? + if [ "$option" != 0 ]; then + #User wants to customize software + customizeOptions + else + #OK Button selected, running with defaults + defaultOptions + fi +} -if [ "$?" != 0 ] ; then - zenity --error \ - --text="Firstboot Configuration Error" -fi +lastMSG() { + #Insert Welcome message here + zenity --info --icon=distributor-logo-Aeon-symbolic --no-wrap --title 'Welcome to openSUSE Aeon' \ + --text 'Congratulations!\n\nYour system is ready to be used\n\nWe hope you enjoy using openSUSE Aeon' \ + --width 300 --height 300 +} + +detectLocale() { + if [[ ! "${LANG}" =~ ^en_ ]]; then + need_locale=${LANG} + fi + +} + +show_progress() { + ( + echo "# Waiting for Internet connection" + until /usr/bin/curl -s --max-time 5 https://flathub.org > /dev/null; do sleep 1; done + while /usr/bin/pgrep -f '/usr/bin/flatpak|/usr/sbin/transactional-update|/usr/bin/pkexec' >/dev/null; do + echo "# Installing Packages" + sleep 1 + done + )| zenity --progress --title="Final Setup" --width=300 --pulsate --auto-close --no-cancel +} + +install_locale() { + pkexec sh -c "/usr/sbin/transactional-update -n run zypper aloc ${need_locale} && /usr/sbin/transactional-update -n apply" + if [ "$?" != 0 ] ; then + zenity --error \ + --text="Installing Locales Failed" + exit 1 + fi + for i in "$HOME/Desktop" "$HOME/Downloads" "$HOME/Templates" "$HOME/Public" "$HOME/Documents" "$HOME/Music" "$HOME/Pictures" "$HOME/Videos" + do + rmdir $i + done + xdg-user-dirs-update --force +} + +run_tasks() { + until /usr/bin/curl -s --max-time 5 https://flathub.org > /dev/null; do sleep 1; done + if [[ -n "${need_locale}" ]]; then + install_locale & + fi + installFlatpakRepo + for pkg in "${pkgs[@]}"; do + installFlatpakPackage $pkg & + done +} + +detectLocale +firstMSG +run_tasks & +show_progress +lastMSG diff --git a/gnome-branding-Aeon.changes b/gnome-branding-Aeon.changes index d34ef59..cb49fda 100644 --- a/gnome-branding-Aeon.changes +++ b/gnome-branding-Aeon.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu May 23 12:53:48 UTC 2024 - Richard Brown + +- Rewrite aeon-firstboot to be multi-threaded and install locales + (boo#1224328, boo#1213055, boo#1208869, boo#1217466, boo#1223608) + ------------------------------------------------------------------- Thu Dec 28 14:52:59 UTC 2023 - dopice <0xdopice@protonmail.com> diff --git a/gnome-branding-Aeon.spec b/gnome-branding-Aeon.spec index 9023ca8..9e8d252 100644 --- a/gnome-branding-Aeon.spec +++ b/gnome-branding-Aeon.spec @@ -1,7 +1,7 @@ # # spec file for package gnome-branding-Aeon # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # Copyright (c) 2021 SUSE Software Solutions GmbH # # All modifications and additions to the file contributed by third parties