shrub/.travis/get-or-build-pill.sh

76 lines
2.1 KiB
Bash
Raw Normal View History

2017-12-02 06:20:24 +03:00
#!/bin/bash
2017-12-02 08:55:19 +03:00
set -euo pipefail
# set -x
2017-12-02 06:20:24 +03:00
# XX use -s instead of hash pill
HASH=$(git -C .. log -1 HEAD --format=%H -- sys/)
2017-12-02 06:20:24 +03:00
export PILL_NAME="git-${HASH:0:10}"
2017-12-02 08:55:19 +03:00
if [ ! ${PILL_FORCE:-} ]; then
2017-12-02 06:20:24 +03:00
wget https://bootstrap.urbit.org/$PILL_NAME.pill -O urbit.pill && exit 0
fi
# if wget failed
2017-12-02 06:57:11 +03:00
2017-12-02 08:55:19 +03:00
if [ ${TRAVIS_COMMIT:-} ] && [ $TRAVIS_COMMIT != $HASH ]; then
echo Directory sys/ not modified in commit $TRAVIS_COMMIT
echo FIXME ignoring, as current sys/ commits are unlikely to contain the pill-build code
2017-12-02 07:57:53 +03:00
echo
2017-12-02 06:57:11 +03:00
# echo For auto-build please tag and push $HASH
# exit 1
fi
2017-12-02 06:20:24 +03:00
mkdir prev
2017-12-02 07:52:41 +03:00
{
2017-12-02 08:55:19 +03:00
echo Pilling: trying pinned fakezod
wget -i pin-parent-pill-pier.url -O - | tar xvz -C prev/ &&
echo Downloaded prev/zod
2017-12-02 07:52:41 +03:00
} || {
2017-12-02 08:55:19 +03:00
echo Pilling: Parent-pill pier not available, trying preceding pill commit
2017-12-02 07:52:41 +03:00
HASH2=$(git -C .. log -2 $HASH --format=%H -- sys/ | tail -1)
PILL_NAME2="git-${HASH2:0:10}"
2017-12-02 08:55:19 +03:00
wget https://bootstrap.urbit.org/$PILL_NAME2.pill -O urbit.pill &&
echo FIXME running test script to create fakezod, this might be overkill **
lsc test.ls &&
mv urbit.pill prev/urbit.pill &&
2017-12-02 07:52:41 +03:00
mv zod prev/zod
} || {
2017-12-02 08:55:19 +03:00
echo Pilling: Out of ideas
2017-12-02 07:52:41 +03:00
exit 1
}
2017-12-02 06:20:24 +03:00
lsc <<done
2017-12-02 06:20:24 +03:00
do
require! <[ stream-snitch once recursive-copy wait-on ]>
pty = require \pty.js
urbit = pty.spawn './urbit' <[-FI zod prev/zod]>
.on \data -> process.stdout.write it
on-next = (re,cb)->
urbit.pipe (new stream-snitch re).on \match once cb
on-next /\n(\/~|ford: )/ ->
console.log "\n\n---\nnode: detected error\n---\n\n"
set-timeout (-> process.exit 1), 1000
<- on-next /dojo> /
{PILL_NAME} = process.env
urbit.write "|autoload |\r"
urbit.write "|mount %\r"
<- wait-on resources: <[ prev/zod/home ]>
<- recursive-copy '../sys/' 'prev/zod/home/sys/' {+overwrite} .then
<- on-next /sync/
urbit.write "|label %home %#PILL_NAME\r"
urbit.write ".urbit/pill +solid /==/#PILL_NAME/sys, =dub &\r"
<- wait-on resources: <[ prev/zod/.urb/put/urbit.pill ]>
urbit.write "\04"
process.exit 0
done
cp prev/zod/.urb/put/urbit.pill urbit.pill
mkdir built-pill; cp urbit.pill built-pill/$PILL_NAME.pill
2017-12-02 07:57:53 +03:00
echo
echo Created $PILL_NAME.pill, to be uploaded if tests pass
echo