-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for adding, removing, and updating
pkgx
packages (#111)
Allow to add/remove/update pkgx packages
- Loading branch information
Showing
3 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
home/.chezmoiscripts/run_after_30-install-pkgx-packages.sh.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/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" | ||
{ | ||
grep --recursive --binary-files=without-match --files-with-matches \ | ||
--word-regexp "exec pkgx +${package}" "${HOME}/.local/bin" || true | ||
} | xargs --no-run-if-empty rm -f | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.