Commit b350fb1b authored by nimrod's avatar nimrod
Browse files

Update DevEx for the win.

Replace the *-daily scripts with a nicer update script with tab
completion.
parent 0bcf54ea
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
# vim: ft=bash

_update() {
    local cur prev words cword opts
    _init_completion || return
    opts='-h -d'
    if [[ $cur == -* ]]
    then
        COMPREPLY=($(compgen -W "$opts" -- "$cur"))
    else
        COMPREPLY=($(compgen -W "all apt flatpak workbench" -- "$cur"))
    fi
}

complete -F _update update

Documents/bin/apt-daily

deleted100755 → 0
+0 −2
Original line number Diff line number Diff line
#!/bin/sh
exec sudo /bin/sh -c 'apt-get update && apt-get dist-upgrade --download-only --yes && apt-get autoclean'

Documents/bin/flatpak-daily

deleted100755 → 0
+0 −6
Original line number Diff line number Diff line
#!/bin/sh
set -eu

flatpak --system update --appstream
flatpak --system update --assumeyes
flatpak --system uninstall --unused --assumeyes

Documents/bin/update

0 → 100755
+77 −0
Original line number Diff line number Diff line
#!/bin/sh
set -eu

usage () {
    echo "Usage: $0 [-d] [all|apt|flatpak|workbench]"
}

header () {
    printf '\n\e[1;92m=== %s ====\e[0m\n\n' "$*" >&2
}

_apt () {
    header Updating APT
    if [ -n "${DOWNLOAD_ONLY:-}" ]
    then
        sudo /bin/sh -c 'apt-get update && apt-get dist-upgrade --download-only --yes && apt-get autoclean'
    else
        sudo /bin/sh -c 'apt-get update && apt-get dist-upgrade --yes --auto-remove --purge && apt-get autoclean'
    fi
}

_flatpak() {
    header Updating Flatpak
    flatpak --system update --appstream

    if [ -n "${DOWNLOAD_ONLY:-}" ]
    then
        flatpak --system update --assumeyes --no-deploy
    else
        flatpak --system update --assumeyes
        flatpak --system uninstall --unused --assumeyes
    fi
}

_workbench() {
    header Updating Workbench
    if [ -n "${DOWNLOAD_ONLY:-}" ]
    then
        wb --dry-update
    else
        wb --update
    fi
}

_all() {
    _apt
    _flatpak
    _workbench
}

while getopts 'dh' opt
do
    case "$opt" in
        d) DOWNLOAD_ONLY=1;;
        h) usage;;
        *) usage; exit 1;;
    esac
done

shift "$(( OPTIND - 1 ))"

if [ "$#" -eq 0 ]
then
    _all
elif [ "$#" -gt 1 ]
then
    usage
    exit 1
else
    case "$1" in
        all) _all;;
        apt) _apt;;
        flatpak) _flatpak;;
        workbench|wb) _workbench;;
        *) usage; exit 1;;
    esac
fi