]> git.madduck.net Git - code/mbuild.git/blob - mbuild.sh

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

97fcc53838a0fb4a472aa2e2e705d7eadc92074d
[code/mbuild.git] / mbuild.sh
1 #!/bin/sh
2 #
3 # mbuild - make sbuild and reprepro work together
4 #
5 # Copyright (c) 2008 martin f. krafft <madduck@debian.org>
6 # Released under the terms of the Artistic Licence 2.0.
7 #
8 set -eu
9
10 BUNDLEDIR="$HOME/reprepro/bundles"
11 REPREPRODIR="$HOME/reprepro"
12
13 DINSTALL="reprepro --basedir $REPREPRODIR include \$dist"
14
15 GNUPGHOME="$REPREPRODIR/.gnupg"; export GNUPGHOME
16 KEYID=330c4a75
17
18 DIR="$HOME/sbuild"
19 cd "$DIR"
20
21 sbuild_args=
22 schangesfile=
23 arch=
24 dist=
25 for opt in "$@"; do
26   case "$opt" in
27     --arch=*) arch="${opt#--arch=}";;
28     --dist=*) dist="${opt#--dist=}";;
29     -sa) sbuild_args="${sbuild_args:+$sbuild_args }--force-orig-source";;
30     --*) sbuild_args="${sbuild_args:+$sbuild_args }$opt";;
31     *_source.changes)
32       if [ -z "$schangesfile" ]; then
33         if [ -f "$opt" ] && [ -r "$opt" ]; then
34           schangesfile="$opt"
35         else
36           echo "E: file does not exist: $opt" >&2
37           exit 1
38         fi
39       else
40         echo "E: cannot pass more than one source changes file: $opt" >&2
41         exit 1
42       fi
43       ;;
44     *)
45       echo "E: unknown option: $opt" >&1
46       exit 1
47       ;;
48   esac
49 done
50
51 schangesfile_basename="${schangesfile##*/}"
52 packagenameversion="${schangesfile_basename%_*}"
53
54 builddir="$(mktemp -dp "$DIR" "${packagenameversion}.XXXXXXXX")"
55 trap "rm -R '$builddir'" 0
56
57 cd "${schangesfile%/*}"
58 dcmd cp "${schangesfile##*/}" "$builddir"
59 schangesfile="$schangesfile_basename"
60
61 cd "$builddir"
62
63 sbuild $sbuild_args --arch="$arch" --arch-all --dist="$dist" --keyid=$KEYID \
64   "$packagenameversion".dsc
65
66 changesfile="${packagenameversion}_${arch}.changes"
67
68 eval $DINSTALL "$schangesfile"
69 eval $DINSTALL "$changesfile"
70
71 mv "$changesfile" "${changesfile}.binonly"
72 mergechanges "$schangesfile" "${changesfile}.binonly" > "$changesfile"
73 rm "${changesfile}.binonly" "$schangesfile"
74
75 bundle="$BUNDLEDIR/${packagenameversion}.bundle.tar"
76 dcmd tar -chf "$bundle" "$changesfile"
77
78 rm -r "$builddir"
79 trap - 0
80
81 echo "Bundle available at $bundle"