summaryrefslogtreecommitdiff
path: root/scripts/dist
blob: 9fd078ceefbbe8a804e2fe2e14f65d38e6cb3f6e (plain)
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
125
#! /bin/sh
#
# This file is part of rsbackup
# Copyright (C) 2010, 2011, 2013-16 Richard Kettlewell
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
set -e

# s COMMAND...
#
# Echo a command then execute it.
s() {
  echo "$@" >&2
  "$@"
}

# r HOST COMMAND...
#
# Echo a command then execute it remotely.
r() {
  h=$1
  shift
  echo "$h:" "$@" >&2
  case "$h" in
  chroot:* )
    (
      cd
      schroot -pc${h#chroot:} -- bash -c "$@"
    )
    ;;
  * )
    ssh $h "$@"
    ;;
  esac
}

# build HOST ARCH
#
# Create a .deb on HOST for architecture ARCH, then copy it back here
# and add it to the list of build products.
build() {
  host=$1
  arch=$2

  debs=""
  for b in $binpkgs; do
    debs="$debs ${b}_${debversion}_${arch}.deb"
  done
  echo
  echo "Build on $host for $arch"
  echo
  r $host "mkdir -p _builds"
  r $host "cd _builds && rm -rf ${source} ${archive} ${debs}"
  case "$host" in
  chroot:* )
    cp ${archive} $HOME/_builds/.
    ;;
  * )
    s scp ${archive} $host:_builds/.
    ;;
  esac
  r $host "cd _builds && tar xfz ${archive}"
  r $host "cd _builds/${source} && debian/rules build"
  r $host "cd _builds/${source} && fakeroot debian/rules binary"
  for deb in $debs; do
    case "$host" in
    chroot:* )
      cp $HOME/_builds/$deb products/
      ;;
    * )
      s scp $host:_builds/$deb products/
      ;;
    esac
  done
  echo
  echo "Built $debs"
  echo
}

rm -rf products
mkdir products

# Make sure auto*-generated files are up to date
s ./autogen.sh
s ./configure

# Build the source archive
s make -C doc html
s make distcheck

srcpkg=rsbackup                 # source package name
binpkgs="rsbackup"              # binary packages
version=$(make echo-version)    # get version number
debversion=$(dpkg-parsechangelog -ldebian/changelog -SVersion)
source=${srcpkg}-${version}     # source directory
archive=${srcpkg}-${version}.tar.gz # tarball

# Build .deb files
s build araminta amd64          # stretch
s build chroot:stretch32 i386   # stretch

cp ${archive} doc/*.html doc/*.css products/.
rm -f products/*.in.html
mv products//CHANGES.html products/rsbackup-CHANGES.html
lintian -i -I products/*.deb
cd products
for f in *.tar.gz *.deb; do
    echo
    echo "* Signing $f ..."
    echo
    gpg -a -b "$f"
done
cd ..
ls -l products