Improvements to the build system imported from other projects

This commit is contained in:
Héctor Molinero Fernández 2019-09-02 21:49:16 +02:00
parent 693468585b
commit bd84e60962
7 changed files with 56 additions and 55 deletions

4
.github/FUNDING.yml vendored
View File

@ -1,3 +1 @@
# These are supported funding model platforms custom: https://hector.molinero.dev/donate

custom: https://www.paypal.me/hectormf

View File

@ -1,38 +1,38 @@
image: docker:stable image: "docker.io/docker:stable"


services: services:
- docker:dind - "docker:dind"


stages: stages:
- build:images - "build:images"
- push:images - "push:images"


variables: variables:
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: "tcp://docker:2375"
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: "overlay2"


build:image: build:image:
stage: build:images stage: "build:images"
before_script: before_script:
- docker info - "docker info"
- apk add --no-cache coreutils git make xz - "apk add --no-cache coreutils git make xz"
script: script:
- make build-image save-image - "make build-image save-image"
artifacts: artifacts:
expire_in: 1 hour expire_in: "1 hour"
paths: paths:
- dist/ - "dist/"


push:image: push:image:
stage: push:images stage: "push:images"
before_script: before_script:
- apk add --no-cache coreutils git make xz - "apk add --no-cache coreutils git make xz"
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}" >/dev/null 2>&1 - "docker login -u \"${CI_REGISTRY_USER:?}\" -p \"${CI_REGISTRY_PASSWORD:?}\" \"${CI_REGISTRY:?}\" >/dev/null 2>&1"
script: script:
- make load-image push-image - "make load-image push-image"
only: only:
- /^v([0-9.]+)(-.+)?$/ - "/^v([0-9.]+)(-.+)?$/"
except: except:
- branches - "branches"
dependencies: dependencies:
- build:image - "build:image"

View File

