Skip to content

Commit

Permalink
consistent prerequisite update experience
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Aug 31, 2023
1 parent e5e3b91 commit a6900de
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 63 deletions.
48 changes: 25 additions & 23 deletions .github/workflows/dorothy-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
# let dorothy set itself up for development
dorothy dev
- name: 'Dorothy Test'
# shell: 'script -q -e -c "bash {0}"' <-- [-e] not available on macos
shell: bash
run: |
# source dorothy
Expand Down Expand Up @@ -105,42 +104,45 @@ jobs:
if command -v apt-get; then
# for ubuntu/debian/kali
apt-get update
apt-get install -y bash curl util-linux moreutils
elif command -v apk; then
# for alpine
apk add bash curl util-linux moreutils
apt-get install -y bash curl git
elif command -v zypper; then
# for opensuse
zypper --non-interactive install bash curl util-linux moreutils
zypper --non-interactive --gpg-auto-import-keys refresh
zypper --non-interactive install bash curl
elif command -v apk; then
# for alpine
apk update
apk add bash curl git grep
elif command -v pamac; then
# for manjaro
pamac install --no-confirm bash curl util-linux moreutils
# for manjaro, prefer over arch as majaro also contains pacman
pamac install --no-confirm bash curl
elif command -v pacman; then
# for arch besides manjaro
pacman --sync --refresh --needed --noconfirm bash curl util-linux moreutils
elif command -v yum; then
# for arch
pacman-key --init
pacman --refresh --sync --needed --noconfirm bash curl
elif command -v urpmi; then
# for mageia, prefer over fedora as mageia also contains dnf
# https://wiki.mageia.org/en/Cauldron
# --allowerasing needed due to: https://github.com/bevry/dorothy/actions/runs/6033044029/job/16369147940
urpmi --auto-update --auto
dnf check-update --assumeyes
dnf upgrade --assumeyes --refresh --best --allowerasing
urpmi bash curl
elif command -v dnf; then
# for fedora
yum install -y bash curl util-linux moreutils
dnf --assumeyes --refresh --best --allowerasing install bash curl
elif command -v xbps-install; then
# for void linux
xbps-install --sync --update --yes xbps
xbps-install --sync --yes bash curl util-linux moreutils
xbps-install --sync --yes bash curl
elif command -v nix-env; then
# for nix
nix-env --install --attr nixpkgs.bash nixpkgs.curl nixpkgs.util-linux moreutils
nix-env --install --attr nixpkgs.bash nixpkgs.curl
elif command -v emerge; then
# for gentoo
emerge app-shells/bash net-misc/curl sys-apps/util-linux moreutils
elif command -v urpmi; then
# for mageia
# https://wiki.mageia.org/en/Cauldron
# --allowerasing needed due to: https://github.com/bevry/dorothy/actions/runs/6033044029/job/16369147940
urpmi --auto-update --auto
dnf upgrade --assumeyes --refresh --best --allowerasing
urpmi bash curl util-linux moreutils
emerge app-shells/bash net-misc/curl
fi
- name: 'Dorothy Remote Tests'
# shell: 'script -q -e -c "bash {0}"'
shell: bash
run: |
# clone dorothy and run tests
Expand Down
96 changes: 78 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,41 +53,101 @@ Dorothy maintainers and users are occasionally driving Dorothy on:

