Skip to content

A hardened Linux desktop, rebuilt from scratch, with your Windows apps built in. Free and open source.

1.8 KB
Raw Blame
#!/bin/sh
# Files 0.1.11 to 0.1.16 listed two Qt build tools as needed to run it, so
# updates brought Qt's developer packages onto every PC. Nothing in Wild OS
# takes unneeded packages away again, so this does, once, a few minutes
# after a start-up.
#
# It only ever removes packages from the list below, and only those apt
# itself counts as no longer needed: installed automatically and wanted by
# nothing. One somebody installed on purpose, or that another program
# needs, stays.
set -u

stamp=/var/lib/wildos/files-dev-tools-removed
brought="assistant-qt6 designer-qt6 libclang-cpp19 libclang1-19 libgl-dev
libglx-dev libopengl-dev libqt6designer6 libqt6designercomponents6
libqt6help6 libqt6test6 libvulkan-dev libx11-dev libxau-dev libxcb1-dev
libxdmcp-dev linguist-qt6 qdoc-qt6 qmake6 qmake6-bin qt6-base-dev
qt6-base-dev-tools qt6-documentation-tools qt6-l10n-tools qt6-tools-dev
qt6-tools-dev-tools x11proto-dev xorg-sgml-doctools xtrans-dev"

done_with_it() {
    mkdir -p "${stamp%/*}"
    : > "$stamp"
    exit 0
}

listed() {
    case " $(echo $2) " in
        *" $1 "*) return 0 ;;
    esac
    return 1
}

unneeded=$(apt-get -s autoremove 2>/dev/null | awk '$1 == "Remv" { print $2 }')
remove=
for package in $brought; do
    if listed "$package" "$unneeded"; then
        remove="$remove $package"
    fi
done
[ -n "$remove" ] || done_with_it

# Removing them must take nothing else with it.
for package in $(apt-get -s remove $remove 2>/dev/null | awk '$1 == "Remv" { print $2 }'); do
    listed "$package" "$remove" || done_with_it
done

# An update may be running: wait for it rather than fail. If it never
# frees up, the next start-up tries again.
if DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::Lock::Timeout=900 remove $remove >/dev/null 2>&1; then
    done_with_it
fi
exit 0