From 3796740095fc4485a31d16838d7736d2aaec4767 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sat, 21 Jul 2012 21:58:43 -0400 Subject: Implement "build" command. --- diff --git a/src/deb.sh b/src/deb.sh index 897aee3..efc272a 100755 --- a/src/deb.sh +++ b/src/deb.sh @@ -19,7 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -COMMANDS='init config update download edit builddsc push' +COMMANDS='init config update download edit builddsc build push' CONFIG_NAMES='mirror distribution component remote buildcmd' main() @@ -379,6 +379,57 @@ EOF > "${DEB_TREE}/pkgs/${pkg}/${pkg}.debdiff" } +cmd_build() +{ + find_deb_dir + config_load + + if [ ${#} -lt 1 ]; then + cat >&2 < [...] +EOF + exit 1 + fi + + pkg="${1}" + shift + opts="${@}" + + # Ensure that source package is built. + [ ! -f "${DEB_TREE}/pkgs/${pkg}/"*.dsc ] && \ + error 'Source package "%s" not built' "${pkg}" + + # Find DSC file and make the build command. + dsc="$(ls "${DEB_TREE}/pkgs/${pkg}/"*.dsc)" + buildcmd="$(echo "${CONFIG_buildcmd}" | \ + sed -e "s@%distribution%@${CONFIG_distribution}@g" \ + -e "s@%opts%@${opts}@g;s@%dsc%@${dsc##*/}@g")" + + # Create build directory if it doesn't exist. + mkdir -p "${DEB_TREE}/builds/${pkg}" + + # Get list of source package files. + files="${dsc##*/}" + while read line; do + if [ "${line#Files:}" != "${line}" ]; then + while read sum size file; do + files="${files} ${file}" + done + fi + done < "${dsc}" + + # Copy source package files. + cd "${DEB_TREE}/pkgs/${pkg}" + cp -p ${files} "${DEB_TREE}/builds/${pkg}" + + # Build. + cd "${DEB_TREE}/builds/${pkg}" + ${buildcmd} + + # Remove source package files from build directory. + rm -f ${files} +} + cmd_push() { find_deb_dir -- cgit v0.9.1