Browse Source

Provide build locks

Also separate out some of the utility functions.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
pull/4/head
Shawn Webb 11 months ago
parent
commit
97a1456a45
Signed by: shawn.webb <shawn.webb@hardenedbsd.org> GPG Key ID: FF2E67A277F8E1FA
4 changed files with 92 additions and 8 deletions
  1. +12
    -5
      bin/ci.sh
  2. +3
    -2
      lib/build.sh
  3. +1
    -1
      lib/publish.sh
  4. +76
    -0
      lib/util.sh

+ 12
- 5
bin/ci.sh View File

@@ -26,24 +26,31 @@

. ./lib/build.sh
. ./lib/publish.sh
. ./lib/util.sh

main() {
HBSD_BUILDNUMBER=1
HBSD_INDEX_FILE=/build/index
HBSD_KERNEL=HARDENEDBSD
HBSD_LOCKFILE=/tmp/13-current.amd64.lock
HBSD_NJOBS=4
HBSD_OBJRELDIR=/usr/obj/usr/src/amd64.amd64/release
HBSD_OBJRELDIR=/usr/obj/scratch/src/hbsd-13/amd64.amd64/release
HBSD_PUBDIR=/build/pub
HBSD_SRC=/usr/src
HBSD_SRC=/scratch/src/hbsd-13
HBSD_STAGEDIR=/build/stage
HBSD_TARGET=amd64
HBSD_TARGET_ARCH=amd64
HBSD_NOCLEAN="-DNO_CLEAN"

build_hardenedbsd && \
assert_unlocked && \
lock_build && \
update_codebase && \
build_hardenedbsd && \
build_release && \
stage_release && \
sign_release && \
publish_release && \
kick_publisher_tires
kick_publisher_tires && \
unlock_build
return ${?}
}



+ 3
- 2
lib/build.sh View File

@@ -33,14 +33,14 @@ build_hardenedbsd() {
-j ${HBSD_NJOBS} \
TARGET=${HBSD_TARGET} \
TARGET_ARCH=${HBSD_TARGET_ARCH} \
-DNO_CLEAN \
${HBSD_NOCLEAN} \
buildworld
make \
-j ${HBSD_NJOBS} \
TARGET=${HBSD_TARGET} \
TARGET_ARCH=${HBSD_TARGET_ARCH} \
KERNCONF=${HBSD_KERNEL} \
-DNO_KERNELCLEAN \
${HBSD_NOCLEAN} \
buildkernel
)
return ${?}
@@ -96,6 +96,7 @@ sign_release() {
-name '*.txz' \
-o -name '*.img' \
-o -name '*.iso' \
-o -name '*.xz' \
-o -name 'MANIFEST'); do
f=${file##*/}
sha256 ${f} >> CHECKSUMS.SHA256


+ 1
- 1
lib/publish.sh View File

@@ -25,7 +25,7 @@
# SUCH DAMAGE.

publish_release() {
mv ${HBSD_STAGEDIR} ${HBSD_PUBDIR}/${HBSD_BUILDNUMBER}
mv ${HBSD_STAGEDIR} ${HBSD_PUBDIR}/$(build_number)
return ${?}
}



+ 76
- 0
lib/util.sh View File

@@ -0,0 +1,76 @@
#!/bin/sh
#-
# Copyright (c) 2019 HardenedBSD
# Author: Shawn Webb <shawn.webb@hardenedbsd.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.

is_locked() {
if [ -e ${HBSD_LOCKFILE} ]; then
return 0
fi

return 1
}

lock_build() {
touch ${HBSD_LOCKFILE}
return ${?}
}

unlock_build() {
rm -f ${HBSD_LOCKFILE}
return ${?}
}

assert_unlocked() {
if is_locked; then
echo "Build locked. Remove ${HBSD_LOCKFILE}"
exit 1
fi

return 0
}

build_number() {
local n

if [ -e ${HBSD_INDEX_FILE} ]; then
n=$(cat ${HBSD_INDEX_FILE})
n=$((${n} + 1))
echo ${n} | tee ${HBSD_INDEX_FILE}
return 0
fi

echo 1
return 0
}

update_codebase() {
(
set -ex

cd ${HBSD_SRC}
git pull
)
return ${?}
}

Loading…
Cancel
Save