Skip to content

Instantly share code, notes, and snippets.

@DrJume
Created November 7, 2020 08:20
Show Gist options
  • Save DrJume/5a1be9b77e33d636bf05bd02d446bf22 to your computer and use it in GitHub Desktop.
Save DrJume/5a1be9b77e33d636bf05bd02d446bf22 to your computer and use it in GitHub Desktop.
Alpine script using ncurses dialog which helps with installing missing *-doc packages from apk
#!/bin/sh
[ ! -x "$(command -v dialog)" ] && ( apk add dialog || exit)
installed_pkgs=$(apk list -I -q | awk '{ print $1 }' | sed -E 's/(.+)(-[[:digit:]]).+/\1/')
installed_pkgs_doc=$(echo "$installed_pkgs" | grep "\-doc")
installed_pkgs_without_doc=$(echo "$installed_pkgs" | grep -v '\-doc')
installed_pkgs_append_doc=$(echo "$installed_pkgs_without_doc" | awk '{ print $0"-doc" }')
potential_pkgs_doc=$(echo "$installed_pkgs_append_doc" | grep -E -v $(echo "$installed_pkgs_doc" | tr '\n' '|' | sed -E 's/\|$//'))
missing_pkgs_doc=$(echo "$potential_pkgs_doc" | xargs -n30 | xargs apk -v info -d)
checklist_missing_pkgs_doc=$(echo "$missing_pkgs_doc" | sed -E -e 's/([^:]+): (.*)/\1 "\2"/' -e 's/$/ 0/')
missing_pkgs_doc_to_install=$(echo "$checklist_missing_pkgs_doc" | xargs dialog --checklist "Select which missing doc packages you want to install:" 0 0 0 3>&1 1>&2 2>&3)
dialog --clear
clear
echo $missing_pkgs_doc_to_install | xargs -r -n30 apk add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment