Mercurial > mxe-octave
annotate tools/msys2-install.py @ 5545:78a98ff1efd8
configure.ac: Default USE_SYSTEM_OCTAVE to MXE_NATIVE_BUILD (bug #49503).
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Fri, 02 Oct 2020 13:54:27 +0200 |
parents | 898c27394c57 |
children | 602265d1c653 |
rev | line source |
---|---|
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
1 #!/usr/bin/python3 |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
2 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
3 import sys |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
4 import os |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
5 import re |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
6 import tempfile |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
7 import shutil |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
8 import fnmatch |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
9 import subprocess |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
10 import glob |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
11 import calendar; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
12 import time; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
13 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
14 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
15 class Env: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
16 verbose = True; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
17 tmp = "/tmp"; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
18 msysdir = "/tmp/msys3"; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
19 tar = "tar"; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
20 cleanup = False; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
21 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
22 def read_options_file(optfile): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
23 with open(optfile, 'r') as f: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
24 lines = f.read().splitlines() |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
25 #d = dict(s.split(' = ',1) for s in lines if s.find(' = ') != -1) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
26 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
27 x = {} |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
28 for s in lines: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
29 if s.find(' = ') != -1: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
30 v = s.split(' = ',1) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
31 if not v[0] in x: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
32 x[v[0]] = [] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
33 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
34 x[v[0]].append(v[1]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
35 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
36 return x |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
37 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
38 def save_list_file(listfile, values, hdr): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
39 with open(listfile, 'wt') as f: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
40 if hdr: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
41 f.write(hdr + "\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
42 for v in values: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
43 f.write(v + "\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
44 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
45 pkg= {'license': 'GPL', 'replaces': 'pacman-contrib', 'pkgname': 'pacman', 'builddate': '1532933269', 'pkgdesc': 'A library-based package manager with dependency support (MSYS2 port)', 'checkdepend': 'python2', 'url': 'https://www.archlinux.org/pacman/', 'backup': 'etc/makepkg_mingw64.conf', 'makedepend': 'libunistring-devel', 'depend': 'xz', 'pkgbase': 'pacman', 'optdepend': 'vim', 'provides': 'pacman-contrib', 'group': 'base-devel', 'packager': 'Alexey Pavlov <alexpux@gmail.com>', 'size': '47739904', 'arch': 'i686', 'conflict': 'pacman-contrib', 'pkgver': '5.1.1-2'} |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
46 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
47 def save_desc_file(descfile, pkginfo): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
48 with open(descfile, 'wt') as f: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
49 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
50 f.write("%NAME%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
51 v = pkginfo.get('pkgname',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
52 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
53 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
54 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
55 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
56 f.write("%VERSION%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
57 v = pkginfo.get('pkgver',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
58 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
59 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
60 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
61 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
62 f.write("%DESC%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
63 v = pkginfo.get('pkgdesc',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
64 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
65 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
66 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
67 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
68 f.write("%ARCH%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
69 v = pkginfo.get('arch',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
70 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
71 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
72 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
73 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
74 f.write("%BUILDDATE%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
75 v = pkginfo.get('builddate',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
76 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
77 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
78 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
79 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
80 t = calendar.timegm(time.gmtime()) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
81 f.write("%INSTALLDATE%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
82 f.write(str(t) + "\n\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
83 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
84 f.write("%PACKAGER%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
85 v = pkginfo.get('packager', []) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
86 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
87 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
88 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
89 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
90 f.write("%SIZE%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
91 v = pkginfo.get('size',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
92 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
93 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
94 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
95 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
96 f.write("%GROUPS%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
97 v = pkginfo.get('group',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
98 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
99 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
100 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
101 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
102 f.write("%LICENSE%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
103 v = pkginfo.get('license',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
104 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
105 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
106 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
107 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
108 f.write("%VALIDATION%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
109 v = pkginfo.get('validation',['pgp']) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
110 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
111 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
112 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
113 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
114 f.write("%REPLACES%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
115 v = pkginfo.get('replaces',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
116 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
117 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
118 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
119 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
120 f.write("%DEPENDS%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
121 v = pkginfo.get('depend', []) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
122 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
123 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
124 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
125 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
126 f.write("%OPTDEPENDS%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
127 v = pkginfo.get('optdepend',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
128 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
129 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
130 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
131 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
132 f.write("%CONFLICTS%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
133 v = pkginfo.get('conflict',[]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
134 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
135 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
136 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
137 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
138 f.write("%PROVIDES%\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
139 v = pkginfo.get('provides', []) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
140 for l in v: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
141 f.write(l+"\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
142 f.write("\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
143 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
144 def create_msys_dirs(sysdir): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
145 if os.path.exists(sysdir) == False: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
146 os.makedirs(sysdir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
147 if os.path.exists(sysdir + "/var/lib/pacman/local") == False: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
148 os.makedirs(sysdir + "/var/lib/pacman/local") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
149 # db file |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
150 if os.path.exists(sysdir + "/var/lib/pacman/local/ALPM_DB_VERSION") == False: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
151 with open(sysdir + "/var/lib/pacman/local/ALPM_DB_VERSION", 'wt') as f: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
152 f.write("9\n") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
153 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
154 def uninstall_pkg(pkgname, env): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
155 pkgpath = env.msysdir + "/var/lib/pacman/local/" |
5361
1cbfb3375099
* tools/msys2-install.py: better attempt to get pk info directory for a name
John Donoghue <john.donoghue@ieee.org>
parents:
5247
diff
changeset
|
156 files=glob.glob(pkgpath + pkgname + "-" + "[r0-9].*") |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
157 for f in files: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
158 if env.verbose: |
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
159 print ("uninstalling " + f) |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
160 shutil.rmtree(f) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
161 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
162 def install_pkg(pkg, env): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
163 pkg = os.path.abspath(pkg) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
164 currdir = os.getcwd() |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
165 status = 0 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
166 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
167 try: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
168 ## Check that the directory in prefix exist. If it doesn't: create it! |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
169 tmpdir = tempfile.mkdtemp("-pkg","tmp", env.tmp) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
170 if env.verbose: |
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
171 print ("using tempdir ", tmpdir) |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
172 os.chdir(tmpdir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
173 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
174 # unpack dir |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
175 if env.verbose: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
176 os.system(env.tar + " xvpf '" + pkg + "'") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
177 else: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
178 os.system(env.tar + " xpf '" + pkg + "'") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
179 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
180 pkginfo = read_options_file(tmpdir + '/.PKGINFO') |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
181 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
182 # uninstall prev versions |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
183 uninstall_pkg(pkginfo.get('pkgname')[0], env) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
184 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
185 # copy files to dest |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
186 filelist = [] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
187 tmplen = len(tmpdir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
188 if not tmpdir.endswith('/'): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
189 tmplen = tmplen + 1 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
190 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
191 for root, dirs, files in os.walk(tmpdir): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
192 for dir in dirs: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
193 fullpath = os.path.join(root, dir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
194 fullpath = fullpath[tmplen:] + "/" |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
195 filelist.append(fullpath) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
196 if os.path.exists(env.msysdir + "/" + fullpath) == False: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
197 os.makedirs(env.msysdir + "/" + fullpath) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
198 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
199 for file in files: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
200 if not file.startswith('.'): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
201 fullpath = os.path.join(root, file) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
202 fullpath = fullpath[tmplen:] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
203 filelist.append(fullpath) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
204 if env.verbose: |
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
205 print ("installing " + fullpath) |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
206 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
207 # dele old file fo can copy new with perms (if ld file would allow write) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
208 if os.path.isfile(env.msysdir + "/" + fullpath): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
209 os.remove(env.msysdir + "/" + fullpath) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
210 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
211 shutil.copy2(os.path.join(root, file), env.msysdir + "/" + fullpath) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
212 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
213 if env.verbose: |
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
214 print ("creating package files") |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
215 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
216 # create pkg files needed |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
217 pkg_name_ver = pkginfo.get('pkgname', [''])[0] + "-" + pkginfo.get('pkgver',[''])[0] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
218 pkg_info_dir = env.msysdir + "/var/lib/pacman/local/" + pkg_name_ver |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
219 if os.path.exists(pkg_info_dir) == False: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
220 os.makedirs(pkg_info_dir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
221 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
222 save_list_file (pkg_info_dir + "/files", filelist, "%FILES%") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
223 save_desc_file (pkg_info_dir + "/desc", pkginfo) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
224 shutil.copy2(tmpdir + "/.MTREE", pkg_info_dir + "/mtree") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
225 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
226 finally: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
227 if env.verbose: |
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
228 print ("cleaning up") |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
229 os.chdir(currdir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
230 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
231 if env.cleanup: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
232 shutil.rmtree(tmpdir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
233 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
234 return status |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
235 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
236 def install (args): |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
237 env = Env() |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
238 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
239 files = [] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
240 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
241 for a in args: |
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
242 print ("{}".format(a)) |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
243 c=a.split("=") |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
244 key=c[0] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
245 if len(c) > 1: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
246 val=c[1] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
247 else: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
248 val="" |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
249 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
250 if key == "--verbose": |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
251 env.verbose = True; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
252 elif key == "-no-cleanup": |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
253 env.cleanup = False; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
254 elif key == "--msys-dir": |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
255 if val: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
256 env.msysdir = val; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
257 elif val == "": |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
258 files.append(key) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
259 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
260 # set up env |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
261 if os.environ.get("TMP") != None: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
262 env.tmp = os.environ["TMP"] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
263 os.environ['TMP'] = env.tmp; |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
264 if os.environ.get("TAR") != None: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
265 env.tar = os.environ["TAR"] |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
266 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
267 create_msys_dirs(env.msysdir) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
268 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
269 status = 0 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
270 for a in files: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
271 status = install_pkg(a, env) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
272 if status != 0: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
273 break |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
274 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
275 return status |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
276 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
277 def show_usage(): |
5494
898c27394c57
Use python3 in scripts (bug #58689).
John Donoghue <john.donoghue@ieee.org>
parents:
5361
diff
changeset
|
278 print (sys.argv[0], "[options] pkg1 [pkg2]") |
4793
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
279 |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
280 if __name__ == "__main__": |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
281 if len(sys.argv) > 1: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
282 status = install(sys.argv[1:]) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
283 sys.exit(status) |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
284 else: |
202fa20cf559
add msys2 environment/tools option, use seprate post-install script to finalize install
John Donoghue
parents:
diff
changeset
|
285 show_usage() |