CVE-2018-16841 heimdal: Fix segfault on PKINIT with mis-matching principal
[Samba.git] / buildtools / bin / waf-1.9
bloba83a2430ed359302c27b1f3007f271793badd302
1 #!/usr/bin/env python
2 # encoding: ISO8859-1
3 # Thomas Nagy, 2005-2015
5 """
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 3. The name of the author may not be used to endorse or promote products
18 derived from this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
21 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31 """
33 import os, sys, inspect
35 VERSION="1.9.10"
36 REVISION="x"
37 GIT="x"
38 INSTALL=''
39 C1='#>'
40 C2='#6'
41 C3='#4'
42 cwd = os.getcwd()
43 join = os.path.join
46 WAF='waf'
47 def b(x):
48 return x
49 if sys.hexversion>0x300000f:
50 WAF='waf3'
51 def b(x):
52 return x.encode()
54 def err(m):
55 print(('\033[91mError: %s\033[0m' % m))
56 sys.exit(1)
58 def unpack_wafdir(dir, src):
59 f = open(src,'rb')
60 c = 'corrupt archive (%d)'
61 while 1:
62 line = f.readline()
63 if not line: err('run waf-light from a folder containing waflib')
64 if line == b('#==>\n'):
65 txt = f.readline()
66 if not txt: err(c % 1)
67 if f.readline() != b('#<==\n'): err(c % 2)
68 break
69 if not txt: err(c % 3)
70 txt = txt[1:-1].replace(b(C1), b('\n')).replace(b(C2), b('\r')).replace(b(C3), b('\x00'))
72 import shutil, tarfile
73 try: shutil.rmtree(dir)
74 except OSError: pass
75 try:
76 for x in ('Tools', 'extras'):
77 os.makedirs(join(dir, 'waflib', x))
78 except OSError:
79 err("Cannot unpack waf lib into %s\nMove waf in a writable directory" % dir)
81 os.chdir(dir)
82 tmp = 't.bz2'
83 t = open(tmp,'wb')
84 try: t.write(txt)
85 finally: t.close()
87 try:
88 t = tarfile.open(tmp)
89 except:
90 try:
91 os.system('bunzip2 t.bz2')
92 t = tarfile.open('t')
93 tmp = 't'
94 except:
95 os.chdir(cwd)
96 try: shutil.rmtree(dir)
97 except OSError: pass
98 err("Waf cannot be unpacked, check that bzip2 support is present")
100 try:
101 for x in t: t.extract(x)
102 finally:
103 t.close()
105 for x in ('Tools', 'extras'):
106 os.chmod(join('waflib',x), 493)
108 if sys.hexversion<0x300000f:
109 sys.path = [join(dir, 'waflib')] + sys.path
110 import fixpy2
111 fixpy2.fixdir(dir)
113 os.remove(tmp)
114 os.chdir(cwd)
116 try: dir = unicode(dir, 'mbcs')
117 except: pass
118 try:
119 from ctypes import windll
120 windll.kernel32.SetFileAttributesW(dir, 2)
121 except:
122 pass
124 def test(dir):
125 try:
126 os.stat(join(dir, 'waflib'))
127 return os.path.abspath(dir)
128 except OSError:
129 pass
131 def find_lib():
132 return os.path.abspath(os.path.join(os.path.dirname(__file__), '../../third_party/waf'))
134 wafdir = find_lib()
135 sys.path.insert(0, wafdir)
137 if __name__ == '__main__':
139 # TODO: remove these when possible
140 from waflib.extras import compat15
141 import sys
143 from waflib.Tools import ccroot, c, ar, compiler_c, gcc
144 sys.modules['cc'] = c
145 sys.modules['ccroot'] = ccroot
146 sys.modules['ar'] = ar
147 sys.modules['compiler_cc'] = compiler_c
148 sys.modules['gcc'] = gcc
150 from waflib import Options
151 Options.lockfile = os.environ.get('WAFLOCK', '.lock-wscript')
152 if os.path.isfile(Options.lockfile) and os.stat(Options.lockfile).st_size == 0:
153 os.environ['NOCLIMB'] = "1"
154 # there is a single top-level, but libraries must build independently
155 os.environ['NO_LOCK_IN_TOP'] = "1"
157 from waflib import Task
158 class o(object):
159 display = None
160 Task.classes['cc_link'] = o
162 from waflib import Scripting
163 Scripting.waf_entry_point(cwd, VERSION, wafdir)