1#!/bin/sh23set -e45msg() {6 local color=${2:-green}7 case "$color" in8 red) color="31";;9 green) color="32";;10 yellow) color="33";;11 blue) color="34";;12 *) color="32";;13 esac14 printf "\033[1;%sm>>>\033[1;0m %s\n" "$color" "$1" | xargs >&215}1617die() {18 msg "$1" red19 exit 120}2122get_release() {23 BASEBRANCH=$(git rev-parse --abbrev-ref HEAD)24 case $BASEBRANCH in25 *-stable) echo v"${BASEBRANCH%-*}";;26 master) echo edge;;27 *) die "Branch \"$BASEBRANCH\" not supported!"28 esac29}303132RDEST="${RDEST:-io.lin.moe::mirrors.koi.moe/lin}"33TDEST="pkg/lin"34RELEASE=$(get_release)3536mkdir -p "${TDEST}"3738msg "## Retrieving packages from remote repository."39rsync-ssl -av --delete-excluded "${RDEST}/${RELEASE}/" "${TDEST}"4041msg "## Invoking buildrepo."42buildrepo -a "$(pwd)" -d "$(pwd)/${TDEST%/*}" -R -p lin4344msg "## Pushing packages to remote repository."45rsync-ssl -av --delete-excluded "${TDEST}/" "${RDEST}/${RELEASE}/"