#!/bin/bash ################################# # Bash script to complement bug #13616 # this will grab the current USE from emerge info # Copyright Gentoo Linux # Written By John Mylchreest ################################# PKG_DIR="/var/db/pkg/" PACKAGE_USE_FILE="/etc/portage/package.use" CURRENT_FLAGS="$(emerge info | grep USE | sed 's:"::g' | sed 's:USE=::g')" if [ ! "$(whoami)" == "root" ] ; then echo "This script must be ran as root" exit 0 fi if [ -f "${PACKAGE_USE_FILE}" ] ; then echo "Moving ${PACKAGE_USE_FILE} to ${PACKAGE_USE_FILE}.orig" mv ${PACKAGE_USE_FILE} ${PACKAGE_USE_FILE}.orig fi echo "Searching packages currently installed for variation on USE flags, This will take a LONG time..." for x in $(grep -F -R "" ${PKG_DIR}/*/*/USE) do PKG_TMP=$(echo ${x} | cut -f1 -d: | sed "s:${PKG_DIR}\/::g" | sed "s:-[0-9].*::g") if [ -n "$(echo ${PKG_TMP} | grep "/")" ] ; then if [ -n "${PACKAGE_USE}" ] ; then echo " Found ${PACKAGE_NAME}->'${PACKAGE_USE}'" $(echo "${PACKAGE_NAME} ${PACKAGE_USE}" | sed 's: : :g' >> ${PACKAGE_USE_FILE}) fi PACKAGE_NAME=${PKG_TMP} PACKAGE_USE="" echo "Checking: ${PACKAGE_NAME}" else [ -z "$(echo " ${CURRENT_FLAGS}" | grep " ${PKG_TMP}" 2> /dev/null)" ] && PACKAGE_USE="${PACKAGE_USE} ${PKG_TMP}" fi done echo "Finished, please check ${PACKAGE_USE_FILE} for correctness"