Commit | Line | Data |
---|---|---|
44955b68 | 1 | #!/bin/bash |
9f26b93f FT |
2 | |
3 | set -e | |
4 | ||
5 | usage() { | |
6 | echo "usage: dcp-update-apt PACKAGE" | |
7 | } | |
8 | ||
9 | getaptsrc() { | |
10 | mkdir "apt-tmp" | |
11 | (cd "apt-tmp"; apt-get source "$1") || false | |
12 | ||
13 | sdir= | |
14 | for f in "apt-tmp"/*; do | |
15 | if [ -d "$f" ]; then | |
16 | if [ -z "$sdir" ]; then | |
17 | sdir="$f" | |
18 | else | |
19 | echo "dcp-update-apt: got more than one directory from apt-get; cannot continue" >&2 | |
20 | exit 1 | |
21 | fi | |
22 | fi | |
23 | done | |
24 | if [ -z "$sdir" ]; then | |
25 | echo "dcp-update-apt: could not find any source directory" >&2 | |
26 | exit 1 | |
27 | fi | |
28 | mv "$sdir" "src" | |
29 | rm -rf "apt-tmp" | |
30 | ||
31 | git add src | |
32 | } | |
33 | ||
34 | if [ $# -lt 1 ]; then | |
35 | usage >&2 | |
36 | exit 1 | |
37 | fi | |
38 | ||
39 | git rm --quiet -r src | |
40 | getaptsrc "$1" | |
41 | git commit -q -m "Updated from upstream" || true |