File: dom-new-git-repo

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 (105 lines) | stat: -rwxr-xr-x 2,657 bytes parent folder | download | duplicates (4)
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
#!/bin/bash
set -e

NOTIFY_EMAIL="pkg-ocaml-maint-commits@lists.alioth.debian.org"

PACKAGE="$1"
TARBALL="$2"
if [ -z "$PACKAGE" ] ; then
  echo "Usage: dom-new-git-repo PKGNAME [ UPSTREAM_TARBALL | --notifications ]"
  exit 1
fi
if [ ! -f "$TARBALL" ]; then
  INJECT_TARBALL="no"
else
  INJECT_TARBALL="yes"
fi

if [ -n "$DOM_ALIOTH_USER" ]; then
  ALIOTH="${DOM_ALIOTH_USER}@git.debian.org"
else
  ALIOTH="git.debian.org"
fi

REPODIR="/git/pkg-ocaml-maint/packages/$PACKAGE.git"


initialize_alioth_repos () {
echo "I: initialize (empty) remote repository on git.d.o"
# see http://wiki.debian.org/Alioth/Git
cat <<EOCMD | ssh $ALIOTH sh
umask 002
set -e

# create repo and add some metadata
mkdir "$REPODIR"
cd "$REPODIR"
git --bare init --shared
echo "$PACKAGE packaging" > description
EOCMD
}


setup_notifications () {
echo "I: set up commit notification (mail and KGB)"
cat <<EOCMD | ssh $ALIOTH sh
umask 002

cd "$REPODIR"
chmod a+x hooks/post-update 2>/dev/null || mv hooks/post-update.sample hooks/post-update
git config --add hooks.mailinglist "$NOTIFY_EMAIL"
git config --add hooks.bcc "dispatch+${PACKAGE}_vcs@tracker.debian.org"
echo "#!/bin/bash" > hooks/post-receive
echo 'DIR=\`basename \$(readlink -f \$GIT_DIR)\`' >> hooks/post-receive
echo 'PKG=\${DIR%.git}' >> hooks/post-receive
echo 'tee >(kgb-client --conf /git/pkg-ocaml-maint/kgbclient.conf --repository git --git-reflog - --module \$PKG) >(/usr/local/bin/git-commit-notice) >/dev/null' >> hooks/post-receive
chmod 775 hooks/post-receive
EOCMD
}


git_push () {
   echo "I: pushing first changes to alioth.d.o"
   git remote add origin "git+ssh://$ALIOTH/$REPODIR"
   git push --all
   git push --tags
}

initialize_alioth_repos

if [ "$INJECT_TARBALL" = "yes" ] ; then
  setup_notifications
  echo "I: check in upstream tarball and setup branch layout"
  tmpdir=`mktemp -dt new-git-tmp.XXXXXXXXXX`
  trap "rm -rf $tmpdir" EXIT
  if [ "${TARBALL:0:1}" != "/" ] ; then
    TARBALL="`pwd`/$TARBALL"
  fi
  (cd $tmpdir
   git init
   # see #475554
   #git commit --allow-empty -m 'commit root'
   #git branch upstream
   gbp import-orig --pristine-tar "$TARBALL"
   git_push)
elif git show-ref --quiet 2>/dev/null ; then
  echo "I: we are in a git repos"
  git_push
  setup_notifications
elif [ "$2" = "--notifications" ]; then
  echo "I: nothing to be pushed, but we set up notifications as requested"
  setup_notifications
else
  echo "E: nothing to do"
  exit 1
fi


echo "I: all done. You can now checkout your new git repo with:"
echo
echo "   git clone git+ssh://$ALIOTH/$REPODIR"
echo
echo "I: or, for extra goodies (recommended):"
echo
echo "   dom-git-checkout $PACKAGE"
echo