summaryrefslogtreecommitdiff
path: root/emerge-client
blob: eddfac187ea77e33f74e6cc84cc9c3fa14d778d4 (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
#!/usr/bin/env bash

# This script is for a binhost client.
# Script creating new binhost directories if they don't exist
# after changing profile/gcc versions.
# To be placed in $PATH before /usr/bin/emerge, for instance /usr/bin/local

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='example_user'
BINHOST_SERVER='example_binhost_server'
BINHOST_PATH='/var/www/binhost/rpi3/binpkgs/'

export BINHOST_DIR=${BINHOST_DIR}

NEW_PORTAGE_BINHOST="PORTAGE_BINHOST='ssh://$BINHOST_USER@$BINHOST_SERVER$BINHOST_PATH$PKGDIR'"
OLD_BINHOST=$(grep PORTAGE_BINHOST=\' make.conf)
if [ "$OLD_BINHOST" != "$NEW_PORTAGE_BINHOST" ];then
    echo "Replacing old binhost value in make.conf with new"
    echo "Old value: $OLD_BINHOST"
    echo "New value: $NEW_PORTAGE_BINHOST"
    sed -i '/^PORTAGE_BINHOST/i # Old PORTAGE_BINHOST:' make.conf
    sed -i 's/^PORTAGE_BINHOST/# PORTAGE_BINHOST/' make.conf
    sed -i "/^# PORTAGE_BINHOST/a $NEW_PORTAGE_BINHOST" make.conf
    echo "Proceeding with emerge ..."
else
    echo "Binhost value has not changed, proceeding with emerge ..."
fi