1
# (c) Canonical Ltd, 2006
2
# written by Alexander Belchenko for bzr project
4
# This script will be executed after installation of bzrlib package
5
# and before installer exits.
6
# All printed data will appear on the last screen of installation
8
# The main goal of this script is to create special batch file
9
# launcher for bzr. Typical content of this batch file is:
12
# This file works only on Windows 2000/XP. For win98 there is
13
# should be "%1 %2 %3 %4 %5 %6 %7 %8 %9" instead of "%*".
14
# Or even more complex thing.
16
# [bialix]: bzr de-facto does not support win98.
17
# Although it seems to work on. Sometimes.
24
if len(sys.argv) == 2 and sys.argv[1] == "-install":
25
# try to detect version number automatically
31
ver = bzrlib.__version__
34
# XXX change message for something more appropriate
37
Congratulation! Bzr successfully installed.
41
batch_path = "bzr.bat"
46
scripts_dir = os.path.join(prefix, "Scripts")
47
script_path = os.path.join(scripts_dir, "bzr")
48
python_path = os.path.join(prefix, "python.exe")
49
batch_str = "@%s %s %%*\n" % (python_path, script_path)
50
batch_path = script_path + ".bat"
51
f = file(batch_path, "w")
54
file_created(batch_path) # registering manually created files for
55
# auto-deinstallation procedure
57
# inform user where batch launcher is.
58
print "Created:", batch_path
59
print "Use this batch file to run bzr"
61
print "ERROR: Unable to create %s: %s" % (batch_path, e)
63
# make entry in APPDATA
64
appdata = get_special_folder_path("CSIDL_APPDATA")
65
dst = os.path.join(appdata, "bazaar", "2.0")
66
if not os.path.isdir(dst):
69
print "Configuration files stored in %s" % \
70
dst.encode(locale.getpreferredencoding(), 'replace')
71
# create dummy bazaar.conf
72
f = file(os.path.join(dst,'bazaar.conf'), 'w')
73
f.write("# main configuration file of Bazaar\n"
75
"#email=Your Name <you@domain.com>\n")
78
## this hunk borrowed from pywin32_postinstall.py
79
# use bdist_wininst builtins to create a shortcut.
80
# CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and
81
# will fail there if the user has no admin rights.
82
if get_root_hkey()==_winreg.HKEY_LOCAL_MACHINE:
84
fldr = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
86
# No CSIDL_COMMON_PROGRAMS on this platform
87
fldr = get_special_folder_path("CSIDL_PROGRAMS")
89
# non-admin install - always goes in this user's start menu.
90
fldr = get_special_folder_path("CSIDL_PROGRAMS")
93
fldr = os.path.join(fldr, 'Bazaar')
94
if not os.path.isdir(fldr):
96
directory_created(fldr)
98
# link to documentation
99
docs = os.path.join(sys.exec_prefix, 'Doc', 'Bazaar', 'index.htm')
100
dst = os.path.join(fldr, 'Documentation.lnk')
101
create_shortcut(docs, 'Bazaar Documentation', dst)
103
print 'Documentation for Bazaar: Start => Programs => Bazaar'
106
cmd = os.environ.get('COMSPEC', 'cmd.exe')
107
dst = os.path.join(fldr, 'Start bzr.lnk')
109
'Start bzr in cmd shell',
112
os.path.join(sys.exec_prefix, 'Scripts'))