]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
Enable Travis CI, simplified Debian packaging (#318)
authorLadislav Slezák <lslezak@suse.cz>
Fri, 13 Jan 2017 08:36:01 +0000 (09:36 +0100)
committerGitHub <noreply@github.com>
Fri, 13 Jan 2017 08:36:01 +0000 (09:36 +0100)
* Travis support

* Simplify Debian packaging

* Update debian.changelog

* Build also on Ubuntu 16.10

* Travis docu fix, replace '**' in scripts

18 files changed:
.travis.debian.sh [new symlink]
.travis.fedora.sh [new file with mode: 0755]
.travis.leap.sh [new symlink]
.travis.tumbleweed.sh [new file with mode: 0755]
.travis.ubuntu.sh [new file with mode: 0755]
.travis.yml [new file with mode: 0644]
Dockerfile.debian [new file with mode: 0644]
Dockerfile.fedora [new file with mode: 0644]
Dockerfile.leap [new file with mode: 0644]
Dockerfile.tumbleweed [new file with mode: 0644]
Dockerfile.ubuntu [new file with mode: 0644]
Makefile.am
README.Travis.md [new file with mode: 0644]
README.md
debian/debian.changelog
debian/debian.compat [new file with mode: 0644]
debian/debian.rules
debian/debian.snapper.install

diff --git a/.travis.debian.sh b/.travis.debian.sh
new file mode 120000 (symlink)
index 0000000..5dd578c
--- /dev/null
@@ -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 (executable)
index 0000000..b27704f
--- /dev/null
@@ -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 (symlink)
index 0000000..f8ff96b
--- /dev/null
@@ -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 (executable)
index 0000000..464c673
--- /dev/null
@@ -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 (executable)
index 0000000..888e4a1
--- /dev/null
@@ -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 (file)
index 0000000..be5f7e3
--- /dev/null
@@ -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.<distro> file for building the image
+  - docker build -f Dockerfile.$BUILD_FLAVOR -t snapper-devel .
+
+script:
+  # run the respective .travis.<distro>.sh script
+  - docker run -it snapper-devel ./.travis.$BUILD_FLAVOR.sh
diff --git a/Dockerfile.debian b/Dockerfile.debian
new file mode 100644 (file)
index 0000000..69304b9
--- /dev/null
@@ -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 (file)
index 0000000..fa5b8de
--- /dev/null
@@ -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 (file)
index 0000000..062bd27
--- /dev/null
@@ -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 (file)
index 0000000..285a1d4
--- /dev/null
@@ -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 (file)
index 0000000..842979b
--- /dev/null
@@ -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
index f69c43b2843c3a8659ead07804234e08914ca117..f501a8a1d653477e7518511df269eedaf2c39282 100644 (file)
@@ -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 (file)
index 0000000..77b4799
--- /dev/null
@@ -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.
+
index e62da0d6f681c2c76623610e957a6e751f13d093..a08e91ee259b941f8d5861b6c46107872af974d6 100644 (file)
--- 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)).
 
index 87081cbe94519ce4e30aa1388a4163714c45e4fa..016beca021c2ac8423f2e28af10d72f131308f98 100644 (file)
@@ -1,3 +1,9 @@
+snapper (0.4.1-0) stable; urgency=low
+
+  * Updated to version 0.4.1
+
+ -- Arvin Schnell <aschnell@suse.com>  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 (file)
index 0000000..7f8f011
--- /dev/null
@@ -0,0 +1 @@
+7
index cf15d01b2b4e8c56234deb5962d3117e218aa37c..5fc245c14c7bd8552eeddad5333915454a30a85c 100644 (file)
@@ -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
index f957310bceb298fabcc216ec2899774daf162f61..0c58d85789f89b44d6dbb6bfef9ea8c5726dc24e 100644 (file)
@@ -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