~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
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
# 2007/01/30    added *real* support of win98.
19
20
 
20
21
import os
21
22
import sys
22
23
import _winreg
23
24
 
 
25
from bzrlib import win32utils
 
26
 
24
27
 
25
28
def _quoted_path(path):
26
29
    if ' ' in path:
29
32
        return path
30
33
 
31
34
def _win_batch_args():
32
 
    if os.name == 'nt':
 
35
    if win32utils.winver == 'Windows NT':
33
36
        return '%*'
34
37
    else:
35
38
        return '%1 %2 %3 %4 %5 %6 %7 %8 %9'
62
65
        python_path = _quoted_path(os.path.join(prefix, "python.exe"))
63
66
        args = _win_batch_args()
64
67
        batch_str = "@%s %s %s" % (python_path, script_path, args)
65
 
        # minimal support of win98
66
 
        # if there is no HOME in system then set it for Bazaar manually
67
 
        homes = ('BZR_HOME', 'APPDATA', 'HOME')
68
 
        for home in homes:
69
 
            bzr_home = os.environ.get(home, None)
70
 
            if bzr_home is not None:
71
 
                break
72
 
        else:
73
 
            try:
74
 
                bzr_home = get_special_folder('CSIDL_APPDATA')
75
 
            except OSError:
76
 
                # no Application Data
77
 
                bzr_home = ''
78
 
 
79
 
            if not bzr_home:
80
 
                bzr_home = os.path.splitdrive(sys.prefix)[0] + '\\'
81
 
 
82
 
            batch_str = ("@SET BZR_HOME=" + _quoted_path(bzr_home) + "\n" +
 
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" +
83
78
                         batch_str)
84
79
 
85
 
        batch_path = script_path + ".bat"
 
80
        batch_path = os.path.join(scripts_dir, "bzr.bat")
86
81
        f = file(batch_path, "w")
87
82
        f.write(batch_str)
88
83
        f.close()
95
90
    except Exception, e:
96
91
        print "ERROR: Unable to create %s: %s" % (batch_path, e)
97
92
 
98
 
    # make entry in bzr home directory
99
 
    dst = os.path.join(bzr_home, "bazaar", "2.0")
100
 
    if not os.path.isdir(dst):
101
 
        os.makedirs(dst)
102
 
        import locale
103
 
        print "Configuration files stored in %s" % \
104
 
              dst.encode(locale.getpreferredencoding(), 'replace')
105
 
        # create dummy bazaar.conf
106
 
        f = file(os.path.join(dst,'bazaar.conf'), 'w')
107
 
        f.write("# main configuration file of Bazaar\n"
108
 
                "[DEFAULT]\n"
109
 
                "#email=Your Name <you@domain.com>\n")
110
 
        f.close()
111
 
 
112
93
    ## this hunk borrowed from pywin32_postinstall.py
113
94
    # use bdist_wininst builtins to create a shortcut.
114
95
    # CSIDL_COMMON_PROGRAMS only available works on NT/2000/XP, and