Last active
October 10, 2015 23:15
-
-
Save rdnetto/522839021a240650c20d to your computer and use it in GitHub Desktop.
Script for updating Portage files in Sabayon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# sync-entropy-files.sh | |
# Copyright Reuben D'Netto 2014. Published under Apache 2.0 license. | |
# This script updates the portage files used in Sabayon so that entropy and portage don't step on each other's feet | |
BUILD_DIR="/var/cache/sabayon-build" | |
ARCH=$(uname -m) | |
[[ "$ARCH" == "i686" || "$ARCH" == "x86_64" ]] && ARCH="intel" | |
# Generates filenames for config file protection | |
function protect { | |
DIR=$(dirname $1) | |
FILE=$(basename $1) | |
for i in `seq 0 9999`; do | |
PROTECTED_FILE=$(printf "%s/._cfg%.4i_%s" $DIR $i $FILE) | |
[ -f "$PROTECTED_FILE" ] || return | |
done | |
echo "Too many config protection files: $i" >&2 | |
exit 1 | |
} | |
# Pull latest files from github | |
if [ -d $BUILD_DIR ]; then | |
OLD_HEAD=$(git -C $BUILD_DIR rev-parse HEAD) | |
git -C $BUILD_DIR pull || exit 1 | |
else | |
git clone "https://github.com/Sabayon/build.git" $BUILD_DIR || exit 1 | |
git -C $BUILD_DIR config --add branch.master.rebase true | |
fi | |
if [ ! -d $BUILD_DIR/conf/$ARCH ]; then | |
echo "Unknown architecture '$ARCH'." >&2 | |
exit 1 | |
fi | |
# Update files | |
echo "Updating Sabayon portage files..." | |
cd $BUILD_DIR/conf/$ARCH/portage | |
for file in * */* */*/* ; do | |
if [ -f "/etc/portage/$file" -a -f "$file" ]; then | |
if ! cmp -s "/etc/portage/$file" "$file"; then | |
protect "/etc/portage/$file" | |
cp -n $file $PROTECTED_FILE | |
fi | |
elif [ -f $file ]; then | |
echo "WARNING: Skipping $file" >&2 | |
fi | |
done | |
if [ ! -z "$BUILD_DIR" ]; then | |
echo "" | |
echo "Sabayon portage file changes:" | |
if [ "${OLD_HEAD}" != "${HEAD}" ]; then | |
git -C $BUILD_DIR log --oneline ${OLD_HEAD}..HEAD -- conf | |
else | |
echo "(none)" | |
fi | |
echo "" | |
fi | |
# Don't need to notify the user, because emerge will do that for us (when called from eix-sync) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed some issues.
HEAD was not defined and the pager didn't work well with eix-sync.
https://gist.github.com/0a0da4476b6d1cf68e72.git