summaryrefslogtreecommitdiff
path: root/emerge-client
blob: 3ceae8f19c279d256fb0726618f23d9e01632abf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/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 "$@"