diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2dac0ce..4afb4db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,12 +44,13 @@ Apart from trivial changes (like simple typo fixes), it is advised to first [ope ### Coding style When submitting code changes, try to respect the coding style and the overall way things work, as much as possible. -For instance, for the main bash script: +For instance: - Stick to bash syntax - Variables should use the `"${var}"` format - Use the `{main,info,ask,warning,error}_msg` functions to print messages - Use `"$(eval_gettext "string")"` for any string chain that should be included in translations +- The main `arch-update.sh` script should only be used as a wrapper around "libraries" stored in `src/lib/` - [...] Bash code is checked with [shellcheck](https://www.shellcheck.net/). @@ -102,6 +103,17 @@ The recently introduced -l/--list option was missing from the man page style: Typo fixes in README and man pages ``` +```text +chore!(code structure): Split the script functions into separate libraries + +Split the functions inside the main script into their own separate libraries scripts to improve readability and ease the overall maintenance and contribution processes. + +Closes https://github.com/Antiz96/arch-update/issues/230 + +BREAKING CHANGE: The python script for the systray applet is now sourced as a library by the main script (and not executed from `"installation_prefix"/bin/` anymore). +People that installed Arch-Update from source will have to either uninstall it (with `make uninstall`) **before** pulling and installing the new version (with `make install`), or they will have to manually remove the `arch-update-tray` file from their system (which is under `/usr/local/bin/` if the default installation prefix was used) after upgrading from `v2.x.x` to `v3.x.x`. Otherwise, the `arch-update-tray` file will remain un-tracked on the system. +``` + ### License By contributing to this project, you agree that your contributions will be licensed under the [GPL-3.0 license](https://github.com/Antiz96/arch-update/blob/main/LICENSE) (or any later version of this license). diff --git a/Makefile b/Makefile index 7812663..5cf5c9e 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,11 @@ PREFIX ?= /usr/local all: install: - # Install scripts - install -Dm 755 "src/script/${pkgname}.sh" "${DESTDIR}${PREFIX}/bin/${pkgname}" - install -Dm 755 "src/script/${pkgname}-tray.py" "${DESTDIR}${PREFIX}/bin/${pkgname}-tray" + # Install main script + install -Dm 755 "src/${pkgname}.sh" "${DESTDIR}${PREFIX}/bin/${pkgname}" + + # Install libraries + install -Dm 755 src/lib/* -t "${DESTDIR}${PREFIX}/share/${pkgname}/lib/" # Install icons install -Dm 664 "src/icons/${pkgname}.svg" "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/${pkgname}.svg" @@ -56,9 +58,11 @@ install: install -Dm 644 "res/config/${pkgname}.conf.example" "${DESTDIR}${PREFIX}/share/doc/${pkgname}/${pkgname}.conf.example" uninstall: - # Delete scripts + # Delete main script rm -f "${DESTDIR}${PREFIX}/bin/${pkgname}" - rm -f "${DESTDIR}${PREFIX}/bin/${pkgname}-tray" + + # Delete data folder (which stores libraries) + rm -rf "${DESTDIR}${PREFIX}/share/${pkgname}" # Delete icons rm -rf "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/${pkgname}.svg" diff --git a/README-fr.md b/README-fr.md index 9c0f05b..54d8042 100644 --- a/README-fr.md +++ b/README-fr.md @@ -188,6 +188,7 @@ Codes de sortie : 11 Erreur lors du redémarrage des services nécessitant un redémarrage après mise à jour 12 Erreur lors du traitement des fichiers pacnew 13 Erreur lors de l'édition du fichier de configuration avec l'option `--edit-config` +14 Le dossier de librairies n'a pas été trouvé ``` Pour plus d'informations, consultez la page de manuel arch-update(1). diff --git a/README.md b/README.md index 815f605..d75370e 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ Exit Codes: 11 Error when restarting services that require a post upgrade restart 12 Error during the pacnew files processing 13 Error when editing the configuration file with the `--edit-config` option +14 Libraries directory not found ``` For more information, see the arch-update(1) man page. diff --git a/RELEASE.md b/RELEASE.md index 4cca4b9..7a7e249 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -11,7 +11,7 @@ export TAG="X.Y.Z" - Bump version in where necessary: ```bash -sed -i "s/$(arch-update -V | cut -f2 -d " ")/${TAG}/g" doc/man/arch-update.* doc/man/fr/arch-update.* po/* src/script/arch-update.sh +sed -i "s/$(arch-update -V | cut -f2 -d " ")/${TAG}/g" doc/man/arch-update.* doc/man/fr/arch-update.* po/* src/arch-update.sh ``` - Update changelog: diff --git a/doc/man/arch-update.1 b/doc/man/arch-update.1 index b3cd607..bf3f726 100644 --- a/doc/man/arch-update.1 +++ b/doc/man/arch-update.1 @@ -245,6 +245,10 @@ Error when restarting services that require a post upgrade restart .B 13 .RB "Error when editing the configuration file with the " "--edit-config " "option" +.TP +.B 14 +Libraries directory not found + .SH SEE ALSO .BR checkupdates (8), .BR pacman (8), diff --git a/doc/man/fr/arch-update.1 b/doc/man/fr/arch-update.1 index bee40cc..34d92c7 100644 --- a/doc/man/fr/arch-update.1 +++ b/doc/man/fr/arch-update.1 @@ -245,6 +245,10 @@ Erreur lors du traitement des fichiers pacnew .B 13 .RB "Erreur lors de l'édition du fichier de configuration avec l'option " "--edit-config" +.TP +.B 14 +Le dossier de librairies n'a pas été trouvé + .SH VOIR AUSSI .BR checkupdates (8), .BR pacman (8), diff --git a/po/arch-update.pot b/po/arch-update.pot index c5c067e..bf82685 100644 --- a/po/arch-update.pot +++ b/po/arch-update.pot @@ -16,65 +16,106 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/script/arch-update.sh:130 +#: src/lib/check.sh:34 src/lib/check.sh:37 +#, sh-format +msgid "${update_number} update available" +msgstr "" + +#: src/lib/check.sh:42 src/lib/check.sh:44 +#, sh-format +msgid "${update_number} updates available" +msgstr "" + +#: src/lib/common.sh:78 #, sh-format msgid "WARNING" msgstr "" -#: src/script/arch-update.sh:136 +#: src/lib/common.sh:84 #, sh-format msgid "ERROR" msgstr "" -#: src/script/arch-update.sh:141 +#: src/lib/common.sh:89 #, sh-format msgid "Press \"enter\" to continue " msgstr "" -#: src/script/arch-update.sh:147 +#: src/lib/common.sh:95 #, sh-format msgid "Press \"enter\" to quit " msgstr "" -#: src/script/arch-update.sh:160 +#: src/lib/common.sh:108 #, sh-format msgid "A privilege elevation command is required (sudo, doas or run0)\\n" msgstr "" -#: src/script/arch-update.sh:165 +#: src/lib/common.sh:113 #, sh-format msgid "" "The ${su_cmd} command set for privilege escalation in the arch-update.conf " "configuration file is not found\\n" msgstr "" -#: src/script/arch-update.sh:197 +#: src/lib/edit-config.sh:9 src/lib/show-config.sh:9 +#, sh-format +msgid "" +"No configuration file found\\nYou can generate one with \"arch-update --gen-" +"config\"" +msgstr "" + +#: src/lib/edit-config.sh:13 +#, sh-format +msgid "" +"Unable to determine the editor to use\\nThe \"EDITOR\" environment variable " +"is not set and \"nano\" (fallback option) is not installed" +msgstr "" + +#: src/lib/gen-config.sh:19 +#, sh-format +msgid "Example configuration file not found" +msgstr "" + +#: src/lib/gen-config.sh:25 +#, sh-format +msgid "" +"The '${config_file}' configuration file already exists\\nPlease, remove it " +"before generating a new one" +msgstr "" + +#: src/lib/gen-config.sh:30 +#, sh-format +msgid "The '${config_file}' configuration file has been generated" +msgstr "" + +#: src/lib/help.sh:8 #, sh-format msgid "" "An update notifier/applier for Arch Linux that assists you with important " "pre/post update tasks." msgstr "" -#: src/script/arch-update.sh:199 +#: src/lib/help.sh:10 #, sh-format msgid "Run ${name} to perform the main 'update' function:" msgstr "" -#: src/script/arch-update.sh:200 +#: src/lib/help.sh:11 #, sh-format msgid "" "Display the list of packages available for update, then ask for the user's " "confirmation to proceed with the installation." msgstr "" -#: src/script/arch-update.sh:201 +#: src/lib/help.sh:12 #, sh-format msgid "" "Before performing the update, it offers to display the latest Arch Linux " "news." msgstr "" -#: src/script/arch-update.sh:202 +#: src/lib/help.sh:13 #, sh-format msgid "" "Post update, it checks for orphan/unused packages, old cached packages, " @@ -82,12 +123,12 @@ msgid "" "post upgrade restart and, if there are, offers to process them." msgstr "" -#: src/script/arch-update.sh:204 +#: src/lib/help.sh:15 #, sh-format msgid "Options:" msgstr "" -#: src/script/arch-update.sh:205 +#: src/lib/help.sh:16 #, sh-format msgid "" " -c, --check Check for available updates, change the systray icon and " @@ -95,150 +136,141 @@ msgid "" "there are new available updates compared to the last check)" msgstr "" -#: src/script/arch-update.sh:206 +#: src/lib/help.sh:17 #, sh-format msgid " -l, --list Display the list of pending updates" msgstr "" -#: src/script/arch-update.sh:207 +#: src/lib/help.sh:18 #, sh-format msgid " -d, --devel Include AUR development packages updates" msgstr "" -#: src/script/arch-update.sh:208 +#: src/lib/help.sh:19 #, sh-format msgid "" " -n, --news [Num] Display latest Arch news, you can optionally specify the " "number of Arch news to display with '--news [Num]' (e.g. '--news 10')" msgstr "" -#: src/script/arch-update.sh:209 +#: src/lib/help.sh:20 #, sh-format msgid " -D, --debug Display debug traces" msgstr "" -#: src/script/arch-update.sh:210 +#: src/lib/help.sh:21 #, sh-format msgid "" " --gen-config Generate a default/example 'arch-update.conf' " "configuration file" msgstr "" -#: src/script/arch-update.sh:211 +#: src/lib/help.sh:22 #, sh-format msgid "" " --show-config Display the 'arch-update.conf' configuration file " "currently used (if it exists)" msgstr "" -#: src/script/arch-update.sh:212 +#: src/lib/help.sh:23 #, sh-format msgid "" " --edit-config Edit the 'arch-update.conf' configuration file currently " "used (if it exists)" msgstr "" -#: src/script/arch-update.sh:213 +#: src/lib/help.sh:24 #, sh-format msgid "" " --tray Launch the Arch-Update systray applet, you can " "optionally add the '--enable' argument to start it automatically at boot" msgstr "" -#: src/script/arch-update.sh:214 +#: src/lib/help.sh:25 #, sh-format msgid " -h, --help Display this help message and exit" msgstr "" -#: src/script/arch-update.sh:215 +#: src/lib/help.sh:26 #, sh-format msgid " -V, --version Display version information and exit" msgstr "" -#: src/script/arch-update.sh:217 +#: src/lib/help.sh:28 #, sh-format msgid "For more information, see the ${name}(1) man page." msgstr "" -#: src/script/arch-update.sh:218 +#: src/lib/help.sh:29 #, sh-format msgid "" "Certain options can be enabled/disabled or modified via the ${name}.conf " "configuration file, see the ${name}.conf(5) man page." msgstr "" -#: src/script/arch-update.sh:229 +#: src/lib/invalid_option.sh:7 #, sh-format msgid "" "${name}: invalid option -- '${option}'\\nTry '${name} --help' for more " "information." msgstr "" -#: src/script/arch-update.sh:269 src/script/arch-update.sh:271 -#, sh-format -msgid "${update_number} update available" -msgstr "" - -#: src/script/arch-update.sh:276 src/script/arch-update.sh:278 +#: src/lib/kernel_reboot.sh:10 #, sh-format -msgid "${update_number} updates available" -msgstr "" - -#: src/script/arch-update.sh:294 -#, sh-format -msgid "Looking for updates...\\n" -msgstr "" - -#: src/script/arch-update.sh:315 -#, sh-format -msgid "Packages:" +msgid "" +"Reboot required:\\nThere's a pending kernel update on your system requiring " +"a reboot to be applied\\n" msgstr "" -#: src/script/arch-update.sh:320 +#: src/lib/kernel_reboot.sh:11 #, sh-format -msgid "AUR Packages:" +msgid "Would you like to reboot now? [y/N]" msgstr "" -#: src/script/arch-update.sh:325 +#: src/lib/kernel_reboot.sh:15 src/lib/list_packages.sh:60 +#: src/lib/orphan_packages.sh:25 src/lib/orphan_packages.sh:59 +#: src/lib/packages_cache.sh:30 src/lib/pacnew_files.sh:21 #, sh-format -msgid "Flatpak Packages:" +msgid "Y" msgstr "" -#: src/script/arch-update.sh:331 +#: src/lib/kernel_reboot.sh:15 src/lib/list_packages.sh:60 +#: src/lib/orphan_packages.sh:25 src/lib/orphan_packages.sh:59 +#: src/lib/packages_cache.sh:30 src/lib/pacnew_files.sh:21 #, sh-format -msgid "No update available\\n" +msgid "y" msgstr "" -#: src/script/arch-update.sh:339 +#: src/lib/kernel_reboot.sh:27 #, sh-format -msgid "Proceed with update? [Y/n]" +msgid "Rebooting in ${sec}...\\r" msgstr "" -#: src/script/arch-update.sh:342 src/script/arch-update.sh:512 -#: src/script/arch-update.sh:545 src/script/arch-update.sh:587 -#: src/script/arch-update.sh:654 src/script/arch-update.sh:754 +#: src/lib/kernel_reboot.sh:33 #, sh-format -msgid "Y" +msgid "" +"An error has occurred during the reboot process\\nThe reboot has been " +"aborted\\n" msgstr "" -#: src/script/arch-update.sh:342 src/script/arch-update.sh:512 -#: src/script/arch-update.sh:545 src/script/arch-update.sh:587 -#: src/script/arch-update.sh:654 src/script/arch-update.sh:754 +#: src/lib/kernel_reboot.sh:41 #, sh-format -msgid "y" +msgid "" +"The reboot hasn't been performed\\nPlease, consider rebooting to finalize " +"the pending kernel update\\n" msgstr "" -#: src/script/arch-update.sh:347 +#: src/lib/kernel_reboot.sh:45 #, sh-format -msgid "The update has been aborted\\n" +msgid "No pending kernel update found\\n" msgstr "" -#: src/script/arch-update.sh:357 +#: src/lib/list_news.sh:7 #, sh-format msgid "Looking for recent Arch News..." msgstr "" -#: src/script/arch-update.sh:362 +#: src/lib/list_news.sh:12 #, sh-format msgid "" "Unable to retrieve recent Arch News (HTTP error response or request " @@ -246,36 +278,36 @@ msgid "" "updating your system" msgstr "" -#: src/script/arch-update.sh:371 +#: src/lib/list_news.sh:22 #, sh-format msgid "No recent Arch News found" msgstr "" -#: src/script/arch-update.sh:384 +#: src/lib/list_news.sh:36 #, sh-format msgid "Arch News:" msgstr "" -#: src/script/arch-update.sh:389 +#: src/lib/list_news.sh:41 #, sh-format msgid "[NEW]" msgstr "" -#: src/script/arch-update.sh:400 +#: src/lib/list_news.sh:53 #, sh-format msgid "" "Select the news to read (e.g. 1 3 5), select 0 to read them all or press " "\"enter\" to quit:" msgstr "" -#: src/script/arch-update.sh:402 +#: src/lib/list_news.sh:55 #, sh-format msgid "" "Select the news to read (e.g. 1 3 5), select 0 to read them all or press " "\"enter\" to proceed with update:" msgstr "" -#: src/script/arch-update.sh:425 +#: src/lib/list_news.sh:78 #, sh-format msgid "" "Unable to retrieve the selected Arch News (HTTP error response or request " @@ -283,352 +315,319 @@ msgid "" "updating your system" msgstr "" -#: src/script/arch-update.sh:430 +#: src/lib/list_news.sh:83 #, sh-format msgid "Title:" msgstr "" -#: src/script/arch-update.sh:431 +#: src/lib/list_news.sh:84 #, sh-format msgid "Author:" msgstr "" -#: src/script/arch-update.sh:432 +#: src/lib/list_news.sh:85 #, sh-format msgid "Publication date:" msgstr "" -#: src/script/arch-update.sh:433 +#: src/lib/list_news.sh:86 #, sh-format msgid "URL:" msgstr "" -#: src/script/arch-update.sh:451 +#: src/lib/list_packages.sh:7 #, sh-format -msgid "Updating Packages...\\n" +msgid "Looking for updates...\\n" msgstr "" -#: src/script/arch-update.sh:456 src/script/arch-update.sh:470 -#: src/script/arch-update.sh:483 +#: src/lib/list_packages.sh:32 #, sh-format -msgid "" -"An error has occurred during the update process\\nThe update has been " -"aborted\\n" +msgid "Packages:" msgstr "" -#: src/script/arch-update.sh:465 +#: src/lib/list_packages.sh:37 #, sh-format -msgid "Updating AUR Packages...\\n" +msgid "AUR Packages:" msgstr "" -#: src/script/arch-update.sh:479 +#: src/lib/list_packages.sh:42 #, sh-format -msgid "Updating Flatpak Packages...\\n" +msgid "Flatpak Packages:" msgstr "" -#: src/script/arch-update.sh:490 +#: src/lib/list_packages.sh:48 #, sh-format -msgid "The update has been applied\\n" +msgid "No update available\\n" +msgstr "" + +#: src/lib/list_packages.sh:56 +#, sh-format +msgid "Proceed with update? [Y/n]" msgstr "" -#: src/script/arch-update.sh:502 +#: src/lib/list_packages.sh:66 +#, sh-format +msgid "The update has been aborted\\n" +msgstr "" + +#: src/lib/orphan_packages.sh:14 #, sh-format msgid "Orphan Packages:" msgstr "" -#: src/script/arch-update.sh:506 +#: src/lib/orphan_packages.sh:18 #, sh-format msgid "" "Would you like to remove this orphan package (and its potential " "dependencies) now? [y/N]" msgstr "" -#: src/script/arch-update.sh:508 +#: src/lib/orphan_packages.sh:20 #, sh-format msgid "" "Would you like to remove these orphan packages (and their potential " "dependencies) now? [y/N]" msgstr "" -#: src/script/arch-update.sh:514 +#: src/lib/orphan_packages.sh:27 #, sh-format msgid "Removing Orphan Packages...\\n" msgstr "" -#: src/script/arch-update.sh:518 src/script/arch-update.sh:551 -#: src/script/arch-update.sh:594 src/script/arch-update.sh:604 -#: src/script/arch-update.sh:614 src/script/arch-update.sh:623 +#: src/lib/orphan_packages.sh:32 src/lib/orphan_packages.sh:65 +#: src/lib/packages_cache.sh:38 src/lib/packages_cache.sh:48 +#: src/lib/packages_cache.sh:58 src/lib/packages_cache.sh:67 #, sh-format msgid "" "An error has occurred during the removal process\\nThe removal has been " "aborted\\n" msgstr "" -#: src/script/arch-update.sh:521 src/script/arch-update.sh:554 +#: src/lib/orphan_packages.sh:35 src/lib/orphan_packages.sh:68 #, sh-format msgid "The removal has been applied\\n" msgstr "" -#: src/script/arch-update.sh:526 src/script/arch-update.sh:558 -#: src/script/arch-update.sh:631 +#: src/lib/orphan_packages.sh:40 src/lib/orphan_packages.sh:72 +#: src/lib/packages_cache.sh:75 #, sh-format msgid "The removal hasn't been applied\\n" msgstr "" -#: src/script/arch-update.sh:530 +#: src/lib/orphan_packages.sh:44 #, sh-format msgid "No orphan package found\\n" msgstr "" -#: src/script/arch-update.sh:535 +#: src/lib/orphan_packages.sh:49 #, sh-format msgid "Flatpak Unused Packages:" msgstr "" -#: src/script/arch-update.sh:539 +#: src/lib/orphan_packages.sh:53 #, sh-format msgid "Would you like to remove this Flatpak unused package now? [y/N]" msgstr "" -#: src/script/arch-update.sh:541 +#: src/lib/orphan_packages.sh:55 #, sh-format msgid "Would you like to remove these Flatpak unused packages now? [y/N]" msgstr "" -#: src/script/arch-update.sh:547 +#: src/lib/orphan_packages.sh:61 #, sh-format msgid "Removing Flatpak Unused Packages..." msgstr "" -#: src/script/arch-update.sh:562 +#: src/lib/orphan_packages.sh:76 #, sh-format msgid "No Flatpak unused package found\\n" msgstr "" -#: src/script/arch-update.sh:579 +#: src/lib/packages_cache.sh:21 #, sh-format msgid "Cached Packages:\\nThere's an old or uninstalled cached package\\n" msgstr "" -#: src/script/arch-update.sh:580 +#: src/lib/packages_cache.sh:22 #, sh-format msgid "Would you like to remove it from the cache now? [Y/n]" msgstr "" -#: src/script/arch-update.sh:582 +#: src/lib/packages_cache.sh:24 #, sh-format msgid "Cached Packages:\\nThere are old and/or uninstalled cached packages\\n" msgstr "" -#: src/script/arch-update.sh:583 +#: src/lib/packages_cache.sh:25 #, sh-format msgid "Would you like to remove them from the cache now? [Y/n]" msgstr "" -#: src/script/arch-update.sh:590 src/script/arch-update.sh:610 +#: src/lib/packages_cache.sh:33 src/lib/packages_cache.sh:54 #, sh-format msgid "Removing old cached packages..." msgstr "" -#: src/script/arch-update.sh:600 src/script/arch-update.sh:619 +#: src/lib/packages_cache.sh:44 src/lib/packages_cache.sh:63 #, sh-format msgid "Removing uninstalled cached packages..." msgstr "" -#: src/script/arch-update.sh:635 +#: src/lib/packages_cache.sh:79 #, sh-format msgid "No old or uninstalled cached package found\\n" msgstr "" -#: src/script/arch-update.sh:644 +#: src/lib/pacnew_files.sh:10 #, sh-format msgid "Pacnew Files:" msgstr "" -#: src/script/arch-update.sh:648 +#: src/lib/pacnew_files.sh:14 #, sh-format msgid "Would you like to process this file now? [Y/n]" msgstr "" -#: src/script/arch-update.sh:650 +#: src/lib/pacnew_files.sh:16 #, sh-format msgid "Would you like to process these files now? [Y/n]" msgstr "" -#: src/script/arch-update.sh:656 +#: src/lib/pacnew_files.sh:23 #, sh-format msgid "Processing Pacnew Files...\\n" msgstr "" -#: src/script/arch-update.sh:660 +#: src/lib/pacnew_files.sh:28 #, sh-format msgid "The pacnew file(s) processing has been applied\\n" msgstr "" -#: src/script/arch-update.sh:663 +#: src/lib/pacnew_files.sh:31 #, sh-format msgid "An error occurred during the pacnew file(s) processing\\n" msgstr "" -#: src/script/arch-update.sh:669 +#: src/lib/pacnew_files.sh:37 #, sh-format msgid "" "The pacnew file(s) processing hasn't been applied\\nPlease, consider " "processing them promptly\\n" msgstr "" -#: src/script/arch-update.sh:673 +#: src/lib/pacnew_files.sh:41 #, sh-format msgid "No pacnew file found\\n" msgstr "" -#: src/script/arch-update.sh:685 +#: src/lib/restart_services.sh:13 #, sh-format msgid "Services:\\nThe following service requires a post upgrade restart\\n" msgstr "" -#: src/script/arch-update.sh:687 +#: src/lib/restart_services.sh:15 #, sh-format msgid "Services:\\nThe following services require a post upgrade restart\\n" msgstr "" -#: src/script/arch-update.sh:697 +#: src/lib/restart_services.sh:25 #, sh-format msgid "" "Select the service(s) to restart (e.g. 1 3 5), select 0 to restart them all " "or press \"enter\" to continue without restarting the service(s):" msgstr "" -#: src/script/arch-update.sh:703 src/script/arch-update.sh:730 +#: src/lib/restart_services.sh:31 src/lib/restart_services.sh:58 #, sh-format msgid "Service(s) restarted successfully\\n" msgstr "" -#: src/script/arch-update.sh:706 src/script/arch-update.sh:733 +#: src/lib/restart_services.sh:34 src/lib/restart_services.sh:61 #, sh-format msgid "" "An error has occurred during the service(s) restart\\nPlease, verify the " "above service(s) status\\n" msgstr "" -#: src/script/arch-update.sh:719 +#: src/lib/restart_services.sh:47 #, sh-format msgid "The ${service_selected} service has been successfully restarted" msgstr "" -#: src/script/arch-update.sh:721 +#: src/lib/restart_services.sh:49 #, sh-format msgid "" "An error has occurred during the restart of the ${service_selected} service" msgstr "" -#: src/script/arch-update.sh:737 +#: src/lib/restart_services.sh:65 #, sh-format msgid "" "The service(s) restart hasn't been performed\\nPlease, consider restarting " "services that have been updated to fully apply the upgrade\\n" msgstr "" -#: src/script/arch-update.sh:741 +#: src/lib/restart_services.sh:69 #, sh-format msgid "No service requiring a post upgrade restart found\\n" msgstr "" -#: src/script/arch-update.sh:750 -#, sh-format -msgid "" -"Reboot required:\\nThere's a pending kernel update on your system requiring " -"a reboot to be applied\\n" -msgstr "" - -#: src/script/arch-update.sh:751 -#, sh-format -msgid "Would you like to reboot now? [y/N]" -msgstr "" - -#: src/script/arch-update.sh:764 -#, sh-format -msgid "Rebooting in ${sec}...\\r" -msgstr "" - -#: src/script/arch-update.sh:770 -#, sh-format -msgid "" -"An error has occurred during the reboot process\\nThe reboot has been " -"aborted\\n" +#: src/lib/tray.py:123 +msgid "Run Arch-Update" msgstr "" -#: src/script/arch-update.sh:778 -#, sh-format -msgid "" -"The reboot hasn't been performed\\nPlease, consider rebooting to finalize " -"the pending kernel update\\n" +#: src/lib/tray.py:124 +msgid "Exit" msgstr "" -#: src/script/arch-update.sh:782 +#: src/lib/tray.sh:20 #, sh-format -msgid "No pending kernel update found\\n" +msgid "Arch-Update tray desktop file not found" msgstr "" -#: src/script/arch-update.sh:838 +#: src/lib/tray.sh:27 #, sh-format -msgid "Example configuration file not found" +msgid "The '${tray_desktop_file_autostart}' file already exists" msgstr "" -#: src/script/arch-update.sh:843 +#: src/lib/tray.sh:32 #, sh-format msgid "" -"The '${config_file}' configuration file already exists\\nPlease, remove it " -"before generating a new one" +"The '${tray_desktop_file_autostart}' file has been created, the Arch-Update " +"systray applet will be automatically started at your next log on\\nTo start " +"it right now, you can launch the \"Arch-Update Systray Applet\" application " +"from your app menu" msgstr "" -#: src/script/arch-update.sh:848 +#: src/lib/tray.sh:42 #, sh-format -msgid "The '${config_file}' configuration file has been generated" +msgid "There's already a running instance of the Arch-Update systray applet" msgstr "" -#: src/script/arch-update.sh:853 src/script/arch-update.sh:861 +#: src/lib/update.sh:9 #, sh-format -msgid "" -"No configuration file found\\nYou can generate one with \"arch-update --gen-" -"config\"" +msgid "Updating Packages...\\n" msgstr "" -#: src/script/arch-update.sh:865 +#: src/lib/update.sh:15 src/lib/update.sh:30 src/lib/update.sh:44 #, sh-format msgid "" -"Unable to determine the editor to use\\nThe \"EDITOR\" environment variable " -"is not set and \"nano\" (fallback option) is not installed" -msgstr "" - -#: src/script/arch-update.sh:883 -#, sh-format -msgid "Arch-Update tray desktop file not found" +"An error has occurred during the update process\\nThe update has been " +"aborted\\n" msgstr "" -#: src/script/arch-update.sh:890 +#: src/lib/update.sh:24 #, sh-format -msgid "The '${tray_desktop_file_autostart}' file already exists" +msgid "Updating AUR Packages...\\n" msgstr "" -#: src/script/arch-update.sh:895 +#: src/lib/update.sh:40 #, sh-format -msgid "" -"The '${tray_desktop_file_autostart}' file has been created, the Arch-Update " -"systray applet will be automatically started at your next log on\\nTo start " -"it right now, you can launch the \"Arch-Update Systray Applet\" application " -"from your app menu" +msgid "Updating Flatpak Packages...\\n" msgstr "" -#: src/script/arch-update.sh:903 +#: src/lib/update.sh:51 #, sh-format -msgid "There's already a running instance of the Arch-Update systray applet" -msgstr "" - -#: src/script/arch-update-tray.py:123 -msgid "Run Arch-Update" -msgstr "" - -#: src/script/arch-update-tray.py:124 -msgid "Exit" +msgid "The update has been applied\\n" msgstr "" diff --git a/po/fr.po b/po/fr.po index 86ff6e8..d1d7b89 100644 --- a/po/fr.po +++ b/po/fr.po @@ -16,32 +16,42 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/script/arch-update.sh:130 +#: src/lib/check.sh:34 src/lib/check.sh:37 +#, sh-format +msgid "${update_number} update available" +msgstr "${update_number} mise à jour disponible" + +#: src/lib/check.sh:42 src/lib/check.sh:44 +#, sh-format +msgid "${update_number} updates available" +msgstr "${update_number} mises à jour disponibles" + +#: src/lib/common.sh:78 #, sh-format msgid "WARNING" msgstr "AVERTISSEMENT" -#: src/script/arch-update.sh:136 +#: src/lib/common.sh:84 #, sh-format msgid "ERROR" msgstr "ERREUR" -#: src/script/arch-update.sh:141 +#: src/lib/common.sh:89 #, sh-format msgid "Press \"enter\" to continue " msgstr "Appuyez sur \"entrée\" pour continuer " -#: src/script/arch-update.sh:147 +#: src/lib/common.sh:95 #, sh-format msgid "Press \"enter\" to quit " msgstr "Appuyez sur \"entrée\" pour quitter " -#: src/script/arch-update.sh:160 +#: src/lib/common.sh:108 #, sh-format msgid "A privilege elevation command is required (sudo, doas or run0)\\n" msgstr "Une commande d'élévation de privilège est requise (sudo, doas ou run0)\\n" -#: src/script/arch-update.sh:165 +#: src/lib/common.sh:113 #, sh-format msgid "" "The ${su_cmd} command set for privilege escalation in the arch-update.conf " @@ -50,7 +60,44 @@ msgstr "" "La commande ${su_cmd} définie pour l'élévation de privilège dans le fichier " "de configuration arch-update.conf n'est pas disponible\\n" -#: src/script/arch-update.sh:197 +#: src/lib/edit-config.sh:9 src/lib/show-config.sh:9 +#, sh-format +msgid "" +"No configuration file found\\nYou can generate one with \"arch-update --gen-" +"config\"" +msgstr "" +"Aucun fichier de configuration n'a été trouvé\\nVous pouvez en générer un avec \"arch-update --gen-" +"config\"" + +#: src/lib/edit-config.sh:13 +#, sh-format +msgid "" +"Unable to determine the editor to use\\nThe \"EDITOR\" environment variable " +"is not set and \"nano\" (fallback option) is not installed" +msgstr "" +"Impossible de déterminer l'éditeur à utiliser\\n La variable d'environnement \"EDITOR\" " +"n'est pas paramétrée et \"nano\" (option de secours) n'est pas installé" + +#: src/lib/gen-config.sh:19 +#, sh-format +msgid "Example configuration file not found" +msgstr "Fichier de configuration exemple non trouvé" + +#: src/lib/gen-config.sh:25 +#, sh-format +msgid "" +"The '${config_file}' configuration file already exists\\nPlease, remove it " +"before generating a new one" +msgstr "" +"Le fichier de configuration '${config_file}' existe déjà.\\nVeuillez le supprimer " +"avant d'en générer un nouveau" + +#: src/lib/gen-config.sh:30 +#, sh-format +msgid "The '${config_file}' configuration file has been generated" +msgstr "Le fichier de configuration '${config_file}' a été généré" + +#: src/lib/help.sh:8 #, sh-format msgid "" "An update notifier/applier for Arch Linux that assists you with important " @@ -59,12 +106,12 @@ msgstr "" "Un notificateur/applicateur de mises à jour pour Arch Linux qui vous assiste dans les " "tâches importantes d'avant/après mise à jour." -#: src/script/arch-update.sh:199 +#: src/lib/help.sh:10 #, sh-format msgid "Run ${name} to perform the main 'update' function:" msgstr "Lancez ${name} pour exécuter la fonction principale 'update' :" -#: src/script/arch-update.sh:200 +#: src/lib/help.sh:11 #, sh-format msgid "" "Display the list of packages available for update, then ask for the user's " @@ -73,7 +120,7 @@ msgstr "" "Afficher la liste des paquets disponibles pour mise à jour, puis demander la confirmation de l'utilisateur " "pour procéder à l'installation." -#: src/script/arch-update.sh:201 +#: src/lib/help.sh:12 #, sh-format msgid "" "Before performing the update, it offers to display the latest Arch Linux " @@ -82,7 +129,7 @@ msgstr "" "Avant d'effectuer la mise à jour, elle propose d'afficher les dernières news " "d'Arch Linux." -#: src/script/arch-update.sh:202 +#: src/lib/help.sh:13 #, sh-format msgid "" "Post update, it checks for orphan/unused packages, old cached packages, " @@ -93,12 +140,12 @@ msgstr "" "de fichiers pacnew/pacsave, les mises à jour du noyau en attente, ainsi que les services nécessitant un " "redémarrage d'après mise à jour et, s'il y en a, propose de les traiter." -#: src/script/arch-update.sh:204 +#: src/lib/help.sh:15 #, sh-format msgid "Options:" msgstr "Options :" -#: src/script/arch-update.sh:205 +#: src/lib/help.sh:16 #, sh-format msgid "" " -c, --check Check for available updates, change the systray icon and " @@ -109,17 +156,17 @@ msgstr "" "envoie une notification de bureau contenant le nombre de mises à jour disponibles (s'" "il y a des nouvelles mises à jour depuis le dernier check)" -#: src/script/arch-update.sh:206 +#: src/lib/help.sh:17 #, sh-format msgid " -l, --list Display the list of pending updates" msgstr " -l, --list Afficher les mises à jours en attente" -#: src/script/arch-update.sh:207 +#: src/lib/help.sh:18 #, sh-format msgid " -d, --devel Include AUR development packages updates" msgstr " -d, --devel Inclure les mises à jour des paquets de développement AUR" -#: src/script/arch-update.sh:208 +#: src/lib/help.sh:19 #, sh-format msgid "" " -n, --news [Num] Display latest Arch news, you can optionally specify the " @@ -128,12 +175,12 @@ msgstr "" " -n, --news [Num] Afficher les dernières Arch news, vous pouvez optionnellement spécifier le " "nombre de Arch news à afficher avec '--news [Num]' (e.g. '--news 10')" -#: src/script/arch-update.sh:209 +#: src/lib/help.sh:20 #, sh-format msgid " -D, --debug Display debug traces" msgstr " -D, --debug Afficher les traces de débogage" -#: src/script/arch-update.sh:210 +#: src/lib/help.sh:21 #, sh-format msgid "" " --gen-config Generate a default/example 'arch-update.conf' " @@ -142,7 +189,7 @@ msgstr "" " --gen-config Générer un fichier de configuration 'arch-update.conf' " "par défaut/exemple" -#: src/script/arch-update.sh:211 +#: src/lib/help.sh:22 #, sh-format msgid "" " --show-config Display the 'arch-update.conf' configuration file " @@ -151,7 +198,7 @@ msgstr "" " --show-config Afficher le fichier de configuration 'arch-update.conf' " "actuellement utilisé (s'il existe)" -#: src/script/arch-update.sh:212 +#: src/lib/help.sh:23 #, sh-format msgid "" " --edit-config Edit the 'arch-update.conf' configuration file currently " @@ -160,7 +207,7 @@ msgstr "" " --edit-config Editer le fichier de configuration 'arch-update.conf' actuellement " "utilisé (s'il existe)" -#: src/script/arch-update.sh:213 +#: src/lib/help.sh:24 #, sh-format msgid "" " --tray Launch the Arch-Update systray applet, you can " @@ -169,22 +216,22 @@ msgstr "" " --tray Lancer l'applet systray d'Arch-Update, vous pouvez " "optionnellement ajouter l'argument '--enable' pour la démarrer automatiquement au démarrage du système" -#: src/script/arch-update.sh:214 +#: src/lib/help.sh:25 #, sh-format msgid " -h, --help Display this help message and exit" msgstr " -h, --help Afficher ce message d'aide et quitter" -#: src/script/arch-update.sh:215 +#: src/lib/help.sh:26 #, sh-format msgid " -V, --version Display version information and exit" msgstr " -V, --version Afficher les informations de version et quitter" -#: src/script/arch-update.sh:217 +#: src/lib/help.sh:28 #, sh-format msgid "For more information, see the ${name}(1) man page." msgstr "Pour plus d'informations, consultez la page de manuel ${name}(1)." -#: src/script/arch-update.sh:218 +#: src/lib/help.sh:29 #, sh-format msgid "" "Certain options can be enabled/disabled or modified via the ${name}.conf " @@ -193,7 +240,7 @@ msgstr "" "Certaines options peuvent être activées/désactivées ou modifiées via le fichier de configuration ${name}.conf, " "voir la page de manuel ${name}.conf(5)." -#: src/script/arch-update.sh:229 +#: src/lib/invalid_option.sh:7 #, sh-format msgid "" "${name}: invalid option -- '${option}'\\nTry '${name} --help' for more " @@ -202,71 +249,68 @@ msgstr "" "${name}: option invalide -- '${option}'\\nEssayez '${name} --help' pour plus " "d'informations." -#: src/script/arch-update.sh:269 src/script/arch-update.sh:271 -#, sh-format -msgid "${update_number} update available" -msgstr "${update_number} mise à jour disponible" - -#: src/script/arch-update.sh:276 src/script/arch-update.sh:278 -#, sh-format -msgid "${update_number} updates available" -msgstr "${update_number} mises à jour disponibles" - -#: src/script/arch-update.sh:294 -#, sh-format -msgid "Looking for updates...\\n" -msgstr "Recherche de mises à jour...\\n" - -#: src/script/arch-update.sh:315 +#: src/lib/kernel_reboot.sh:10 #, sh-format -msgid "Packages:" -msgstr "Paquets :" +msgid "" +"Reboot required:\\nThere's a pending kernel update on your system requiring " +"a reboot to be applied\\n" +msgstr "" +"Redémarrage nécessaire :\\nIl y a une mise à jour du noyau en attente sur votre système qui nécessite " +"un redémarrage pour être appliquée\\n" -#: src/script/arch-update.sh:320 +#: src/lib/kernel_reboot.sh:11 #, sh-format -msgid "AUR Packages:" -msgstr "Paquets AUR :" +msgid "Would you like to reboot now? [y/N]" +msgstr "Voulez-vous redémarrer votre système maintenant ? [o/N]" -#: src/script/arch-update.sh:325 +#: src/lib/kernel_reboot.sh:15 src/lib/list_packages.sh:60 +#: src/lib/orphan_packages.sh:25 src/lib/orphan_packages.sh:59 +#: src/lib/packages_cache.sh:30 src/lib/pacnew_files.sh:21 #, sh-format -msgid "Flatpak Packages:" -msgstr "Paquets Flatpak :" +msgid "Y" +msgstr "O" -#: src/script/arch-update.sh:331 +#: src/lib/kernel_reboot.sh:15 src/lib/list_packages.sh:60 +#: src/lib/orphan_packages.sh:25 src/lib/orphan_packages.sh:59 +#: src/lib/packages_cache.sh:30 src/lib/pacnew_files.sh:21 #, sh-format -msgid "No update available\\n" -msgstr "Aucune mise à jour disponible\\n" +msgid "y" +msgstr "o" -#: src/script/arch-update.sh:339 +#: src/lib/kernel_reboot.sh:27 #, sh-format -msgid "Proceed with update? [Y/n]" -msgstr "Procéder à la mise à jour ? [O/n]" +msgid "Rebooting in ${sec}...\\r" +msgstr "Redémarrage dans ${sec}...\\r" -#: src/script/arch-update.sh:342 src/script/arch-update.sh:512 -#: src/script/arch-update.sh:545 src/script/arch-update.sh:587 -#: src/script/arch-update.sh:654 src/script/arch-update.sh:754 +#: src/lib/kernel_reboot.sh:33 #, sh-format -msgid "Y" -msgstr "O" +msgid "" +"An error has occurred during the reboot process\\nThe reboot has been " +"aborted\\n" +msgstr "" +"Une erreur est survenue pendant le processus de redémarrage\\nLe redémarrage a été " +"abandonné\\n" -#: src/script/arch-update.sh:342 src/script/arch-update.sh:512 -#: src/script/arch-update.sh:545 src/script/arch-update.sh:587 -#: src/script/arch-update.sh:654 src/script/arch-update.sh:754 +#: src/lib/kernel_reboot.sh:41 #, sh-format -msgid "y" -msgstr "o" +msgid "" +"The reboot hasn't been performed\\nPlease, consider rebooting to finalize " +"the pending kernel update\\n" +msgstr "" +"Le redémarrage n'a pas été effectué\\nVeuillez considérer redémarrer votre système pour finaliser " +"la mise à jour du noyau en attente\\n" -#: src/script/arch-update.sh:347 +#: src/lib/kernel_reboot.sh:45 #, sh-format -msgid "The update has been aborted\\n" -msgstr "La mise à jour a été abandonnée\\n" +msgid "No pending kernel update found\\n" +msgstr "Aucune mise à jour du noyau en attente n'a été trouvée\\n" -#: src/script/arch-update.sh:357 +#: src/lib/list_news.sh:7 #, sh-format msgid "Looking for recent Arch News..." msgstr "Recherche des Arch News récentes..." -#: src/script/arch-update.sh:362 +#: src/lib/list_news.sh:12 #, sh-format msgid "" "Unable to retrieve recent Arch News (HTTP error response or request " @@ -277,22 +321,22 @@ msgstr "" "d'attente de la demande dépassé)\\nVeuillez consultez les dernières " "news à l'adresse suivante avant de mettre à jour votre système : https://archlinux.org" -#: src/script/arch-update.sh:371 +#: src/lib/list_news.sh:22 #, sh-format msgid "No recent Arch News found" msgstr "Aucune Arch News récente trouvée" -#: src/script/arch-update.sh:384 +#: src/lib/list_news.sh:36 #, sh-format msgid "Arch News:" msgstr "Arch News :" -#: src/script/arch-update.sh:389 +#: src/lib/list_news.sh:41 #, sh-format msgid "[NEW]" msgstr "[NOUVEAU]" -#: src/script/arch-update.sh:400 +#: src/lib/list_news.sh:53 #, sh-format msgid "" "Select the news to read (e.g. 1 3 5), select 0 to read them all or press " @@ -301,7 +345,7 @@ msgstr "" "Sélectionnez les news à lire (par exemple: 1 3 5), sélectionnez 0 pour toutes les lire " "ou appuyez sur \"entrée\" pour quitter :" -#: src/script/arch-update.sh:402 +#: src/lib/list_news.sh:55 #, sh-format msgid "" "Select the news to read (e.g. 1 3 5), select 0 to read them all or press " @@ -310,7 +354,7 @@ msgstr "" "Sélectionnez les news à lire (par exemple: 1 3 5), sélectionnez 0 pour toutes les lire " "ou appuyez sur \"entrée\" pour procéder à la mise à jour :" -#: src/script/arch-update.sh:425 +#: src/lib/list_news.sh:78 #, sh-format msgid "" "Unable to retrieve the selected Arch News (HTTP error response or request " @@ -321,62 +365,67 @@ msgstr "" "de la demande dépassé)\\nVeuillez consultez la news sélectionnée " "à l'adresse suivante avant de mettre à jour votre système : ${news_url}" -#: src/script/arch-update.sh:430 +#: src/lib/list_news.sh:83 #, sh-format msgid "Title:" msgstr "Titre :" -#: src/script/arch-update.sh:431 +#: src/lib/list_news.sh:84 #, sh-format msgid "Author:" msgstr "Auteur :" -#: src/script/arch-update.sh:432 +#: src/lib/list_news.sh:85 #, sh-format msgid "Publication date:" msgstr "Date de publication :" -#: src/script/arch-update.sh:433 +#: src/lib/list_news.sh:86 #, sh-format msgid "URL:" msgstr "URL :" -#: src/script/arch-update.sh:451 +#: src/lib/list_packages.sh:7 #, sh-format -msgid "Updating Packages...\\n" -msgstr "Mise à jour des paquets...\\n" +msgid "Looking for updates...\\n" +msgstr "Recherche de mises à jour...\\n" -#: src/script/arch-update.sh:456 src/script/arch-update.sh:470 -#: src/script/arch-update.sh:483 +#: src/lib/list_packages.sh:32 #, sh-format -msgid "" -"An error has occurred during the update process\\nThe update has been " -"aborted\\n" -msgstr "" -"Une erreur est survenue pendant le processus de mise à jour\\nLa mise à jour a été " -"abandonnée\\n" +msgid "Packages:" +msgstr "Paquets :" -#: src/script/arch-update.sh:465 +#: src/lib/list_packages.sh:37 #, sh-format -msgid "Updating AUR Packages...\\n" -msgstr "Mise à jour des paquets AUR...\\n" +msgid "AUR Packages:" +msgstr "Paquets AUR :" -#: src/script/arch-update.sh:479 +#: src/lib/list_packages.sh:42 #, sh-format -msgid "Updating Flatpak Packages...\\n" -msgstr "Mise à jour des paquets Flatpak...\\n" +msgid "Flatpak Packages:" +msgstr "Paquets Flatpak :" -#: src/script/arch-update.sh:490 +#: src/lib/list_packages.sh:48 #, sh-format -msgid "The update has been applied\\n" -msgstr "La mise à jour a été appliquée\\n" +msgid "No update available\\n" +msgstr "Aucune mise à jour disponible\\n" + +#: src/lib/list_packages.sh:56 +#, sh-format +msgid "Proceed with update? [Y/n]" +msgstr "Procéder à la mise à jour ? [O/n]" + +#: src/lib/list_packages.sh:66 +#, sh-format +msgid "The update has been aborted\\n" +msgstr "La mise à jour a été abandonnée\\n" -#: src/script/arch-update.sh:502 +#: src/lib/orphan_packages.sh:14 #, sh-format msgid "Orphan Packages:" msgstr "Paquets orphelins :" -#: src/script/arch-update.sh:506 +#: src/lib/orphan_packages.sh:18 #, sh-format msgid "" "Would you like to remove this orphan package (and its potential " @@ -385,7 +434,7 @@ msgstr "" "Voulez-vous supprimer ce paquet orphelin (et ses potentielles " "dépendances) maintenant ? [o/N]" -#: src/script/arch-update.sh:508 +#: src/lib/orphan_packages.sh:20 #, sh-format msgid "" "Would you like to remove these orphan packages (and their potential " @@ -394,14 +443,14 @@ msgstr "" "Voulez-vous supprimer ces paquets orphelins (et leurs potentielles " "dépendances) maintenant ? [o/N]" -#: src/script/arch-update.sh:514 +#: src/lib/orphan_packages.sh:27 #, sh-format msgid "Removing Orphan Packages...\\n" msgstr "Suppression des paquets orphelins...\\n" -#: src/script/arch-update.sh:518 src/script/arch-update.sh:551 -#: src/script/arch-update.sh:594 src/script/arch-update.sh:604 -#: src/script/arch-update.sh:614 src/script/arch-update.sh:623 +#: src/lib/orphan_packages.sh:32 src/lib/orphan_packages.sh:65 +#: src/lib/packages_cache.sh:38 src/lib/packages_cache.sh:48 +#: src/lib/packages_cache.sh:58 src/lib/packages_cache.sh:67 #, sh-format msgid "" "An error has occurred during the removal process\\nThe removal has been " @@ -410,113 +459,113 @@ msgstr "" "Une erreur est survenue pendant le processus de suppression\\nLa suppression a été " "abandonnée\\n" -#: src/script/arch-update.sh:521 src/script/arch-update.sh:554 +#: src/lib/orphan_packages.sh:35 src/lib/orphan_packages.sh:68 #, sh-format msgid "The removal has been applied\\n" msgstr "La suppression a été appliquée\\n" -#: src/script/arch-update.sh:526 src/script/arch-update.sh:558 -#: src/script/arch-update.sh:631 +#: src/lib/orphan_packages.sh:40 src/lib/orphan_packages.sh:72 +#: src/lib/packages_cache.sh:75 #, sh-format msgid "The removal hasn't been applied\\n" msgstr "La suppression n'a pas été appliquée\\n" -#: src/script/arch-update.sh:530 +#: src/lib/orphan_packages.sh:44 #, sh-format msgid "No orphan package found\\n" msgstr "Aucun paquet orphelin n'a été trouvé\\n" -#: src/script/arch-update.sh:535 +#: src/lib/orphan_packages.sh:49 #, sh-format msgid "Flatpak Unused Packages:" msgstr "Paquets Flatpak inutilisés :" -#: src/script/arch-update.sh:539 +#: src/lib/orphan_packages.sh:53 #, sh-format msgid "Would you like to remove this Flatpak unused package now? [y/N]" msgstr "Voulez-vous supprimer ce paquet Flatpak inutilisé maintenant ? [o/N]" -#: src/script/arch-update.sh:541 +#: src/lib/orphan_packages.sh:55 #, sh-format msgid "Would you like to remove these Flatpak unused packages now? [y/N]" msgstr "Voulez-vous supprimer ces paquets Flatpak inutilisés maintenant ? [o/N]" -#: src/script/arch-update.sh:547 +#: src/lib/orphan_packages.sh:61 #, sh-format msgid "Removing Flatpak Unused Packages..." msgstr "Suppression des paquets Flatpak inutilisés..." -#: src/script/arch-update.sh:562 +#: src/lib/orphan_packages.sh:76 #, sh-format msgid "No Flatpak unused package found\\n" msgstr "Aucun paquet Flatpak inutilisé n'a été trouvé\\n" -#: src/script/arch-update.sh:579 +#: src/lib/packages_cache.sh:21 #, sh-format msgid "Cached Packages:\\nThere's an old or uninstalled cached package\\n" msgstr "Paquets mis en cache :\\nIl y a un paquet ancien ou désinstallé mis en cache\\n" -#: src/script/arch-update.sh:580 +#: src/lib/packages_cache.sh:22 #, sh-format msgid "Would you like to remove it from the cache now? [Y/n]" msgstr "Voulez-vous le supprimer du cache maintenant ? [O/n]" -#: src/script/arch-update.sh:582 +#: src/lib/packages_cache.sh:24 #, sh-format msgid "Cached Packages:\\nThere are old and/or uninstalled cached packages\\n" msgstr "Paquets mis en cache :\\nIl y a plusieurs paquets anciens ou désinstallés mis en cache\\n" -#: src/script/arch-update.sh:583 +#: src/lib/packages_cache.sh:25 #, sh-format msgid "Would you like to remove them from the cache now? [Y/n]" msgstr "Voulez-vous les supprimer du cache maintenant ? [O/n]" -#: src/script/arch-update.sh:590 src/script/arch-update.sh:610 +#: src/lib/packages_cache.sh:33 src/lib/packages_cache.sh:54 #, sh-format msgid "Removing old cached packages..." msgstr "Suppression des anciens paquets mis en cache..." -#: src/script/arch-update.sh:600 src/script/arch-update.sh:619 +#: src/lib/packages_cache.sh:44 src/lib/packages_cache.sh:63 #, sh-format msgid "Removing uninstalled cached packages..." msgstr "Suppression des paquets désinstallés mis en cache..." -#: src/script/arch-update.sh:635 +#: src/lib/packages_cache.sh:79 #, sh-format msgid "No old or uninstalled cached package found\\n" msgstr "Aucun paquet ancien ou désinstallé mis en cache n'a été trouvé\\n" -#: src/script/arch-update.sh:644 +#: src/lib/pacnew_files.sh:10 #, sh-format msgid "Pacnew Files:" msgstr "Fichiers Pacnew :" -#: src/script/arch-update.sh:648 +#: src/lib/pacnew_files.sh:14 #, sh-format msgid "Would you like to process this file now? [Y/n]" msgstr "Voulez-vous traiter ce fichier maintenant ? [O/n]" -#: src/script/arch-update.sh:650 +#: src/lib/pacnew_files.sh:16 #, sh-format msgid "Would you like to process these files now? [Y/n]" msgstr "Voulez-vous traiter ces fichiers maintenant ? [O/n]" -#: src/script/arch-update.sh:656 +#: src/lib/pacnew_files.sh:23 #, sh-format msgid "Processing Pacnew Files...\\n" msgstr "Traitement des fichiers pacnew...\\n" -#: src/script/arch-update.sh:660 +#: src/lib/pacnew_files.sh:28 #, sh-format msgid "The pacnew file(s) processing has been applied\\n" msgstr "Le traitement des fichiers pacnew a été appliqué\\n" -#: src/script/arch-update.sh:663 +#: src/lib/pacnew_files.sh:31 #, sh-format msgid "An error occurred during the pacnew file(s) processing\\n" msgstr "Une erreur est survenue durant le traitement du/des fichier(s) pacnew\\n" -#: src/script/arch-update.sh:669 +#: src/lib/pacnew_files.sh:37 #, sh-format msgid "" "The pacnew file(s) processing hasn't been applied\\nPlease, consider " @@ -525,22 +574,22 @@ msgstr "" "Le traitement des fichiers pacnew n'a pas été appliqué\\nVeuillez considérer " "les traiter promptement\\n" -#: src/script/arch-update.sh:673 +#: src/lib/pacnew_files.sh:41 #, sh-format msgid "No pacnew file found\\n" msgstr "Aucun fichier pacnew n'a été trouvé\\n" -#: src/script/arch-update.sh:685 +#: src/lib/restart_services.sh:13 #, sh-format msgid "Services:\\nThe following service requires a post upgrade restart\\n" msgstr "Services :\\nLe service suivant requiert un redémarrage suite à sa mise à jour\\n" -#: src/script/arch-update.sh:687 +#: src/lib/restart_services.sh:15 #, sh-format msgid "Services:\\nThe following services require a post upgrade restart\\n" msgstr "Services :\\nLes services suivants requièrent un redémarrage suite à leur mise à jour\\n" -#: src/script/arch-update.sh:697 +#: src/lib/restart_services.sh:25 #, sh-format msgid "" "Select the service(s) to restart (e.g. 1 3 5), select 0 to restart them all " @@ -549,12 +598,12 @@ msgstr "" "Sélectionnez le(s) service(s) à redémarrer (par exemple: 1 3 5); sélectionnez 0 pour tous les redémarrer " "ou appuyez sur \"entrée\" pour continuer sans redémarrer le(s) service(s) :" -#: src/script/arch-update.sh:703 src/script/arch-update.sh:730 +#: src/lib/restart_services.sh:31 src/lib/restart_services.sh:58 #, sh-format msgid "Service(s) restarted successfully\\n" msgstr "Service(s) redémarré(s) avec succès\\n" -#: src/script/arch-update.sh:706 src/script/arch-update.sh:733 +#: src/lib/restart_services.sh:34 src/lib/restart_services.sh:61 #, sh-format msgid "" "An error has occurred during the service(s) restart\\nPlease, verify the " @@ -563,19 +612,19 @@ msgstr "" "Une erreur est survenue pendant le redémarrage du/des service(s)\\n Veuillez vérifier " "le statut des services ci-dessus\\n" -#: src/script/arch-update.sh:719 +#: src/lib/restart_services.sh:47 #, sh-format msgid "The ${service_selected} service has been successfully restarted" msgstr "Le service ${service_selected} a été redémarré avec succès" -#: src/script/arch-update.sh:721 +#: src/lib/restart_services.sh:49 #, sh-format msgid "" "An error has occurred during the restart of the ${service_selected} service" msgstr "" "Une erreur est survenue pendant le redémarrage du service ${service_selected}" -#: src/script/arch-update.sh:737 +#: src/lib/restart_services.sh:65 #, sh-format msgid "" "The service(s) restart hasn't been performed\\nPlease, consider restarting " @@ -584,101 +633,30 @@ msgstr "" "Le redémarrage du/des service(s) n'a pas été appliqué\\nVeuillez considérer redémarrer " "les services qui ont été mis à jour pour appliquer complètement la mise à niveau\\n" -#: src/script/arch-update.sh:741 +#: src/lib/restart_services.sh:69 #, sh-format msgid "No service requiring a post upgrade restart found\\n" msgstr "Aucun service nécessitant un redémarrage suite à la mise à jour n'a été trouvé\\n" -#: src/script/arch-update.sh:750 -#, sh-format -msgid "" -"Reboot required:\\nThere's a pending kernel update on your system requiring " -"a reboot to be applied\\n" -msgstr "" -"Redémarrage nécessaire :\\nIl y a une mise à jour du noyau en attente sur votre système qui nécessite " -"un redémarrage pour être appliquée\\n" - -#: src/script/arch-update.sh:751 -#, sh-format -msgid "Would you like to reboot now? [y/N]" -msgstr "Voulez-vous redémarrer votre système maintenant ? [o/N]" - -#: src/script/arch-update.sh:764 -#, sh-format -msgid "Rebooting in ${sec}...\\r" -msgstr "Redémarrage dans ${sec}...\\r" - -#: src/script/arch-update.sh:770 -#, sh-format -msgid "" -"An error has occurred during the reboot process\\nThe reboot has been " -"aborted\\n" -msgstr "" -"Une erreur est survenue pendant le processus de redémarrage\\nLe redémarrage a été " -"abandonné\\n" - -#: src/script/arch-update.sh:778 -#, sh-format -msgid "" -"The reboot hasn't been performed\\nPlease, consider rebooting to finalize " -"the pending kernel update\\n" -msgstr "" -"Le redémarrage n'a pas été effectué\\nVeuillez considérer redémarrer votre système pour finaliser " -"la mise à jour du noyau en attente\\n" - -#: src/script/arch-update.sh:782 -#, sh-format -msgid "No pending kernel update found\\n" -msgstr "Aucune mise à jour du noyau en attente n'a été trouvée\\n" - -#: src/script/arch-update.sh:838 -#, sh-format -msgid "Example configuration file not found" -msgstr "Fichier de configuration exemple non trouvé" - -#: src/script/arch-update.sh:843 -#, sh-format -msgid "" -"The '${config_file}' configuration file already exists\\nPlease, remove it " -"before generating a new one" -msgstr "" -"Le fichier de configuration '${config_file}' existe déjà.\\nVeuillez le supprimer " -"avant d'en générer un nouveau" - -#: src/script/arch-update.sh:848 -#, sh-format -msgid "The '${config_file}' configuration file has been generated" -msgstr "Le fichier de configuration '${config_file}' a été généré" - -#: src/script/arch-update.sh:853 src/script/arch-update.sh:861 -#, sh-format -msgid "" -"No configuration file found\\nYou can generate one with \"arch-update --gen-" -"config\"" -msgstr "" -"Aucun fichier de configuration n'a été trouvé\\nVous pouvez en générer un avec \"arch-update --gen-" -"config\"" +#: src/lib/tray.py:123 +msgid "Run Arch-Update" +msgstr "Lancer Arch-Update" -#: src/script/arch-update.sh:865 -#, sh-format -msgid "" -"Unable to determine the editor to use\\nThe \"EDITOR\" environment variable " -"is not set and \"nano\" (fallback option) is not installed" -msgstr "" -"Impossible de déterminer l'éditeur à utiliser\\n La variable d'environnement \"EDITOR\" " -"n'est pas paramétrée et \"nano\" (option de secours) n'est pas installé" +#: src/lib/tray.py:124 +msgid "Exit" +msgstr "Quitter" -#: src/script/arch-update.sh:883 +#: src/lib/tray.sh:20 #, sh-format msgid "Arch-Update tray desktop file not found" msgstr "Le fichier Arch-Update tray desktop n'a pas été trouvé" -#: src/script/arch-update.sh:890 +#: src/lib/tray.sh:27 #, sh-format msgid "The '${tray_desktop_file_autostart}' file already exists" msgstr "Le fichier '${tray_desktop_file_autostart}' existe déjà" -#: src/script/arch-update.sh:895 +#: src/lib/tray.sh:32 #, sh-format msgid "" "The '${tray_desktop_file_autostart}' file has been created, the Arch-Update " @@ -691,15 +669,36 @@ msgstr "" "immédiatement, vous pouvez lancer l'application \"Arch-Update Systray Applet\" " "depuis votre menu d'application" -#: src/script/arch-update.sh:903 +#: src/lib/tray.sh:42 #, sh-format msgid "There's already a running instance of the Arch-Update systray applet" msgstr "Il y a déjà une instance de l'applet systray d'Arch-Update en cours d'exécution" -#: src/script/arch-update-tray.py:123 -msgid "Run Arch-Update" -msgstr "Lancer Arch-Update" +#: src/lib/update.sh:9 +#, sh-format +msgid "Updating Packages...\\n" +msgstr "Mise à jour des paquets...\\n" -#: src/script/arch-update-tray.py:124 -msgid "Exit" -msgstr "Quitter" +#: src/lib/update.sh:15 src/lib/update.sh:30 src/lib/update.sh:44 +#, sh-format +msgid "" +"An error has occurred during the update process\\nThe update has been " +"aborted\\n" +msgstr "" +"Une erreur est survenue pendant le processus de mise à jour\\nLa mise à jour a été " +"abandonnée\\n" + +#: src/lib/update.sh:24 +#, sh-format +msgid "Updating AUR Packages...\\n" +msgstr "Mise à jour des paquets AUR...\\n" + +#: src/lib/update.sh:40 +#, sh-format +msgid "Updating Flatpak Packages...\\n" +msgstr "Mise à jour des paquets Flatpak...\\n" + +#: src/lib/update.sh:51 +#, sh-format +msgid "The update has been applied\\n" +msgstr "La mise à jour a été appliquée\\n" diff --git a/src/arch-update.sh b/src/arch-update.sh new file mode 100755 index 0000000..baecc0d --- /dev/null +++ b/src/arch-update.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +# arch-update: An update notifier/applier for Arch Linux that assists you with important pre/post update tasks +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# General variables +name="arch-update" +_name="Arch-Update" +version="2.3.3" +option="${1}" + +# Define the directory containing libraries +if [ -d "${XDG_DATA_HOME}/${name}/lib" ]; then + libdir="${XDG_DATA_HOME}/${name}/lib" +elif [ -d "${HOME}/.local/share/${name}/lib" ]; then + libdir="${HOME}/.local/share/${name}/lib" +elif [ -d "${XDG_DATA_DIRS}/${name}/lib" ]; then + libdir="${XDG_DATA_DIRS}/${name}/lib" +elif [ -d "/usr/local/share/${name}/lib" ]; then + libdir="/usr/local/share/${name}/lib" +elif [ -d "/usr/share/${name}/lib" ]; then + libdir="/usr/share/${name}/lib" +else + echo -e >&2 "ERROR: Libraries directory not found" + exit 14 +fi + +# Source the "config" library which contains every configuration parameters, pre-steps and pre-verifications required for Arch-Update to work properly +# shellcheck source=src/lib/config.sh +source "${libdir}/config.sh" + +# Source the "common" library which contains variables and functions commonly used across Arch-Update stages +# shellcheck source=src/lib/common.sh +source "${libdir}/common.sh" + +# Source the different libraries depending on the option(s) passed +case "${option}" in + "") + # Source the "full_upgrade" library which executes the series of relevant functions/libraries to perform a complete and proper update of the system + # shellcheck source=src/lib/full_upgrade.sh + source "${libdir}/full_upgrade.sh" + ;; + -d|--devel) + # Set the "--devel" flag for AUR helpers (yay/paru) + devel_flag+=("--devel") + + # Source the "full_upgrade" library which executes the series of relevant functions/libraries to perform a complete and proper update of the system + # shellcheck source=src/lib/full_upgrade.sh + source "${libdir}/full_upgrade.sh" + ;; + -c|--check) + # Source the "check" library which checks for available updates + # shellcheck source=src/lib/check.sh + source "${libdir}/check.sh" + ;; + -l|--list) + # Set that the "-l/--list" option is used (required for the "list_packages" library to only print the list of packages available for update without asking for the user confirmation to apply them) + list_option="y" + + # Source the "list_packages" library which displays the list of packages available for updates + # shellcheck source=src/lib/list_packages.sh + source "${libdir}/list_packages.sh" + ;; + -n|--news) + # Set that news should be shown and that the "-n/--news" option is used (required for the "list_news" library to only print the list of recent Arch news without looking to continue with the update process) + show_news="y" + news_option="y" + + # Check if the user specified a specific number of news to display + if [ "${2}" -gt 0 ] 2> /dev/null; then + news_num="${2}" + fi + + # Source the "list_news" library which displays the latest Arch news and offers to read them + # shellcheck source=src/lib/list_news.sh + source "${libdir}/list_news.sh" + ;; + --gen-config) + # Source the "gen-config" library which generates a default "arch-update.conf" configuration file (if it doesn't exists yet) + # shellcheck source=src/lib/gen-config.sh + source "${libdir}/gen-config.sh" + ;; + --show-config) + # Source the "show-config" library which displays the current "arch-update.conf" configuration file + # shellcheck source=src/lib/show-config.sh + source "${libdir}/show-config.sh" + ;; + --edit-config) + # Source the "edit-config" library which edits the current "arch-update.conf" configuration file + # shellcheck source=src/lib/edit-config.sh + source "${libdir}/edit-config.sh" + ;; + --tray) + # Source the "tray" library which starts the Arch-Update systray applet + # shellcheck source=src/lib/tray.sh + source "${libdir}/tray.sh" + ;; + -h|--help) + # Source the "help" library which displays the help message + # shellcheck source=src/lib/help.sh + source "${libdir}/help.sh" + ;; + -V|--version) + # Source the "version" library which displays version information + # shellcheck source=src/lib/version.sh + source "${libdir}/version.sh" + ;; + *) + # Source the "invalid_option" library which displays an error when an invalid option is passed + # shellcheck source=src/lib/invalid_option.sh + source "${libdir}/invalid_option.sh" + ;; +esac diff --git a/src/lib/check.sh b/src/lib/check.sh new file mode 100755 index 0000000..40be48b --- /dev/null +++ b/src/lib/check.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# check.sh: Check for available updates +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +if [ -n "${aur_helper}" ] && [ -n "${flatpak}" ]; then + update_available=$(checkupdates ; "${aur_helper}" -Qua ; flatpak update | sed -n '/^ 1./,$p' | awk '{print $2}' | grep -v '^$' | sed '$d') +elif [ -n "${aur_helper}" ] && [ -z "${flatpak}" ]; then + update_available=$(checkupdates ; "${aur_helper}" -Qua) +elif [ -z "${aur_helper}" ] && [ -n "${flatpak}" ]; then + update_available=$(checkupdates ; flatpak update | sed -n '/^ 1./,$p' | awk '{print $2}' | grep -v '^$' | sed '$d') +else + update_available=$(checkupdates) +fi + +if [ -n "${notif}" ]; then + # shellcheck disable=SC2154 + echo "${update_available}" > "${statedir}/current_updates_check" + sed -i '/^\s*$/d' "${statedir}/current_updates_check" +fi + +if [ -n "${update_available}" ]; then + state_updates_available + + if [ -n "${notif}" ]; then + if ! diff "${statedir}/current_updates_check" "${statedir}/last_updates_check" &> /dev/null; then + update_number=$(wc -l "${statedir}/current_updates_check" | awk '{print $1}') + # shellcheck disable=SC2154 + last_notif_id=$(cat "${tmpdir}/last_notif_id" 2> /dev/null) + if [ "${update_number}" -eq 1 ]; then + if [ -z "${last_notif_id}" ]; then + # shellcheck disable=SC2154 + notify-send -p -i "${name}" "${_name}" "$(eval_gettext "\${update_number} update available")" > "${tmpdir}/last_notif_id" + else + # shellcheck disable=SC2154 + notify-send -p -r "${last_notif_id}" -i "${name}" "${_name}" "$(eval_gettext "\${update_number} update available")" > "${tmpdir}/last_notif_id" + fi + + else + if [ -z "${last_notif_id}" ]; then + notify-send -p -i "${name}" "${_name}" "$(eval_gettext "\${update_number} updates available")" > "${tmpdir}/last_notif_id" + else + notify-send -p -r "${last_notif_id}" -i "${name}" "${_name}" "$(eval_gettext "\${update_number} updates available")" > "${tmpdir}/last_notif_id" + fi + fi + fi + fi +else + state_up_to_date +fi + +if [ -f "${statedir}/current_updates_check" ]; then + mv -f "${statedir}/current_updates_check" "${statedir}/last_updates_check" +fi + + diff --git a/src/lib/common.sh b/src/lib/common.sh new file mode 100755 index 0000000..81d833a --- /dev/null +++ b/src/lib/common.sh @@ -0,0 +1,127 @@ +#!/bin/bash + +# common.sh: Set variables and functions commonly used across Arch-Update stages +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# Definition of the AUR helper to use (depending on if/which one is installed on the system) for the optional AUR packages support +if command -v paru > /dev/null; then + # shellcheck disable=SC2034 + aur_helper="paru" +elif command -v yay > /dev/null; then + # shellcheck disable=SC2034 + aur_helper="yay" +fi + +# Check if flatpak is installed for the optional Flatpak support +# shellcheck disable=SC2034 +flatpak=$(command -v flatpak) + +# Check if notify-send is installed for the optional desktop notification support +# shellcheck disable=SC2034 +notif=$(command -v notify-send) + +# Definition of the diff program to use (if it is set in the arch-update.conf configuration file) +if [ -n "${diff_prog}" ]; then + if [ "${su_cmd}" == "sudo" ]; then + diff_prog_opt=("DIFFPROG=${diff_prog}") + elif [ "${su_cmd}" == "run0" ]; then + diff_prog_opt+=("--setenv=DIFFPROG=${diff_prog}") + fi +fi + +# Definition of the colors for the colorized output +if [ -z "${no_color}" ]; then + bold="\e[1m" + blue="${bold}\e[34m" + green="${bold}\e[32m" + yellow="${bold}\e[33m" + red="${bold}\e[31m" + color_off="\e[0m" + # shellcheck disable=SC2034 + pacman_color_opt="always" +else + # shellcheck disable=SC2034 + pacman_color_opt="never" + contrib_color_opt+=("--nocolor") +fi + +# Definition of the main_msg function: Display a message as a main message +main_msg() { + msg="${1}" + echo -e "${blue}==>${color_off}${bold} ${msg}${color_off}" +} + +# Definition of the info_msg function: Display a message as an information message +info_msg() { + msg="${1}" + echo -e "${green}==>${color_off}${bold} ${msg}${color_off}" +} + +# Definition of the ask_msg function: Display a message as an interactive question +ask_msg() { + msg="${1}" + # shellcheck disable=SC2034 + read -rp $"$(echo -e "${blue}->${color_off}${bold} ${msg}${color_off} ")" answer +} + +# Definition of the ask_msg_array function: Display a message as an interactive question with multiple possible answers +ask_msg_array() { + msg="${1}" + # shellcheck disable=SC2034 + read -rp $"$(echo -e "${blue}->${color_off}${bold} ${msg}${color_off} ")" -a answer_array +} + +# Definition of the warning_msg function: Display a message as a warning message +warning_msg() { + msg="${1}" + echo -e "${yellow}==> $(eval_gettext "WARNING"):${color_off}${bold} ${msg}${color_off}" +} + +# Definition of the error_msg function: Display a message as an error message +error_msg() { + msg="${1}" + echo -e >&2 "${red}==> $(eval_gettext "ERROR"):${color_off}${bold} ${msg}${color_off}" +} + +# Definition of the continue_msg function: Display the continue message +continue_msg() { + msg="$(eval_gettext "Press \"enter\" to continue ")" + read -n 1 -r -s -p $"$(info_msg "${msg}")" && echo +} + +# Definition of the quit_msg function: Display the quit message +quit_msg() { + msg="$(eval_gettext "Press \"enter\" to quit ")" + read -n 1 -r -s -p $"$(info_msg "${msg}")" && echo +} + +# Definition of the elevation command to use (depending on which one is installed on the system and if it's not already defined in arch-update.conf) +if [ -z "${su_cmd}" ]; then + if command -v sudo > /dev/null; then + su_cmd="sudo" + elif command -v doas > /dev/null; then + su_cmd="doas" + elif command -v run0 > /dev/null; then + su_cmd="run0" + else + error_msg "$(eval_gettext "A privilege elevation command is required (sudo, doas or run0)\n")" && quit_msg + exit 2 + fi +else + if ! command -v "${su_cmd}" > /dev/null; then + error_msg "$(eval_gettext "The \${su_cmd} command set for privilege escalation in the arch-update.conf configuration file is not found\n")" && quit_msg + exit 2 + fi +fi + +# Definition of the state_updates_available function: Change state to "updates-available" +state_updates_available() { + # shellcheck disable=SC2154 + echo "${name}_updates-available" > "${statedir}/current_state" +} + +# Definition of the state_up_to_date function: Change state to "up to date" +state_up_to_date() { + echo "${name}" > "${statedir}/current_state" +} diff --git a/src/lib/config.sh b/src/lib/config.sh new file mode 100755 index 0000000..9a2a2f6 --- /dev/null +++ b/src/lib/config.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +# config.sh: Set configuration parameters, pre-steps and pre-verifications required for Arch-Update to work properly +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# Display debug traces if the -D/--debug argument is passed +for arg in "${@}"; do + case "${arg}" in + -D|--debug) + set -x + ;; + esac +done + +# Reset the option var if it is equal to -D/--debug (to avoid false negative "invalid option" error) +# shellcheck disable=SC2154 +case "${option}" in + -D|--debug) + unset option + ;; +esac + +# Create state and tmp dirs if they don't exist +# shellcheck disable=SC2154 +statedir="${XDG_STATE_HOME:-${HOME}/.local/state}/${name}" +tmpdir="${TMPDIR:-/tmp}/${name}-${UID}" +mkdir -p "${statedir}" "${tmpdir}" + +# Declare necessary parameters for translations +# shellcheck disable=SC1091 +. gettext.sh +# shellcheck disable=SC2154 +export TEXTDOMAIN="${_name}" # Using "Arch-Update" as TEXTDOMAIN to avoid conflicting with the "arch-update" TEXTDOMAIN used by the arch-update Gnome extension (https://extensions.gnome.org/extension/1010/archlinux-updates-indicator/) +if [ -f "${XDG_DATA_HOME}/locale/fr/LC_MESSAGES/${_name}.mo" ]; then + export TEXTDOMAINDIR="${XDG_DATA_HOME}/locale" +elif [ -f "${HOME}/.local/share/locale/fr/LC_MESSAGES/${_name}.mo" ]; then + export TEXTDOMAINDIR="${HOME}/.local/share/locale" +elif [ -f "${XDG_DATA_DIRS}/locale/fr/LC_MESSAGES/${_name}.mo" ]; then + export TEXTDOMAINDIR="${XDG_DATA_DIRS}/locale" +elif [ -f "/usr/local/share/locale/fr/LC_MESSAGES/${_name}.mo" ]; then + export TEXTDOMAINDIR="/usr/local/share/locale" +fi + +# Checking options in arch-update.conf +config_file="${XDG_CONFIG_HOME:-${HOME}/.config}/${name}/${name}.conf" + +if grep -Eq '^[[:space:]]*NoColor[[:space:]]*$' "${config_file}" 2> /dev/null; then + # shellcheck disable=SC2034 + no_color="y" +fi + +if grep -Eq '^[[:space:]]*NoVersion[[:space:]]*$' "${config_file}" 2> /dev/null; then + # shellcheck disable=SC2034 + no_version="y" +fi + +if grep -Eq '^[[:space:]]*AlwaysShowNews[[:space:]]*$' "${config_file}" 2> /dev/null; then + # shellcheck disable=SC2034 + show_news="y" +fi + +if grep -Eq '^[[:space:]]*NewsNum[[:space:]]*=[[:space:]]*[1-9][0-9]*[[:space:]]*$' "${config_file}" 2> /dev/null; then + # shellcheck disable=SC2034 + news_num=$(grep -E '^[[:space:]]*NewsNum[[:space:]]*=[[:space:]]*[1-9][0-9]*[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') +else + # shellcheck disable=SC2034 + news_num="5" +fi + +if grep -Eq '^[[:space:]]*KeepOldPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null; then + old_packages_num=$(grep -E '^[[:space:]]*KeepOldPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') +else + # shellcheck disable=SC2034 + old_packages_num="3" +fi + +if grep -Eq '^[[:space:]]*KeepUninstalledPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null; then + uninstalled_packages_num=$(grep -E '^[[:space:]]*KeepUninstalledPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') +else + # shellcheck disable=SC2034 + uninstalled_packages_num="0" +fi + +if grep -Eq '^[[:space:]]*PrivilegeElevationCommand[[:space:]]*=[[:space:]]*(sudo|doas|run0)[[:space:]]*$' "${config_file}" 2> /dev/null; then + # shellcheck disable=SC2034 + su_cmd=$(grep -E '^[[:space:]]*PrivilegeElevationCommand[[:space:]]*=[[:space:]]*(sudo|doas|run0)[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') +fi + +if grep -Eq '^[[:space:]]*DiffProg[[:space:]]*=[[:space:]]*[^[:space:]].*[[:space:]]*$' "${config_file}" 2> /dev/null; then + # shellcheck disable=SC2034 + diff_prog=$(grep -E '^[[:space:]]*DiffProg[[:space:]]*=[[:space:]]*[^[:space:]].*[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') +fi diff --git a/src/lib/edit-config.sh b/src/lib/edit-config.sh new file mode 100755 index 0000000..dccb11e --- /dev/null +++ b/src/lib/edit-config.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# edit-config.sh: Edit the current "arch-update.conf" configuration file +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck disable=SC2154 +if [ ! -f "${config_file}" ]; then + error_msg "$(eval_gettext "No configuration file found\nYou can generate one with \"arch-update --gen-config\"")" + exit 13 +else + if ! "${EDITOR:-nano}" "${config_file}" 2> /dev/null; then + error_msg "$(eval_gettext "Unable to determine the editor to use\nThe \"EDITOR\" environment variable is not set and \"nano\" (fallback option) is not installed")" + exit 13 + fi +fi diff --git a/src/lib/full_upgrade.sh b/src/lib/full_upgrade.sh new file mode 100755 index 0000000..51697c5 --- /dev/null +++ b/src/lib/full_upgrade.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# full_upgrade.sh: Execute the series of relevant functions/libraries to perform a complete and proper update of the system +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# Source the "list_packages" library which displays the list of packages available for updates +# shellcheck source=src/lib/list_packages.sh disable=SC2154 +source "${libdir}/list_packages.sh" + +# If the user gave the confirmation to proceed to apply updates +if [ -n "${proceed_with_update}" ]; then + # Source the "list_news" library which displays the latest Arch news and offers to read them + # shellcheck source=src/lib/list_news.sh + source "${libdir}/list_news.sh" + + # Source the "update" library which updates packages + # shellcheck source=src/lib/update.sh + source "${libdir}/update.sh" + + # Record the date of the last successful update (used by other stages) + date +%Y-%m-%d > "${statedir}/last_update_run" +fi + +# Source the "orphan_packages" library which displays orphan packages and offers to remove them +# shellcheck source=src/lib/orphan_packages.sh +source "${libdir}/orphan_packages.sh" + +# Source the "packages_cache" library which searches for old package archives in pacman cache and offers to remove them +# shellcheck source=src/lib/packages_cache.sh +source "${libdir}/packages_cache.sh" + +# Source the "pacnew_files" library which display pacnew files and offers to process them +# shellcheck source=src/lib/pacnew_files.sh +source "${libdir}/pacnew_files.sh" + +# Source the "kernel_reboot" library which check if there's a pending kernel update requiring a reboot to be applied +# shellcheck source=src/lib/kernel_reboot.sh +source "${libdir}/kernel_reboot.sh" + +# Source the "restart_services" library which displays services requiring a post update restart and offers to restart them +# shellcheck source=src/lib/restart_services.sh +source "${libdir}/restart_services.sh" + +# Display the "quit" message on successful full upgrade +quit_msg diff --git a/src/lib/gen-config.sh b/src/lib/gen-config.sh new file mode 100755 index 0000000..e2cf464 --- /dev/null +++ b/src/lib/gen-config.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# gen.config.sh: Generate a default "arch-update.conf" configuration file (if it doesn't exists yet) +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck disable=SC2154 +if [ -f "${XDG_DATA_HOME}/doc/${name}/${name}.conf.example" ]; then + example_config_file="${XDG_DATA_HOME}/doc/${name}/${name}.conf.example" +elif [ -f "${HOME}/.local/share/doc/${name}/${name}.conf.example" ]; then + example_config_file="${HOME}/.local/share/doc/${name}/${name}.conf.example" +elif [ -f "${XDG_DATA_DIRS}/doc/${name}/${name}.conf.example" ]; then + example_config_file="${XDG_DATA_DIRS}/doc/${name}/${name}.conf.example" +elif [ -f "/usr/local/share/doc/${name}/${name}.conf.example" ]; then + example_config_file="/usr/local/share/doc/${name}/${name}.conf.example" +elif [ -f "/usr/share/doc/${name}/${name}.conf.example" ]; then + example_config_file="/usr/share/doc/${name}/${name}.conf.example" +else + error_msg "$(eval_gettext "Example configuration file not found")" + exit 8 +fi + +# shellcheck disable=SC2154 +if [ -f "${config_file}" ]; then + error_msg "$(eval_gettext "The '\${config_file}' configuration file already exists\nPlease, remove it before generating a new one")" + exit 8 +else + mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/${name}/" + cp "${example_config_file}" "${config_file}" || exit 8 + info_msg "$(eval_gettext "The '\${config_file}' configuration file has been generated")" +fi diff --git a/src/lib/help.sh b/src/lib/help.sh new file mode 100755 index 0000000..1c85e6c --- /dev/null +++ b/src/lib/help.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# help.sh: Display the help message +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +cat <&2 "$(eval_gettext "\${name}: invalid option -- '\${option}'\nTry '\${name} --help' for more information.")" +exit 1 diff --git a/src/lib/kernel_reboot.sh b/src/lib/kernel_reboot.sh new file mode 100755 index 0000000..9f4b178 --- /dev/null +++ b/src/lib/kernel_reboot.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# kernel_reboot.sh: Check if there's a pending kernel update requiring a reboot to be applied +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +kernel_compare=$(file /boot/vmlinuz* /usr/lib/modules/*/vmlinuz* | sed 's/^.*version\ //' | awk '{print $1}' | grep "$(uname -r)") + +if [ -z "${kernel_compare}" ]; then + main_msg "$(eval_gettext "Reboot required:\nThere's a pending kernel update on your system requiring a reboot to be applied\n")" + ask_msg "$(eval_gettext "Would you like to reboot now? [y/N]")" + + # shellcheck disable=SC2154 + case "${answer}" in + "$(eval_gettext "Y")"|"$(eval_gettext "y")") + echo + + # shellcheck disable=SC2317,SC2329 + restore_cursor() { + tput cnorm + } + trap restore_cursor EXIT + + # shellcheck disable=SC2034 + for sec in {5..1}; do + # shellcheck disable=SC2154 + tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in \${sec}...\r")${color_off}" + sleep 1 + done + + if ! reboot; then + echo + error_msg "$(eval_gettext "An error has occurred during the reboot process\nThe reboot has been aborted\n")" && quit_msg + exit 6 + else + exit 0 + fi + ;; + *) + echo + warning_msg "$(eval_gettext "The reboot hasn't been performed\nPlease, consider rebooting to finalize the pending kernel update\n")" + ;; + esac +else + info_msg "$(eval_gettext "No pending kernel update found\n")" +fi diff --git a/src/lib/list_news.sh b/src/lib/list_news.sh new file mode 100755 index 0000000..8220f48 --- /dev/null +++ b/src/lib/list_news.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# list_news.sh: Display the latest Arch news and offer to read them +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +info_msg "$(eval_gettext "Looking for recent Arch News...")" +news=$(curl -m 30 -Lfs https://www.archlinux.org/news || echo "error") + +if [ "${news}" == "error" ]; then + echo + warning_msg "$(eval_gettext "Unable to retrieve recent Arch News (HTTP error response or request timeout)\nPlease, look for any recent news at https://archlinux.org before updating your system")" +else + if [ -z "${show_news}" ]; then + # shellcheck disable=SC2154 + echo "${news}" | htmlq -a title a | grep ^"View:" | sed "s/View:\ //g" | head -1 > "${statedir}/current_news_check" + + if ! diff "${statedir}/current_news_check" "${statedir}/last_news_check" &> /dev/null; then + show_news="y" + else + echo + info_msg "$(eval_gettext "No recent Arch News found")" + fi + + if [ -f "${statedir}/current_news_check" ]; then + mv -f "${statedir}/current_news_check" "${statedir}/last_news_check" + fi + fi + + if [ -n "${show_news}" ]; then + # shellcheck disable=SC2154 + news_titles=$(echo "${news}" | htmlq -a title a | grep ^"View:" | sed "s/View:\ //g" | head -"${news_num}") + mapfile -t news_dates < <(echo "${news}" | htmlq td | grep -v "class" | grep "[0-9]" | sed "s/<[^>]*>//g" | sed "s/\.//g" | head -"${news_num}" | xargs -I{} date -d "{}" "+%s") + + echo + main_msg "$(eval_gettext "Arch News:")" + + i=1 + while IFS= read -r line; do + if [ -z "${news_option}" ] && [ "${news_dates["${i}-1"]}" -ge "$(date -d "$(cat "${statedir}/last_update_run" 2> /dev/null)" +%s)" ] 2> /dev/null; then + new_tag="$(eval_gettext "[NEW]")" + # shellcheck disable=SC2154 + echo -e "${i} - ${line} ${green}${new_tag}${color_off}" + else + echo "${i} - ${line}" + fi + ((i=i+1)) + done < <(printf '%s\n' "${news_titles}") + + echo + + if [ -n "${news_option}" ]; then + ask_msg_array "$(eval_gettext "Select the news to read (e.g. 1 3 5), select 0 to read them all or press \"enter\" to quit:")" + else + ask_msg_array "$(eval_gettext "Select the news to read (e.g. 1 3 5), select 0 to read them all or press \"enter\" to proceed with update:")" + fi + + if [ "${answer_array[0]}" -eq 0 ] 2> /dev/null; then + answer_array=() + for ((i=1; i<=news_num; i++)); do + answer_array+=("${i}") + done + else + array_to_string=$(printf "%s\n" "${answer_array[@]}") + mapfile -t answer_array < <(echo "${array_to_string}" | awk '!seen[$0]++') + fi + + for num in "${answer_array[@]}"; do + if [ "${num}" -le "${news_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then + printed_news="y" + news_selected=$(sed -n "${num}"p <<< "${news_titles}") + news_path=$(echo "${news_selected}" | sed s/\ -//g | sed s/\ /-/g | sed s/[.]//g | sed s/=//g | sed s/\>//g | sed s/\ /dev/null | grep ".service" | cut -f2 -d "'") + services_num=$(echo "${services}" | wc -l) + + if [ -n "${services}" ]; then + if [ "${services_num}" -eq 1 ]; then + main_msg "$(eval_gettext "Services:\nThe following service requires a post upgrade restart\n")" + else + main_msg "$(eval_gettext "Services:\nThe following services require a post upgrade restart\n")" + fi + + i=1 + while IFS= read -r line; do + echo "${i} - ${line}" + ((i=i+1)) + done < <(printf '%s\n' "${services}") + + echo + ask_msg_array "$(eval_gettext "Select the service(s) to restart (e.g. 1 3 5), select 0 to restart them all or press \"enter\" to continue without restarting the service(s):")" + echo + + if [ "${answer_array[0]}" -eq 0 ] 2> /dev/null; then + # shellcheck disable=SC2086,SC2154 + if "${su_cmd}" systemctl restart ${services}; then + info_msg "$(eval_gettext "Service(s) restarted successfully\n")" + + else + error_msg "$(eval_gettext "An error has occurred during the service(s) restart\nPlease, verify the above service(s) status\n")" && quit_msg + exit 11 + fi + else + array_to_string=$(printf "%s\n" "${answer_array[@]}") + mapfile -t answer_array < <(echo "${array_to_string}" | awk '!seen[$0]++') + + for num in "${answer_array[@]}"; do + if [ "${num}" -le "${services_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then + service_restarted="y" + service_selected=$(sed -n "${num}"p <<< "${services}") + + if "${su_cmd}" systemctl restart "${service_selected}"; then + info_msg "$(eval_gettext "The \${service_selected} service has been successfully restarted")" + else + error_msg "$(eval_gettext "An error has occurred during the restart of the \${service_selected} service")" + service_fail="y" + fi + fi + done + + if [ -n "${service_restarted}" ]; then + if [ -z "${service_fail}" ]; then + echo + info_msg "$(eval_gettext "Service(s) restarted successfully\n")" + else + echo + error_msg "$(eval_gettext "An error has occurred during the service(s) restart\nPlease, verify the above service(s) status\n")" && quit_msg + exit 11 + fi + else + warning_msg "$(eval_gettext "The service(s) restart hasn't been performed\nPlease, consider restarting services that have been updated to fully apply the upgrade\n")" + fi + fi + else + info_msg "$(eval_gettext "No service requiring a post upgrade restart found\n")" + fi +fi diff --git a/src/lib/show-config.sh b/src/lib/show-config.sh new file mode 100755 index 0000000..fc33fb7 --- /dev/null +++ b/src/lib/show-config.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# show-config.sh: Display the current "arch-update.conf" configuration file +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck disable=SC2154 +if [ ! -f "${config_file}" ]; then + error_msg "$(eval_gettext "No configuration file found\nYou can generate one with \"arch-update --gen-config\"")" + exit 9 +else + cat "${config_file}" || exit 9 +fi diff --git a/src/script/arch-update-tray.py b/src/lib/tray.py similarity index 100% rename from src/script/arch-update-tray.py rename to src/lib/tray.py diff --git a/src/lib/tray.sh b/src/lib/tray.sh new file mode 100755 index 0000000..340dc43 --- /dev/null +++ b/src/lib/tray.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# tray.sh: Start the Arch-Update systray applet +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +if [ "${2}" == "--enable" ]; then + # shellcheck disable=SC2154 + if [ -f "${XDG_DATA_HOME}/applications/${name}-tray.desktop" ]; then + tray_desktop_file="${XDG_DATA_HOME}/applications/${name}-tray.desktop" + elif [ -f "${HOME}/.local/share/applications/${name}-tray.desktop" ]; then + tray_desktop_file="${HOME}/.local/share/applications/${name}-tray.desktop" + elif [ -f "${XDG_DATA_DIRS}/applications/${name}-tray.desktop" ]; then + tray_desktop_file="${XDG_DATA_DIRS}/applications/${name}-tray.desktop" + elif [ -f "/usr/local/share/applications/${name}-tray.desktop" ]; then + tray_desktop_file="/usr/local/share/applications/${name}-tray.desktop" + elif [ -f "/usr/share/applications/${name}-tray.desktop" ]; then + tray_desktop_file="/usr/share/applications/${name}-tray.desktop" + else + error_msg "$(eval_gettext "Arch-Update tray desktop file not found")" + exit 10 + fi + + tray_desktop_file_autostart="${XDG_CONFIG_HOME:-${HOME}/.config}/autostart/arch-update-tray.desktop" + + if [ -f "${tray_desktop_file_autostart}" ]; then + error_msg "$(eval_gettext "The '\${tray_desktop_file_autostart}' file already exists")" + exit 10 + else + mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/autostart/" + cp "${tray_desktop_file}" "${tray_desktop_file_autostart}" || exit 10 + info_msg "$(eval_gettext "The '\${tray_desktop_file_autostart}' file has been created, the Arch-Update systray applet will be automatically started at your next log on\nTo start it right now, you can launch the \"Arch-Update Systray Applet\" application from your app menu")" + fi +else + # shellcheck disable=SC2154 + if [ ! -f "${statedir}/current_state" ]; then + state_up_to_date + fi + + # shellcheck disable=SC2154 + if pgrep -f "${libdir}/tray.py" > /dev/null; then + error_msg "$(eval_gettext "There's already a running instance of the Arch-Update systray applet")" + exit 3 + fi + + # shellcheck disable=SC2154 + "${libdir}/tray.py" || exit 3 +fi diff --git a/src/lib/update.sh b/src/lib/update.sh new file mode 100755 index 0000000..7648955 --- /dev/null +++ b/src/lib/update.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +# update.sh: Update packages +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +if [ -n "${packages}" ]; then + echo + main_msg "$(eval_gettext "Updating Packages...\n")" + + # shellcheck disable=SC2154 + if ! "${su_cmd}" pacman --color "${pacman_color_opt}" -Syu; then + state_updates_available + echo + error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg + exit 5 + else + packages_updated="y" + fi +fi + +if [ -n "${aur_packages}" ]; then + echo + main_msg "$(eval_gettext "Updating AUR Packages...\n")" + + # shellcheck disable=SC2154 + if ! "${aur_helper}" --color "${pacman_color_opt}" "${devel_flag[@]}" -Syu; then + state_updates_available + echo + error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg + exit 5 + else + # shellcheck disable=SC2034 + packages_updated="y" + fi +fi + +if [ -n "${flatpak_packages}" ]; then + echo + main_msg "$(eval_gettext "Updating Flatpak Packages...\n")" + + if ! flatpak update; then + state_updates_available + error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg + exit 5 + fi +fi + +state_up_to_date +echo +info_msg "$(eval_gettext "The update has been applied\n")" diff --git a/src/lib/version.sh b/src/lib/version.sh new file mode 100755 index 0000000..70da887 --- /dev/null +++ b/src/lib/version.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# version.sh: Display version information +# https://github.com/Antiz96/arch-update +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck disable=SC2154 +echo "${name} ${version}" diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh deleted file mode 100755 index 4dd6699..0000000 --- a/src/script/arch-update.sh +++ /dev/null @@ -1,919 +0,0 @@ -#!/bin/bash - -# arch-update: An update notifier/applier for Arch Linux that assists you with important pre/post update tasks. -# https://github.com/Antiz96/arch-update -# SPDX-License-Identifier: GPL-3.0-or-later - -# General variables -name="arch-update" -_name="Arch-Update" -version="2.3.3" -option="${1}" - -# Display debug traces if the -D/--debug argument is passed -for arg in "${@}"; do - case "${arg}" in - -D|--debug) - set -x - ;; - esac -done - -# Reset the option var if it is equal to -D/--debug (to avoid false negative "invalid option" error) -case "${option}" in - -D|--debug) - unset option - ;; -esac - -# Declare necessary parameters for translations -# shellcheck disable=SC1091 -. gettext.sh -export TEXTDOMAIN="${_name}" # Using "Arch-Update" as TEXTDOMAIN to avoid conflicting with the "arch-update" TEXTDOMAIN used by the arch-update Gnome extension (https://extensions.gnome.org/extension/1010/archlinux-updates-indicator/) -if [ -f "${XDG_DATA_HOME}/locale/fr/LC_MESSAGES/${_name}.mo" ]; then - export TEXTDOMAINDIR="${XDG_DATA_HOME}/locale" -elif [ -f "${HOME}/.local/share/locale/fr/LC_MESSAGES/${_name}.mo" ]; then - export TEXTDOMAINDIR="${HOME}/.local/share/locale" -elif [ -f "${XDG_DATA_DIRS}/locale/fr/LC_MESSAGES/${_name}.mo" ]; then - export TEXTDOMAINDIR="${XDG_DATA_DIRS}/locale" -elif [ -f "/usr/local/share/locale/fr/LC_MESSAGES/${_name}.mo" ]; then - export TEXTDOMAINDIR="/usr/local/share/locale" -fi - -# Checking options in arch-update.conf -config_file="${XDG_CONFIG_HOME:-${HOME}/.config}/${name}/${name}.conf" - -if grep -Eq '^[[:space:]]*NoColor[[:space:]]*$' "${config_file}" 2> /dev/null; then - no_color="y" -fi - -if grep -Eq '^[[:space:]]*NoVersion[[:space:]]*$' "${config_file}" 2> /dev/null; then - no_version="y" -fi - -if grep -Eq '^[[:space:]]*AlwaysShowNews[[:space:]]*$' "${config_file}" 2> /dev/null; then - show_news="y" -fi - -if grep -Eq '^[[:space:]]*NewsNum[[:space:]]*=[[:space:]]*[1-9][0-9]*[[:space:]]*$' "${config_file}" 2> /dev/null; then - news_num=$(grep -E '^[[:space:]]*NewsNum[[:space:]]*=[[:space:]]*[1-9][0-9]*[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') -else - news_num="5" -fi - -if grep -Eq '^[[:space:]]*KeepOldPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null; then - old_packages_num=$(grep -E '^[[:space:]]*KeepOldPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') -else - old_packages_num="3" -fi - -if grep -Eq '^[[:space:]]*KeepUninstalledPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null; then - uninstalled_packages_num=$(grep -E '^[[:space:]]*KeepUninstalledPackages[[:space:]]*=[[:space:]]*[0-9]+[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') -else - uninstalled_packages_num="0" -fi - -if grep -Eq '^[[:space:]]*PrivilegeElevationCommand[[:space:]]*=[[:space:]]*(sudo|doas|run0)[[:space:]]*$' "${config_file}" 2> /dev/null; then - su_cmd=$(grep -E '^[[:space:]]*PrivilegeElevationCommand[[:space:]]*=[[:space:]]*(sudo|doas|run0)[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') -fi - -if grep -Eq '^[[:space:]]*DiffProg[[:space:]]*=[[:space:]]*[^[:space:]].*[[:space:]]*$' "${config_file}" 2> /dev/null; then - diff_prog=$(grep -E '^[[:space:]]*DiffProg[[:space:]]*=[[:space:]]*[^[:space:]].*[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]') -fi - -# Definition of the colors for the colorized output -if [ -z "${no_color}" ]; then - bold="\e[1m" - blue="${bold}\e[34m" - green="${bold}\e[32m" - yellow="${bold}\e[33m" - red="${bold}\e[31m" - color_off="\e[0m" - pacman_color_opt="always" -else - pacman_color_opt="never" - contrib_color_opt+=("--nocolor") -fi - -# Create state and tmp dirs if they don't exist -statedir="${XDG_STATE_HOME:-${HOME}/.local/state}/${name}" -tmpdir="${TMPDIR:-/tmp}/${name}-${UID}" -mkdir -p "${statedir}" "${tmpdir}" - -# Definition of the main_msg function: Display a message as a main message -main_msg() { - msg="${1}" - echo -e "${blue}==>${color_off}${bold} ${msg}${color_off}" -} - -# Definition of the info_msg function: Display a message as an information message -info_msg() { - msg="${1}" - echo -e "${green}==>${color_off}${bold} ${msg}${color_off}" -} - -# Definition of the ask_msg function: Display a message as an interactive question -ask_msg() { - msg="${1}" - read -rp $"$(echo -e "${blue}->${color_off}${bold} ${msg}${color_off} ")" answer -} - -# Definition of the ask_msg_array function: Display a message as an interactive question with multiple possible answers -ask_msg_array() { - msg="${1}" - read -rp $"$(echo -e "${blue}->${color_off}${bold} ${msg}${color_off} ")" -a answer_array -} - -# Definition of the warning_msg function: Display a message as a warning message -warning_msg() { - msg="${1}" - echo -e "${yellow}==> $(eval_gettext "WARNING"):${color_off}${bold} ${msg}${color_off}" -} - -# Definition of the error_msg function: Display a message as an error message -error_msg() { - msg="${1}" - echo -e >&2 "${red}==> $(eval_gettext "ERROR"):${color_off}${bold} ${msg}${color_off}" -} - -# Definition of the continue_msg function: Display the continue message -continue_msg() { - msg="$(eval_gettext "Press \"enter\" to continue ")" - read -n 1 -r -s -p $"$(info_msg "${msg}")" && echo -} - -# Definition of the quit_msg function: Display the quit message -quit_msg() { - msg="$(eval_gettext "Press \"enter\" to quit ")" - read -n 1 -r -s -p $"$(info_msg "${msg}")" && echo -} - -# Definition of the elevation command to use (depending on which one is installed on the system and if it's not already defined in arch-update.conf) -if [ -z "${su_cmd}" ]; then - if command -v sudo > /dev/null; then - su_cmd="sudo" - elif command -v doas > /dev/null; then - su_cmd="doas" - elif command -v run0 > /dev/null; then - su_cmd="run0" - else - error_msg "$(eval_gettext "A privilege elevation command is required (sudo, doas or run0)\n")" && quit_msg - exit 2 - fi -else - if ! command -v "${su_cmd}" > /dev/null; then - error_msg "$(eval_gettext "The \${su_cmd} command set for privilege escalation in the arch-update.conf configuration file is not found\n")" && quit_msg - exit 2 - fi -fi - -# Definition of the diff program to use (if it is set in the arch-update.conf configuration file) -if [ -n "${diff_prog}" ]; then - if [ "${su_cmd}" == "sudo" ]; then - diff_prog_opt=("DIFFPROG=${diff_prog}") - elif [ "${su_cmd}" == "run0" ]; then - diff_prog_opt+=("--setenv=DIFFPROG=${diff_prog}") - fi -fi - -# Definition of the AUR helper to use (depending on if/which one is installed on the system) for the optional AUR packages support -if command -v paru > /dev/null; then - aur_helper="paru" -elif command -v yay > /dev/null; then - aur_helper="yay" -fi - -# Check if flatpak is installed for the optional Flatpak support -flatpak=$(command -v flatpak) - -# Check if notify-send is installed for the optional desktop notification support -notif=$(command -v notify-send) - -# Definition of the help function: Display the help message -help() { - cat <&2 "$(eval_gettext "\${name}: invalid option -- '\${option}'\nTry '\${name} --help' for more information.")" - exit 1 -} - -# Definition of the state_updates_available function: Change state to "updates-available" -state_updates_available() { - echo "${name}_updates-available" > "${statedir}/current_state" -} - -# Definition of the state_up_to_date function: Change state to "up to date" -state_up_to_date() { - echo "${name}" > "${statedir}/current_state" -} - -# Definition of the check function: Check for available updates, change the icon accordingly and send a desktop notification containing the number of available updates -check() { - if [ -n "${aur_helper}" ] && [ -n "${flatpak}" ]; then - update_available=$(checkupdates ; "${aur_helper}" -Qua ; flatpak update | sed -n '/^ 1./,$p' | awk '{print $2}' | grep -v '^$' | sed '$d') - elif [ -n "${aur_helper}" ] && [ -z "${flatpak}" ]; then - update_available=$(checkupdates ; "${aur_helper}" -Qua) - elif [ -z "${aur_helper}" ] && [ -n "${flatpak}" ]; then - update_available=$(checkupdates ; flatpak update | sed -n '/^ 1./,$p' | awk '{print $2}' | grep -v '^$' | sed '$d') - else - update_available=$(checkupdates) - fi - - if [ -n "${notif}" ]; then - echo "${update_available}" > "${statedir}/current_updates_check" - sed -i '/^\s*$/d' "${statedir}/current_updates_check" - fi - - if [ -n "${update_available}" ]; then - state_updates_available - - if [ -n "${notif}" ]; then - if ! diff "${statedir}/current_updates_check" "${statedir}/last_updates_check" &> /dev/null; then - update_number=$(wc -l "${statedir}/current_updates_check" | awk '{print $1}') - last_notif_id=$(cat "${tmpdir}/last_notif_id" 2> /dev/null) - if [ "${update_number}" -eq 1 ]; then - if [ -z "${last_notif_id}" ]; then - notify-send -p -i "${name}" "${_name}" "$(eval_gettext "\${update_number} update available")" > "${tmpdir}/last_notif_id" - else - notify-send -p -r "${last_notif_id}" -i "${name}" "${_name}" "$(eval_gettext "\${update_number} update available")" > "${tmpdir}/last_notif_id" - fi - - else - if [ -z "${last_notif_id}" ]; then - notify-send -p -i "${name}" "${_name}" "$(eval_gettext "\${update_number} updates available")" > "${tmpdir}/last_notif_id" - else - notify-send -p -r "${last_notif_id}" -i "${name}" "${_name}" "$(eval_gettext "\${update_number} updates available")" > "${tmpdir}/last_notif_id" - fi - fi - fi - fi - else - state_up_to_date - fi - - if [ -f "${statedir}/current_updates_check" ]; then - mv -f "${statedir}/current_updates_check" "${statedir}/last_updates_check" - fi -} - -# Definition of the list_packages function: Display packages that are available for update and offer to apply them if there are -list_packages() { - info_msg "$(eval_gettext "Looking for updates...\n")" - - if [ -z "${no_version}" ]; then - packages=$(checkupdates "${contrib_color_opt[@]}") - else - packages=$(checkupdates "${contrib_color_opt[@]}" | awk '{print $1}') - fi - - if [ -n "${aur_helper}" ]; then - if [ -z "${no_version}" ]; then - aur_packages=$("${aur_helper}" --color "${pacman_color_opt}" "${devel_flag[@]}" -Qua) - else - aur_packages=$("${aur_helper}" --color "${pacman_color_opt}" "${devel_flag[@]}" -Qua | awk '{print $1}') - fi - fi - - if [ -n "${flatpak}" ]; then - flatpak_packages=$(flatpak update | sed -n '/^ 1./,$p' | awk '{print $2}' | grep -v '^$' | sed '$d') - fi - - if [ -n "${packages}" ]; then - main_msg "$(eval_gettext "Packages:")" - echo -e "${packages}\n" - fi - - if [ -n "${aur_packages}" ]; then - main_msg "$(eval_gettext "AUR Packages:")" - echo -e "${aur_packages}\n" - fi - - if [ -n "${flatpak_packages}" ]; then - main_msg "$(eval_gettext "Flatpak Packages:")" - echo -e "${flatpak_packages}\n" - fi - - if [ -z "${packages}" ] && [ -z "${aur_packages}" ] && [ -z "${flatpak_packages}" ]; then - state_up_to_date - info_msg "$(eval_gettext "No update available\n")" - - if [ -n "${list_option}" ]; then - exit 7 - fi - else - state_updates_available - if [ -z "${list_option}" ]; then - ask_msg "$(eval_gettext "Proceed with update? [Y/n]")" - - case "${answer}" in - "$(eval_gettext "Y")"|"$(eval_gettext "y")"|"") - proceed_with_update="y" - echo - ;; - *) - error_msg "$(eval_gettext "The update has been aborted\n")" && quit_msg - exit 4 - ;; - esac - fi - fi -} - -# Definition of the list_news function: Display the latest Arch news and offers to read them -list_news() { - info_msg "$(eval_gettext "Looking for recent Arch News...")" - news=$(curl -m 30 -Lfs https://www.archlinux.org/news || echo "error") - - if [ "${news}" == "error" ]; then - echo - warning_msg "$(eval_gettext "Unable to retrieve recent Arch News (HTTP error response or request timeout)\nPlease, look for any recent news at https://archlinux.org before updating your system")" - else - if [ -z "${show_news}" ]; then - echo "${news}" | htmlq -a title a | grep ^"View:" | sed "s/View:\ //g" | head -1 > "${statedir}/current_news_check" - - if ! diff "${statedir}/current_news_check" "${statedir}/last_news_check" &> /dev/null; then - show_news="y" - else - echo - info_msg "$(eval_gettext "No recent Arch News found")" - fi - - if [ -f "${statedir}/current_news_check" ]; then - mv -f "${statedir}/current_news_check" "${statedir}/last_news_check" - fi - fi - - if [ -n "${show_news}" ]; then - news_titles=$(echo "${news}" | htmlq -a title a | grep ^"View:" | sed "s/View:\ //g" | head -"${news_num}") - mapfile -t news_dates < <(echo "${news}" | htmlq td | grep -v "class" | grep "[0-9]" | sed "s/<[^>]*>//g" | sed "s/\.//g" | head -"${news_num}" | xargs -I{} date -d "{}" "+%s") - - echo - main_msg "$(eval_gettext "Arch News:")" - - i=1 - while IFS= read -r line; do - if [ -z "${news_option}" ] && [ "${news_dates["${i}-1"]}" -ge "$(date -d "$(cat "${statedir}/last_update_run" 2> /dev/null)" +%s)" ] 2> /dev/null; then - new_tag="$(eval_gettext "[NEW]")" - echo -e "${i} - ${line} ${green}${new_tag}${color_off}" - else - echo "${i} - ${line}" - fi - ((i=i+1)) - done < <(printf '%s\n' "${news_titles}") - - echo - - if [ -n "${news_option}" ]; then - ask_msg_array "$(eval_gettext "Select the news to read (e.g. 1 3 5), select 0 to read them all or press \"enter\" to quit:")" - else - ask_msg_array "$(eval_gettext "Select the news to read (e.g. 1 3 5), select 0 to read them all or press \"enter\" to proceed with update:")" - fi - - if [ "${answer_array[0]}" -eq 0 ] 2> /dev/null; then - answer_array=() - for ((i=1; i<=news_num; i++)); do - answer_array+=("${i}") - done - else - array_to_string=$(printf "%s\n" "${answer_array[@]}") - mapfile -t answer_array < <(echo "${array_to_string}" | awk '!seen[$0]++') - fi - - for num in "${answer_array[@]}"; do - if [ "${num}" -le "${news_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then - printed_news="y" - news_selected=$(sed -n "${num}"p <<< "${news_titles}") - news_path=$(echo "${news_selected}" | sed s/\ -//g | sed s/\ /-/g | sed s/[.]//g | sed s/=//g | sed s/\>//g | sed s/\ /dev/null | grep ".service" | cut -f2 -d "'") - services_num=$(echo "${services}" | wc -l) - - if [ -n "${services}" ]; then - if [ "${services_num}" -eq 1 ]; then - main_msg "$(eval_gettext "Services:\nThe following service requires a post upgrade restart\n")" - else - main_msg "$(eval_gettext "Services:\nThe following services require a post upgrade restart\n")" - fi - - i=1 - while IFS= read -r line; do - echo "${i} - ${line}" - ((i=i+1)) - done < <(printf '%s\n' "${services}") - - echo - ask_msg_array "$(eval_gettext "Select the service(s) to restart (e.g. 1 3 5), select 0 to restart them all or press \"enter\" to continue without restarting the service(s):")" - echo - - if [ "${answer_array[0]}" -eq 0 ] 2> /dev/null; then - # shellcheck disable=SC2086 - if "${su_cmd}" systemctl restart ${services}; then - info_msg "$(eval_gettext "Service(s) restarted successfully\n")" - - else - error_msg "$(eval_gettext "An error has occurred during the service(s) restart\nPlease, verify the above service(s) status\n")" && quit_msg - exit 11 - fi - else - array_to_string=$(printf "%s\n" "${answer_array[@]}") - mapfile -t answer_array < <(echo "${array_to_string}" | awk '!seen[$0]++') - - for num in "${answer_array[@]}"; do - if [ "${num}" -le "${services_num}" ] 2> /dev/null && [ "${num}" -gt "0" ]; then - service_restarted="y" - service_selected=$(sed -n "${num}"p <<< "${services}") - - if "${su_cmd}" systemctl restart "${service_selected}"; then - info_msg "$(eval_gettext "The \${service_selected} service has been successfully restarted")" - else - error_msg "$(eval_gettext "An error has occurred during the restart of the \${service_selected} service")" - service_fail="y" - fi - fi - done - - if [ -n "${service_restarted}" ]; then - if [ -z "${service_fail}" ]; then - echo - info_msg "$(eval_gettext "Service(s) restarted successfully\n")" - else - echo - error_msg "$(eval_gettext "An error has occurred during the service(s) restart\nPlease, verify the above service(s) status\n")" && quit_msg - exit 11 - fi - else - warning_msg "$(eval_gettext "The service(s) restart hasn't been performed\nPlease, consider restarting services that have been updated to fully apply the upgrade\n")" - fi - fi - else - info_msg "$(eval_gettext "No service requiring a post upgrade restart found\n")" - fi - fi -} -# Definition of the kernel_reboot function: Verify if there's a kernel update waiting for a reboot to be applied -kernel_reboot() { - kernel_compare=$(file /boot/vmlinuz* /usr/lib/modules/*/vmlinuz* | sed 's/^.*version\ //' | awk '{print $1}' | grep "$(uname -r)") - - if [ -z "${kernel_compare}" ]; then - main_msg "$(eval_gettext "Reboot required:\nThere's a pending kernel update on your system requiring a reboot to be applied\n")" - ask_msg "$(eval_gettext "Would you like to reboot now? [y/N]")" - - case "${answer}" in - "$(eval_gettext "Y")"|"$(eval_gettext "y")") - echo - - # shellcheck disable=SC2317,SC2329 - restore_cursor() { - tput cnorm - } - trap restore_cursor EXIT - # shellcheck disable=SC2034 - for sec in {5..1}; do - tput civis ; echo -ne "${blue}==>${color_off}${bold} $(eval_gettext "Rebooting in \${sec}...\r")${color_off}" - sleep 1 - done - - if ! reboot; then - echo - error_msg "$(eval_gettext "An error has occurred during the reboot process\nThe reboot has been aborted\n")" && quit_msg - exit 6 - else - exit 0 - fi - ;; - *) - echo - warning_msg "$(eval_gettext "The reboot hasn't been performed\nPlease, consider rebooting to finalize the pending kernel update\n")" - ;; - esac - else - info_msg "$(eval_gettext "No pending kernel update found\n")" - fi -} - -# Definition of the full_upgrade function: Launch the relevant series of function for a complete and proper update -full_upgrade() { - list_packages - if [ -n "${proceed_with_update}" ]; then - list_news - update - date +%Y-%m-%d > "${statedir}/last_update_run" - fi - orphan_packages - packages_cache - pacnew_files - kernel_reboot - restart_services - quit_msg -} - -# Execute the different functions depending on the option -case "${option}" in - "") - full_upgrade - ;; - -d|--devel) - devel_flag+=("--devel") - full_upgrade - ;; - -c|--check) - check - ;; - -l|--list) - list_option="y" - list_packages - ;; - -n|--news) - show_news="y" - news_option="y" - if [ "${2}" -gt 0 ] 2> /dev/null; then - news_num="${2}" - fi - list_news - ;; - --gen-config) - if [ -f "${XDG_DATA_HOME}/doc/${name}/${name}.conf.example" ]; then - example_config_file="${XDG_DATA_HOME}/doc/${name}/${name}.conf.example" - elif [ -f "${HOME}/.local/share/doc/${name}/${name}.conf.example" ]; then - example_config_file="${HOME}/.local/share/doc/${name}/${name}.conf.example" - elif [ -f "${XDG_DATA_DIRS}/doc/${name}/${name}.conf.example" ]; then - example_config_file="${XDG_DATA_DIRS}/doc/${name}/${name}.conf.example" - elif [ -f "/usr/local/share/doc/${name}/${name}.conf.example" ]; then - example_config_file="/usr/local/share/doc/${name}/${name}.conf.example" - elif [ -f "/usr/share/doc/${name}/${name}.conf.example" ]; then - example_config_file="/usr/share/doc/${name}/${name}.conf.example" - else - error_msg "$(eval_gettext "Example configuration file not found")" - exit 8 - fi - - if [ -f "${config_file}" ]; then - error_msg "$(eval_gettext "The '\${config_file}' configuration file already exists\nPlease, remove it before generating a new one")" - exit 8 - else - mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/${name}/" - cp "${example_config_file}" "${config_file}" || exit 8 - info_msg "$(eval_gettext "The '\${config_file}' configuration file has been generated")" - fi - ;; - --show-config) - if [ ! -f "${config_file}" ]; then - error_msg "$(eval_gettext "No configuration file found\nYou can generate one with \"arch-update --gen-config\"")" - exit 9 - else - cat "${config_file}" || exit 9 - fi - ;; - --edit-config) - if [ ! -f "${config_file}" ]; then - error_msg "$(eval_gettext "No configuration file found\nYou can generate one with \"arch-update --gen-config\"")" - exit 13 - else - if ! "${EDITOR:-nano}" "${config_file}" 2> /dev/null; then - error_msg "$(eval_gettext "Unable to determine the editor to use\nThe \"EDITOR\" environment variable is not set and \"nano\" (fallback option) is not installed")" - exit 13 - fi - fi - ;; - --tray) - if [ "${2}" == "--enable" ]; then - if [ -f "${XDG_DATA_HOME}/applications/${name}-tray.desktop" ]; then - tray_desktop_file="${XDG_DATA_HOME}/applications/${name}-tray.desktop" - elif [ -f "${HOME}/.local/share/applications/${name}-tray.desktop" ]; then - tray_desktop_file="${HOME}/.local/share/applications/${name}-tray.desktop" - elif [ -f "${XDG_DATA_DIRS}/applications/${name}-tray.desktop" ]; then - tray_desktop_file="${XDG_DATA_DIRS}/applications/${name}-tray.desktop" - elif [ -f "/usr/local/share/applications/${name}-tray.desktop" ]; then - tray_desktop_file="/usr/local/share/applications/${name}-tray.desktop" - elif [ -f "/usr/share/applications/${name}-tray.desktop" ]; then - tray_desktop_file="/usr/share/applications/${name}-tray.desktop" - else - error_msg "$(eval_gettext "Arch-Update tray desktop file not found")" - exit 10 - fi - - tray_desktop_file_autostart="${XDG_CONFIG_HOME:-${HOME}/.config}/autostart/arch-update-tray.desktop" - - if [ -f "${tray_desktop_file_autostart}" ]; then - error_msg "$(eval_gettext "The '\${tray_desktop_file_autostart}' file already exists")" - exit 10 - else - mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/autostart/" - cp "${tray_desktop_file}" "${tray_desktop_file_autostart}" || exit 10 - info_msg "$(eval_gettext "The '\${tray_desktop_file_autostart}' file has been created, the Arch-Update systray applet will be automatically started at your next log on\nTo start it right now, you can launch the \"Arch-Update Systray Applet\" application from your app menu")" - fi - else - if [ ! -f "${statedir}/current_state" ]; then - state_up_to_date - fi - - if pgrep -f arch-update-tray > /dev/null; then - error_msg "$(eval_gettext "There's already a running instance of the Arch-Update systray applet")" - exit 3 - fi - - arch-update-tray || exit 3 - fi - ;; - -h|--help) - help - ;; - -V|--version) - version - ;; - *) - invalid_option - ;; -esac