annotate nt/installer/Wise/pre_wise.py @ 2479:0b63b42e826c

[xemacs-hg @ 2005-01-13 22:53:17 by viteno] Update xemacs_extra_name.
author viteno
date Thu, 13 Jan 2005 22:53:17 +0000
parents a268de273009
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2370
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
1 import string
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
2 import re
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
3 import os
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
4 import types
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
5
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
6 infile=open("xemacs.tmpl","r")
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
7
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
8 import version
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
9 import dirs
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
10 import filelist
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
11 import packages
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
12
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
13 def letter(package):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
14 index = packages.all.index(package)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
15 if index>29:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
16 raise "WISE error: too many components"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
17 return chr(ord("A")+index)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
18
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
19 def letters(package_list):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
20 ret = ""
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
21 for p in package_list:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
22 ret = ret+letter(p)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
23 return ret
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
24
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
25 def describe(package):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
26 if package in packages.descriptions.keys():
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
27 return ": "+packages.descriptions[package]
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
28 else: return ""
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
29
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
30 def ifblock(var,val):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
31 return("item: If/While Statement\n Variable=%s\n Value=%s\n Flags=00001010\nend\n" % (var,val))
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
32
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
33 def endblock():
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
34 return("item: End Block\nend\n")
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
35
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
36 def setvar(var,val):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
37 return("item: Set Variable\n Variable=%s\n Value=%s\n Flags=10000000\nend\n" % (string.upper(var), val))
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
38
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
39 def default_letters_of_category(cat):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
40 val = ""
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
41 for p in packages.default:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
42 if packages.category_of_package(p) == cat:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
43 val = val + packages.letter_of_package(p)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
44 return val
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
45
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
46 def set_category_defaults():
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
47 ret = ""
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
48 for c in packages.category_names:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
49 ret = ret + setvar(c, default_letters_of_category(c))
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
50 return ret
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
51
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
52 def do_category(cat):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
53 ret = ifblock("COMPONENTS", packages.letter_of_category(cat))
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
54 for pkg in packages.packages_of_category(cat):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
55 ret = ret + ifblock(string.upper(cat),packages.letter_of_package(pkg))
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
56 for f in files_of_package(pkg):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
57 ret = ret+install_pkg_file(f)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
58 ret = ret + endblock()
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
59 ret = ret + endblock()
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
60 return ret
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
61
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
62 def files_of_package(package):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
63 manifest_file = dirs.packages + "\\pkginfo\\MANIFEST." + package
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
64 manifest = open(manifest_file,"r")
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
65 lines = manifest.readlines()
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
66 lines = map(lambda s:s[:-1], lines)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
67 lines = map(lambda s:string.replace(s,'/','\\'), lines)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
68 return lines
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
69
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
70 def category_dialog(cat):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
71 npkg = len(packages.packages_of_category(cat))
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
72 ret=""
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
73 ret=ret+" item: Dialog\n Title="+packages.category_descriptions[cat]+" Packages\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
74 ret=ret+" Width=210\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
75 ret=ret+" Height=%d\n" % (45+npkg*10)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
76 ret=ret+" Font Name=Helv\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
77 ret=ret+" Font Size=8\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
78 ret=ret+" item: Push Button\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
79 ret=ret+" Rectangle=107 %d 147 %d\n" % (5+npkg*10+2, 5+npkg*10+17)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
80 ret=ret+" Create Flags=01010000000000010000000000000001\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
81 ret=ret+" Text=OK\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
82 ret=ret+" end\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
83 ret=ret+" item: Push Button\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
84 ret=ret+" Rectangle=153 %d 193 %d\n" % (5+npkg*10+2, 5+npkg*10+17)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
85 ret=ret+" Variable=%s\n" % string.upper(cat)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
86 ret=ret+" Value=%%%s_SAVE%%\n" % string.upper(cat)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
87 ret=ret+" Create Flags=01010000000000010000000000000000\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
88 ret=ret+" Flags=0000000000000001\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
89 ret=ret+" Text=Cancel\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
90 ret=ret+" end\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
91 ret=ret+" item: Checkbox\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
92 ret=ret+" Rectangle=0 5 191 %d\n" % (10*npkg)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
93 ret=ret+" Variable=%s\n"%string.upper(cat)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
94 ret=ret+" Create Flags=01010000000000010000000000000011\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
95 ret=ret+" Flags=0000000000000010\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
96 for pkg in packages.packages_of_category(cat):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
97 ret = ret+" Text=%s: %s\n"%( pkg, packages.package_descriptions[pkg])
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
98 ret=ret+" Text=\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
99 ret=ret+" end\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
100 ret=ret+" end\n"
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
101 return ret
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
102
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
103 def src_path(src,name):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
104 return src + "\\" + name
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
105
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
106 def dst_path(dst,name):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
107 return "%MAINDIR%"+"\\"+dst+"\\" + name
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
108
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
109 def install_file(name,src,dst):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
110 return("item: Install File\n Source=%s\n Destination=%s\n Flags=0000000010000010\nend\n" % (src_path(src,name),dst_path(dst,name)))
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
111
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
112 def install_pkg_file(name):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
113 return install_file(name,dirs.packages,dirs.pkg_dst)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
114
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
115 def do_package(package):
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
116 return ifblock("COMPONENTS",letter(package)) + \
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
117 string.join(map(install_pkg_file,files(package)),"")+ \
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
118 endblock()
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
119
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
120 for line in infile.readlines():
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
121 left=string.find(line,"<<<")
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
122 if left>=0:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
123 right=string.find(line,">>>")
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
124 expr=line[left+3:right]
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
125 val=eval(expr)
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
126 if type(val)==types.StringType:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
127 print line[:left] + val + line[right+3:],
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
128 elif type(val)==types.ListType:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
129 for v in val:
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
130 print line[:left] + v + line[right+3:],
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
131 else: print line,
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
132
a268de273009 [xemacs-hg @ 2004-11-05 23:11:42 by ben]
ben
parents: 398
diff changeset
133