#!/bin/bash # if one thing fails, abort entirely set -e to_install=(world) if [[ $1 = lucky ]]; then eix-update eix --stable --only-names | grep -E -v '^(acct|virtual|sec)-' | sort -u > /tmp/stable eix --installed --only-names | sort -u > /tmp/installed comm -23 /tmp/stable /tmp/installed > /tmp/uninstalled-stable sed -i 's/--binpkg-respect-use//' /etc/portage/make.conf to_install=(--autounmask --autounmask-keep-keywords --autounmask-license n --autounmask-write --autounmask-continue $(shuf -n1 /tmp/uninstalled-stable)) elif [[ $1 ]]; then pushd /etc/portage/variants/$1 while read -r -d '' line; do dest=../../${line%.footer} if [[ ${line} = world* ]]; then dest=/var/lib/portage/world fi if [[ ${line} = world.remove ]]; then emerge -C $(<"${line}") elif [[ ${line} = *.footer ]]; then cat "${line}" >> "${dest}" else mkdir -p "${dest%/*}" cp "${line}" "${dest}" fi done < <(find . -type f -printf '%P\0') if [[ -f buildpkgonly ]]; then ./buildpkgonly fi popd fi emerge -uDNkq --changed-deps --backtrack=100 --keep-going "${to_install[@]}" if [[ ! $1 ]]; then emerge --depclean --quiet-unmerge-warn fi