From: Ladislav Slezák Date: Fri, 13 Jan 2017 08:36:01 +0000 (+0100) Subject: Enable Travis CI, simplified Debian packaging (#318) X-Git-Tag: v0.5.0~13 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=fcdb8f8f2fceef92e0ac0b76d211f17fe7c46f84;p=thirdparty%2Fsnapper.git Enable Travis CI, simplified Debian packaging (#318) * Travis support * Simplify Debian packaging * Update debian.changelog * Build also on Ubuntu 16.10 * Travis docu fix, replace '**' in scripts --- diff --git a/.travis.debian.sh b/.travis.debian.sh new file mode 120000 index 00000000..5dd578c3 --- /dev/null +++ b/.travis.debian.sh @@ -0,0 +1 @@ +.travis.ubuntu.sh \ No newline at end of file diff --git a/.travis.fedora.sh b/.travis.fedora.sh new file mode 100755 index 00000000..b27704f5 --- /dev/null +++ b/.travis.fedora.sh @@ -0,0 +1,25 @@ +#! /bin/bash + +set -e -x + +make -f Makefile.repo +make package + +# Build the binary package locally, use plain "rpmbuild" to make it simple. +# "osc build" is too resource hungry (builds a complete chroot from scratch). +# Moreover it does not work in a Docker container (it fails when trying to mount +# /proc and /sys in the chroot). +mkdir -p /root/rpmbuild/SOURCES +cp package/* /root/rpmbuild/SOURCES +rpmbuild -bb -D "fedora_version 25" -D "jobs `nproc`" package/*.spec + +# test the %pre/%post scripts by installing/updating/removing the built packages +# ignore the dependencies to make the test easier, as a smoke test it's good enough +rpm -iv --force --nodeps /root/rpmbuild/RPMS/*/*.rpm + +# smoke test, make sure snapper at least starts +snapper --version + +rpm -Uv --force --nodeps /root/rpmbuild/RPMS/*/*.rpm +# get the plain package names and remove all packages at once +rpm -ev --nodeps `rpm -q --qf '%{NAME} ' -p /root/rpmbuild/RPMS/**/*.rpm` diff --git a/.travis.leap.sh b/.travis.leap.sh new file mode 120000 index 00000000..f8ff96b9 --- /dev/null +++ b/.travis.leap.sh @@ -0,0 +1 @@ +.travis.tumbleweed.sh \ No newline at end of file diff --git a/.travis.tumbleweed.sh b/.travis.tumbleweed.sh new file mode 100755 index 00000000..464c6731 --- /dev/null +++ b/.travis.tumbleweed.sh @@ -0,0 +1,24 @@ +#! /bin/bash + +set -e -x + +make -f Makefile.repo +make package + +# Build the binary package locally, use plain "rpmbuild" to make it simple. +# "osc build" is too resource hungry (builds a complete chroot from scratch). +# Moreover it does not work in a Docker container (it fails when trying to mount +# /proc and /sys in the chroot). +cp package/* /usr/src/packages/SOURCES/ +rpmbuild -bb -D "jobs `nproc`" package/*.spec + +# test the %pre/%post scripts by installing/updating/removing the built packages +# ignore the dependencies to make the test easier, as a smoke test it's good enough +rpm -iv --force --nodeps /usr/src/packages/RPMS/*/*.rpm + +# smoke test, make sure snapper at least starts +snapper --version + +rpm -Uv --force --nodeps /usr/src/packages/RPMS/*/*.rpm +# get the plain package names and remove all packages at once +rpm -ev --nodeps `rpm -q --qf '%{NAME} ' -p /usr/src/packages/RPMS/**/*.rpm` diff --git a/.travis.ubuntu.sh b/.travis.ubuntu.sh new file mode 100755 index 00000000..888e4a14 --- /dev/null +++ b/.travis.ubuntu.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +set -e -x + +make -f Makefile.repo + +# convert the OBS Debian files to the native Debian files +(cd debian && rename 's/^debian\.//' debian.*) + +# build binary packages +dpkg-buildpackage -j`nproc` -rfakeroot -b + +# install the built packages +dpkg -i ../*.deb + +# smoke test, make sure snapper at least starts +snapper --version + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..be5f7e39 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +sudo: required +language: bash +services: + - docker + +# define the build matrix +env: + - BUILD_FLAVOR=tumbleweed + - BUILD_FLAVOR=leap + - BUILD_FLAVOR=fedora + - BUILD_FLAVOR=ubuntu + - BUILD_FLAVOR=debian + +before_install: + # use the Dockerfile. file for building the image + - docker build -f Dockerfile.$BUILD_FLAVOR -t snapper-devel . + +script: + # run the respective .travis..sh script + - docker run -it snapper-devel ./.travis.$BUILD_FLAVOR.sh diff --git a/Dockerfile.debian b/Dockerfile.debian new file mode 100644 index 00000000..69304b92 --- /dev/null +++ b/Dockerfile.debian @@ -0,0 +1,33 @@ +# Build Debian 8 image +FROM debian:8 + +# see https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/run +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + acl-dev \ + autoconf \ + automake \ + build-essential \ + debhelper \ + devscripts \ + docbook-xsl \ + fakeroot \ + g++ \ + gettext \ + libboost-dev \ + libboost-system-dev \ + libboost-test-dev \ + libboost-thread-dev \ + libdbus-1-dev \ + libmount-dev \ + libpam-dev \ + libtool \ + libxml2-dev \ + libz-dev \ + locales-all \ + xsltproc + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY . /usr/src/app diff --git a/Dockerfile.fedora b/Dockerfile.fedora new file mode 100644 index 00000000..fa5b8dea --- /dev/null +++ b/Dockerfile.fedora @@ -0,0 +1,28 @@ +# Build Fedora 25 image +FROM fedora:25 + +RUN dnf -y install \ + autoconf \ + automake \ + boost-devel \ + dbus-devel \ + docbook-style-xsl \ + e2fsprogs-devel \ + gcc-c++ \ + gettext \ + glibc-langpack-de \ + glibc-langpack-en \ + libacl-devel \ + libmount-devel \ + libtool \ + libxml2-devel \ + libxslt \ + make \ + pam-devel \ + pkgconfig \ + rpm-build + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY . /usr/src/app diff --git a/Dockerfile.leap b/Dockerfile.leap new file mode 100644 index 00000000..062bd275 --- /dev/null +++ b/Dockerfile.leap @@ -0,0 +1,26 @@ +# Build the latest openSUSE Leap (42.x) image +FROM opensuse:leap + +RUN zypper --non-interactive in --no-recommends \ + autoconf \ + automake \ + boost-devel \ + dbus-1-devel \ + docbook-xsl-stylesheets \ + e2fsprogs-devel \ + gcc-c++ \ + grep \ + libacl-devel \ + libbtrfs-devel \ + libmount-devel \ + libtool \ + libxml2-devel \ + libxslt \ + pam-devel \ + rpm-build \ + which + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY . /usr/src/app diff --git a/Dockerfile.tumbleweed b/Dockerfile.tumbleweed new file mode 100644 index 00000000..285a1d4d --- /dev/null +++ b/Dockerfile.tumbleweed @@ -0,0 +1,26 @@ +# Build the latest openSUSE Tumbleweed image +FROM opensuse:tumbleweed + +RUN zypper --non-interactive in --no-recommends \ + autoconf \ + automake \ + boost-devel \ + dbus-1-devel \ + docbook-xsl-stylesheets \ + e2fsprogs-devel \ + gcc-c++ \ + grep \ + libacl-devel \ + libbtrfs-devel \ + libmount-devel \ + libtool \ + libxml2-devel \ + libxslt \ + pam-devel \ + rpm-build \ + which + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY . /usr/src/app diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu new file mode 100644 index 00000000..842979b7 --- /dev/null +++ b/Dockerfile.ubuntu @@ -0,0 +1,34 @@ +# Build Ubuntu 16.10 image +FROM ubuntu:16.10 + +# see https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/run +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + acl-dev \ + autoconf \ + automake \ + build-essential \ + debhelper \ + devscripts \ + docbook-xsl \ + fakeroot \ + g++ \ + gettext \ + language-pack-de \ + language-pack-en \ + libboost-dev \ + libboost-system-dev \ + libboost-test-dev \ + libboost-thread-dev \ + libdbus-1-dev \ + libmount-dev \ + libpam-dev \ + libtool \ + libxml2-dev \ + libz-dev \ + xsltproc + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app + +COPY . /usr/src/app diff --git a/Makefile.am b/Makefile.am index f69c43b2..f501a8a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,8 @@ UBUNTU_FLAVOURS = \ xUbuntu_14.10 \ xUbuntu_15.04 \ xUbuntu_15.10 \ - xUbuntu_16.04 + xUbuntu_16.04 \ + xUbuntu_16.10 show-debian: @echo "Debian flavors: $(DEBIAN_FLAVOURS)" diff --git a/README.Travis.md b/README.Travis.md new file mode 100644 index 00000000..77b47998 --- /dev/null +++ b/README.Travis.md @@ -0,0 +1,31 @@ +# Travis CI + +By default Travis uses Ubuntu 14.04 LTS for building, but it is possible to run +the build in any Linux distribution using [Docker](https://www.docker.com/). + +## Setup + +For each target distribution there is a `Dockerfile` and the respective +`.travis.sh` script. The `Dockerfile` defines the steps needed for building +the Docker image, the script runs the build in the specific distribution. + +The `.travis.yml` file defines the build matrix which runs builds for all +configured distributions in parallel. It is defined in the `env` section, +see more details in the [Travis documentation]( +https://docs.travis-ci.com/user/customizing-the-build#Build-Matrix). + +## Running the Build Locally + +- [Install and start Docker](https://docs.docker.com/engine/installation/linux/) +- Run (as `root`) the same commands as in the `.travis.yml` file, that means: +- First build the docker image locally, e.g. `docker build -f + Dockerfile.tumbleweed -t snapper-devel .`, the Docker image automatically + includes also the copy of the current Snapper sources. +- Then run the build: `docker run -it --rm snapper-devel ./.travis.tumbleweed.sh` + (The `--rm` will cleanup the new Docker image layer created by the build, + if you want to inspect the build artifacts then remove it.) +- If you need to debug a failure then run `bash` instead of the Travis script + and run the build steps manually. If you need an editor or some other tool + you can install them via the respective packaging tool, see the `Dockerfile` + for examples. + diff --git a/README.md b/README.md index e62da0d6..a08e91ee 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Snapper ======= +[![Build Status](https://travis-ci.org/openSUSE/snapper.svg?branch=master)](https://travis-ci.org/openSUSE/snapper) + Snapper is a tool for Linux file system snapshot management. Apart from the obvious creation and deletion of snapshots it can compare snapshots and revert differences between them. In simple terms, this allows root and @@ -31,6 +33,9 @@ sudo zypper install git libmount-devel dbus-1-devel libacl-devel \ docbook-xsl-stylesheets libxml2-devel libbtrfs-devel ``` +Alternatively you can use a [Docker](https://www.docker.com/) container, +see [REAME.Travis.md](REAME.Travis.md) file for some hints. + ### Building Snapper You can download the sources and build Snapper by using these commands: @@ -68,7 +73,8 @@ destroy your data! Run these tests only in a testing environment!* ### Releasing - Before releasing the Snapper package ensure that the changes made to the package -are mentioned in the `package/snapper.changes` file. +are mentioned in the `package/snapper.changes` file, update also the +`debian/debian.changelog` file. - Make sure the units tests still passes ([see above](#running-tests)). diff --git a/debian/debian.changelog b/debian/debian.changelog index 87081cbe..016beca0 100644 --- a/debian/debian.changelog +++ b/debian/debian.changelog @@ -1,3 +1,9 @@ +snapper (0.4.1-0) stable; urgency=low + + * Updated to version 0.4.1 + + -- Arvin Schnell Wed, 21 Dec 2016 11:26:28 +0100 + snapper (0.3.3-0) stable; urgency=low * Updated to version 0.3.3 diff --git a/debian/debian.compat b/debian/debian.compat new file mode 100644 index 00000000..7f8f011e --- /dev/null +++ b/debian/debian.compat @@ -0,0 +1 @@ +7 diff --git a/debian/debian.rules b/debian/debian.rules index cf15d01b..5fc245c1 100644 --- a/debian/debian.rules +++ b/debian/debian.rules @@ -3,9 +3,6 @@ # Turn on verbose mode. export DH_VERBOSE=1 -# Set debhelper compatibility version. -export DH_COMPAT=5 - CFLAGS = -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 -Wall @@ -13,59 +10,14 @@ else CFLAGS += -O2 -Wall endif -build: build-stamp -build-stamp: - dh_testdir - - ./configure --docdir=/usr/share/doc/packages/snapper --disable-silent-rules \ - --disable-ext4 --enable-xattrs --disable-rollback --disable-btrfs-quota - make - - make check - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - - make clean || true - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - make install DESTDIR=/usr/src/packages/BUILD/debian/tmp - install -D -m 644 data/sysconfig.snapper /usr/src/packages/BUILD/debian/tmp/etc/sysconfig/snapper - -# Build architecture-independent files here. -binary-indep: build install - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - - mv debian/tmp/etc/cron.hourly/suse.de-snapper debian/tmp/etc/cron.hourly/snapper - mv debian/tmp/etc/cron.daily/suse.de-snapper debian/tmp/etc/cron.daily/snapper +# allow parallel builds +%: + dh $@ --parallel - dh_install --sourcedir=debian/tmp - dh_installman - dh_installchangelogs - dh_strip - dh_compress - dh_fixperms - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb +override_dh_auto_configure: + dh_auto_configure -- --docdir=/usr/share/doc/packages/snapper --disable-silent-rules \ + --disable-ext4 --enable-xattrs --disable-rollback --disable-btrfs-quota -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install +override_dh_auto_install: + dh_auto_install + install -D -m 644 data/sysconfig.snapper $$(pwd)/debian/tmp/etc/sysconfig/snapper diff --git a/debian/debian.snapper.install b/debian/debian.snapper.install index f957310b..0c58d857 100644 --- a/debian/debian.snapper.install +++ b/debian/debian.snapper.install @@ -1,5 +1,5 @@ -etc/cron.daily/snapper -etc/cron.hourly/snapper +etc/cron.daily/suse.de-snapper etc/cron.daily/snapper +etc/cron.hourly/suse.de-snapper etc/cron.hourly/snapper etc/dbus-1/system.d/org.opensuse.Snapper.conf etc/logrotate.d/snapper usr/bin/snapper