automate/build_deb_from_dsc.sh

45 lines
780 B
Bash
Executable File

#!/usr/bin/env bash
apt-get install -y git-buildpackage
if [ "$1" == "-h" ]; then
echo "Usage: `basename $0` Takes a build location and a dsc file
or a url to one and builds and installs the result."
exit 0
fi
BUILD_DIR=$1/build
mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR}
# Download the package to build
gbp import-dsc -v --allow-unauthenticated $2
cd *
# Install the build deps
mk-build-deps debian/control
DEPS_DEB=$(ls *deb)
dpkg -i ${DEPS_DEB}
apt-get -f install -y
rm ${DEPS_DEB}
# Build the packages
dpkg-buildpackage -us -uc -b
# Remove the build deps
APT_REMOVE=${DEPS_DEB%%\_*}
apt-get -y remove --purge ${APT_REMOVE}
apt-get -y autoremove
# Install the built debs
INSTALL_DEB=${APT_REMOVE%%_*}
dpkg -i ../${INSTALL_DEB}_*deb
apt-get -f install -y