File: obs-commit-version.sh

package info (click to toggle)
actor-framework 0.17.6-3.2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 9,008 kB
  • sloc: cpp: 77,684; sh: 674; python: 309; makefile: 13
file content (124 lines) | stat: -rwxr-xr-x 4,086 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash

# obs-commit-version.sh: update CAF packages on OBS from Jenkins.
# This shell script is created for easy updating CAF binary packages located
# on OpenSUSE Build Service (OBS). It should be issued from the Jenkins after
# release has proven to be operating, like this:
#
#     $ make
#     $ make test
#     $ make doc                       <-- this is a necessary step!
#     $ scripts/obs-commit-version.sh [--nightly|--release]
#
# In brief, it performs the following steps:
#
#  1. Determines current version from <caf/config.h> header. It's crucial to
#     have this version set correctly for script to operate properly.
#  2. Determines current branch. If it's 'master' then rebuild stable
#     packages, if it's 'develop' then rebuild nightly.
#  3. Checks out OBS project using "osc" tool. It uses default credentials
#     specified in ~/.oscrc configuration file.
#  4. Puts new source tarball into OBS project.
#  5. Updates version in various spec files.
#  6. Commits changes files to trigger new OBS build.
#
# Copyright (c) 2015, Pavel Kretov <firegurafiku@gmail.com>
# Copyright (c) 2015, Dominik Charousset <dominik.charousset@haw-hamburg.de>
#
# Distributed under the terms and conditions of the BSD 3-Clause License or
# (at your option) under the terms and conditions of the Boost Software
# License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE.
#
# If you did not receive a copy of the license files, see
# http://opensource.org/licenses/BSD-3-Clause and
# http://www.boost.org/LICENSE_1_0.txt.

set -o nounset
set -o errexit

# Script configuration (yet unlikely to change in the future).
confReleaseProject="devel:libraries:caf"
confNightlyProject="devel:libraries:caf:nightly"
confReleasePackage="caf"
confNightlyPackage="caf"

# Check for 'osc' command.
type osc >/dev/null 2>&1 || {
  echo "This script requires 'osc', please install it first." >&2
  exit 1
}

if [ "$#" -ne 1 ] ; then
  echo "Either --release or --nightly option must be specified." >&2
  exit 1
fi

sourceDir="$PWD"

# Check if header exists.
if [ ! -f "$sourceDir/libcaf_core/caf/config.hpp" ] ; then
  echo "This script must be called from the root directly of CAF." >&2
  exit 1
fi

if [ ! -f "$sourceDir/manual.pdf" ] ; then
  echo "Documentation must be generated before calling this script." >&2
  exit 1
fi

# Extract version information from header file.
versionAsInt=$(grep "#define CAF_VERSION" libcaf_core/caf/config.hpp | awk '{print $3'})
versionMajor=$(echo "$versionAsInt / 10000" | bc)
versionMinor=$(echo "( $versionAsInt / 100 ) % 100" | bc)
versionPatch=$(echo "$versionAsInt % 100" | bc)
versionAsStr="$versionMajor.$versionMinor.$versionPatch"

if [ "$1" = "--release" ] ; then
  projectName="$confReleaseProject"
  packageName="$confReleasePackage"
  packageVersion="${versionAsStr}"
elif [ "$1" = "--nightly" ] ; then
  projectName="$confNightlyProject"
  packageName="$confNightlyPackage"
  packageVersion="${versionAsStr}.$(date +%Y%m%d)"
else
  # Don't prevent other branches from building, but issue a warning.
  echo "Use with either '--nightly' or '--release'. Exitting." >&2
  exit
fi

packageFqn="$projectName/$packageName"
sourceTarball="${packageVersion}.tar.gz"
buildDir="$sourceDir/build"
obsDir="$buildDir/obs-temp"

# Prepare a directory for checkout.
[ -d "$obsDir" ] && rm -rf "$obsDir"
mkdir -p "$obsDir"
cd "$obsDir"

# Checkout the project from OBS into a newly created directory.
echo "[obs-commit-version] Checking out"
osc checkout "$packageFqn"

# Remove old tarball.
cd "$packageFqn"
osc remove *.tar.gz

# And generate a new tarball.
cd "$sourceDir"
echo "[obs-commit-version] Generating tarball: ${versionAsStr}.tar.gz"
tar czf "$obsDir/$packageFqn/$sourceTarball" --exclude ".git" --exclude "build" *
cd - >/dev/null

osc add "$sourceTarball"

# Fix package version and commit.
sed -i.bk -E \
  -e "s/^Version:([ ]+).+/Version:\1$packageVersion/g" \
  "$packageName.spec" \
  "$packageName.dsc"

echo "[obs-commit-version] Comitting: $packageVersion, $1"
osc commit -m "Automatic commit: $packageVersion, $1"