diff --git a/config/modules/portage-snapshot.conf b/config/modules/portage-snapshot.conf new file mode 100644 index 0000000..3f7ebf7 --- /dev/null +++ b/config/modules/portage-snapshot.conf @@ -0,0 +1,3 @@ +# This option specifies a read-only Portage tree mirror, that allows end-users to +# synchronize to. It will be used to create Portage snapshot. +PRODUCTION_PORTAGE=( "git://remotehost.org/portage.git" "git" ) diff --git a/modules/portage-snapshot.ezmod b/modules/portage-snapshot.ezmod new file mode 100644 index 0000000..936a547 --- /dev/null +++ b/modules/portage-snapshot.ezmod @@ -0,0 +1,28 @@ +# Copyright 2010-2012, Asio Software Technologies +# Distributed under the terms of the GNU General Public License v3 +EZMOD_DESCRIPTION="Creates a Portage snapshot ready to use at production" +EZMOD_COMPATIBILITY="ezsync" +EZMOD_AUTHOR="Rafal Kupiec" +EZMOD_VERSION="1.0" + +ezsync_postcommit() { + printInfo "Creating Portage tree snapshot..." + snapshotPortage ${PRODUCTION_PORTAGE[0]} ${PRODUCTION_PORTAGE[1]} || return 1 + local SNAPSHOTS=$(find ${SNAPSHOTSDIR} -type f -name \*.xz | sort -r) + local n=0 + for ARCHIVE in ${SNAPSHOTS}; do + if [[ ${n} < ${ARCHIVESTOKEEP} ]]; then + ((n++)) + continue + fi + rm -f ${ARCHIVE} + rm -f ${ARCHIVE}.* + done + if [ ${REMOTEDOWNLOAD} != "" ]; then + printInfo "Synchronizing remote download..." + run "rsync --archive --compress --copy-links --delete-after \ + --safe-links --verbose --rsh=\"${BINDIR}/ssh_wrapper.sh\" \ + \"${SNAPSHOTSDIR}/\" \"${REMOTEDOWNLOAD}/snapshots\"" || return 1 + fi + return 0 +}