@ -35,8 +35,8 @@ RUN mkdir -p /var/lib/qemu/images/ /var/lib/qemu/iso/
ARG REACTOS_ISO_URL=https://downloads.sourceforge.net/project/reactos/ReactOS/0.4.11/ReactOS-0.4.11-iso.zip ARG REACTOS_ISO_URL=https://downloads.sourceforge.net/project/reactos/ReactOS/0.4.11/ReactOS-0.4.11-iso.zip
ARG REACTOS_ISO_CHECKSUM=68120b3481c99c6b0563d5f3ec469ab197f2c8abc38d29adba4c40d01acd92c8 ARG REACTOS_ISO_CHECKSUM=68120b3481c99c6b0563d5f3ec469ab197f2c8abc38d29adba4c40d01acd92c8
RUN mkdir /tmp/reactos/ \ RUN mkdir /tmp/reactos/ \
&& curl -Lo /tmp/reactos/reactos.zip "${REACTOS_ISO_URL}" \ && curl -Lo /tmp/reactos/reactos.zip "${REACTOS_ISO_URL:?}" \
&& echo "${REACTOS_ISO_CHECKSUM} /tmp/reactos/reactos.zip" | sha256sum -c \ && echo "${REACTOS_ISO_CHECKSUM:?} /tmp/reactos/reactos.zip" | sha256sum -c \
&& unzip /tmp/reactos/reactos.zip -d /tmp/reactos/ \ && unzip /tmp/reactos/reactos.zip -d /tmp/reactos/ \
&& mv /tmp/reactos/*.iso /var/lib/qemu/iso/reactos.iso \ && mv /tmp/reactos/*.iso /var/lib/qemu/iso/reactos.iso \
&& rm -rf /tmp/reactos/ && rm -rf /tmp/reactos/
@ -53,4 +53,4 @@ EXPOSE 5900/tcp
## noVNC ## noVNC
EXPOSE 6080/tcp EXPOSE 6080/tcp


CMD ["/usr/local/bin/docker-foreground-cmd"] CMD ["/usr/local/bin/container-foreground-cmd"]

View File

@ -93,9 +93,9 @@ push-image:
version: version:
@if printf -- '%s' '$(IMAGE_VERSION)' | grep -q '^v[0-9]\{1,\}$$'; then \ @if printf -- '%s' '$(IMAGE_VERSION)' | grep -q '^v[0-9]\{1,\}$$'; then \
NEW_IMAGE_VERSION=$$(awk -v 'v=$(IMAGE_VERSION)' 'BEGIN {printf "v%.0f", substr(v,2)+1}'); \ NEW_IMAGE_VERSION=$$(awk -v 'v=$(IMAGE_VERSION)' 'BEGIN {printf "v%.0f", substr(v,2)+1}'); \
printf -- '%s\n' "$${NEW_IMAGE_VERSION}" > ./VERSION; \ printf -- '%s\n' "$${NEW_IMAGE_VERSION:?}" > '$(VERSION_FILE)'; \
'$(GIT)' add ./VERSION; '$(GIT)' commit -m "$${NEW_IMAGE_VERSION}"; \ '$(GIT)' add '$(VERSION_FILE)'; '$(GIT)' commit -m "$${NEW_IMAGE_VERSION:?}"; \
'$(GIT)' tag -a "$${NEW_IMAGE_VERSION}" -m "$${NEW_IMAGE_VERSION}"; \ '$(GIT)' tag -a "$${NEW_IMAGE_VERSION:?}" -m "$${NEW_IMAGE_VERSION:?}"; \
else \ else \
>&2 printf -- 'Malformed version string: %s\n' '$(IMAGE_VERSION)'; \ >&2 printf -- 'Malformed version string: %s\n' '$(IMAGE_VERSION)'; \
exit 1; \ exit 1; \

41
run.sh
View File

@ -3,42 +3,45 @@
set -eu set -eu
export LC_ALL=C export LC_ALL=C


DOCKER=$(command -v docker 2>/dev/null)

IMAGE_REGISTRY=docker.io
IMAGE_NAMESPACE=hectormolinero IMAGE_NAMESPACE=hectormolinero
IMAGE_PROJECT=qemu-reactos IMAGE_PROJECT=qemu-reactos
IMAGE_TAG=latest IMAGE_TAG=latest
IMAGE_NAME=${IMAGE_NAMESPACE}/${IMAGE_PROJECT}:${IMAGE_TAG} IMAGE_NAME=${IMAGE_REGISTRY:?}/${IMAGE_NAMESPACE:?}/${IMAGE_PROJECT:?}:${IMAGE_TAG:?}
CONTAINER_NAME=${IMAGE_PROJECT} CONTAINER_NAME=${IMAGE_PROJECT:?}


imageExists() { [ -n "$(docker images -q "$1")" ]; } imageExists() { [ -n "$("${DOCKER:?}" images -q "${1:?}")" ]; }
containerExists() { docker ps -aqf name="$1" --format '{{.Names}}' | grep -Fxq "$1"; } containerExists() { "${DOCKER:?}" ps -af name="${1:?}" --format '{{.Names}}' | grep -Fxq "${1:?}"; }
containerIsRunning() { docker ps -qf name="$1" --format '{{.Names}}' | grep -Fxq "$1"; } containerIsRunning() { "${DOCKER:?}" ps -f name="${1:?}" --format '{{.Names}}' | grep -Fxq "${1:?}"; }


if ! imageExists "${IMAGE_NAME}"; then if ! imageExists "${IMAGE_NAME:?}" && ! imageExists "${IMAGE_NAME#docker.io/}"; then
>&2 printf -- '%s\n' "\"${IMAGE_NAME}\" image doesn't exist!" >&2 printf -- '%s\n' "\"${IMAGE_NAME:?}\" image doesn't exist!"
exit 1 exit 1
fi fi


if containerIsRunning "${CONTAINER_NAME}"; then if containerIsRunning "${CONTAINER_NAME:?}"; then
printf -- '%s\n' "Stopping \"${CONTAINER_NAME}\" container..." printf -- '%s\n' "Stopping \"${CONTAINER_NAME:?}\" container..."
docker stop "${CONTAINER_NAME}" >/dev/null "${DOCKER:?}" stop "${CONTAINER_NAME:?}" >/dev/null
fi fi


if containerExists "${CONTAINER_NAME}"; then if containerExists "${CONTAINER_NAME:?}"; then
printf -- '%s\n' "Removing \"${CONTAINER_NAME}\" container..." printf -- '%s\n' "Removing \"${CONTAINER_NAME:?}\" container..."
docker rm "${CONTAINER_NAME}" >/dev/null "${DOCKER:?}" rm "${CONTAINER_NAME:?}" >/dev/null
fi fi


printf -- '%s\n' "Creating \"${CONTAINER_NAME}\" container..." printf -- '%s\n' "Creating \"${CONTAINER_NAME:?}\" container..."
docker run --detach \ "${DOCKER:?}" run --detach \
--name "${CONTAINER_NAME}" \ --name "${CONTAINER_NAME:?}" \
--hostname "${CONTAINER_NAME}" \ --hostname "${CONTAINER_NAME:?}" \
--restart on-failure:3 \ --restart on-failure:3 \
--log-opt max-size=32m \ --log-opt max-size=32m \
--publish '127.0.0.1:5900:5900/tcp' \ --publish '127.0.0.1:5900:5900/tcp' \
--publish '127.0.0.1:6080:6080/tcp' \ --publish '127.0.0.1:6080:6080/tcp' \
--publish '127.0.0.1:15900:15900/tcp' \ --publish '127.0.0.1:15900:15900/tcp' \
--privileged --env QEMU_KVM=true \ --privileged --env QEMU_KVM=true \
"${IMAGE_NAME}" "$@" >/dev/null "${IMAGE_NAME:?}" "$@" >/dev/null


printf -- '%s\n\n' 'Done!' printf -- '%s\n\n' 'Done!'
exec docker logs -f "${CONTAINER_NAME}" exec "${DOCKER:?}" logs -f "${CONTAINER_NAME:?}"

View File

@ -4,7 +4,7 @@ set -eu


# Create ReactOS disk # Create ReactOS disk
if [ ! -f /var/lib/qemu/images/reactos.img ]; then if [ ! -f /var/lib/qemu/images/reactos.img ]; then
qemu-img create -f "${QEMU_DISK_FORMAT}" /var/lib/qemu/images/reactos.img "${QEMU_DISK_SIZE}" qemu-img create -f "${QEMU_DISK_FORMAT:?}" /var/lib/qemu/images/reactos.img "${QEMU_DISK_SIZE:?}"
fi fi


# Start all services # Start all services

View File

@ -3,16 +3,16 @@
set -eu set -eu


QEMU=$(command -v qemu-system-x86_64) QEMU=$(command -v qemu-system-x86_64)
QEMU_ARGS="${QEMU_ARGS-} -smp ${QEMU_CPU} -m ${QEMU_RAM}" QEMU_ARGS="${QEMU_ARGS-} -smp ${QEMU_CPU:?} -m ${QEMU_RAM:?}"
QEMU_ARGS="${QEMU_ARGS-} -vga std -display vnc=:0" QEMU_ARGS="${QEMU_ARGS-} -vga std -display vnc=:0"
QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/images/reactos.img,index=0,media=disk,format=${QEMU_DISK_FORMAT}" QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/images/reactos.img,index=0,media=disk,format=${QEMU_DISK_FORMAT:?}"
QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/iso/reactos.iso,index=2,media=cdrom,format=raw" QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/iso/reactos.iso,index=2,media=cdrom,format=raw"
QEMU_ARGS="${QEMU_ARGS-} -boot order=${QEMU_BOOT_ORDER},menu=${QEMU_BOOT_MENU},splash-time=5000" QEMU_ARGS="${QEMU_ARGS-} -boot order=${QEMU_BOOT_ORDER:?},menu=${QEMU_BOOT_MENU:?},splash-time=5000"
QEMU_ARGS="${QEMU_ARGS-} -netdev user,id=n0,${QEMU_NET_OPTIONS} -device ${QEMU_NET_DEVICE},netdev=n0" QEMU_ARGS="${QEMU_ARGS-} -netdev user,id=n0,${QEMU_NET_OPTIONS:?} -device ${QEMU_NET_DEVICE:?},netdev=n0"
QEMU_ARGS="${QEMU_ARGS-} -usb -device usb-tablet" QEMU_ARGS="${QEMU_ARGS-} -usb -device usb-tablet"
QEMU_ARGS="${QEMU_ARGS-} -k ${QEMU_KEYBOARD}" QEMU_ARGS="${QEMU_ARGS-} -k ${QEMU_KEYBOARD:?}"
if [ "${QEMU_KVM}" = true ]; then QEMU_ARGS="${QEMU_ARGS-} -enable-kvm"; fi if [ "${QEMU_KVM:?}" = true ]; then QEMU_ARGS="${QEMU_ARGS-} -enable-kvm"; fi


cd ~/ cd ~/
exec 2>&1 exec 2>&1
exec "${QEMU}" ${QEMU_ARGS} exec "${QEMU:?}" ${QEMU_ARGS:?}