Mercurial > mxe-octave
comparison tools/msys2-install.py @ 5494:898c27394c57
Use python3 in scripts (bug #58689).
* Makefile.in: native mingw, depend on python3, set PYTHON3 var
* tools/msys2-install.py: update for python3 syntax
* tools/pkg-install.py: update for python3 syntax
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sat, 04 Jul 2020 12:14:29 -0400 |
parents | 1cbfb3375099 |
children | 602265d1c653 |
comparison
equal
deleted
inserted
replaced
5493:dace3d372190 | 5494:898c27394c57 |
---|---|
1 #!/usr/bin/python2 | 1 #!/usr/bin/python3 |
2 | 2 |
3 import sys | 3 import sys |
4 import os | 4 import os |
5 import re | 5 import re |
6 import tempfile | 6 import tempfile |
154 def uninstall_pkg(pkgname, env): | 154 def uninstall_pkg(pkgname, env): |
155 pkgpath = env.msysdir + "/var/lib/pacman/local/" | 155 pkgpath = env.msysdir + "/var/lib/pacman/local/" |
156 files=glob.glob(pkgpath + pkgname + "-" + "[r0-9].*") | 156 files=glob.glob(pkgpath + pkgname + "-" + "[r0-9].*") |
157 for f in files: | 157 for f in files: |
158 if env.verbose: | 158 if env.verbose: |
159 print "uninstalling " + f | 159 print ("uninstalling " + f) |
160 shutil.rmtree(f) | 160 shutil.rmtree(f) |
161 | 161 |
162 def install_pkg(pkg, env): | 162 def install_pkg(pkg, env): |
163 pkg = os.path.abspath(pkg) | 163 pkg = os.path.abspath(pkg) |
164 currdir = os.getcwd() | 164 currdir = os.getcwd() |
166 | 166 |
167 try: | 167 try: |
168 ## Check that the directory in prefix exist. If it doesn't: create it! | 168 ## Check that the directory in prefix exist. If it doesn't: create it! |
169 tmpdir = tempfile.mkdtemp("-pkg","tmp", env.tmp) | 169 tmpdir = tempfile.mkdtemp("-pkg","tmp", env.tmp) |
170 if env.verbose: | 170 if env.verbose: |
171 print "using tempdir ", tmpdir | 171 print ("using tempdir ", tmpdir) |
172 os.chdir(tmpdir) | 172 os.chdir(tmpdir) |
173 | 173 |
174 # unpack dir | 174 # unpack dir |
175 if env.verbose: | 175 if env.verbose: |
176 os.system(env.tar + " xvpf '" + pkg + "'") | 176 os.system(env.tar + " xvpf '" + pkg + "'") |
200 if not file.startswith('.'): | 200 if not file.startswith('.'): |
201 fullpath = os.path.join(root, file) | 201 fullpath = os.path.join(root, file) |
202 fullpath = fullpath[tmplen:] | 202 fullpath = fullpath[tmplen:] |
203 filelist.append(fullpath) | 203 filelist.append(fullpath) |
204 if env.verbose: | 204 if env.verbose: |
205 print "installing " + fullpath | 205 print ("installing " + fullpath) |
206 | 206 |
207 # dele old file fo can copy new with perms (if ld file would allow write) | 207 # dele old file fo can copy new with perms (if ld file would allow write) |
208 if os.path.isfile(env.msysdir + "/" + fullpath): | 208 if os.path.isfile(env.msysdir + "/" + fullpath): |
209 os.remove(env.msysdir + "/" + fullpath) | 209 os.remove(env.msysdir + "/" + fullpath) |
210 | 210 |
211 shutil.copy2(os.path.join(root, file), env.msysdir + "/" + fullpath) | 211 shutil.copy2(os.path.join(root, file), env.msysdir + "/" + fullpath) |
212 | 212 |
213 if env.verbose: | 213 if env.verbose: |
214 print "creating package files" | 214 print ("creating package files") |
215 | 215 |
216 # create pkg files needed | 216 # create pkg files needed |
217 pkg_name_ver = pkginfo.get('pkgname', [''])[0] + "-" + pkginfo.get('pkgver',[''])[0] | 217 pkg_name_ver = pkginfo.get('pkgname', [''])[0] + "-" + pkginfo.get('pkgver',[''])[0] |
218 pkg_info_dir = env.msysdir + "/var/lib/pacman/local/" + pkg_name_ver | 218 pkg_info_dir = env.msysdir + "/var/lib/pacman/local/" + pkg_name_ver |
219 if os.path.exists(pkg_info_dir) == False: | 219 if os.path.exists(pkg_info_dir) == False: |
223 save_desc_file (pkg_info_dir + "/desc", pkginfo) | 223 save_desc_file (pkg_info_dir + "/desc", pkginfo) |
224 shutil.copy2(tmpdir + "/.MTREE", pkg_info_dir + "/mtree") | 224 shutil.copy2(tmpdir + "/.MTREE", pkg_info_dir + "/mtree") |
225 | 225 |
226 finally: | 226 finally: |
227 if env.verbose: | 227 if env.verbose: |
228 print "cleaning up" | 228 print ("cleaning up") |
229 os.chdir(currdir) | 229 os.chdir(currdir) |
230 | 230 |
231 if env.cleanup: | 231 if env.cleanup: |
232 shutil.rmtree(tmpdir) | 232 shutil.rmtree(tmpdir) |
233 | 233 |
237 env = Env() | 237 env = Env() |
238 | 238 |
239 files = [] | 239 files = [] |
240 | 240 |
241 for a in args: | 241 for a in args: |
242 print a | 242 print ("{}".format(a)) |
243 c=a.split("=") | 243 c=a.split("=") |
244 key=c[0] | 244 key=c[0] |
245 if len(c) > 1: | 245 if len(c) > 1: |
246 val=c[1] | 246 val=c[1] |
247 else: | 247 else: |
273 break | 273 break |
274 | 274 |
275 return status | 275 return status |
276 | 276 |
277 def show_usage(): | 277 def show_usage(): |
278 print sys.argv[0], "[options] pkg1 [pkg2]" | 278 print (sys.argv[0], "[options] pkg1 [pkg2]") |
279 | 279 |
280 if __name__ == "__main__": | 280 if __name__ == "__main__": |
281 if len(sys.argv) > 1: | 281 if len(sys.argv) > 1: |
282 status = install(sys.argv[1:]) | 282 status = install(sys.argv[1:]) |
283 sys.exit(status) | 283 sys.exit(status) |