diff --git a/commands/setup-util b/commands/setup-util index 692699d67..eadc41d1e 100755 --- a/commands/setup-util +++ b/commands/setup-util @@ -1107,7 +1107,8 @@ function setup_util() ( # Debian # apt / Ubuntu / Debian / Linux Mint / elementary OS / etc - # installs remote .deb packages + # supports installing/uninstalling aplitude deb packages + # supports installing/uninstalling downloaded .deb files # sucessor to aptitude # https://wiki.debian.org/Apt function do_apt_key_fetch { @@ -1121,7 +1122,7 @@ function setup_util() ( fi } function do_apt { - local args=() packages=() repo="$APT_REPO" key="$APT_KEY" id="$APT_ID" keyring='' + local args=() packages=() repo="$APT_REPO" key="$APT_KEY" id="$APT_ID" keyring='' download_index download_url download_filepath if test "${#APT[@]}" -ne 0; then packages+=("${APT[@]}") elif test "${#DEB[@]}" -ne 0; then @@ -1312,6 +1313,19 @@ function setup_util() ( ) fi + # convert urls to local + for download_index in "${!packages[@]}"; do + download_url="${packages[download_index]}" + if [[ $download_url == 'http'* ]]; then + # fetch temp path + download_filepath="$(fs-temp --touch --directory='setup-util' --file="$name.deb")" + # download to temp path + down --filepath="$download_filepath" "$download_url" + # apt supports .deb packages for install and uninstall + packages[download_index]="$download_filepath" + fi + done + # packages # use `apt-get`, as `apt` produces this warning on Ubuntu 20.04.3 LTS # WARNING: apt does not have a stable CLI interface. Use with caution in scripts. @@ -1319,10 +1333,10 @@ function setup_util() ( } # dpkg / Debian / Ubuntu / Linux Mint / elementary OS / etc - # installs local .deb files, and with our helper, remote .deb files + # supports installing/uninstalling downloaded .deb files # https://man7.org/linux/man-pages/man1/dpkg.1.html function do_dpkg { - local args=() packages=() i=0 download_filepath='' url='' + local args=() packages=() download_index download_filepath download_url if test "${#DPKG[@]}" -ne 0; then packages+=("${DPKG[@]}") elif test "${#DEB[@]}" -ne 0; then @@ -1351,16 +1365,29 @@ function setup_util() ( ) fi + # dependencies + if test "$action" = 'uninstall'; then + source "$DOROTHY/sources/ripgrep.bash" + fi + # convert urls to local - for i in "${!packages[@]}"; do - url="${packages[i]}" - if [[ $url == 'http'* ]]; then + for download_index in "${!packages[@]}"; do + download_url="${packages[download_index]}" + if [[ $download_url == 'http'* ]]; then # fetch temp path download_filepath="$(fs-temp --touch --directory='setup-util' --file="$name.deb")" # download to temp path - down --filepath="$download_filepath" "$url" - # update packge with its download path - packages[i]="$download_filepath" + down --filepath="$download_filepath" "$download_url" + # adjust the cmd + if test "$action" = 'uninstall'; then + # if uninstalling, use the package name + packages[download_index]="$( + dpkg -I "$download_filepath" | rg -o --regexp='Package:\s+(.+)' --replace='$1' + )" + else + # update packge with its download path if installing + packages[download_index]="$download_filepath" + fi fi done