File: dom-mrconfig

package info (click to toggle)
dh-ocaml 2.5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 352 kB
  • sloc: xml: 1,746; perl: 1,063; sh: 244; makefile: 105
file content (111 lines) | stat: -rwxr-xr-x 2,505 bytes parent folder | download | duplicates (8)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh
set -e

msg() {
    echo "I: $1"
}

output() {
    echo "$1" >> $OUTPUT
}

if [ "$1" = "-h" ] ; then
    cat <<EOF
Usage: dom-mrconfig [ -h ] [ CONFIG_FILE ]
EOF
    exit 0
fi

msg "Setting up output file"
OUTPUT="$1"
if [ -z "$OUTPUT" ] ; then
    OUTPUT="mrconfig"
fi

msg "Retreiving package list"

# Packages hosted in Git
GIT_REPODIR="/git/pkg-ocaml-maint/packages/"
GIT_PKGS=`ssh alioth.debian.org ls -1 $GIT_REPODIR | sed 's/.git$//'`

# Packages hosted in Svn
SVN_REPODIR="svn+ssh://svn.debian.org/svn/pkg-ocaml-maint/trunk"
SVN_PKGS=`svn ls $SVN_REPODIR/packages | grep -v git-repo | sed 's/\///'`

# Packages not migrated to Git
## lablgtk has been migrated to Git and its new git repository name is lablgtk2
SVN_REMAINING_PKGS=`echo "${SVN_PKGS}" | grep -F "${GIT_PKGS}" -x -v | grep -x -v lablgtk`

msg "Generating mrconfig file in $OUTPUT"

# Backup the output file if it exists
if [ -f $OUTPUT ]; then
    mv $OUTPUT ${OUTPUT}\~
fi

# Setting up mr lib
output '[DEFAULT]
lib=
      msg () {
        echo "I: $1"
      }
      git_checkout () {
        git clone git+ssh://git.debian.org'"$GIT_REPODIR"'$1.git &&
        cd $1 &&
        { git branch --track upstream remotes/origin/upstream || true; } &&
        { git branch --track pristine-tar remotes/origin/pristine-tar || true; }
      }
      svn_checkout () {
        svn co '"$SVN_REPODIR"'/$1
      }
      update_check () {
        if [ -d .git ]; then
          dom-safe-pull
        else
          svn update
          if [ -f "trunk/README" ] && grep -q "This package has moved" trunk/README; then
            cd ..
            msg "Deleting old svn repository: packages/$1"
            rm -rf $1/* $1/.*
            msg "Checkout new git repository"
            git_checkout $1
          fi
        fi
      }
'

# Sections for Git repositories
for i in $GIT_PKGS; do
    output "[packages/$i]
checkout = git_checkout $i
update = update_check $i
"
done

# Sections for Svn repositories
for i in $SVN_REMAINING_PKGS; do
    output "[packages/$i]
checkout = svn_checkout packages/$i
update = update_check $i
"
done

msg "Setting up sections for projects and tools"

# Adding other useful repositories
for i in  projects tools; do
  output "[$i]
checkout = svn_checkout $i
"
done

# Warn if changes have been made
if [ -f ${OUTPUT}\~ ] && diff -u ${OUTPUT}\~ ${OUTPUT}; then
    rm ${OUTPUT}\~
    msg "no changes"
else
    msg "$OUTPUT changed!"
fi

# Finish
msg "all done, enjoy: mr -c $OUTPUT [checkout,update,...]"