diff options
Diffstat (limited to '')
-rwxr-xr-x | add-copyright.sh | 72 | ||||
-rwxr-xr-x | update-svn-properties.py | 171 |
2 files changed, 0 insertions, 243 deletions
diff --git a/add-copyright.sh b/add-copyright.sh deleted file mode 100755 index f567412..0000000 --- a/add-copyright.sh +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | TEMPNAME="copyright_script_temp_file" | ||
4 | COPYNAME="copyright_script_copyright_notice" | ||
5 | |||
6 | URL="http://opensimulator.org/" | ||
7 | PROJNAME="OpenSim" | ||
8 | |||
9 | cat > ${COPYNAME} <<EOF | ||
10 | /* | ||
11 | * Copyright (c) Contributors, ${URL} | ||
12 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
13 | * | ||
14 | * Redistribution and use in source and binary forms, with or without | ||
15 | * modification, are permitted provided that the following conditions are met: | ||
16 | * * Redistributions of source code must retain the above copyright | ||
17 | * notice, this list of conditions and the following disclaimer. | ||
18 | * * Redistributions in binary form must reproduce the above copyright | ||
19 | * notice, this list of conditions and the following disclaimer in the | ||
20 | * documentation and/or other materials provided with the distribution. | ||
21 | * * Neither the name of the ${PROJNAME} Project nor the | ||
22 | * names of its contributors may be used to endorse or promote products | ||
23 | * derived from this software without specific prior written permission. | ||
24 | * | ||
25 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS \`\`AS IS'' AND ANY | ||
26 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
27 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
28 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
29 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
30 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
31 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
32 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
35 | */ | ||
36 | |||
37 | EOF | ||
38 | |||
39 | has_bom() { | ||
40 | CHARS=`hexdump -c $1 | head -n1 | cut -d\ -f1-4` | ||
41 | BOMMARK="0000000 357 273 277" | ||
42 | if [ "${CHARS}" == "${BOMMARK}" ]; then | ||
43 | echo 1 | ||
44 | else | ||
45 | echo 0 | ||
46 | fi | ||
47 | } | ||
48 | |||
49 | for f in `find . -iname "*.cs"`; do | ||
50 | head -n2 $f | tail -n1 > ${TEMPNAME} | ||
51 | grep -q Copyright ${TEMPNAME} | ||
52 | if [ $? == 1 ]; then | ||
53 | BOMSTATUS=`has_bom $f` | ||
54 | rm ${TEMPNAME} | ||
55 | |||
56 | if [ ${BOMSTATUS} == 1 ]; then | ||
57 | echo -ne \\0357\\0273\\0277 > ${TEMPNAME} | ||
58 | fi | ||
59 | |||
60 | cat ${COPYNAME} >> ${TEMPNAME} | ||
61 | |||
62 | if [ ${BOMSTATUS} == 1 ]; then | ||
63 | cat $f | perl -p -e "s/^\\xEF\\xBB\\xBF//" >> ${TEMPNAME} | ||
64 | else | ||
65 | cat $f >> ${TEMPNAME} | ||
66 | fi | ||
67 | |||
68 | mv ${TEMPNAME} $f | ||
69 | fi | ||
70 | done | ||
71 | |||
72 | rm -f ${COPYNAME} ${TEMPNAME} | ||
diff --git a/update-svn-properties.py b/update-svn-properties.py deleted file mode 100755 index f8d53bf..0000000 --- a/update-svn-properties.py +++ /dev/null | |||
@@ -1,171 +0,0 @@ | |||
1 | #!/usr/bin/env python | ||
2 | |||
3 | import os, os.path, popen2, re, string, sys | ||
4 | |||
5 | def text(file): | ||
6 | return { | ||
7 | "svn:eol-style" : "native" | ||
8 | } | ||
9 | |||
10 | def script(file): | ||
11 | return { | ||
12 | "svn:eol-style" : "native", | ||
13 | "svn:executable" : "*" | ||
14 | } | ||
15 | |||
16 | def executable(file): | ||
17 | return { | ||
18 | "svn:executable" : "*", | ||
19 | "svn:mime-type" : "application/octet-stream" | ||
20 | } | ||
21 | |||
22 | def binary(file): | ||
23 | return { | ||
24 | "svn:mime-type" : "application/octet-stream" | ||
25 | } | ||
26 | |||
27 | def is_binary(file): | ||
28 | f = open(file) | ||
29 | data = f.read() | ||
30 | f.close() | ||
31 | |||
32 | for c in data: | ||
33 | if c not in string.printable: | ||
34 | return True | ||
35 | return False | ||
36 | |||
37 | def binary_or_text(file): | ||
38 | if is_binary(file): | ||
39 | return binary(file) | ||
40 | else: | ||
41 | return text(file) | ||
42 | |||
43 | property_map = { | ||
44 | ".bat" : script, | ||
45 | ".build" : text, | ||
46 | ".cfg" : text, | ||
47 | ".cgi" : text, | ||
48 | ".conf" : text, | ||
49 | ".config" : text, | ||
50 | ".cs" : text, | ||
51 | ".csproj" : text, | ||
52 | ".dat" : binary_or_text, | ||
53 | ".dll" : binary, | ||
54 | ".dylib" : binary, | ||
55 | ".example" : text, | ||
56 | ".exe" : executable, | ||
57 | ".fxcop" : text, | ||
58 | ".hgignore" : text, | ||
59 | ".ico" : binary, | ||
60 | ".include" : text, | ||
61 | ".ini" : text, | ||
62 | ".j2c" : binary, | ||
63 | ".jp2" : binary, | ||
64 | ".lsl" : text, | ||
65 | ".mdp" : text, | ||
66 | ".mds" : text, | ||
67 | ".nsi" : text, | ||
68 | ".ogg" : binary, | ||
69 | ".pdb" : binary, | ||
70 | ".php" : script, | ||
71 | ".pidb" : binary, | ||
72 | ".pl" : script, | ||
73 | ".plist" : text, | ||
74 | ".pm" : text, | ||
75 | ".png" : binary, | ||
76 | ".py" : script, | ||
77 | ".rb" : script, | ||
78 | ".resx" : text, | ||
79 | ".settings" : text, | ||
80 | ".stetic" : text, | ||
81 | ".sh" : script, | ||
82 | ".snk" : binary, | ||
83 | ".so" : binary, | ||
84 | ".sql" : text, | ||
85 | ".txt" : text, | ||
86 | ".user" : text, | ||
87 | ".userprefs" : text, | ||
88 | ".usertasks" : text, | ||
89 | ".xml" : text, | ||
90 | ".xsd" : text | ||
91 | } | ||
92 | |||
93 | def propset(file, property, value): | ||
94 | os.system('svn propset %s "%s" "%s"' % (property, value, file)) | ||
95 | |||
96 | def propdel(file, property): | ||
97 | os.system('svn propdel %s "%s"' % (property, file)) | ||
98 | |||
99 | def propget(file, property): | ||
100 | output, input, error = popen2.popen3('svn propget %s "%s"' % (property, file)) | ||
101 | |||
102 | err = error.read() | ||
103 | if err != "": | ||
104 | output.close() | ||
105 | error.close() | ||
106 | input.close() | ||
107 | return "" | ||
108 | |||
109 | result = output.read() | ||
110 | output.close() | ||
111 | error.close() | ||
112 | input.close() | ||
113 | return result.strip() | ||
114 | |||
115 | def proplist(file): | ||
116 | output, input, error = popen2.popen3('svn proplist "%s"' % file) | ||
117 | |||
118 | err = error.read() | ||
119 | if err != "": | ||
120 | output.close() | ||
121 | error.close() | ||
122 | input.close() | ||
123 | return None | ||
124 | |||
125 | result = output.readlines() | ||
126 | output.close() | ||
127 | error.close() | ||
128 | input.close() | ||
129 | if len(result) > 0 and re.match("^Properties on .*:$", result[0]) is not None: | ||
130 | return [r.strip() for r in result[1:]] | ||
131 | else: | ||
132 | return "" | ||
133 | |||
134 | def update_file(file, properties, ignorelist): | ||
135 | current_props = proplist(file) | ||
136 | |||
137 | if current_props is None: | ||
138 | # svn error occurred -- probably an unversioned file | ||
139 | return | ||
140 | |||
141 | for p in current_props: | ||
142 | if p not in ignorelist and not properties.has_key(p): | ||
143 | propdel(file, p) | ||
144 | |||
145 | for p in properties: | ||
146 | if p not in current_props or propget(file, p) != properties[p]: | ||
147 | propset(file, p, properties[p]) | ||
148 | |||
149 | def update(dir, ignorelist): | ||
150 | for f in os.listdir(dir): | ||
151 | fullpath = os.path.join(dir, f) | ||
152 | if os.path.isdir(fullpath): | ||
153 | if not os.path.islink(fullpath): | ||
154 | update(fullpath, ignorelist) | ||
155 | else: | ||
156 | extension = os.path.splitext(fullpath)[1].lower() | ||
157 | if property_map.has_key(extension): | ||
158 | update_file(fullpath, property_map[extension](fullpath), ignorelist) | ||
159 | elif extension != "" and proplist(fullpath) is not None: | ||
160 | print "Warning: No properties defined for %s files (%s)" % (extension, fullpath) | ||
161 | |||
162 | def main(argv = None): | ||
163 | if argv is None: | ||
164 | argv = sys.argv | ||
165 | |||
166 | ignorelist = ("svn:keywords",) | ||
167 | |||
168 | update(".", ignorelist) | ||
169 | |||
170 | if __name__ == "__main__": | ||
171 | sys.exit(main()) | ||