Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 16 additions & 56 deletions misc/build-cproc.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

## $1 : version, currently cproc does not have any and only uses master branch.
## $2 : destination: a directory or S3 path (eg. s3://...)
## $2 : destination: a directory
## $3 : last revision successfully build (optional)

set -ex
source common.sh

ROOT=$PWD
VERSION="${1}"
LAST_REVISION="${3-}"

Expand All @@ -17,67 +17,27 @@ fi

URL="https://git.sr.ht/~mcf/cproc"
BRANCH="master"
QBE_URL="git://c9x.me/qbe.git"
QBE_BRANCH="master"

BASENAME=cproc-${VERSION}-$(date +%Y%m%d)
FULLNAME=${BASENAME}.tar.xz
OUTPUT=${ROOT}/${FULLNAME}
S3OUTPUT=
if [[ $2 =~ ^s3:// ]]; then
S3OUTPUT=$2
else
if [[ -d "${2}" ]]; then
OUTPUT=$2/${FULLNAME}
else
OUTPUT=${2-$OUTPUT}
fi
fi

REVISION=$(git ls-remote --heads "${URL}" "refs/heads/${BRANCH}" | cut -f 1)
echo "ce-build-revision:${REVISION}"
echo "ce-build-output:${OUTPUT}"

if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
echo "ce-build-status:SKIPPED"
exit
fi
CPROC_REVISION=$(get_remote_revision "${URL}" "heads/${BRANCH}")
QBE_REVISION=$(get_remote_revision "${QBE_URL}" "heads/${QBE_BRANCH}")
REVISION="${CPROC_REVISION}_qbe-${QBE_REVISION}"

## From now, no unset variable
set -u
FULLNAME=cproc-${VERSION}-$(date +%Y%m%d)
OUTPUT=$(realpath "$2/${FULLNAME}.tar.xz")

OUTPUT=$(realpath "${OUTPUT}")
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"

rm -rf build-cproc
mkdir -p build-cproc

pushd build-cproc
DESTDIR="${PWD}/stage"

git clone --depth 1 "${URL}" --branch "${BRANCH}"
pushd cproc

## Temporary (hopefully) patch to support basic --version
##
## The following 2 lines are needed on virgin system where nothing is
## configured. git really needs something here, or it will fail. Even using
## --author is not enough.
git config user.email || git config user.email "none@example.com"
git config user.name || git config user.name "None"

git am ../../cproc-version.patch

./configure
make -j"$(nproc)" install DESTDIR="${DESTDIR}" BINDIR=/bin
popd

make -j"$(nproc)"
make install DESTDIR="$PWD/root" BINDIR=/bin

pushd root

export XZ_DEFAULTS="-T 0"
tar Jcf "${OUTPUT}" --transform "s,^./,./${BASENAME}/," ./
git clone --depth 1 "${QBE_URL}" --branch "${QBE_BRANCH}"
make -C qbe -j"$(nproc)" install DESTDIR="${DESTDIR}" BINDIR=/bin

if [[ -n "${S3OUTPUT}" ]]; then
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}"
fi

popd
popd
echo "ce-build-status:OK"
complete "${DESTDIR}" "${FULLNAME}" "${OUTPUT}"
72 changes: 0 additions & 72 deletions misc/cproc-version.patch

This file was deleted.