Files
mrw-cxx/resolve-debbuilddeps.sh

67 lines
1.8 KiB
Bash
Raw Normal View History

2015-09-11 10:42:51 +00:00
#! /bin/bash -ex
## @id $Id$
## Resolve Debian Build Dependencies
## Installs all the required packages
## Call: ./resolve-debbuilddeps 'name of build schroot'
## e.g. call: ./resolve-debbuilddeps trusty_amd64
## 1 2 3 4 5 6 7 8
## 45678901234567890123456789012345678901234567890123456789012345678901234567890
SCHROOTNAME="$1"
function install() {
if test -n "${SCHROOTNAME}"; then
if schroot -c "${SCHROOTNAME}" -u root -d / -- apt-get -y install $*; then
return 0
fi
else
if apt-get -y install $*; then
return 0
fi
fi
}
2015-11-03 09:29:22 +00:00
if test -e debian/control.in -a ! -e debian/control; then
sed 's,@[^@]*@, dummytext,g' debian/control.in > debian/control
trap "rm debian/control" INT TERM EXIT
fi
2015-09-11 10:42:51 +00:00
if test -n "${SCHROOTNAME}"; then
schroot -c "${SCHROOTNAME}" -u root -d / -- apt-get -y install dpkg-dev
2015-09-11 10:42:51 +00:00
DEPS=$(schroot -c "${SCHROOTNAME}" -- dpkg-checkbuilddeps 2>&1 || true)
else
apt-get -y install dpkg-dev
2015-09-11 10:42:51 +00:00
DEPS=$(dpkg-checkbuilddeps 2>&1 || true)
fi
DEPS=$(echo "$DEPS" | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}')
2015-11-03 09:29:22 +00:00
TO_INSTALL=
2015-09-11 10:42:51 +00:00
for pa in ${DEPS}; do
2015-11-03 09:29:22 +00:00
if test ${pa//|/} = ${pa}; then
TO_INSTALL+=" ${pa}"
continue;
fi
2015-09-11 10:42:51 +00:00
success=0
2015-11-03 09:29:22 +00:00
for p in ${pa//|/ }; do
if install ${TO_INSTALL} ${p}; then
TO_INSTALL+=" ${p}"
success=1
break
2015-09-11 10:42:51 +00:00
fi
done
if test ${success} -eq 0; then
echo "**** Error: Installation Failed: ${pa}"
2015-11-03 09:29:22 +00:00
exit 1
2015-09-11 10:42:51 +00:00
fi
done
if test -n "${TO_INSTALL}" && ! install ${TO_INSTALL}; then
echo "**** Error: Installation Failed: ${TO_INSTALL}"
2015-11-03 09:29:22 +00:00
exit 1
fi
2015-09-11 10:42:51 +00:00
echo "**** Success: All Dependencies Resolved"