File: svn-do

package info (click to toggle)
svn-buildpackage 0.6.16etch1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 260 kB
  • ctags: 42
  • sloc: perl: 1,399; makefile: 76; sh: 26
file content (83 lines) | stat: -rw-r--r-- 2,285 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
#
# svn-do
#
# svn-do will use svn-buildpackage to export a source, run a command inside the
# exported source, and -- if the command succeeds -- copy back the debian/ tree
#
# Copyright (C) 2006 Loc Minier <lool@dooz.org>
#
# 1) clean the tree (useful if this requires the full source tree)
#    % svn-do debclean
#    I: Exporting source tree via svn-buildpackage...
#    [...]
#    I: Running command: debclean
#    [...]
#    I: Copying back the debian/ tree...
#    `debian/control' ->
#    `/home/lool/svn/debian/pkg-gnome/desktop/unstable/nautilus-cd-burner/debian/control'
#
# 2) use quilt to refresh a patch
#    % QUILT_PATCHES=debian/patches svn-do \
#        sh -c "quilt push 002_static-linking-dont-build-perf.patch; quilt refresh"
#    [...]
#    I: Copying back the debian/ tree...
#    [...]
#    `debian/patches/002_static-linking-dont-build-perf.patch' ->
#    `/home/lool/svn/debian/pkg-gnome/desktop/experimental/gtk+2.0/debian/patches/002_static-linking-dont-build-perf.patch'
#
# 3) start a source editing session and decide later not to copy back the
#    debian/ tree
#    % svn-do $SHELL
#    [...]
#    I: Running command: /bin/zsh
#    % exit 1
#    E: command exited with 1; not copying back the debian/ tree.
#
# 4) edit a patch in a CDBS' simple-patchsys based package
#    % svn-do cdbs-edit-patch 02_pmount.patch
#    [...]

set -e

OLD_WD=$(pwd)

if ! [ -d .svn ]; then
    echo "E: Not in a SVN checkout" >&2
    exit 1
fi

if ! dh_testdir; then
    echo "E: Not in a Debian source tree" >&2
    exit 1
fi

echo "I: Exporting source tree via svn-buildpackage..." >&2
tree=$(LC_ALL=C svn-buildpackage --svn-dont-clean --svn-export | sed -n 's/.*exported to \(.*\)/\1/p')

if [ -z "$tree" ]; then
    echo "E: Export failed, check your svn-buildpackage configuration"
    exit 1
fi

# uncomment this if you want to purge the exported tree on completion
# (successful or not)
#cleanup() {
#    echo "I: Cleaning up..." >&2
#    rm -rf "$*"
#}
#trap "cleanup $tree" 0 1 2 3 9 11 13 15

cd "$tree"
echo "I: Running command: $*"
("$@")

err=$?

if [ 0 != $err ]; then
    echo "E: command exited with $err; not copying back the debian/ tree." >&2
    exit 1
fi

echo "I: Copying back the debian/ tree..." >&2
cp -vuapf debian/* "$OLD_WD/debian"