#!/usr/bin/env bash ############################################################################# # This script is for a binhost client. # # # # Script deciding on a correct PORTAGE_BINHOST variable # # after change of profile/gcc version. # # This script will only use new PORTAGE_BINHOST for current emerge, # # leaving it untouched in make.conf. # # You will have to update make.conf manually # # # # In order to use, rename to `emerge` and place in # # $PATH before /usr/bin/emerge, for instance /usr/bin/local # # call `source /etc/profile` and `env-update`. Check script permissions. # # # # Note: do not use blindly, back up your make.conf first. # # # ############################################################################# PROFILE=$(eselect profile show|sed -n 2p|cut -d '/' -f4) GCC_VERSION=$(eselect gcc show|cut -d '-' -f5) PKGDIR="${PROFILE}/gcc-${GCC_VERSION}.x/armv8a" BINHOST_USER='orp' BINHOST_SERVER='onge' BINHOST_PATH='/var/www/binhost/rpi3/binpkgs/' MAKE_CONF='/etc/portage/make.conf' NEW_PORTAGE_BINHOST="PORTAGE_BINHOST='ssh://$BINHOST_USER@$BINHOST_SERVER$BINHOST_PATH$PKGDIR'" OLD_BINHOST=$(grep -e "^PORTAGE_BINHOST=" $MAKE_CONF) if [ -n "$OLD_BINHOST" ]; then # Old PORTAGE_BINHOST exists if [ "$OLD_BINHOST" != "$NEW_PORTAGE_BINHOST" ];then echo "PORTAGE_BINHOST:" echo "Old value: $OLD_BINHOST" echo "New value: $NEW_PORTAGE_BINHOST" echo "You may want to write the new PORTAGE_BINHOST in make.conf." echo "Proceeding with emerge using new PORTAGE_BINHOST value..." else echo "Binhost value has not changed, proceeding with emerge ..." fi else echo "No PORTAGE_BINHOST variable found" fi PORTAGE_BINHOST=$NEW_PORTAGE_BINHOST /usr/bin/emerge "$@"