16
16
# [bialix]: bzr de-facto does not support win98.
17
17
# Although it seems to work on. Sometimes.
18
# 2006/07/30 added minimal support of win98.
19
# 2007/01/30 added *real* support of win98.
25
from bzrlib import win32utils
28
def _quoted_path(path):
30
return '"' + path + '"'
34
def _win_batch_args():
35
if win32utils.winver == 'Windows NT':
38
return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
41
if "-install" in sys.argv[1:]:
22
if len(sys.argv) == 2 and sys.argv[1] == "-install":
42
23
# try to detect version number automatically
51
32
# XXX change message for something more appropriate
54
35
Congratulation! Bzr successfully installed.
58
39
batch_path = "bzr.bat"
59
prefix = sys.exec_prefix
63
44
scripts_dir = os.path.join(prefix, "Scripts")
64
script_path = _quoted_path(os.path.join(scripts_dir, "bzr"))
65
python_path = _quoted_path(os.path.join(prefix, "python.exe"))
66
args = _win_batch_args()
67
batch_str = "@%s %s %s" % (python_path, script_path, args)
69
# if there is no HOME for bzr then set it for Bazaar manually
70
base = os.environ.get('BZR_HOME', None)
72
base = win32utils.get_appdata_location()
74
base = os.environ.get('HOME', None)
76
base = os.path.splitdrive(sys.prefix)[0] + '\\'
77
batch_str = ("@SET BZR_HOME=" + _quoted_path(base) + "\n" +
80
batch_path = os.path.join(scripts_dir, "bzr.bat")
45
script_path = os.path.join(scripts_dir, "bzr")
46
python_path = os.path.join(prefix, "python.exe")
47
batch_str = "@%s %s %%*\n" % (python_path, script_path)
48
batch_path = script_path + ".bat"
81
49
f = file(batch_path, "w")
89
57
print "Use this batch file to run bzr"
90
58
except Exception, e:
91
59
print "ERROR: Unable to create %s: %s" % (batch_path, e)
93
## this hunk borrowed from pywin32_postinstall.py
94
# use bdist_wininst builtins to create a shortcut.
95
# CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and
96
# will fail there if the user has no admin rights.
97
if get_root_hkey()==_winreg.HKEY_LOCAL_MACHINE:
99
fldr = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
101
# No CSIDL_COMMON_PROGRAMS on this platform
102
fldr = get_special_folder_path("CSIDL_PROGRAMS")
104
# non-admin install - always goes in this user's start menu.
105
fldr = get_special_folder_path("CSIDL_PROGRAMS")
108
fldr = os.path.join(fldr, 'Bazaar')
109
if not os.path.isdir(fldr):
111
directory_created(fldr)
113
# link to documentation
114
docs = os.path.join(sys.exec_prefix, 'Doc', 'Bazaar', 'index.html')
115
dst = os.path.join(fldr, 'Documentation.lnk')
116
create_shortcut(docs, 'Bazaar Documentation', dst)
118
print 'Documentation for Bazaar: Start => Programs => Bazaar'
122
cmd = os.environ.get('COMSPEC', 'cmd.exe')
125
# minimal support of win98
126
cmd = os.environ.get('COMSPEC', 'command.com')
128
dst = os.path.join(fldr, 'Start bzr.lnk')
130
'Start bzr in cmd shell',
133
os.path.join(sys.exec_prefix, 'Scripts'))
137
uninst = os.path.join(sys.exec_prefix, 'Removebzr.exe')
138
dst = os.path.join(fldr, 'Uninstall Bazaar.lnk')
139
create_shortcut(uninst,
142
'-u bzr-wininst.log',