1
1
# (c) Canonical Ltd, 2006
2
# written by Alexander Belchenko for brz project
2
# written by Alexander Belchenko for bzr project
4
# This script will be executed after installation of breezy package
4
# This script will be executed after installation of brzlib package
5
5
# and before installer exits.
6
6
# All printed data will appear on the last screen of installation
8
8
# The main goal of this script is to create special batch file
9
# launcher for brz. Typical content of this batch file is:
9
# launcher for bzr. Typical content of this batch file is:
12
12
# This file works only on Windows 2000/XP. For win98 there is
13
13
# should be "%1 %2 %3 %4 %5 %6 %7 %8 %9" instead of "%*".
14
14
# Or even more complex thing.
16
# [bialix]: brz de-facto does not support win98.
16
# [bialix]: bzr de-facto does not support win98.
17
17
# Although it seems to work on. Sometimes.
18
18
# 2006/07/30 added minimal support of win98.
19
19
# 2007/01/30 added *real* support of win98.
41
41
if "-install" in sys.argv[1:]:
42
42
# try to detect version number automatically
45
45
except ImportError:
48
ver = breezy.__version__
48
ver = brzlib.__version__
51
51
# XXX change message for something more appropriate
54
Congratulation! Brz successfully installed.
58
batch_path = "brz.bat"
54
Congratulation! Bzr successfully installed.
58
batch_path = "bzr.bat"
59
59
prefix = sys.exec_prefix
63
63
scripts_dir = os.path.join(prefix, "Scripts")
64
script_path = _quoted_path(os.path.join(scripts_dir, "brz"))
64
script_path = _quoted_path(os.path.join(scripts_dir, "bzr"))
65
65
python_path = _quoted_path(os.path.join(prefix, "python.exe"))
66
66
args = _win_batch_args()
67
67
batch_str = "@%s %s %s" % (python_path, script_path, args)
69
# if there is no HOME for brz then set it for Breezy manually
70
base = os.environ.get('brz_HOME', None)
69
# if there is no HOME for bzr then set it for Bazaar manually
70
base = os.environ.get('BZR_HOME', None)
72
72
base = win32utils.get_appdata_location()
74
74
base = os.environ.get('HOME', None)
76
76
base = os.path.splitdrive(sys.prefix)[0] + '\\'
77
batch_str = ("@SET brz_HOME=" + _quoted_path(base) + "\n" +
77
batch_str = ("@SET BZR_HOME=" + _quoted_path(base) + "\n" +
80
batch_path = os.path.join(scripts_dir, "brz.bat")
81
with open(batch_path, "w") as f:
83
# registering manually created files for auto-deinstallation procedure
84
file_created(batch_path)
80
batch_path = os.path.join(scripts_dir, "bzr.bat")
81
f = file(batch_path, "w")
84
file_created(batch_path) # registering manually created files for
85
# auto-deinstallation procedure
86
87
# inform user where batch launcher is.
87
print("Created:", batch_path)
88
print("Use this batch file to run brz")
89
except Exception as e:
90
print("ERROR: Unable to create %s: %s" % (batch_path, e))
88
print "Created:", batch_path
89
print "Use this batch file to run bzr"
91
print "ERROR: Unable to create %s: %s" % (batch_path, e)
92
93
## this hunk borrowed from pywin32_postinstall.py
93
94
# use bdist_wininst builtins to create a shortcut.
94
95
# CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and
95
96
# will fail there if the user has no admin rights.
96
if get_root_hkey() == _winreg.HKEY_LOCAL_MACHINE:
97
if get_root_hkey()==_winreg.HKEY_LOCAL_MACHINE:
98
99
fldr = get_special_folder_path("CSIDL_COMMON_PROGRAMS")
103
104
# non-admin install - always goes in this user's start menu.
104
105
fldr = get_special_folder_path("CSIDL_PROGRAMS")
107
fldr = os.path.join(fldr, 'Breezy')
108
fldr = os.path.join(fldr, 'Bazaar')
108
109
if not os.path.isdir(fldr):
110
111
directory_created(fldr)
112
113
# link to documentation
113
docs = os.path.join(sys.exec_prefix, 'Doc', 'Breezy', 'index.html')
114
docs = os.path.join(sys.exec_prefix, 'Doc', 'Bazaar', 'index.html')
114
115
dst = os.path.join(fldr, 'Documentation.lnk')
115
create_shortcut(docs, 'Breezy Documentation', dst)
116
create_shortcut(docs, 'Bazaar Documentation', dst)
116
117
file_created(dst)
117
print('Documentation for Breezy: Start => Programs => Breezy')
118
print 'Documentation for Bazaar: Start => Programs => Bazaar'
120
121
if os.name == 'nt':
121
122
cmd = os.environ.get('COMSPEC', 'cmd.exe')
124
125
# minimal support of win98
125
126
cmd = os.environ.get('COMSPEC', 'command.com')
127
dst = os.path.join(fldr, 'Start brz.lnk')
128
dst = os.path.join(fldr, 'Start bzr.lnk')
128
129
create_shortcut(cmd,
129
'Start brz in cmd shell',
130
'Start bzr in cmd shell',
132
133
os.path.join(sys.exec_prefix, 'Scripts'))
133
134
file_created(dst)
135
136
# uninstall shortcut
136
uninst = os.path.join(sys.exec_prefix, 'Removebrz.exe')
137
dst = os.path.join(fldr, 'Uninstall Breezy.lnk')
137
uninst = os.path.join(sys.exec_prefix, 'Removebzr.exe')
138
dst = os.path.join(fldr, 'Uninstall Bazaar.lnk')
138
139
create_shortcut(uninst,
141
'-u brz-wininst.log',
142
'-u bzr-wininst.log',
144
145
file_created(dst)