From b132748288b71ae127028f08ef42630515ea1ecb Mon Sep 17 00:00:00 2001 From: belliash Date: Tue, 17 Jan 2012 11:29:03 +0100 Subject: [PATCH] Add local-mirror module --- config/modules/local-mirror.conf | 7 +++++++ modules/local-mirror.ezmod | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/modules/local-mirror.conf create mode 100644 modules/local-mirror.ezmod diff --git a/config/modules/local-mirror.conf b/config/modules/local-mirror.conf new file mode 100644 index 0000000..ec96edc --- /dev/null +++ b/config/modules/local-mirror.conf @@ -0,0 +1,7 @@ +# This specifies the local repository with the base path. This is the directory, where +# Portage mirror will be saved. Don't forget to uncomment this option! +#LOCALMIRROR_PATH="/path/to/portage-mirror.git" + +# Directive sets a username, that will be used to pull changes from remote repository. +# This is useful when the local daemon is running with different permissions. +LOCALMIRROR_USER="root" diff --git a/modules/local-mirror.ezmod b/modules/local-mirror.ezmod new file mode 100644 index 0000000..c47b91f --- /dev/null +++ b/modules/local-mirror.ezmod @@ -0,0 +1,24 @@ +# Copyright 2010-2012, Asio Software Technologies +# Distributed under the terms of the GNU General Public License v3 +EZMOD_DESCRIPTION="Synchronizes local Portage mirror" +EZMOD_COMPATIBILITY="ezsync" +EZMOD_AUTHOR="Rafal Kupiec" +EZMOD_VERSION="1.0" + +ezsync_postcommit() { + if [ "${LOCALMIRROR_PATH}" != "" ]; then + printInfo "Synchronizing local Portage mirror..." + if [ "$(toUpper ${PORTAGE_BUILD[1]})" != "GIT" ]; then + printWarn "Local mirror actually supports only GIT!" + return 1 + fi + if [ -d ${LOCALMIRROR_PATH} ]; then + cd ${LOCALMIRROR_PATH} + run "su ${LOCALMIRROR_USER} -s \"/bin/sh\" -c \"git fetch --all\"" || return 1 + else + makeDirectory ${LOCALMIRROR_PATH} + run "su ${LOCALMIRROR_USER} -s \"/bin/sh\" -c \"git clone --mirror --bare ${PORTAGE_BUILD[2]} ${LOCALMIRROR_PATH}\"" || return 1 + fi + fi + return 0 +}