Upload Tizen:Base source
[profile/ivi/python.git] / packaging / python-distutils-rpm-8.patch
1 Index: Python-2.6.2/Lib/distutils/command/install.py
2 ===================================================================
3 --- Python-2.6.2.orig/Lib/distutils/command/install.py
4 +++ Python-2.6.2/Lib/distutils/command/install.py
5 @@ -168,6 +168,8 @@ class install (Command):
6  
7          ('record=', None,
8           "filename in which to record list of installed files"),
9 +        ('record-rpm=', None,
10 +         "filename in which to record list of installed files and directories suitable as filelist for rpm"),
11          ]
12  
13      boolean_options = ['compile', 'force', 'skip-build', 'user']
14 @@ -243,6 +245,7 @@ class install (Command):
15          #self.install_info = None
16  
17          self.record = None
18 +        self.record_rpm = None
19  
20  
21      # -- Option finalizing methods -------------------------------------
22 @@ -592,12 +595,61 @@ class install (Command):
23              self.create_path_file()
24  
25          # write list of installed files, if requested.
26 -        if self.record:
27 +        if self.record or self.record_rpm:
28              outputs = self.get_outputs()
29              if self.root:               # strip any package prefix
30                  root_len = len(self.root)
31                  for counter in xrange(len(outputs)):
32                      outputs[counter] = outputs[counter][root_len:]
33 +            if self.record_rpm:         # add directories
34 +                self.record = self.record_rpm
35 +                dirs = []
36 +                # directories to reject:
37 +                rejectdirs = [
38 +                    '/etc',
39 +                    '/',
40 +                    '',
41 +                    self.prefix,
42 +                    self.exec_prefix,
43 +                    self.install_base,
44 +                    self.install_platbase,
45 +                    self.install_purelib,
46 +                    self.install_platlib,
47 +                    self.install_headers[:len(self.install_headers) - len(self.distribution.get_name()) - 1],
48 +                    self.install_libbase,
49 +                    self.install_scripts,
50 +                    self.install_data,
51 +                    os.path.join(self.install_data, 'share'),
52 +                    os.path.join(self.install_data, 'share', 'doc'),
53 +                    ]
54 +                # directories whose childs reject:
55 +                rejectdirs2 = [
56 +                    os.path.join(self.install_data, 'share', 'man'),
57 +                    ]
58 +                # directories whose grandsons reject:
59 +                rejectdirs3 = [
60 +                    os.path.join(self.install_data, 'share', 'man'),
61 +                    os.path.join(self.install_data, 'share', 'locale'),
62 +                    ]
63 +                for counter in xrange(len(rejectdirs)):
64 +                    if len(rejectdirs[counter]) > root_len:
65 +                        rejectdirs[counter] = rejectdirs[counter][root_len:]
66 +                for counter in xrange(len(rejectdirs2)):
67 +                    if len(rejectdirs2[counter]) > root_len:
68 +                        rejectdirs2[counter] = rejectdirs2[counter][root_len:]
69 +                for counter in xrange(len(rejectdirs3)):
70 +                    if len(rejectdirs3[counter]) > root_len:
71 +                        rejectdirs3[counter] = rejectdirs3[counter][root_len:]
72 +                for counter in xrange(len(outputs)):
73 +                    directory = os.path.dirname(outputs[counter])
74 +                    while directory not in rejectdirs and \
75 +                            os.path.dirname(directory) not in rejectdirs2 and \
76 +                            os.path.dirname(os.path.dirname(directory)) not in rejectdirs3:
77 +                        dirname = '%dir ' + directory
78 +                        if dirname not in dirs:
79 +                            dirs.append(dirname)
80 +                        directory = os.path.dirname(directory)
81 +                outputs += dirs
82              self.execute(write_file,
83                           (self.record, outputs),
84                           "writing list of installed files to '%s'" %