/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/win32/bzr-win32-bdist-postinstall.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 07:23:36 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730072336-3e9fd7ddb67b5f47
More branding: bazaar-ng -> Bazaar; bazaar-ng.org -> bazaar-vcs.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#
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.
20
18
 
21
19
import os
22
20
import sys
23
21
import _winreg
24
22
 
25
 
from bzrlib import win32utils
26
 
 
27
 
 
28
 
def _quoted_path(path):
29
 
    if ' ' in path:
30
 
        return '"' + path + '"'
31
 
    else:
32
 
        return path
33
 
 
34
 
def _win_batch_args():
35
 
    if win32utils.winver == 'Windows NT':
36
 
        return '%*'
37
 
    else:
38
 
        return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
39
 
 
40
 
 
41
 
if "-install" in sys.argv[1:]:
 
23
 
 
24
if len(sys.argv) == 2 and sys.argv[1] == "-install":
42
25
    # try to detect version number automatically
43
26
    try:
44
27
        import bzrlib
56
39
""" % ver
57
40
 
58
41
    batch_path = "bzr.bat"
59
 
    prefix = sys.exec_prefix
 
42
    prefix = sys.prefix
60
43
    try:
61
44
        ##
62
45
        # try to create
63
46
        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)
68
 
        # support of win98
69
 
        # if there is no HOME for bzr then set it for Bazaar manually
70
 
        base = os.environ.get('BZR_HOME', None)
71
 
        if base is None:
72
 
            base = win32utils.get_appdata_location()
73
 
        if base is None:
74
 
            base = os.environ.get('HOME', None)
75
 
        if base is None:
76
 
            base = os.path.splitdrive(sys.prefix)[0] + '\\'
77
 
            batch_str = ("@SET BZR_HOME=" + _quoted_path(base) + "\n" +
78
 
                         batch_str)
79
 
 
80
 
        batch_path = os.path.join(scripts_dir, "bzr.bat")
 
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"
81
51
        f = file(batch_path, "w")
82
52
        f.write(batch_str)
83
53
        f.close()
90
60
    except Exception, e:
91
61
        print "ERROR: Unable to create %s: %s" % (batch_path, e)
92
62
 
 
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):
 
67
        os.makedirs(dst)
 
68
        import locale
 
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"
 
74
                "[DEFAULT]\n"
 
75
                "#email=Your Name <you@domain.com>\n")
 
76
        f.close()
 
77
 
93
78
    ## this hunk borrowed from pywin32_postinstall.py
94
79
    # use bdist_wininst builtins to create a shortcut.
95
80
    # CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and
111
96
        directory_created(fldr)
112
97
 
113
98
    # link to documentation
114
 
    docs = os.path.join(sys.exec_prefix, 'Doc', 'Bazaar', 'index.html')
 
99
    docs = os.path.join(sys.exec_prefix, 'Doc', 'Bazaar', 'index.htm')
115
100
    dst = os.path.join(fldr, 'Documentation.lnk')
116
101
    create_shortcut(docs, 'Bazaar Documentation', dst)
117
102
    file_created(dst)
118
103
    print 'Documentation for Bazaar: Start => Programs => Bazaar'
119
104
 
120
105
    # bzr in cmd shell
121
 
    if os.name == 'nt':
122
 
        cmd = os.environ.get('COMSPEC', 'cmd.exe')
123
 
        args = "/K bzr help"
124
 
    else:
125
 
        # minimal support of win98
126
 
        cmd = os.environ.get('COMSPEC', 'command.com')
127
 
        args = "bzr help"
 
106
    cmd = os.environ.get('COMSPEC', 'cmd.exe')
128
107
    dst = os.path.join(fldr, 'Start bzr.lnk')
129
108
    create_shortcut(cmd,
130
109
                    'Start bzr in cmd shell',
131
110
                    dst,
132
 
                    args,
 
111
                    "/K bzr help",
133
112
                    os.path.join(sys.exec_prefix, 'Scripts'))
134
113
    file_created(dst)
135
 
 
136
 
    # uninstall shortcut
137
 
    uninst = os.path.join(sys.exec_prefix, 'Removebzr.exe')
138
 
    dst = os.path.join(fldr, 'Uninstall Bazaar.lnk')
139
 
    create_shortcut(uninst,
140
 
                    'Uninstall Bazaar',
141
 
                    dst,
142
 
                    '-u bzr-wininst.log',
143
 
                    sys.exec_prefix,
144
 
                    )
145
 
    file_created(dst)