#!/bin/sh # # mbuild - make sbuild and reprepro work together # # Copyright (c) 2008 martin f. krafft # Released under the terms of the Artistic Licence 2.0. # set -eu BUNDLEDIR="$HOME/reprepro/bundles" REPREPRODIR="$HOME/reprepro" DINSTALL="reprepro --basedir $REPREPRODIR include \$dist" GNUPGHOME="$REPREPRODIR/.gnupg"; export GNUPGHOME KEYID=330c4a75 DIR="$HOME/sbuild" cd "$DIR" sbuild_args= schangesfile= arch= dist= for opt in "$@"; do case "$opt" in --arch=*) arch="${opt#--arch=}";; --dist=*) dist="${opt#--dist=}";; -sa) sbuild_args="${sbuild_args:+$sbuild_args }--force-orig-source";; --*) sbuild_args="${sbuild_args:+$sbuild_args }$opt";; *_source.changes) if [ -z "$schangesfile" ]; then if [ -f "$opt" ] && [ -r "$opt" ]; then schangesfile="$opt" else echo "E: file does not exist: $opt" >&2 exit 1 fi else echo "E: cannot pass more than one source changes file: $opt" >&2 exit 1 fi ;; *) echo "E: unknown option: $opt" >&1 exit 1 ;; esac done schangesfile_basename="${schangesfile##*/}" packagenameversion="${schangesfile_basename%_*}" builddir="$(mktemp -dp "$DIR" "${packagenameversion}.XXXXXXXX")" trap "rm -R '$builddir'" 0 cd "${schangesfile%/*}" dcmd cp "${schangesfile##*/}" "$builddir" schangesfile="$schangesfile_basename" cd "$builddir" sbuild $sbuild_args --arch="$arch" --arch-all --dist="$dist" --keyid=$KEYID \ "$packagenameversion".dsc changesfile="${packagenameversion}_${arch}.changes" $SHELL eval $DINSTALL "$schangesfile" eval $DINSTALL "$changesfile" mv "$changesfile" "${changesfile}.binonly" mergechanges "$schangesfile" "${changesfile}.binonly" > "$changesfile" rm "${changesfile}.binonly" "$schangesfile" bundle="$BUNDLEDIR/${packagenameversion}.bundle.tar" dcmd tar -chf "$bundle" "$changesfile" rm -r "$builddir" trap - 0 echo "Bundle available at $bundle"