build: rpm + deb targets, build-in-docker targets, CircleCI pipeline rewrite

Co-authored-by: Armin Wehrfritz <dkxls23@gmail.com>
This commit is contained in:
Christian Schwarz 2020-09-02 21:34:52 +02:00
parent 5b30ad01ce
commit 91e310b7e3
16 changed files with 573 additions and 151 deletions

View File

@ -1,83 +1,79 @@
version: 2.0
workflows:
version: 2
build:
jobs:
- build-1.11
- build-1.12
- build-1.13
- build-1.14
- build-latest
- test-build-in-docker
jobs:
version: 2.1
# build-latest serves as the template
# we use YAML anchors & aliases to exchange the docker image (and hence Go version used for the build)
build-latest: &build-latest
description: Builds zrepl
parameters:
image:
description: "the docker image that the job should use"
type: string
docker:
- image: circleci/golang:latest
environment:
# required by lazy.sh
TERM: xterm
working_directory: /go/src/github.com/zrepl/zrepl
commands:
setup-home-local-bin:
steps:
- run:
name: Setup environment variables
shell: /bin/bash -euo pipefail
command: |
# used by pip (for docs)
echo 'export PATH="$HOME/.local/bin:$PATH"' >> $BASH_ENV
# we use modules
echo 'export GO111MODULE=on' >> $BASH_ENV
- restore_cache:
keys:
- source
- protobuf
- checkout
- save_cache:
key: source
paths:
- ".git"
# install deps
- run: wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip
- run: echo "6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807 protoc-3.6.1-linux-x86_64.zip" | sha256sum -c
- run: sudo unzip -d /usr protoc-3.6.1-linux-x86_64.zip
- save_cache:
key: protobuf
paths:
- "/usr/include/google/protobuf"
- run: sudo apt update && sudo apt install python3 python3-pip libgirepository1.0-dev gawk
- run: ./lazy.sh devsetup
- run: make zrepl-bin
- run: make vet
- run:
shell: /bin/bash
command: |
needformat="$(make formatcheck)"
if [ -n "$needformat" ]; then
echo "$needformat"
exit 1
mkdir -p "$HOME/.local/bin"
line='export PATH="$HOME/.local/bin:$PATH"'
if grep "$line" $BASH_ENV >/dev/null; then
echo "$line" >> $BASH_ENV
fi
exit 0
- run: make lint
- run: make release
- run: make test-go
# cannot run test-platform because circle-ci runs in linux containers
- store_artifacts:
path: ./artifacts/release
when: always
invoke-lazy-sh:
parameters:
subcommand:
type: string
steps:
- run:
environment:
TERM: xterm
command: ./lazy.sh <<parameters.subcommand>>
apt-update-and-install-common-deps:
steps:
- run: sudo apt update && sudo apt install gawk make
restore-cache-gomod:
steps:
- restore_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
save-cache-gomod:
steps:
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
install-godep:
steps:
- apt-update-and-install-common-deps
- invoke-lazy-sh:
subcommand: godep
install-docdep:
steps:
- apt-update-and-install-common-deps
- run: sudo apt install python3 python3-pip libgirepository1.0-dev
- invoke-lazy-sh:
subcommand: docdep
download-and-install-minio-client:
steps:
- setup-home-local-bin
- restore_cache:
key: minio-client-v2
- run:
shell: /bin/bash -eo pipefail
command: |
if which mc; then exit 0; fi
sudo curl -sSL https://dl.min.io/client/mc/release/linux-amd64/archive/mc.RELEASE.2020-08-20T00-23-01Z \
-o "$HOME/.local/bin/mc"
sudo chmod +x "$HOME/.local/bin/mc"
- save_cache:
key: minio-client-v2
paths:
- "$HOME/.local/bin/mc"
upload-minio:
parameters:
src:
type: string
dst:
type: string
steps:
- run:
shell: /bin/bash -eo pipefail
when: always
@ -88,68 +84,210 @@ jobs:
fi
set -u # from now on
# Download and install minio
curl -sSL https://dl.minio.io/client/mc/release/linux-amd64/mc -o ${GOPATH}/bin/mc
chmod +x ${GOPATH}/bin/mc
mc config host add --api s3v4 zrepl-minio https://minio.cschwarz.com ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY}
# keep in sync with set-github-minio-status
jobprefix=zrepl-ci-artifacts/test/${CIRCLE_SHA1}/${CIRCLE_JOB}
# Upload artifacts
echo "$CIRCLE_BUILD_URL" > ./artifacts/release/cirlceci_build_url
mc cp -r artifacts/release "zrepl-minio/zrepl-ci-artifacts/${CIRCLE_SHA1}/${CIRCLE_JOB}/"
mkdir -p ./artifacts
mc cp -r <<parameters.src>> "zrepl-minio/$jobprefix/<<parameters.dst>>"
# Push Artifact Link to GitHub
REPO="zrepl/zrepl"
COMMIT="${CIRCLE_SHA1}"
JOB_NAME="${CIRCLE_JOB}"
curl "https://api.github.com/repos/$REPO/statuses/$COMMIT" \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_COMMIT_STATUS_TOKEN" \
-X POST \
-d '{"context":"zrepl/publish-ci-artifacts", "state": "success", "description":"CI Build Artifacts for '"$JOB_NAME"'", "target_url":"https://minio.cschwarz.com/minio/zrepl-ci-artifacts/'"$COMMIT"'/"}'
# kick off binary packaging workflow
set-github-minio-status:
parameters:
context:
type: string
description:
type: string
minio-dst:
type: string
steps:
- run:
shell: /bin/bash -eo pipefail
command: |
if [ -n "$CIRCLE_PR_NUMBER" ]; then # CIRCLE_PR_NUMBER is guaranteed to be only present in forked PRs (external)
echo "Forked PR detected. Sry, can't trust you with credentials."
echo "Forked PR detected. Sry, can't trust you with credentials to external artifact store, use CircleCI's instead."
exit 0
fi
set -u # from now on
GITHUB_ACCESS_TOKEN="$ZREPL_DEBIAN_BINARYPACKAGIN_TRIGGER_BUILD_GITHUB_TOKEN" .circleci/trigger_debian_binary_packaging_workflow.bash "$CIRCLE_SHA1" "${CIRCLE_JOB##build-}"
build-1.11:
<<: *build-latest
# keep in sync with with upload-minio command
jobprefix=zrepl-ci-artifacts/test/${CIRCLE_SHA1}/${CIRCLE_JOB}
# Push Artifact Link to GitHub
REPO="zrepl/zrepl"
COMMIT="${CIRCLE_SHA1}"
JOB_NAME="${CIRCLE_JOB}"
CONTEXT="<<parameters.context>>"
DESCRIPTION="<<parameters.description>>"
TARGETURL=https://minio.cschwarz.com/minio/"$jobprefix"/"<<parameters.minio-dst>>"
curl "https://api.github.com/repos/$REPO/statuses/$COMMIT" \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_COMMIT_STATUS_TOKEN" \
-X POST \
-d '{"context":"'"$CONTEXT"'", "state": "success", "description":"'"$DESCRIPTION"'", "target_url":"'"$TARGETURL"'"}'
workflows:
version: 2
build:
jobs:
- quickcheck-docs
- quickcheck-go: &quickcheck-go-smoketest
name: quickcheck-go-amd64-linux-1.15
goversion: &latest-go-release "1.15"
goos: linux
goarch: amd64
- test-go-on-latest-go-release:
goversion: *latest-go-release
- quickcheck-go:
requires:
- quickcheck-go-amd64-linux-1.15 #quickcheck-go-smoketest.name
matrix: &quickcheck-go-matrix
alias: quickcheck-go-matrix
parameters:
goversion: [*latest-go-release, "1.11"]
goos: ["linux", "freebsd"]
goarch: ["amd64", "arm64"]
exclude:
# don't re-do quickcheck-go-smoketest
- goversion: *latest-go-release
goos: linux
goarch: amd64
# not supported by Go 1.11
- goversion: "1.11"
goos: freebsd
goarch: arm64
- request-release-build:
type: approval
requires:
- quickcheck-docs
- quickcheck-go-amd64-linux-1.15 #quickcheck-go-smoketest.name
- quickcheck-go-matrix
- test-go-on-latest-go-release
- release-build:
requires:
- request-release-build
- release-deb:
requires:
- release-build
- release-rpm:
requires:
- release-build
- release-upload:
requires:
- release-build
- release-deb
- release-rpm
jobs:
quickcheck-docs:
docker:
- image: circleci/golang:1.11
build-1.12:
<<: *build-latest
docker:
- image: circleci/golang:1.12
build-1.13:
<<: *build-latest
docker:
- image: circleci/golang:1.13
build-1.14:
<<: *build-latest
docker:
- image: circleci/golang:1.14
# this job tests the build-in-docker instructions
# given in docs/installation/compile-from-source.rst
test-build-in-docker:
description: Check that build-in-docker works
machine:
image: default
- image: cimg/base:2020.08
steps:
- checkout
- run: docker build -t zrepl_build -f build.Dockerfile .
- run:
command: |
docker run -it --rm \
-v "${PWD}:/src" \
--user "$(id -u):$(id -g)" \
zrepl_build make release
- install-docdep
- run: make docs
quickcheck-go:
parameters:
goversion:
type: string
goos:
type: string
goarch:
type: string
docker:
- image: circleci/golang:<<parameters.goversion>>
environment:
GOOS: <<parameters.goos>>
GOARCH: <<parameters.goarch>>
steps:
- checkout
- restore-cache-gomod
- run: go mod download
- run: cd build && go mod download
- save-cache-gomod
- install-godep
- run: make formatcheck
- run: make generate-platform-test-list
- run: make zrepl-bin test-platform-bin
- run: make vet
- run: make lint
- download-and-install-minio-client
- run: rm -f artifacts/generate-platform-test-list
- store_artifacts:
path: artifacts
- upload-minio:
src: artifacts
dst: ""
- set-github-minio-status:
context: artifacts/${CIRCLE_JOB}
description: artifacts of CI job ${CIRCLE_JOB}
minio-dst: ""
test-go-on-latest-go-release:
parameters:
goversion:
type: string
docker:
- image: circleci/golang:<<parameters.goversion>>
steps:
- checkout
- restore-cache-gomod
- run: make test-go
# don't save-cache-gomod here, test-go doesn't pull all the dependencies
release-build:
machine: true
steps:
- checkout
- run: make release-docker
- persist_to_workspace:
root: .
paths: [.]
release-deb:
machine: true
steps:
- attach_workspace:
at: .
- run: make debs-docker
- persist_to_workspace:
root: .
paths:
- "artifacts/*.deb"
release-rpm:
machine: true
steps:
- attach_workspace:
at: .
- run: make rpms-docker
- persist_to_workspace:
root: .
paths:
- "artifacts/*.rpm"
release-upload:
docker:
- image: cimg/base:2020.08
steps:
- attach_workspace:
at: .
- store_artifacts:
path: artifacts
- download-and-install-minio-client
- upload-minio:
src: artifacts
dst: ""
- set-github-minio-status:
context: artifacts/release
description: CI-generated release artifacts
minio-dst: ""

