3 ### Build a Debian package on an sbuild server.
5 ### (c) 2016 Mark Wooding
8 ###----- Licensing notice ---------------------------------------------------
10 ### This program is free software; you can redistribute it and/or modify
11 ### it under the terms of the GNU General Public License as published by
12 ### the Free Software Foundation; either version 2 of the License, or
13 ### (at your option) any later version.
15 ### This program is distributed in the hope that it will be useful,
16 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ### GNU General Public License for more details.
20 ### You should have received a copy of the GNU General Public License
21 ### along with this program; if not, write to the Free Software Foundation,
22 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 ###--------------------------------------------------------------------------
29 fail
() { echo >&2 "$prog: $*"; exit 1; }
30 usage
() { echo "usage: $prog [-ain] [-k KEYID] [-t TARGET] HOST"; }
31 fail_usage
() { usage
>&2; exit 1; }
33 ###--------------------------------------------------------------------------
36 bogusp
=nil noactp
=nil signp
=nil
38 while getopts "haik:np:t:" opt
; do
45 -h Show this help text.
46 -a Build only architecture-dependent packages.
47 -i Build only architecture-neutral packages.
48 -k KEYID Sign the result using KEYID.
49 -n Don't actually do the build.
50 -p DIR Upload additional packages from DIR.
51 -t TARGET Build in TARGET build environment.
55 a
) buildopts
="${buildopts+$buildopts }-a" ;;
56 i
) buildopts
="${buildopts+$buildopts }-i" ;;
57 k
) signp
=t keyid
=$OPTARG ;;
58 n
) buildopts
="${buildopts+$buildopts }-n" noactp
=t
;;
60 t
) buildopts
="${buildopts+$buildopts }-t$OPTARG" ;;
64 shift $
(( $OPTIND - 1 ))
69 case $bogusp in t
) fail_usage
;; esac
70 case $noactp in t
) signp
=nil
;; esac
71 case ${pkgs-/hack} in /*) ;; *) pkgs
=$
(pwd)/$pkgs ;; esac
73 ###--------------------------------------------------------------------------
76 ## Figure out the package name and version number.
78 while read tag value
; do
80 Source
:) pkg
=$value ;;
81 Version
:) ver
=$value ;;
84 $(dpkg-parsechangelog)
86 case ${pkg+t} in t
) ;; *) fail
"can't figure out the package name" ;; esac
87 case ${ver+t} in t
) ;; *) fail
"can't figure out the package version" ;; esac
89 ## Build a Debian source package. Don't sign anything yet. That will happen
90 ## at the end, all in one go.
91 dpkg-buildpackage
-S
-uc
-us
-d
-i
94 [ -f
"$dsc" ] || fail
"where is my \`.dsc' file?"
96 ## Actually do the build. Get a build directory assigned by the server,
97 ## upload the sources, run the build, and collect the results.
98 builddir
=$
(ssh "$host" mdw-sbuild-server dir
"$pkg/$ver")
99 dcmd rsync
-a
"$dsc" "$host:$builddir/"
100 case ${pkgs+t} in t
) rsync
-a
"$pkgs/" "$host:$builddir/pkgs/" ;; esac
101 set +e
; ssh "$host" mdw-sbuild-server
$buildopts build
"$builddir"
103 rsync
-a
"$host:$builddir/" .
/
104 case $rc in 0) ;; *) exit $rc ;; esac
106 ## Merge the change files together, and maybe sign the result.
107 chchch
=${pkg}_
${ver}_source.changes
108 for i
in "${pkg}_${ver}"_
*.changes
; do
109 case " $chchch " in *" $i "*) ;; *) chchch
="$chchch $i" ;; esac
111 mergechanges
-f
$chchch
114 t
) debsign
-k
"$keyid" "${pkg}_${ver}_multi.changes" ;;