OXYGENHUB
◆ v0.4.2 oxygenhub / .flow / warm-target.sh
932 B · Bourne Again Shell (bash) · executable · last changed warm-target: a fresh target disk holds lost+found 1 month ago source blame history raw
1
#!/bin/sh
2
# Start from the build image's prebuilt dependencies, then run the command.
3
# OxygenFlow's rust image holds oxygenhub's dependencies built at /src with
4
# this pipeline's environment (oxygenflow/images/rust, backlog F6b2); the
5
# job's target disk starts empty, so copying them in leaves cargo only this
6
# workspace's own crates to compile. Without them (an older image, or a
7
# failed copy) the job simply builds everything, as before.
8
set -eu
9
warm=/opt/warm/oxygenhub
10
# A fresh ext4 target disk holds only lost+found.
11
if [ -d "$warm" ] && [ -z "$(ls -A target 2>/dev/null | grep -vx 'lost+found')" ]; then
12
    start=$(date +%s)
13
    if cp -R --preserve=timestamps "$warm/." target/; then
14
        echo "flow: prebuilt dependencies copied in $(( $(date +%s) - start )) s"
15
    else
16
        echo "flow: could not copy the prebuilt dependencies; building them" >&2
17
        rm -rf target/* 2>/dev/null || true
18
    fi
19
fi
20
exec "$@"