Annotation of buildman/bm, revision 1.1
1.1 ! snw 1: #!/bin/sh
! 2:
! 3: # SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC
! 4: # SPDX-FileCopyrightText: (C) 2025 Serena Willis
! 5: #
! 6: # SPDX-License-Identifier: AGPL-3.0
! 7:
! 8: #
! 9: # BuildMan 0.0.1
! 10: # Distributed CI/CD system with portability to older UNIX systems
! 11: #
! 12: # bm - primary BuildMan script
! 13: #
! 14: # Copyright (C) 2025 Coherent Logic Development LLC
! 15: #
! 16: # Author: Serena Willis <snw@coherent-logic.com>
! 17: #
! 18:
! 19: PROGN=`basename $0`
! 20:
! 21: if [ -f "/etc/default/bm" ]
! 22: then
! 23: . /etc/default/bm
! 24: else
! 25: echo "${PROGN} error: no /etc/default/bm"
! 26: exit 1
! 27: fi
! 28:
! 29: if [ -z ${BUILDMAN_BASE} ]
! 30: then
! 31: echo "${PROGN} error: BUILDMAN_BASE undefined"
! 32: exit 1
! 33: fi
! 34:
! 35: if [ -z ${BUILDMAN_UID} ]
! 36: then
! 37: echo "${PROGN} error: BUILDMAN_UID undefined"
! 38: exit 1
! 39: fi
! 40:
! 41: if [ -z ${BUILDMAN_GID} ]
! 42: then
! 43: echo "${PROGN} error: BUILDMAN_GID undefined"
! 44: exit 1
! 45: fi
! 46:
! 47: if [ $EUID -ne ${BUILDMAN_UID} ]
! 48: then
! 49: echo "${PROGN} error: must be run as user \"${BUILDMAN_USER}\""
! 50: exit 1
! 51: fi
! 52:
! 53: ACTION=""
! 54: PROJECT=""
! 55: BUILD_HOST=""
! 56: OS=`uname`
! 57:
! 58: if [ "$OS" = "SCO_SV" ] ; then
! 59: THOST=`hostname -s`
! 60: PATH=/usr/gnu/bin:$PATH
! 61: export PATH
! 62: else
! 63: if [ "$OS" = "SunOS" ] ; then
! 64: THOST=`hostname`
! 65: else
! 66: THOST=`hostname -s`
! 67: fi
! 68: fi
! 69:
! 70: tmphost=`echo ${THOST} | cut -d. -f1`
! 71: THOST="${tmphost}"
! 72:
! 73:
! 74: while getopts ':p:h:a:bl:o:' OPTION
! 75: do
! 76: case $OPTION in
! 77:
! 78: l)
! 79: ACTION="list"
! 80: TOLIST="${OPTARG}"
! 81: ;;
! 82:
! 83: o)
! 84: OPTIONS="${OPTARG}"
! 85: ;;
! 86:
! 87: p)
! 88: PROJECT="${OPTARG}"
! 89: ;;
! 90:
! 91: a)
! 92: ACTION="add"
! 93: TOADD="${OPTARG}"
! 94: ;;
! 95:
! 96: b)
! 97: ACTION="build"
! 98: ;;
! 99:
! 100: h)
! 101: BUILD_HOST="${OPTARG}"
! 102: ;;
! 103:
! 104: esac
! 105: done
! 106:
! 107: if [ ! -z "${PROJECT}" ]
! 108: then
! 109: PROJECT_BASE="${BUILDMAN_BASE}/projects/${PROJECT}"
! 110: if [ "${ACTION}" == "add" -a ! -d ${PROJECT_BASE} ]
! 111: then
! 112: echo "$PROGN: creating ${PROJECT} in ${PROJECT_BASE}..."
! 113: mkdir -p "${PROJECT_BASE}"
! 114: fi
! 115:
! 116: if [ ! -d "${PROJECT_BASE}" ]
! 117: then
! 118: echo "$PROGN error: project ${PROJECT} not defined"
! 119: exit 1
! 120: fi
! 121: fi
! 122:
! 123: case $ACTION in
! 124:
! 125: list)
! 126: case $TOLIST in
! 127:
! 128: p|projects)
! 129: ls -d -1 ${BUILDMAN_BASE}/projects/*
! 130: ;;
! 131:
! 132: h|hosts)
! 133: ls -l "${BUILDMAN_BASE}/projects/${PROJECT}/hosts"
! 134: ;;
! 135:
! 136: *)
! 137: echo "$PROGN error: invalid list specifier \"${TOLIST}\""
! 138: exit 1
! 139: ;;
! 140: esac
! 141: ;;
! 142:
! 143: add)
! 144: case $TOADD in
! 145:
! 146: p|project)
! 147: if [ -z "${PROJECT}" ]
! 148: then
! 149: echo "$PROGN error: no project specified (use -p)"
! 150: exit 1
! 151: fi
! 152:
! 153: PBASE="${BUILDMAN_BASE}/projects/${PROJECT}"
! 154: if [ -d "${PBASE}" ]
! 155: then
! 156: echo "$PROGN error: project \"${PROJECT}\" already exists"
! 157: exit 1
! 158: fi
! 159:
! 160: echo "$PROGN: creating directory structure for project \"${PROJECT}\""
! 161: mkdir -p "${PBASE}/hosts"
! 162:
! 163: ;;
! 164:
! 165:
! 166: h|host)
! 167: if [ -z "${PROJECT}" ]
! 168: then
! 169: echo "$PROGN error: no project specified (use -p)"
! 170: exit 1
! 171: fi
! 172:
! 173: PBASE="${BUILDMAN_BASE}/projects/${PROJECT}"
! 174: if [ ! -d "${PBASE}" ]
! 175: then
! 176: echo "$PROGN error: project \"${PROJECT}\" does not exist"
! 177: exit 1
! 178: fi
! 179:
! 180: if [ -z "${BUILD_HOST}" ]
! 181: then
! 182: echo "$PROGN error: no host specified (use -h)"
! 183: exit 1
! 184: fi
! 185:
! 186: HBASE="${PBASE}/hosts/${BUILD_HOST}"
! 187: if [ -d "${HBASE}" ]
! 188: then
! 189: echo "$PROGN error: build host \"${BUILD_HOST}\" already exists"
! 190: exit 1
! 191: fi
! 192:
! 193: echo "$PROGN: adding host \"${BUILD_HOST}\" to project \"${PROJECT}\""
! 194: mkdir -p "${HBASE}"
! 195: ;;
! 196:
! 197: esac
! 198: ;;
! 199:
! 200:
! 201:
! 202: build)
! 203: if [ -z "${BUILD_HOST}" ]
! 204: then
! 205: echo "$PROGN error: no build host specified"
! 206: exit 1
! 207: fi
! 208:
! 209: BUILD_BASE="${PROJECT_BASE}/hosts/${BUILD_HOST}"
! 210:
! 211: if [ ! -d "${BUILD_BASE}" ]
! 212: then
! 213: echo "$PROGN error: build host ${BUILD_HOST} not configured"
! 214: exit 1
! 215: fi
! 216:
! 217: BUILD_WANTED="${PROJECT_BASE}/${HOST}/build-wanted"
! 218:
! 219: if [ -f "${BUILD_WANTED}" ]
! 220: then
! 221: echo "$PROGN error: build already requested"
! 222: exit 1
! 223: fi
! 224:
! 225: touch "${BUILD_WANTED}"
! 226: echo "$PROGN: build of project ${PROJECT} requested on build host ${HOST}"
! 227: ;;
! 228:
! 229: esac
! 230:
! 231:
! 232:
! 233:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>