1 | #!/bin/bash |
---|
2 | #------------------------------------------------------------------------------- |
---|
3 | # (C) British Crown Copyright 2006-17 Met Office. |
---|
4 | # |
---|
5 | # This file is part of FCM, tools for managing and building source code. |
---|
6 | # |
---|
7 | # FCM is free software: you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation, either version 3 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # FCM is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | #------------------------------------------------------------------------------- |
---|
20 | set -eu |
---|
21 | if (($# < 1)); then |
---|
22 | echo "Usage: $(basename $0) DEST" >&2 |
---|
23 | exit 1 |
---|
24 | fi |
---|
25 | DEST=$1 |
---|
26 | if [[ -e $DEST ]]; then |
---|
27 | echo "$DEST: destination already exists." >&2 |
---|
28 | exit 1 |
---|
29 | fi |
---|
30 | THIS_HOME=$(cd $(dirname $0) && pwd) |
---|
31 | WORK_DIR= |
---|
32 | function FINALLY() { |
---|
33 | trap '' ERR |
---|
34 | trap '' EXIT |
---|
35 | cd ~ |
---|
36 | if [[ -n $WORK_DIR ]]; then |
---|
37 | rm -rf $WORK_DIR |
---|
38 | fi |
---|
39 | } |
---|
40 | #------------------------------------------------------------------------------- |
---|
41 | function rsyncs() { |
---|
42 | rsync -a --exclude=".svn" --checksum "$@" |
---|
43 | } |
---|
44 | #------------------------------------------------------------------------------- |
---|
45 | |
---|
46 | WORK_DIR=$(mktemp -d) |
---|
47 | trap FINALLY ERR |
---|
48 | trap FINALLY EXIT |
---|
49 | cd $WORK_DIR |
---|
50 | |
---|
51 | svnadmin create repos |
---|
52 | REPOS_URL=file://$PWD/repos |
---|
53 | svn checkout -q $REPOS_URL working-copy |
---|
54 | mkdir -p working-copy/tutorial/{trunk,branches,tags} |
---|
55 | |
---|
56 | # r1 |
---|
57 | rsyncs $THIS_HOME/trunk-r1/* working-copy/tutorial/trunk/ |
---|
58 | svn add -q working-copy/tutorial |
---|
59 | svn commit -q -m'tutorial: initial import.' working-copy |
---|
60 | svn update -q working-copy |
---|
61 | |
---|
62 | # r2 |
---|
63 | TRUNK_SRC=working-copy/tutorial/trunk/src |
---|
64 | svn move -q $TRUNK_SRC/module/hello_num.f90 $TRUNK_SRC/module/hello_number.f90 |
---|
65 | sed -i 's/Hello World/Hello Earth/' $TRUNK_SRC/module/hello_constants.f90 |
---|
66 | sed -i 's/Hello World/Hello Earth/' $TRUNK_SRC/subroutine/hello_c.c |
---|
67 | svn commit -q -m'tutorial: World=Earth, and correct module name.' working-copy |
---|
68 | svn update -q working-copy |
---|
69 | |
---|
70 | rsyncs $THIS_HOME/hooks/* repos/hooks/ |
---|
71 | curl -o repos/hooks/svnperms.py \ |
---|
72 | http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/svnperms.py |
---|
73 | chmod +x repos/hooks/svnperms.py |
---|
74 | cat >repos/hooks/svnperms.conf <<__SVNPERMS_CONF__ |
---|
75 | [$(basename $DEST)] |
---|
76 | tutorial/branches/[^/]+/.* = *(add,remove,update) |
---|
77 | __SVNPERMS_CONF__ |
---|
78 | mkdir -p $(dirname $DEST) |
---|
79 | svnadmin hotcopy repos $DEST |
---|
80 | echo "$DEST: tutorial repository created." |
---|