view contrib/packaging/dockerrpm @ 45435:64de86fd0984

tags: take lock instead of wlock before writing hgtagsfnodes1 cache This cache is shared across stores and hence we should take store lock before writing to it. Otherwise there will be race where one share with wlock is writing to this cache and other share with wlock is trying to read it simultaneously. Differential Revision: https://phab.mercurial-scm.org/D9001
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 08 Sep 2020 19:36:40 +0530
parents e66a3bfcb19b
children 4713bcf78037
line wrap: on
line source

#!/bin/bash -e

BUILDDIR=$(dirname $0)
export ROOTDIR=$(cd $BUILDDIR/../..; pwd)

PLATFORM="$1"
shift # extra params are passed to buildrpm

DOCKERFILE="$PLATFORM"
OS_RELEASE="${PLATFORM//[a-z]/}"
case "$PLATFORM" in
fedora*)
    DOCKERFILE="${PLATFORM//[0-9]/}.template"
    ;;
esac

DOCKER=$($BUILDDIR/hg-docker docker-path)

CONTAINER=hg-docker-$PLATFORM

if [[ -z "${HG_DOCKER_OWN_USER}" ]]; then
    DOCKERUID=1000
    DOCKERGID=1000
else
    DOCKERUID=$(id -u)
    DOCKERGID=$(id -g)
fi

$BUILDDIR/hg-docker build \
    --build-arg UID=$DOCKERUID \
    --build-arg GID=$DOCKERGID \
    --build-arg OS_RELEASE=${OS_RELEASE:-latest} \
    $BUILDDIR/docker/$DOCKERFILE $CONTAINER

RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
mkdir -p $RPMBUILDDIR
$ROOTDIR/contrib/packaging/buildrpm --rpmbuilddir $RPMBUILDDIR --prepare $*

DSHARED=/mnt/shared
DBUILDUSER=build

$DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
    rpmbuild --define "_topdir $DSHARED" -ba $DSHARED/SPECS/mercurial.spec --clean

$DOCKER run -e http_proxy -e https_proxy -u $DBUILDUSER --rm -v $RPMBUILDDIR:$DSHARED $CONTAINER \
    createrepo $DSHARED

cat << EOF > $RPMBUILDDIR/mercurial.repo
# Place this file in /etc/yum.repos.d/mercurial.repo
[mercurial]
name=Mercurial packages for $PLATFORM
# baseurl=file://$RPMBUILDDIR/
baseurl=http://hg.example.com/build/$PLATFORM/
skip_if_unavailable=True
gpgcheck=0
enabled=1
EOF

echo
echo "Build complete - results can be found in $RPMBUILDDIR"