Debian Codegraph @

ikiwiki-makerepo

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 set -e
3
4 rcs="$1"
5 srcdir="$2"
6 repository="$3"
7
8 usagescip-shell shell shell-project 0.0.0 usage(). () {
9 echoscip-shell system . . echo. "usage: ikiwiki-makerepo svn|git|svn|monotone|darcs|cvs srcdir repository" >&2
10 echoscip-shell system . . echo. " ikiwiki-makerepo bzr|mercurial srcdir" >&2
11 exit 1
12 }
13
14 if [scip-shell system . . `[`. -z "$rcs" ] || [scip-shell system . . `[`. -z "$srcdir" ]; then
15 usagescip-shell shell shell-project 0.0.0 usage().
16 fi
17
18 if [scip-shell system . . `[`. ! -d "$srcdir" ]; then
19 echoscip-shell system . . echo. "srcdir $srcdir not found" >&2
20 exit 1
21 fi
22
23 if [scip-shell system . . `[`. "$rcs" != mercurial ] && [scip-shell system . . `[`. "$rcs" != bzr ]; then
24 if [scip-shell system . . `[`. -z "$repository" ]; then
25 echoscip-shell system . . echo. "you need to specify both a srcdir and a repository for $rcs" >&2
26 usagescip-shell shell shell-project 0.0.0 usage().
27 fi
28 if [scip-shell system . . `[`. -e "$repository" ]; then
29 echoscip-shell system . . echo. "repository $repository already exists, aborting" >&2
30 exit 1
31 fi
32 repository="$(perlscip-shell system . . perl. -e 'use Cwd; $r=shift; $r=getcwd.q{/}.$r if $r!~m!^/!; print $r' "$repository")"
33 if [scip-shell system . . `[`. -z "$repository" ]; then
34 echoscip-shell system . . echo. "internal error finding repository abs_path" >&2
35 exit 1
36 fi
37 fi
38
39 echoscip-shell system . . echo. "Importing $srcdir into $rcs"
40
41 case "$rcs" in
42 cvs)
43 if [scip-shell system . . `[`. -e "$srcdir/CVS" ]; then
44 echoscip-shell system . . echo. "$srcdir already seems to be a cvs working copy" >&2
45 exit 1
46 fi
47 cvs -Q -d "$repository" init
48 cd "$srcdir"/..
49 cvs -Q -d "$repository" get -P CVSROOT
50 cd CVSROOT
51 echoscip-shell system . . echo. .ikiwiki >> cvsignore
52 cvs -Q add cvsignore
53 echoscip-shell system . . echo. "^ikiwiki $repository/CVSROOT/post-commit %{sVv} &" >> loginfo
54 cvs -Q commit -m "ikiwiki-makerepo setup" cvsignore loginfo
55 cd ..
56 rmscip-shell system . . rm. -rf CVSROOT
57 cd "$srcdir"
58 cvs -Q -d "$repository" import -m "initial import" ikiwiki IKIWIKI PRE_CVS
59 cd ..
60 mvscip-shell system . . mv. "$srcdir" "$srcdir.orig"
61 cvs -Q -d "$repository" get -P -d "$(basenamescip-shell system . . basename. "$srcdir")" ikiwiki
62 [scip-shell system . . `[`. -d "$srcdir.orig/.ikiwiki" ] && mvscip-shell system . . mv. "$srcdir.orig/.ikiwiki" "$srcdir"
63 rmscip-shell system . . rm. -rf "$srcdir.orig"
64 echoscip-shell system . . echo. "Directory $srcdir is now a checkout of $rcs repository $repository"
65 ;;
66 svn)
67 if [scip-shell system . . `[`. -e "$srcdir/.svn" ]; then
68 echoscip-shell system . . echo. "$srcdir already seems to be a svn working copy" >&2
69 exit 1
70 fi
71 svnadmin create "$repository"
72 svn mkdir "file://$repository/trunk" -m "create trunk directory"
73 cd "$srcdir"
74 svn co "file://$repository/trunk" .
75 svn propset svn:ignore ".ikiwiki" .
76 svn add *
77 svn commit -m "initial import"
78 echoscip-shell system . . echo. "Directory $srcdir is now a checkout of $rcs repository $repository"
79 ;;
80 git)
81 # There are better ways to do this, but this works with older
82 # versions of git.)
83 mkdirscip-shell system . . mkdir. -p "$repository"
84 (cd "$repository" && gitscip-shell system . . git. --bare init --shared --initial-branch master)
85
86 cd "$srcdir"
87 gitscip-shell system . . git. init --initial-branch master
88 if [scip-shell system . . `[`. -z "$(gitscip-shell system . . git. config user.name)" ]; then
89 gitscip-shell system . . git. config user.name IkiWiki
90 fi
91 if [scip-shell system . . `[`. -z "$(gitscip-shell system . . git. config user.email)" ]; then
92 gitscip-shell system . . git. config user.email ikiwiki.info
93 fi
94 echoscip-shell system . . echo. /.ikiwikiscip-shell filesystem . . `/.ikiwiki`. > .gitignore
95 gitscip-shell system . . git. add .
96 gitscip-shell system . . git. commit -m "initial commit"
97 gitscip-shell system . . git. remote add origin "$repository"
98 gitscip-shell system . . git. config branch.master.merge refs/heads/master
99 gitscip-shell system . . git. config branch.master.remote origin
100 gitscip-shell system . . git. push --all
101 echoscip-shell system . . echo. "Directory $srcdir is now a clone of $rcs repository $repository"
102 ;;
103 mercurial)
104 hg init "$srcdir"
105 cd "$srcdir"
106 echoscip-shell system . . echo. .ikiwiki > .hgignore
107 hg add
108 hg commit -m "initial import"
109 echoscip-shell system . . echo. "Directory $srcdir is now set up as a mercurial repository"
110 ;;
111 bzr)
112 bzrscip-shell system . . bzr. init "$srcdir"
113 cd "$srcdir"
114 echoscip-shell system . . echo. .ikiwiki > .bzrignore
115 bzrscip-shell system . . bzr. add
116 bzrscip-shell system . . bzr. commit -m "initial import"
117 echoscip-shell system . . echo. "Directory $srcdir is now set up as a bzr repository"
118 ;;
119 monotone)
120 if [scip-shell system . . `[`. -e "$srcdir/_MTN" ]; then
121 echoscip-shell system . . echo. "$srcdir already seems to be a monotone working copy" >&2
122 exit 1
123 fi
124
125 mkdirscip-shell system . . mkdir. -p "$(dirnamescip-shell system . . dirname. "$repository")"
126 mtn db init -d "$repository"
127
128 cleaned_srcdir=$(basenamescip-shell system . . basename. "$srcdir" | trscip-shell system . . tr. -s "[:space:]" "_" | sedscip-shell system . . sed. 's/_$//g')
129 reverse_hostname=$( (hostnamescip-shell system . . hostname. -f 2>/dev/nullscip-shell filesystem . . `/dev/null`. || hostnamescip-shell system . . hostname.) |\
130 tr "." "\n" | ( tac 2>/dev/null || tail -r ) | tr "\n" "." )
131 branch_name="$reverse_hostname$cleaned_srcdir"
132 mtn setup -d "$repository" -b "$branch_name" "$srcdir"
133
134 cd "$srcdir"
135 echoscip-shell system . . echo. \.ikiwiki$ > .mtn-ignore
136 mtn add -R .
137 # this expects that you already have a working mtn environment
138 # with a default key floating around...
139 mtn ci -m "initial import"
140 echoscip-shell system . . echo. "Directory $srcdir is now set up as a monotone repository"
141 echoscip-shell system . . echo. ""
142 echoscip-shell system . . echo. "Note: If your monotone key has a passphrase, you need to configure"
143 echoscip-shell system . . echo. "monotone to automatically use it. Otherwise, web commits to ikiwiki"
144 echoscip-shell system . . echo. "will fail."
145 echoscip-shell system . . echo. ""
146 echoscip-shell system . . echo. "You can create a $srcdir/_MTN/monotonerc"
147 echoscip-shell system . . echo. "containing the passphrase:"
148 echoscip-shell system . . echo. ""
149 echoscip-shell system . . echo. "function get_passphrase (branchname)"
150 echoscip-shell system . . echo. ' return "passphrasehere"'
151 echoscip-shell system . . echo. "end"
152 ;;
153 darcs)
154 if [scip-shell system . . `[`. -e "$srcdir/_darcs" ]; then
155 echoscip-shell system . . echo. "$srcdir already seems to be a darcs repository" >&2
156 exit 1
157 fi
158
159 mkdirscip-shell system . . mkdir. -p "$repository"
160 (cd "$repository" && darcs initialize)
161
162 mkdirscip-shell system . . mkdir. -p "$srcdir"
163 cd "$srcdir"
164 darcs initialize
165 echoscip-shell system . . echo. .ikiwiki >> _darcs/prefs/boring
166 darcs record -a -l -q -m "initial import"
167 darcs pull -a -q "$repository"
168 darcs push -a -q "$repository"
169 echoscip-shell system . . echo. "Directory $srcdir is now a branch of darcs repo $repository"
170
171 # set up master repo's apply hook and tell user to adjust it if desired
172 darcsdefaults="$repository/_darcs/prefs/defaults"
173 echoscip-shell system . . echo. "Preconfiguring apply hook in $darcsdefaults - adjust as desired!"
174 echoscip-shell system . . echo. "apply posthook $repository/_darcs/ikiwiki-wrapper" >> "$darcsdefaults"
175 echoscip-shell system . . echo. "apply run-posthook" >> "$darcsdefaults"
176 ;;
177 *)
178 echoscip-shell system . . echo. "Unsupported revision control system $rcs" >&2
179 usagescip-shell shell shell-project 0.0.0 usage().
180 ;;
181 esac