#!/bin/sh BASE=/poudriere/data/packages JAIL=${JAIL:-130amd64} TREE=ci_pkgs REPO=charlotte:/srv/freebsdrepo/${JAIL}/ CONF=/devel/kde/ci LIST=${CONF}/list.txt MAKE=${CONF}/make.conf INFO=${CONF}/info.txt PORTSTREE=/poudriere/ports/${TREE} PACKAGES="${BASE}/${JAIL}-${TREE}/.latest/" copy_file () { FILE="$1" if [ -f "${FILE}" ] ; then rsync -r -v "${FILE}" "${REPO}" fi } git_info () { cd ${PORTSTREE} && git log --pretty -n 1 > "${INFO}" } sync () { echo "== Syncing packages" if [ "x${PACKAGES}y" != "xy" ] ; then if [ "x${REPO}y" != "xy" ] ; then echo rsync -r -v -P -t --delete "${PACKAGES}" "${REPO}" rsync -r -v -P -t --delete "${PACKAGES}" "${REPO}" fi copy_file ${LIST} copy_file ${MAKE} copy_file ${INFO} fi } build_list () { echo "== Building list ${LIST}" prio="" if [ $# -eq 1 ] ; then prio="idprio ${1}" fi ${prio} sudo poudriere bulk -j${JAIL} -p${TREE} -f${LIST} git_info } build_ports () { local ports=$(filter_ports "$*") echo "== Installing ports ${ports}" if [ "x${ports}y" != "xy" ] ; then append "${ports}" sudo poudriere bulk -j${JAIL} -p${TREE} ${ports} fi git_info } append () { ports=$(filter_ports $*) for port in ${ports} ; do grep -q "^${port}$$" "${LIST}" if [ $? -eq 1 ] ; then echo ${port} >> ${LIST} fi done sort -u -o "${LIST}" "${LIST}" } filter_ports () { result="" for item in $* ; do echo "${item}" | grep -qE '^[a-z][A-Za-z0-9-]*/[A-Za-z0-9-]+$' if [ $? -eq 0 ] ; then port="${PORTSTREE}/${item}" if [ -d "${port}" ] ; then result="${result} ${item}" fi fi done echo $(echo "${result}" | sed 's|^ ||g') } cron () { "== Building and syncing new packages" build_list 5 sync } #----------------------------------------------------------------------- PRG="${0##*/}" if [ "x${PRG}y" = "xci_build_portsy" ] ; then build_ports $* elif [ "x${PRG}y" = "xci_build_listy" ] ; then build_list elif [ "x${PRG}y" = "xci_uploady" ] ; then sync elif [ "x${PRG}y" = "xci_runy" ] ; then build_list $* sync else echo "unknown command ${PRG}" filter_ports "$*" fi