Commit e4a328a0 authored by Manuel Moos's avatar Manuel Moos
Browse files

Merge from 0.2.9 with adaptions

Closes #79 and #80
parents c8cb30d0 7e03bf66
Pipeline #239587831 passed with stages
in 53 minutes and 40 seconds
......@@ -2,4 +2,11 @@ Dockerfile
dockerbuild
.dockerignore
.gitlab-ci.yml
.git
builds
docker
#!docker/scripts/*.sh
!docker/build/*.in
!docker/build/*.am
!docker/build/context/*.in
!docker/deploy/*.in
\ No newline at end of file
......@@ -241,7 +241,7 @@ build_collect:
expire_in: 1 week
# deploy to staged environment
deploy-staged:
deploy_staged:
dependencies:
- build_prepare
- build_collect
......@@ -259,23 +259,22 @@ deploy-staged:
- ./docker/deploy/prepare_deploy.sh || exit $?
script:
# mark
- echo ${CI_PIPELINE_IID} > /messageboard/current_pipeline_${CI_COMMIT_REF_NAME}
# now enter the docker build directory and just invoke make there
- cd gitlab_build/docker/build
- make staged_deploy -O -j$(nproc) -k
# do the actual release; manually for final releases, delayed to avoid spam for everyone else
delay-release:
delay_release:
dependencies: []
stage: stage
rules:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: '$CI_COMMIT_REF_PROTECTED == "false"'
when: never
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG'
when: manual
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_BRANCH'
when: delayed
start_in: '6 hours'
......@@ -284,37 +283,87 @@ delay-release:
script: [""]
# do the actual release; manually for final releases, delayed to avoid spam for everyone else
deploy-release:
deploy_release:
dependencies:
- build_prepare
- build_collect
stage: deploy
tags:
- armagetronad_deploy
rules:
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG'
when: manual
- if: '$CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_BRANCH'
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
when: on_success
- when: never
before_script:
- ./docker/scripts/fix_gits.sh || exit $?
- ./docker/deploy/prepare_deploy.sh || exit $?
script:
# test whether we're current
- tagfile=/messageboard/current_pipeline_${CI_COMMIT_REF_NAME}
- if ! echo ${CI_COMMIT_REF_NAME} | grep -q ^release && test -r ${tagfile} && ! test ${CI_PIPELINE_IID} == `cat ${tagfile}`; then
- echo "A newer build is already in the pipeline, abort."
- exit 0
- fi
- docker/scripts/obsolete.sh || exit 0
# build
- cd gitlab_build/docker/build
- rm -rf result.appimage_* context.appimage_* # remake appimages, now we can sign them
- make unstaged_deploy -O -j$(nproc) -k
# test build docker image (hopefully also initiating the cache for later deployment)
# does not really need debtest, but we want to let the Windows builds go first
build_docker:
stage: build_collect
needs:
- build_prepare
- build_debtest
dependencies:
- build_prepare
after_script:
- rm -f ~/.docker/config.json
script:
- make -C gitlab_build/docker/build build_docker.tag || exit $?
# deploy docker image to staging
stage_docker:
stage: stage
needs:
- build_prepare
- build_docker
dependencies:
- build_prepare
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
when: on_success
- when: never
after_script:
- rm -f ~/.docker/config.json
script:
- make -C gitlab_build/docker/build staged_deploy_docker.tag || exit $?
# deploy docker image
deploy_docker:
stage: deploy
needs:
- build_prepare
- stage_docker
- delay_release
dependencies:
- build_prepare
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
when: on_success
- when: never
after_script:
- rm -f ~/.docker/config.json
script:
# test whether we're current
- docker/scripts/obsolete.sh || exit 0
# build
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY 2>&1 | grep -v WARNING\|credential || exit $?
- make -C gitlab_build/docker/build unstaged_deploy_docker.tag || exit $?
# post-build tests
post_test:
......
ARG BASE_BUILD_SMALL=registry.gitlab.com/armagetronad/armagetronad/armalpine_32:028_0
ARG BASE_BUILD_FULL=registry.gitlab.com/armagetronad/armagetronad/armabuild_64:028_0
ARG BASE_LINUX=i386/alpine:3.7
ARG PROGRAM_NAME=armagetronad-unk
ARG PROGRAM_TITLE="Armagetron UNK"
ARG BASE_ALPINE=amd64/alpine:3.12
ARG CONFIGURE_ARGS=""
ARG FAKERELEASE=false
ARG BRANCH=trunk-fix-unknown-bug
ARG PROGNAME="armagetronad"
ARG PROGTITLE="Armagetron Advanced"
########################################
# bootstrap source
FROM ${BASE_BUILD_FULL} AS bootstrap
MAINTAINER Manuel Moos <z-man@users.sf.net>
# runtime prerequisites
FROM ${BASE_ALPINE} AS runtime_base
LABEL maintainer="Manuel Moos <z-man@users.sf.net>"
ENV SOURCE_DIR /home/docker/armagetronad
ENV BUILD_DIR /home/docker/build
ARG PROGNAME
COPY --chown=docker . ${SOURCE_DIR}
RUN chmod 755 ${SOURCE_DIR}
WORKDIR ${SOURCE_DIR}
# these files are in .dockerignore, but if they're in git, restore them.
RUN test -d .git && git checkout .dockerignore .gitlab-ci.yml Dockerfile
RUN git status
#RUN ./batch/make/version .
#RUN false
RUN test -r configure || ./bootstrap.sh
RUN cat version.m4
#RUN false
########################################
# build tarball
FROM bootstrap AS configured
RUN apk add \
bash \
boost-thread \
libxml2 \
libgcc \
libstdc++ \
protobuf \
--no-cache
#ARG PROGRAM_NAME
#ARG PROGRAM_TITLE
ARG FAKERELEASE
ARG BRANCH
RUN mkdir -p ${BUILD_DIR} && chmod 755 ${BUILD_DIR}
WORKDIR ${BUILD_DIR}
RUN . ../armagetronad/docker/scripts/brand.sh . && ARMAGETRONAD_FAKERELEASE=${FAKERELEASE} ../armagetronad/configure --prefix=/usr/local --disable-glout --disable-sysinstall --disable-desktop progname="${PROGRAM_NAME}" progtitle="${PROGRAM_TITLE}"
RUN make -j$(nproc) dist && make -C docker/build tag.gits
RUN if [ ${FAKERELEASE} = true ]; then cp ../armagetronad/docker/build/fakerelease_proto.sh docker/build/fakerelease.sh; fi
WORKDIR /
RUN adduser -D ${PROGNAME}
########################################
# build server
FROM bootstrap AS build_server
ARG PROGRAM_NAME
ARG PROGRAM_TITLE
# development prerequisites
FROM runtime_base AS builder
RUN bash ./configure --prefix=/usr/local --disable-glout --disable-sysinstall --disable-desktop progname="${PROGRAM_NAME}" progtitle="${PROGRAM_TITLE}"
RUN make -j$(nproc)
RUN DESTDIR=/home/docker/destdir make install
# build dependencies
RUN apk add \
autoconf \
automake \
boost-dev \
patch \
bash \
bison \
g++ \
make \
libxml2-dev \
protobuf-dev \
python3 \
--no-cache
########################################
# build client
FROM bootstrap AS build_client
# build
FROM builder as build
ARG PROGRAM_NAME
ARG PROGRAM_TITLE
ARG CONFIGURE_ARGS
ARG FAKERELEASE
ARG PROGNAME
ARG PROGTITLE
RUN bash ./configure --prefix=/usr/local --disable-sysinstall --disable-desktop progname="${PROGRAM_NAME}" progtitle="${PROGRAM_TITLE}"
RUN make -j$(nproc)
RUN DESTDIR=/home/docker/destdir make install
ENV SOURCE_DIR /root/${PROGNAME}
ENV BUILD_DIR /root/build
########################################
COPY . ${SOURCE_DIR}
WORKDIR ${SOURCE_DIR}
FROM ${BASE_LINUX} AS run_server_base
MAINTAINER Manuel Moos <z-man@users.sf.net>
RUN (test -r configure && test -f missing) || (./bootstrap.sh && cat version.m4)
# runtime dependencies
RUN apk add \
boost-thread \
libxml2 \
protobuf \
python \
shadow \
--no-cache
RUN mkdir -p ${BUILD_DIR} && chmod 755 ${BUILD_DIR}
WORKDIR ${BUILD_DIR}
RUN ARMAGETRONAD_FAKERELEASE=${FAKERELEASE} progname="${PROGNAME}" progtitle="${PROGTITLE}" \
${SOURCE_DIR}/configure --prefix=/usr/local --disable-glout --disable-sysinstall --disable-useradd \
--disable-master --disable-uninstall --disable-desktop \
${CONFIGURE_ARGS} && \
make -j `nproc` && \
DESTDIR=/root/destdir make install && \
rm -rf ${SOURCE_DIR} ${BUILD_DIR}
########################################
FROM run_server_base AS run_server
MAINTAINER Manuel Moos <z-man@users.sf.net>
# pack
FROM runtime_base AS runtime
FROM runtime_base AS run_server
ARG PROGRAM_NAME
ARG PROGNAME
WORKDIR /
COPY --chown=root --from=build_server /home/docker/destdir/ /
RUN sh /usr/local/share/games/${PROGRAM_NAME}-dedicated/scripts/sysinstall install /usr/local
COPY --chown=root --from=build /root/destdir /
RUN sh /usr/local/share/games/*-dedicated/scripts/sysinstall install /usr/local && \
echo -e "#!/bin/bash\n/usr/local/bin/${PROGNAME}-dedicated \"\$@\"" > /usr/local/bin/run.sh && \
chmod 755 /usr/local/bin/run.sh
USER ${PROGNAME}
ENTRYPOINT ["/usr/local/bin/run.sh"]
EXPOSE 4534/udp
......@@ -16,7 +16,7 @@ include $(top_srcdir)/Makefile.manual
EXTRA_DIST = README-DEVELOPER README-Subversion README-SDL \
armagetron.kdevelop armagetron.kdevelop.pcs armagetron.kdevses tron.ico \
models sound textures bootstrap.sh music accustomdir.m4 fingerprint \
win32 major_version
win32 major_version Dockerfile
# language/update.py
# resource is included as a subdir for the purpose of keeping this makefile short and delegating
......
......@@ -14,6 +14,17 @@ if test -r batch/make/version; then
echo "Generating version..."
echo "m4_define(AUTOMATIC_VERSION,["`sh batch/make/version $MYDIR`"])" > version.m4 || exit 1
sh batch/make/version --verbose $MYDIR | awk '{ print "#define TRUE_ARMAGETRONAD_" $1 " " substr( $0, index( $0, $2 ) ) }' > src/tTrueVersion.h
# try to fix source epoch
if test -e .git; then
if SOURCE_DATE_EPOCH=`git log --date=unix | grep Date: | head -n 1 | sed -e "s,Date: *,,"`; then
git update-index --refresh > /dev/null
if git diff-index --quiet HEAD --; then
echo "m4_define(SOURCE_DATE_EPOCH,${SOURCE_DATE_EPOCH})" >> version.m4 || exit 1
fi
fi
fi
rm -f version
fi
echo "Copying license..."
......
......@@ -57,19 +57,18 @@ AC_ARG_VAR(SDL_CONFIG,[Configuration script of SDL to use, defaults to sdl-confi
AC_ARG_VAR(SDL2_CONFIG,[Configuration script of SDL to use, defaults to sdl2-config])
AC_ARG_VAR(FREETYPE_CONFIG,[Configuration script of freetype to use, defaults to freetype-config])
# determine date, if possible from prerecorded git log
date_raw_rfc=`grep "Date:" ${srcdir}/ChangeLog | head -n 1 | sed -e 's/Date: *//'`
dnl echo date_raw_rfc=${date_raw_rfc}
date_iso=`date -I` || exit $?
dnl echo date_iso=${date_iso}
date_rfc=`date -R` || exit $?
dnl echo date_rfc=${date_rfc}
test -z "${date_raw_rfc}" || date_iso=`date -I -d "${date_raw_rfc}"` || exit $?
source_date_epoch=SOURCE_DATE_EPOCH
test ${source_date_epoch} = SOURCE_DATE_EPOCH && source_date_epoch=`date +%s`
AC_SUBST(source_date_epoch)
# determine date, following the epoch time if we can
date_iso=`date +%Y-%m-%d -d "@${source_date_epoch}" 2> /dev/null` || date_iso=`date +%Y-%m-%d` || exit $?
dnl echo date_iso=${date_iso}
test -z "${date_raw_rfc}" || date_rfc=`date -R -d "${date_raw_rfc}"` || exit $?
dnl echo date_rfc=${date_rfc}
AC_SUBST(date_iso)
AC_SUBST(date_rfc)
dnl date -R does not have an easy format string replacement and is unsupported in BSD. We don't need it right now, though.
dnl date_rfc=`date -R -d "@${source_date_epoch}"` || exit $?
dnl echo date_rfc=${date_rfc}
dnl AC_SUBST(date_rfc)
AC_ARG_VAR(CXXFLAGS,Flags passed to the C++ compiler)
AC_ARG_VAR(DEBUGLEVEL,[Debug level for developers, normal users can safely ignore it. Accepted values go from 0 to 5. See README-DEVELOPER for details.])
......
......@@ -350,6 +350,17 @@ apptar: apptar.tag
#***************************************************************
# Docker image building
build_docker.tag: rootcontext.64 ${srcdir}/../deploy/deploy_docker.sh CI_INFO
DOCKER_NODEPLOY="nodeploy" ${srcdir}/../deploy/deploy_docker.sh $<.dir/source
echo > $@
deploy_docker.tag: rootcontext.64 ${srcdir}/../deploy/deploy_docker.sh CI_INFO
${srcdir}/../deploy/deploy_docker.sh $<.dir/source
echo > $@
#***************************************************************
# AppImages with optional signing
context.appimage_%: upload/$(PACKAGE_NAME)-%-$(PACKAGE_VERSION).tbz context/version.sh ${srcdir}/context/appimage.sh gits.tag
${srcdir}/prepare_context.sh $@.dir ${srcdir}/context/appimage.sh $(GITS)/pkg2appimage
......
#!/bin/bash
# Builds sources at $1 into docker image, pushes it to repository
# only version-tags stable enough builds
# cwd needs to be the build directory
. ./context/version.sh || exit $?
. ../deploy/targets.sh || exit $?
# register at repository
set +x
if test x${CI_COMMIT_REF_PROTECTED} = xtrue && ! test -z "${CI_REGISTRY_PASSWORD}" && ! test -z "${CI_REGISTRY_USER}" && ! test -z "${CI_REGISTRY}"; then
echo ${CI_REGISTRY_PASSWORD} | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY} 2>&1 | grep -v WARNING\|credential || exit $?
else
CI_COMMIT_REF_PROTECTED=false
fi
if ${STAGING} == true; then
NAME=${PACKAGE_NAME}-staging
else
NAME=${PACKAGE_NAME}
fi
REGISTRY=${CI_REGISTRY_IMAGE:-registry.gitlab.com/armagetronad/armagetronad}
DI_TAG=${NAME}:${PACKAGE_VERSION}
CACHE=${REGISTRY}/cache:${PACKAGE_NAME}
BASE_CACHE=${REGISTRY}/cache:armagetronad
# tag a release; upload if we can
function tag()
{
docker tag ${DI_TAG} $1 || exit $?
if test x${CI_COMMIT_REF_PROTECTED} = xtrue; then
docker push $1 || exit $?
fi
}
# tag a cache; don't upload if we're deploying, there is nothing new to store then
function tag_cache()
{
docker tag ${DI_TAG} $1 || exit $?
if ! test -z "${DOCKER_NODEPLOY}" && test x${CI_COMMIT_REF_PROTECTED} = xtrue; then
docker push $1 || exit $?
fi
}
BUILDARGS="$1"
PAST_CACHE_ARGS=""
# build to target $1 using the repository-stored cache
function build_cached()
{
TARGET=$1
CACHE_ARGS="--cache-from ${CACHE}-${TARGET} \
--cache-from ${BASE_CACHE}-${TARGET}"
set -x
docker pull ${CACHE}-${TARGET} || \
docker pull ${BASE_CACHE}-${TARGET} || \
CACHE_ARGS=""
docker build --pull --target ${TARGET}\
-t ${DI_TAG} ${PAST_CACHE_ARGS} ${CACHE_ARGS} ${BUILDARGS} || exit $?
tag_cache ${CACHE}-${TARGET}
PAST_CACHE_ARGS="--cache-from ${CACHE}-${TARGET} ${PAST_CACHE_ARGS}"
}
build_cached build
build_cached runtime
# final build
docker build --pull \
-t ${DI_TAG} ${PAST_CACHE_ARGS} ${BUILDARGS} || exit $?
if test -z "${DOCKER_NODEPLOY}"; then
if test "${ZI_SERIES}" = "stable" || test "${ZI_SERIES}" = "rc"; then
tag ${REGISTRY}/${DI_TAG} || exit $?
fi
tag ${REGISTRY}/${NAME} || exit $?
fi
docker image rm ${DI_TAG} || exit $?
......@@ -24,83 +24,83 @@ test -z ${SERIES} && exit 1
test -z ${SUFFIX} && exit 1
case ${SERIES}+${SUFFIX}+@version@ in
CURRENT+armagetronad+*_rc_*)
CURRENT+armagetronad+*_rc_*)
SF_DIR="rc/${YEAR}"
LP_SERIES="${VERSION_SERIES}"
ZI_SERIES="rc"
STEAM_BRANCH="staging"
;;
CURRENT+armagetronad+*)
CURRENT+armagetronad+*)
SF_DIR="stable"
LP_SERIES="${VERSION_SERIES}"
ZI_SERIES="stable"
STEAM_BRANCH="staging"
;;
CURRENT+beta+*)
CURRENT+beta+*)
SF_DIR="beta/${YEAR}"
LP_SERIES="${VERSION_SERIES}-snapshots"
ZI_SERIES="beta"
STEAM_BRANCH="beta"
;;
CURRENT+alpha+*)
CURRENT+alpha+*)
SF_DIR="alpha/${YEAR}"
LP_SERIES=""
ZI_SERIES="alpha"
STEAM_BRANCH="alpha"
;;
CURRENT+*)
CURRENT+*)
SF_DIR="alpha/${YEAR}"
LP_SERIES=""
ZI_SERIES="alpha"
STEAM_BRANCH="alpha"
;;
LTS_028*+armagetronad+*_rc_*)
LTS_028*+armagetronad+*_rc_*)
SF_DIR="rc/${YEAR}"
LP_SERIES="0.2.8"
ZI_SERIES="rc"
STEAM_BRANCH=""
;;
LTS_028*+armagetronad+*)
LTS_028*+armagetronad+*)
SF_DIR="stable"
LP_SERIES="0.2.8"
ZI_SERIES="stable"
STEAM_BRANCH=""
;;
LTS_028*+alpha+*)
LTS_028*+alpha+*)
SF_DIR="alpha/${YEAR}"
LP_SERIES=""
ZI_SERIES="alpha"
STEAM_BRANCH=""
;;
LTS_028*+*)
LTS_028*+*)
SF_DIR="beta/${YEAR}"
LP_SERIES="0.2.8-snapshots"
ZI_SERIES="beta"
STEAM_BRANCH=""
;;
*+experimental|EXPERIMENTAL+*)
*+experimental|EXPERIMENTAL+*)
SF_DIR="snapshots/${YEAR}"
LP_SERIES=""
ZI_SERIES="experimental"
STEAM_BRANCH="experimental"
;;
HACK*)
HACK*)
SF_DIR="wip/${YEAR}"
LP_SERIES="hacks"
ZI_SERIES="hacks"
STEAM_BRANCH=""
;;
WIP*)
WIP*)
SF_DIR="wip/${YEAR}"
LP_SERIES=""
ZI_SERIES=""
STEAM_BRANCH=""
;;
*)
*)
SF_DIR="unknown/${YEAR}"
LP_SERIES=""
ZI_SERIES=""
......@@ -112,9 +112,9 @@ esac
# git identity
if which git > /dev/null && test -z "`git config --global user.name`"; then
git config --global user.email "z-man@users.sf.net"
git config --global user.name "Manuel Moos (From GitLab CI)"
git config --global push.default simple
git config --global user.email "z-man@users.sf.net"
git config --global user.name "Manuel Moos (From GitLab CI)"
git config --global push.default simple
fi
# **********************************************************************
......@@ -178,9 +178,9 @@ fi
# base directory for versioned uploads
if test ${STAGING} == true; then
UPLOAD_SCP_BASE=arma0install@builder.armagetronad.org:/home/arma0install/staging/
UPLOAD_SCP_BASE=arma0install@builder.armagetronad.org:/home/arma0install/staging/
else
UPLOAD_SCP_BASE=bazaaarmagetron,armagetronad@frs.sourceforge.net:/home/frs/project/a/ar/armagetronad/
UPLOAD_SCP_BASE=bazaaarmagetron,armagetronad@frs.sourceforge.net:/home/frs/project/a/ar/armagetronad/
fi
# destination for raw SCP/rsync uploads
......@@ -218,8 +218,8 @@ UPLOAD_ZI_SCP=arma0install@builder.armagetronad.org:/home/arma0install/0install/
#UPLOAD_ZI_SCP=arma0install@builder.armagetronad.org:/home/arma0install/0install-staging/
if test ${STAGING} == true; then
# download URI base to use for zeroinstall
DOWNLOAD_URI_BASE=http://download.armagetronad.org/staging/${SF_DIR}/@version@/
# download URI base to use for zeroinstall
DOWNLOAD_URI_BASE=http://download.armagetronad.org/staging/${SF_DIR}/@version@/
elif test "${SF_DIR}" == "stable"; then
# only stable builds go to launchpad permanently
DOWNLOAD_URI_BASE=https://launchpad.net/${LP_PROJECT}/${LP_SERIES}/${LP_VERSION}/+download/
......@@ -277,15 +277,17 @@ EOF
# Deployment requires net access, wait a bit for it to come online
for host in download.armagetronad.org builder.armagetronad.org 0install.armagetronad.org gitlab.com launchpad.net; do
timeout=5
while test ${timeout} -gt 0; do
if curl ${host} --fail --silent --show-error > /dev/null; then
timeout=0
else
echo "Waiting for network: ${timeout}"
sleep 5
timeout=$(( ${timeout} - 1 ))
fi
done
done
if curl -h 2>&1 > /dev/null; then
for host in download.armagetronad.org builder.armagetronad.org 0install.armagetronad.org gitlab.com launchpad.net; do
timeout=5
while test ${timeout} -gt 0; do