File: gen_inst_uninst_list.py

package info (click to toggle)
glob2 0.9.3-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 32,464 kB
  • ctags: 8,802
  • sloc: cpp: 77,112; python: 797; ansic: 154; makefile: 57; sh: 49
file content (58 lines) | stat: -rw-r--r-- 1,483 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys, os, glob

#
# FUNCTION TAKEN FROM http://nsis.sourceforge.net/Talk:Uninstall_only_installed_files
#
def open_file_for_writting(filename):
    "return a handle to the file to write to"
    try:
        h = file(filename, "w")
    except:
        print "Problem opening file %s for writting"%filename
        print __doc__
        sys.exit(1)
    return h

#
# OPEN FILES
#
install_list = open_file_for_writting("windows/install_list.nsh")
uninstall_list = open_file_for_writting("windows/uninstall_list.nsh")

#
# PREPARE ARRAY FOR UNINSTALL LIST
#
folder_list = []
file_list = []

#
# INSTALL LIST
#
for path,dirs,files in list(os.walk('data')) + list(os.walk('maps')) + list(os.walk('campaigns')) + list(os.walk('scripts')):
	print >> install_list, "SetOutPath $INSTDIR\\" + path
	folder_list.append(path)
	for f in files:
		if (f != "SConscript" and f != "SConstruct"):
			print >> install_list, "File ..\\"+path+"\\"+f
			file_list.append(path+"\\"+f)
print >> install_list, "SetOutPath $INSTDIR"
for file in list(os.listdir('./')):
	 if (file.find(".dll") != -1):
		print >> install_list, "File ..\\"+file
		file_list.append(file)

#
# UNINSTALL LIST
#
file_list.reverse()
for file in file_list:
	print >> uninstall_list, "Delete $INSTDIR\\"+file
folder_list.reverse()
for folder in folder_list:
	print >> uninstall_list, "RMDir $INSTDIR\\"+folder

#
# CLOSE FILES
#
install_list.close()
uninstall_list.close()