diff --git a/home/.chezmoiscripts/run_after_30-install-pkgx-packages.sh.tmpl b/home/.chezmoiscripts/run_after_30-install-pkgx-packages.sh.tmpl new file mode 100644 index 0000000..7bf72f6 --- /dev/null +++ b/home/.chezmoiscripts/run_after_30-install-pkgx-packages.sh.tmpl @@ -0,0 +1,43 @@ +#!/bin/bash + +# {{ template "scripts-library" }} + +# The following line is for ShellCheck to correctly identify the above include +true || source ../.chezmoitemplates/scripts-library + +ensure_path_entry "${HOME}/.local/bin" + +function is_pkgx_package_installed() { + local package="$1" + + grep --quiet --recursive --binary-files=without-match --word-regexp \ + "exec pkgx +${package} --" "${HOME}/.local/bin" +} + +readonly unwanted_packages=() + +for package in "${unwanted_packages[@]}"; do + # shellcheck disable=SC2310 + if is_pkgx_package_installed "${package}"; then + log_task "Removing unwanted package '${package}' installed with pkgx" + pkgx uninstall "${package}" + fi +done + +readonly wanted_packages=( + opendev.org/git-review +) + +missing_packages=() + +for package in "${wanted_packages[@]}"; do + # shellcheck disable=SC2310 + if ! is_pkgx_package_installed "${package}"; then + missing_packages+=("${package}") + fi +done + +if [[ ${#missing_packages[@]} -gt 0 ]]; then + log_task "Installing missing packages with pkgx: ${missing_packages[*]}" + pkgx install "${missing_packages[@]}" +fi diff --git a/home/.chezmoiscripts/run_after_81-install-gnome-extensions.sh.tmpl b/home/.chezmoiscripts/run_after_81-install-gnome-extensions.sh.tmpl index a95dc7a..60ee7bf 100644 --- a/home/.chezmoiscripts/run_after_81-install-gnome-extensions.sh.tmpl +++ b/home/.chezmoiscripts/run_after_81-install-gnome-extensions.sh.tmpl @@ -41,11 +41,6 @@ disabled_extensions=( missing_extensions=() -if ! command -v gext >/dev/null; then - log_task "Installing gnome-extensions-cli" - c pipx install gnome-extensions-cli -fi - for extension in "${wanted_extensions[@]}"; do # shellcheck disable=SC2310 if ! is_gnome_extension_installed "${extension}"; then diff --git a/home/dot_local/bin/executable_full-upgrade.tmpl b/home/dot_local/bin/executable_full-upgrade.tmpl index 0e46c60..63cbc7b 100644 --- a/home/dot_local/bin/executable_full-upgrade.tmpl +++ b/home/dot_local/bin/executable_full-upgrade.tmpl @@ -11,6 +11,8 @@ true || source ../../.chezmoitemplates/homebrew-library true || source ../../.chezmoitemplates/volta-library true || source ../../.chezmoitemplates/sdkman-library +ensure_path_entry "${HOME}/.local/bin" + if [[ "${CONTINUE_FROM_DOTFILES:-false}" == false ]]; then if brew --version &>/dev/null; then ( @@ -39,6 +41,42 @@ if [[ "${CONTINUE_FROM_DOTFILES:-false}" == false ]]; then CONTINUE_FROM_DOTFILES=true exec "$0" "$@" fi +if pkgx --version >/dev/null; then + log_task "Updating pkgx stubs" + + pkgx_packages="$( + { grep --recursive --binary-files=without-match --no-filename --only-matching --perl-regexp 'exec pkgx \+\K[^ ]+' "${HOME}/.local/bin" || true; } | sort --unique + )" + + if [[ -z "${pkgx_packages}" ]]; then + log_info "No pkgx packages found" + else + readarray -t pkgx_packages <<<"${pkgx_packages}" + + # This updates the pantry + pkgx --sync >/dev/null + + pkgx uninstall "${pkgx_packages[@]}" + pkgx install "${pkgx_packages[@]}" + + log_task "Updating pkgx packages" + + pkgx_packages_to_update=() + for package in "${pkgx_packages[@]}"; do + if [[ -d "${PKGX_DIR:-"${HOME}/.pkgx"}/${package}" ]]; then + pkgx_packages_to_update+=("+${package}") + fi + done + + if [[ "${#pkgx_packages_to_update[@]}" -gt 0 ]]; then + c pkgx --update "${pkgx_packages_to_update[@]}" >/dev/null + fi + + unset pkgx_packages_to_update + fi + unset pkgx_packages +fi + if apt --version &>/dev/null; then log_task "Updating apt packages" c sudo DEBIAN_FRONTEND=noninteractive apt update --yes diff --git a/home/dot_local/bin/executable_git-review b/home/dot_local/bin/executable_git-review deleted file mode 100644 index 2c0ea89..0000000 --- a/home/dot_local/bin/executable_git-review +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec pkgx +opendev.org/git-review -- git-review "$@" \ No newline at end of file