#!/bin/bash set -e usage() { echo "usage: dcp-update-apt PACKAGE" } getaptsrc() { mkdir "apt-tmp" (cd "apt-tmp"; apt-get source "$1") || false sdir= for f in "apt-tmp"/*; do if [ -d "$f" ]; then if [ -z "$sdir" ]; then sdir="$f" else echo "dcp-update-apt: got more than one directory from apt-get; cannot continue" >&2 exit 1 fi fi done if [ -z "$sdir" ]; then echo "dcp-update-apt: could not find any source directory" >&2 exit 1 fi mv "$sdir" "src" rm -rf "apt-tmp" git add src } if [ $# -lt 1 ]; then usage >&2 exit 1 fi git rm --quiet -r src getaptsrc "$1" git commit -q -m "Updated from upstream" || true