[![Screenshot of the 2022 April Presentation](https://github.com/bevry/dorothy/blob/master/docs/assets/presentation.gif?raw=true)](https://www.youtube.com/watch?v=gWLana1JmNk)

## Try
## Setup

If you just want to trial [Dorothy commands](https://github.com/bevry/dorothy/tree/master/commands) without configuring your shell, you can do the following:
### Prerequisites

macOS:

```bash
# IF you are on Alpine, install the dependencies
doas apk add bash curl git
xcode-select --install
```

# IF you are on Ubuntu, install the dependencies
sudo apt install bash curl git
Ubuntu / Debian / Kali:

# IF you are on macOS, install the dependencies
xcode-select --install
```bash
sudo apt-get update
sudo apt-get install bash curl
```

Fedora:

```bash
dnf check-update
dnf --refresh --best install bash curl
```

OpenSUSE / SUSE:

```bash
zypper --gpg-auto-import-keys refresh
zypper install bash curl
```

Alpine:

```bash
doas apk update
doas apk add bash curl grep
```

Manjaro:

```bash
pamac install bash curl
```

Arch:

```bash
pacman-key --init
pacman --refresh --sync --needed bash curl
```

Gentoo:

```bash
emerge app-shells/bash net-misc/curl
```

Mageia:

```bash
urpmi --auto-update --auto
dnf check-update
urpmi bash curl
```

Nix:

```bash
nix-env --install --attr nixpkgs.bash nixpkgs.curl
```

Void:

```bash
xbps-install --sync --update xbps
xbps-install --sync bash curl
```

### Try

If you just want to trial [Dorothy commands](https://github.com/bevry/dorothy/tree/master/commands) without configuring your shell, you can do the following:

```bash
# To run only a specific command, run the following and swap out `echo-verbose` with whatever command you wish to run
bash -ic "$(curl -fsSL https://dorothy.bevry.me/commands/echo-verbose)" -- a b c

# To run multiple commands in a REPL, run the following then type the commands you wish to execute
eval "$(curl -fsSL https://dorothy.bevry.me/try)"
```

## Install
### Install

To install Dorothy run the following in your favorite terminal application:

```bash
# IF you are on Alpine, install the dependencies
doas apk add bash curl git

# IF you are on Ubuntu, install the dependencies
sudo apt install bash curl git

# IF you are on macOS, install the dependencies
xcode-select --install

# Run the Dorothy installation script
bash -ilc "$(curl -fsSL https://dorothy.bevry.me/install)"
```
Expand Down
45 changes: 25 additions & 20 deletions commands/dorothy
Original file line number Diff line number Diff line change
Expand Up @@ -340,43 +340,48 @@ function dorothy() (

function ensure_prereq_dependencies {
# dorothy has yet to be installed
# don't check for moreutils[sponge], as no way to install that on macos without brew
# this should somewhat coincide with [dorothy-workflow.yml]
# extras: tput/ncurses, ps/procps, moreutils
# don't check for sponge/moreutils as no way to install that on macos without brew, however install it if installing other things
# this should somewhat coincide with:
# [commands/dorothy] - preference sorted, doesn't do updates, don't do noconfirm
# [dorothy-workflow.yml] - preference sorted, does updates, does noconfirm, skips extras
# [readme.md] - popularity sorted, does updates, don't do noconfirm, skips extras (ncurses, moreutils, procps)
if command_missing bash curl grep git tput ps; then
# preference sort
if command_exists apt-get; then
# for ubuntu
try_sudo apt-get update
try_sudo apt-get install -y bash curl git procps # ncurses
elif command_exists apk; then
# for alpine
try_sudo apk add bash curl grep git ncurses
# for ubuntu/debian/kali
# E: Unable to locate package ncurses
try_sudo apt-get install -y bash curl git procps moreutils
elif command_exists zypper; then
# for opensuse
try_sudo zypper --non-interactive install bash curl git-core ncurses
elif command_exists apk; then
# for alpine
try_sudo apk add bash curl grep git ncurses moreutils
elif command_exists pamac; then
# for manjaro
# for manjaro, prefer over arch as majaro also contains pacman
try_sudo pamac install --no-confirm bash curl git ncurses procps-ng
elif command_exists pacman; then
# for arch besides manjaro
try_sudo pacman --sync --needed --noconfirm bash curl git ncurses procps-ng
elif command_exists yum; then
# for arch
try_sudo pacman --refresh --sync --needed --noconfirm bash curl git ncurses procps-ng
elif command_exists urpmi; then
# for mageia, prefer over fedora as mageia contains dnf
try_sudo urpmi bash curl git ncurses
elif command_exists dnf; then
# for fedora
try_sudo yum install -y bash curl git ncurses procps
try_sudo dnf --assumeyes --refresh --best --allowerasing install bash curl git ncurses procps
elif test -x "${HOMEBREW_PREFIX-}/bin/brew"; then
# for macos, don't use command_exists as dorothy has its own brew helper
"${HOMEBREW_PREFIX-}/bin/brew" install bash curl git ncurses
"${HOMEBREW_PREFIX-}/bin/brew" install bash curl git ncurses moreutils
elif command_exists xbps-install; then
# for void
try_sudo xbps-install --sync --yes bash curl git ncurses
try_sudo xbps-install --sync --yes bash curl git ncurses moreutils
elif command_exists nix-env; then
# for nix
try_sudo nix-env --install --attr nixpkgs.bash nixpkgs.curl nixpkgs.git nixpkgs.ncurses nixpkgs.coreutils
try_sudo nix-env --install --attr nixpkgs.coreutils nixpkgs.bash nixpkgs.curl nixpkgs.git nixpkgs.ncurses nixpkgs.moreutils
elif command_exists emerge; then
# for gentoo
try_sudo emerge app-shells/bash net-misc/curl dev-vcs/git sys-libs/ncurses
elif command_exists urpmi; then
# for mageia
try_sudo urpmi bash curl git ncurses
try_sudo emerge app-shells/bash net-misc/curl dev-vcs/git sys-libs/ncurses sys-apps/moreutils
else
# for everything else
cat <<-EOF >/dev/stderr
Expand Down
10 changes: 8 additions & 2 deletions commands/setup-linux
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function setup_linux() (
}

function do_dnf_update {
sudo-helper -- dnf check-update -y
sudo-helper -- dnf check-update --assumeyes
}

function do_pacman_update {
Expand Down Expand Up @@ -174,6 +174,7 @@ function setup_linux() (
'flatpak'
'pamac'
'snap'
'urpmi'
'yum'
'zypper'
)
Expand All @@ -186,11 +187,16 @@ function setup_linux() (
sudo-helper -- apt-get full-upgrade -y
}

function do_urpmi_upgrade {
urpmi --auto-update --auto
}

function do_dnf_upgrade {
# --refresh Set metadata as expired before running the command.
# -y, --assumeyes Automatically answer yes for all questions.
# -b, --best Try the best available package versions in transactions. Specifically during dnf upgrade, which by default skips over updates that can not be installed for dependency reasons, the switch forces DNF to only consider the latest packages. When running into packages with broken dependencies, DNF will fail giving a reason why the latest version can not be installed. Note that the use of the newest available version is only guaranteed for the packages directly requested (e.g. as a command line arguments), and the solver may use older
sudo-helper -- dnf upgrade --assumeyes --refresh --best
# --allowerasing Allow erasing of installed packages to resolve dependencies. This option could be used as an alternative to the yum swap command where packages to remove are not explicitly defined.
sudo-helper -- dnf upgrade --assumeyes --refresh --best --allowerasing
}

function do_flatpak_upgrade {
Expand Down
2 changes: 2 additions & 0 deletions commands/setup-util-moreutils
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function setup_util_moreutils() (
APT='moreutils' # UBUNTU
AUR='moreutils' # ARCH
BREW='moreutils'
EMERGE='sys-apps/moreutils' # GENTOO
NIX='nixpkgs.moreutils'
RPM='moreutils' # FEDORA
URPMI='moreutils' # MAGEIA
XBPS='moreutils' # VOID
Expand Down

0 comments on commit a6900de

Please sign in to comment.