Permalink
Browse files

chore: test Fedora packaging CI via Travis job

closes #578
  • Loading branch information...
praiskup authored and vlsi committed Jun 1, 2016
1 parent 7388dc9 commit 1eb4085c2425e4d6b6fc74c3e2a6b527eb9ff927
@@ -14,6 +14,7 @@ env:
global:
- secure: "3HRd+UJQzXoxmBAiJ8SLFuYK8NvMVgIs0erfcPdgvtfFGTPkH3XMONfNr2VE2uz6qwUB5GWkVzvS4c9CPbnnft9QhyYeeUINiqQMN5+6AN5re3C2D7VQMm3NSB+T2R6zS/18UZW5tIoTJILgl5oRCQFI7RSpqhvZ8nqPxJ4gptI="
- secure: "VrNgbyKQi5HjSMZfkt/zwG+AHk1NW1b+f3Jo1ZH7DCqcgLApwvp4MNsw+XamqHxudjj3Z8+4bYBxG2H6zIOobIyYhBvxUwMq7HTjM4jH8m5phqvQIWZOzZzqguYNNS7JJQUpIMwR7wTuHqucVfMxljoSuXQbs+0BUxo4Eh+FScQ="
- secure: "NI+aqwRLLVt2feJdk/2ZEZnsaPyu+vOx8MahVxjz0UUVvRHVqxM5O1M0R53NJfEeIjflOzgZJwRLqgyl6dkdfjytRhaHWGptQdehV4cwNb+4epnn8WlpRzMac65zTQqnbGVtw9jissDQv6/Zl/+D+DMcU65BbFZkix40whILXG0="
script:
# make sure previous build artifacts are not used for subsequent builds
@@ -44,6 +45,10 @@ cache:
matrix:
fast_finish: true
include:
- env:
- FEDORA_CI=Y
services:
- docker
- jdk: oraclejdk8
sudo: required
dist: trusty
@@ -74,6 +74,11 @@ Snapshot builds (builds from `master` branch) are deployed to Maven Central, so
</dependency>
```
There are also available (snapshot) binary RPMs in Fedora's Copr repository, you
can download them from:
https://copr.fedorainfracloud.org/coprs/g/pgjdbc/pgjdbc-travis/
## Build requirements
In order to build the source code for PgJDBC you will need the following tools:
@@ -196,6 +201,9 @@ Git repository typically contains -SNAPSHOT versions, so you can use the followi
Prerequisites:
- JDK 6, JDK 7, and JDK8 configured in `~/.m2/toolchains.xml`
- a PostgreSQL instance for running tests
- ensure that the RPM packaging CI isn't failing at
[copr web page](https://copr.fedorainfracloud.org/coprs/g/pgjdbc/pgjdbc-travis/builds/) -
possibly bump `parent poms` or `pgjdbc` versions in RPM [spec file](packaging/rpm/postgresql-jdbc.spec).
Procedure:
@@ -0,0 +1,5 @@
*.tar.gz
*.src.rpm
*.spec
copr-token
copr_build_id
@@ -0,0 +1,9 @@
git:
address: 'https://github.com/pgjdbc/pgjdbc.git'
rpmsources: packaging/rpm
spec: postgresql-jdbc.spec
source0:
git_archive:
prefix: postgresql-jdbc-9.5.git
Binary file not shown.
@@ -0,0 +1,21 @@
FROM index.docker.io/fedora:23
MAINTAINER pgjdbc team
ENV HOME=/rpm
ENV container="docker"
RUN dnf -y --setopt=tsflags=nodocs install \
copr-cli \
git \
perl \
perl-YAML \
rpm-build \
rpmdevtools \
&& dnf -y --setopt=tsflags=nodocs clean all --enablerepo='*' \
&& dnf -y update copr-cli python-copr --enablerepo updates-testing
ADD build_local copr-ci-git srpmgen /usr/bin/
WORKDIR /rpm
CMD ["bash"]
@@ -0,0 +1,43 @@
#!/bin/bash
test -z "$RPMBUILD" && RPMBUILD=rpmbuild
ARR=( )
for i in "$@"; do
case "$i" in
--copr)
ARR+=( --define "_source_filedigest_algorithm md5" )
ARR+=( --define "_binary_filedigest_algorithm md5" )
ARR+=( --define "dist %nil" )
;;
*)
ARR+=( "$i" )
;;
esac
done
run_rpmbuild()
{
set -x
echo "$@"
$RPMBUILD \
--define "_sourcedir $PWD" \
--define "_rpmdir $PWD" \
--define "_specdir $PWD" \
--define "_builddir $PWD" \
--define "_srcrpmdir $PWD" \
--buildroot "$PWD/buildroot" \
"$@"
}
case "$0" in
*build_local_nocheck)
ARR+=( --define "runselftest 0" )
ARR+=( --without=check )
;;
esac
run_rpmbuild "${ARR[@]}"
@@ -0,0 +1,71 @@
#! /bin/bash -ex
export TZ=UTC
copr_fe_url=https://copr.fedorainfracloud.org/coprs/g/pgjdbc/pgjdbc-travis/build
copr_be_link=https://copr-be.cloud.fedoraproject.org/results/@pgjdbc/pgjdbc-travis/fedora-rawhide-x86_64/
status_file=copr_build_id
copr_wrapper ()
(
set +x
echo "running copr-cli wrapper"
str="Created builds: "
copr-cli "$@" 2>&1 | \
while read line
do
echo "$line"
case $line in
"$str"*)
echo "${line##$str}" > "$status_file"
;;
esac
done
)
set -o pipefail
cd "$1"
git_rev=$(git rev-parse --short=7 HEAD)
date_rev=$(date +%Y%m%d_%H%M%S)
release=${date_rev}.git$git_rev
sed "s!^Release:.*\$!Release: 1.$release%{?dist}!" "$2".spec.tpl > "$2".spec
srpmgen
build_local -bs "$2".spec --define "dist %nil"
copr_wrapper --config "$1"/copr-token build --nowait @pgjdbc/pgjdbc-travis "$2-$3-1.$release.src.rpm"
copr_build_id=$(cat "$status_file")
concrete_copr_be_link=$copr_be_link$(printf "%08d" "$copr_build_id")-postgresql-jdbc/
set +x
echo "For build status, logs, etc. have a look at
$copr_fe_url/$copr_build_id/
Note that there might be multiple builds submitted, particularly if there copr
is configured to build for multiple versions of Fedora distribution. For
concrete build results against latest Fedora version, have a look at:
$concrete_copr_be_link"
exit_cmd=:
while :
do
status_output=$(copr --config "$1"/copr-token status "$copr_build_id")
case $status_output in
succeeded)
break
;;
failed)
exit_cmd=false
break
;;
*)
echo " * build $copr_build_id is in \"$status_output\" state [$(date)]"
;;
esac
sleep 30
done
echo " * getting the build log for rawhide chroot"
curl $concrete_copr_be_link/build.log.gz | gunzip || :
$exit_cmd
@@ -0,0 +1,63 @@
#! /bin/perl
use YAML;
use File::Basename;
open (my $config_file, "<", ".srpmgen") or die "Couldn't open file: $!";
my ($config) = Load( join('', <$config_file>));
sub info
{
print (" * @_\n");
}
my @sources = `spectool $config->{spec} -S`;
if ($? >> 8) {
die ("can't successfully run 'spectool'");
}
sub obtain_source
{
my ($id, $config) = @_;
if (defined ($config->{git_archive})) {
$config = $config->{git_archive};
my $topleveldir = `git rev-parse --show-toplevel`;
if ($? >> 8) {
die ("can't get git top level directory");
}
chomp ($topleveldir);
my $pfx = $config->{prefix};
system ("git archive --remote $topleveldir --prefix $pfx/ HEAD | gzip > $pfx.tar.gz");
if ($? >> 8) {
die ("can't generate tarball $pfx.tar.gz");
}
return;
}
die ("no method specified to obtain sources for '$id'\n");
}
# Go through all 'SourceN' statements in spec file.
for my $source_line (@sources)
{
chomp $source_line;
my ($id, $source) = split (/ /, $source_line, 2);
$id =~ s/:$//;
$id = lc ($id);
if (defined ($config->{$id})) {
obtain_source ($id, $config->{$id});
}
my $src_basename = basename ($source);
if (! -f "$src_basename") {
info ("getting sources $source");
system ("wget", "$source");
if ($? >> 8) {
die ("can't wget $source");
}
}
}
Oops, something went wrong.

0 comments on commit 1eb4085

Please sign in to comment.