View File

@ -57,6 +57,84 @@ ifeq (SIGN, 1)
endif
@echo "ZREPL RELEASE ARTIFACTS AVAILABLE IN artifacts/release"
release-docker:
docker build -t zrepl_release --pull -f build.Dockerfile .
docker run --rm -i -v $(CURDIR):/src -u $$(id -u):$$(id -g) \
zrepl_release \
make release GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM)
debs-docker:
$(MAKE) _debs_or_rpms_docker _DEB_OR_RPM=deb
rpms-docker:
$(MAKE) _debs_or_rpms_docker _DEB_OR_RPM=rpm
_debs_or_rpms_docker: # artifacts/_zrepl.zsh_completion artifacts/bash_completion docs zrepl-bin
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=amd64
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=arm64
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=arm GOARM=7
$(MAKE) $(_DEB_OR_RPM)-docker GOOS=linux GOARCH=386
rpm: $(ARTIFACTDIR) # artifacts/_zrepl.zsh_completion artifacts/bash_completion docs zrepl-bin
$(eval _ZREPL_RPM_VERSION := $(subst -,.,$(_ZREPL_VERSION)))
$(eval _ZREPL_RPM_TOPDIR_ABS := $(CURDIR)/$(ARTIFACTDIR)/rpmbuild)
rm -rf "$(_ZREPL_RPM_TOPDIR_ABS)"
mkdir "$(_ZREPL_RPM_TOPDIR_ABS)"
mkdir -p "$(_ZREPL_RPM_TOPDIR_ABS)"/{SPECS,RPMS,BUILD,BUILDROOT}
sed "s/^Version:.*/Version: $(_ZREPL_RPM_VERSION)/g" \
packaging/rpm/zrepl.spec > $(_ZREPL_RPM_TOPDIR_ABS)/SPECS/zrepl.spec
# see /usr/lib/rpm/platform
ifeq ($(GOARCH),amd64)
$(eval _ZREPL_RPMBUILD_TARGET := x86_64)
else ifeq ($(GOARCH), 386)
$(eval _ZREPL_RPMBUILD_TARGET := i386)
else ifeq ($(GOARCH), arm64)
$(eval _ZREPL_RPMBUILD_TARGET := aarch64)
else ifeq ($(GOARCH), arm)
$(eval _ZREPL_RPMBUILD_TARGET := armv7hl)
else
$(eval _ZREPL_RPMBUILD_TARGET := $(GOARCH))
endif
rpmbuild \
--build-in-place \
--define "_sourcedir $(CURDIR)" \
--define "_topdir $(_ZREPL_RPM_TOPDIR_ABS)" \
--define "_zrepl_binary_filename zrepl-$(ZREPL_TARGET_TUPLE)" \
--target $(_ZREPL_RPMBUILD_TARGET) \
-bb "$(_ZREPL_RPM_TOPDIR_ABS)"/SPECS/zrepl.spec
cp "$(_ZREPL_RPM_TOPDIR_ABS)"/RPMS/$(_ZREPL_RPMBUILD_TARGET)/zrepl-$(_ZREPL_RPM_VERSION)*.rpm $(ARTIFACTDIR)/
rpm-docker:
docker build -t zrepl_rpm_pkg --pull -f packaging/rpm/Dockerfile .
docker run --rm -i -v $(CURDIR):/build/src -u $$(id -u):$$(id -g) \
zrepl_rpm_pkg \
make rpm GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM)
deb: $(ARTIFACTDIR) # artifacts/_zrepl.zsh_completion artifacts/bash_completion docs zrepl-bin
cp packaging/deb/debian/changelog.template packaging/deb/debian/changelog
sed -i 's/DATE_DASH_R_OUTPUT/$(shell date -R)/' packaging/deb/debian/changelog
VERSION="$(subst -,.,$(_ZREPL_VERSION))"; \
export VERSION="$${VERSION#v}"; \
sed -i 's/VERSION/'"$$VERSION"'/' packaging/deb/debian/changelog
ifeq ($(GOARCH), arm)
$(eval DEB_HOST_ARCH := armhf)
else ifeq ($(GOARCH), 386)
$(eval DEB_HOST_ARCH := i386)
else
$(eval DEB_HOST_ARCH := $(GOARCH))
endif
export ZREPL_DPKG_ZREPL_BINARY_FILENAME=zrepl-$(ZREPL_TARGET_TUPLE); \
dpkg-buildpackage -b --no-sign --host-arch $(DEB_HOST_ARCH)
cp ../*.deb artifacts/
deb-docker:
docker build -t zrepl_debian_pkg --pull -f packaging/deb/Dockerfile .
docker run --rm -i -v $(CURDIR):/build/src -u $$(id -u):$$(id -g) \
zrepl_debian_pkg \
make deb GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM)
# expects `release` target to have run before
NOARCH_TARBALL := $(ARTIFACTDIR)/zrepl-noarch.tar
wrapup-and-checksum:

1
debian Symbolic link
View File

@ -0,0 +1 @@
packaging/deb/debian

View File

@ -14,6 +14,7 @@ Installation
installation/user-privileges
installation/packages
installation/apt-repos
installation/rpm-repos
installation/compile-from-source
installation/freebsd-jail-with-iocage
installation/what-next

View File

@ -7,7 +7,7 @@ Debian / Ubuntu APT repositories
We maintain APT repositories for Debian, Ubuntu and derivatives.
The fingerprint of the signing key is ``E101 418F D3D6 FBCB 9D65 A62D 7086 99FC 5F2E BF16``.
It is available at `<https://zrepl.cschwarz.com/apt/apt-key.asc>`_ .
Please open an issue `in the packaging repository <https://github.com/zrepl/debian-binary-packaging>`_ if you encounter any issues with the repository.
Please open an issue in on GitHub if you encounter any issues with the repository.
The following snippet configure the repository for your Debian or Ubuntu release:
@ -24,6 +24,6 @@ The following snippet configure the repository for your Debian or Ubuntu release
.. NOTE::
Until zrepl reaches 1.0, all APT repositories will be updated to the latest zrepl release immediately.
Until zrepl reaches 1.0, the repositories will be updated to the latest zrepl release immediately.
This includes breaking changes between zrepl versions.
Use ``apt-mark hold zrepl`` to prevent upgrades of zrepl.

View File

@ -30,15 +30,12 @@ The following list may be incomplete, feel free to submit a PR with an update:
* - Arch Linux
- ``yay install zrepl``
- Available on `AUR <https://aur.archlinux.org/packages/zrepl>`_
* - Fedora
* - Fedora, CentOS, RHEL, OpenSUSE
- ``dnf install zrepl``
- Available on `COPR <https://copr.fedorainfracloud.org/coprs/poettlerric/zrepl/>`_
* - CentOS/RHEL
- ``yum install zrepl``
- Available on `COPR <https://copr.fedorainfracloud.org/coprs/poettlerric/zrepl/>`_
- :ref:`RPM repository config <installation-rpm-repos>`
* - Debian + Ubuntu
- ``apt install zrepl``
- APT repository config :ref:`see below <installation-apt-repos>`
- :ref:`APT repository config <installation-apt-repos>`
* - OmniOS
- ``pkg install zrepl``
- Available since `r151030 <https://pkg.omniosce.org/r151030/extra/en/search.shtml?token=zrepl&action=Search>`_

View File

@ -0,0 +1,31 @@
.. _installation-rpm-repos:
RPM repositories
~~~~~~~~~~~~~~~~
We provide a single RPM repository for all RPM-based Linux distros.
The zrepl binary in the repo is the same as the one published to GitHub.
Since Go binaries are statically linked, the RPM should work about everywhere.
The fingerprint of the signing key is ``F6F6 E8EA 6F2F 1462 2878 B5DE 50E3 4417 826E 2CE6``.
It is available at `<https://zrepl.cschwarz.com/rpm/rpm-key.asc>`_ .
Please open an issue on GitHub if you encounter any issues with the repository.
Copy-paste the following snippet into your shell to set up the zrepl repository.
Then ``dnf install zrepl`` and make sure to confirm that the signing key matches the one shown above.
.. literalinclude:: ../../packaging/rpm/zrepl.repo
::
cat > /etc/yum.repos.d/zrepl.repo <<EOF
[zrepl]
name = zrepl
baseurl = https://zrepl.cschwarz.com/rpm/repo
gpgkey = https://zrepl.cschwarz.com/rpm/rpm-key.asc
EOF
.. NOTE::
Until zrepl reaches 1.0, the repository will be updated to the latest zrepl release immediately.
This includes breaking changes between zrepl versions.
If that bothers you, use the `dnf versionlock plugin <https://dnf-plugins-core.readthedocs.io/en/latest/versionlock.html>`_ to pin the version of zrepl on your system.

37
lazy.sh
View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
@ -14,26 +14,31 @@ step() {
echo "${bold}$1${normal}"
}
if ! type go >/dev/null; then
step "go binary not installed or not in \$PATH" 1>&2
exit 1
fi
if [ -z "$GOPATH" ]; then
step "Your GOPATH is not configured correctly" 1>&2
exit 1
fi
if ! (echo "$PATH" | grep "${GOPATH}/bin" > /dev/null); then
step "GOPATH/bin is not in your PATH (it should be towards the start of it)"
exit 1
fi
godep() {
step "install build dependencies (versions pinned in build/go.mod and build/tools.go)"
if ! type go >/dev/null; then
step "go binary not installed or not in \$PATH" 1>&2
exit 1
fi
if [ -z "$GOPATH" ]; then
step "Your GOPATH is not configured correctly" 1>&2
exit 1
fi
if ! (echo "$PATH" | grep "${GOPATH}/bin" > /dev/null); then
step "GOPATH/bin is not in your PATH (it should be towards the start of it)"
exit 1
fi
pushd "$(dirname "${BASH_SOURCE[0]}")"/build
set -x
export GO111MODULE=on # otherwise, a checkout of this repo in GOPATH will disable modules on Go 1.12 and earlier
source <(go env)
export GOOS="$GOHOSTOS"
export GOARCH="$GOHOSTARCH"
# TODO GOARM=$GOHOSTARM?
go build -v -mod=readonly -o "$GOPATH/bin/stringer" golang.org/x/tools/cmd/stringer
go build -v -mod=readonly -o "$GOPATH/bin/protoc-gen-go" github.com/golang/protobuf/protoc-gen-go
go build -v -mod=readonly -o "$GOPATH/bin/enumer" github.com/alvaroloes/enumer

11
packaging/deb/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM debian:latest
RUN apt-get update && apt-get install -y \
build-essential \
devscripts \
dh-exec
RUN mkdir -p /build/src && chmod -R 0777 /build
WORKDIR /build/src

View File

@ -0,0 +1,5 @@
zrepl (VERSION) unstable;
Check https://zrepl.github.io/changelog.html.
-- zrepl build process <me@cschwarz.com> DATE_DASH_R_OUTPUT

View File

@ -0,0 +1 @@
11

View File

@ -0,0 +1,8 @@
Source: zrepl
Maintainer: Christian Schwarz <me@cschwarz.com>
Build-Depends: dh-exec
Package: zrepl
Architecture: arm64 amd64 armhf i386
Description: ZFS replication
zrepl is a one-stop solution for ZFS filesystem replication

50
packaging/deb/debian/rules Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/make -f
%:
dh $@
override_dh_strip:
override_dh_auto_build:
override_dh_auto_clean:
rm -rf debian/renamedir
override_dh_auto_install:
# install the zrepl.service for
# dh_install_systemd and dh_systemd_{start,enable}
install dist/systemd/zrepl.service debian/zrepl.service
sed -i 's#ExecStart=/usr/local/bin/zrepl #ExecStart=/usr/bin/zrepl #' debian/zrepl.service
sed -i 's#ExecStartPre=/usr/local/bin/zrepl #ExecStartPre=/usr/bin/zrepl #' debian/zrepl.service
mkdir -p debian/renamedir
# install binary
stat artifacts/$(ZREPL_DPKG_ZREPL_BINARY_FILENAME)
cp --preserve=all artifacts/$(ZREPL_DPKG_ZREPL_BINARY_FILENAME) debian/renamedir/zrepl
dh_install debian/renamedir/zrepl usr/bin
# install bash completion
dh_install artifacts/bash_completion etc/bash_completion.d/zrepl
dh_install artifacts/_zrepl.zsh_completion usr/share/zsh/vendor-completions
# install docs
dh_install artifacts/docs/html usr/share/doc/zrepl/docs/
# install examples
dh_install config/samples/* usr/share/doc/zrepl/examples
# install default config
mkdir -p debian/tmp/etc/zrepl
chmod 0700 debian/tmp/etc/zrepl
sed 's#USR_SHARE_ZREPL#/usr/share/doc/zrepl#' packaging/systemd-default-zrepl.yml > debian/renamedir/zrepl.yml
dh_install debian/renamedir/zrepl.yml etc/zrepl
# save git revision of this packaging repo
echo $$(git rev-parse HEAD) > debian/packaging-repo-git-revision
dh_install debian/packaging-repo-git-revision usr/share/doc/zrepl
override_dh_auto_test:
# don't run tests at this point

7
packaging/rpm/Dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM fedora:latest
RUN dnf install -y git make bash rpm-build 'dnf-command(builddep)'
ADD packaging/rpm/zrepl.spec /tmp/zrepl.spec
RUN dnf builddep -y /tmp/zrepl.spec
RUN mkdir -p /build/src && chmod -R 0777 /build
WORKDIR /build/src

76
packaging/rpm/zrepl.spec Normal file
View File

@ -0,0 +1,76 @@
# This Spec file packages pre-built artifacts in the artifacts directory
# into an RPM. This means that rpmbuild won't actually build any new artifacts
#
# Read the Makefile first, then come back here.
# Global meta data
Version: SUBSTITUTED_BY_MAKEFILE
%global common_description %{expand:
zrepl is a one-stop, integrated solution for ZFS replication.}
# use gzip to be compatible with centos7
%define _source_payload w9.gzdio
%define _binary_payload w9.gzdio
Name: zrepl
Release: 1
Summary: One-stop, integrated solution for ZFS replication
License: MIT
URL: https://zrepl.github.io/
# Source: we use rpmbuild --build-in-tree => no source
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%description
%{common_description}
%prep
# we use rpmbuild --build-in-tree => no prep or setup
%build
# we don't actually need to build anything here, that has already been done by the Makefile
# Correct the path in the systemd unit file
sed s:/usr/local/bin/:%{_bindir}/:g dist/systemd/zrepl.service > artifacts/rpmbuild/zrepl.service
# Generate the default configuration file
sed 's#USR_SHARE_ZREPL#%{_datadir}/doc/zrepl#' packaging/systemd-default-zrepl.yml > artifacts/rpmbuild/zrepl.yml
%install
install -Dm 0755 artifacts/%{_zrepl_binary_filename} %{buildroot}%{_bindir}/zrepl
install -Dm 0644 artifacts/rpmbuild/zrepl.service %{buildroot}%{_unitdir}/zrepl.service
install -Dm 0644 artifacts/_zrepl.zsh_completion %{buildroot}%{_datadir}/zsh/site-functions/_zrepl
install -Dm 0644 artifacts/bash_completion %{buildroot}%{_datadir}/bash-completion/completions/zrepl
install -Dm 0644 artifacts/rpmbuild/zrepl.yml %{buildroot}%{_sysconfdir}/zrepl/zrepl.yml
install -d %{buildroot}%{_datadir}/doc/zrepl
cp -a artifacts/docs/html %{buildroot}%{_datadir}/doc/zrepl/html
cp -a config/samples %{buildroot}%{_datadir}/doc/zrepl/examples
%post
%systemd_post zrepl.service
%preun
%systemd_preun zrepl.service
%postun
%systemd_postun_with_restart zrepl.service
%files
%defattr(-,root,root)
%license LICENSE
%{_bindir}/zrepl
%config %{_unitdir}/zrepl.service
%dir %{_sysconfdir}/zrepl
%config %{_sysconfdir}/zrepl/zrepl.yml
%{_datadir}/zsh/site-functions/_zrepl
%{_datadir}/bash-completion/completions/zrepl
%{_datadir}/doc/zrepl
%changelog
# TODO: auto-fill changelog from git? -> need same solution for debian

View File

@ -0,0 +1,13 @@
global:
logging:
# use syslog instead of stdout because it makes journald happy
- type: syslog
format: human
level: warn
jobs:
# - name: foo
# type: bar
# see USR_SHARE_ZREPL/examples
# or https://zrepl.github.io/configuration/overview.html