Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 129515 | Differences between
and this patch

Collapse All | Expand All

(-)/diskless/current/usr/sbin/dispatch-conf (-20 / +24 lines)
Lines 19-25 Link Here
19
19
20
import portage, dispatch_conf
20
import portage, dispatch_conf
21
21
22
FIND_EXTANT_CONFIGS  = "find -L %s/ -iname '._cfg????_*' -exec readlink -q -f '{}' ';' | uniq | sed -e 's://:/:g'"
22
FIND_EXTANT_CONFIGS  = "find -L %s/ -iname '._cfg????_*' | sed -e 's://:/:g'"
23
DIFF_CONTENTS        = 'diff -Nu %s %s'
23
DIFF_CONTENTS        = 'diff -Nu %s %s'
24
DIFF_CVS_INTERP      = 'diff -Nu %s %s | grep "^[+-][^+-]" | grep -v "# .Header:.*"'
24
DIFF_CVS_INTERP      = 'diff -Nu %s %s | grep "^[+-][^+-]" | grep -v "# .Header:.*"'
25
DIFF_WSCOMMENTS      = 'diff -Nu %s %s | grep "^[+-][^+-]" | grep -v "^[-+]#" | grep -v "^[-+][:space:]*$"'
25
DIFF_WSCOMMENTS      = 'diff -Nu %s %s | grep "^[+-][^+-]" | grep -v "^[-+]#" | grep -v "^[-+][:space:]*$"'
Lines 100-106 Link Here
100
        #
100
        #
101
101
102
        def f (conf):
102
        def f (conf):
103
            mrgconf = re.sub(r'\._cfg', '._mrg', conf['new'])
103
            mrgconf = re.sub(r'\._cfg', '._mrg', os.path.realpath(conf['new']))
104
            archive = os.path.join(self.options['archive-dir'], conf['current'].lstrip('/'))
104
            archive = os.path.join(self.options['archive-dir'], conf['current'].lstrip('/'))
105
            if self.options['use-rcs'] == 'yes':
105
            if self.options['use-rcs'] == 'yes':
106
                mrgfail = dispatch_conf.rcs_archive(archive, conf['current'], conf['new'], mrgconf)
106
                mrgfail = dispatch_conf.rcs_archive(archive, conf['current'], conf['new'], mrgconf)
Lines 113-127 Link Here
113
            if os.path.exists(mrgconf):
113
            if os.path.exists(mrgconf):
114
                if mrgfail or len(commands.getoutput(DIFF_CONTENTS % (conf['new'], mrgconf))) == 0:
114
                if mrgfail or len(commands.getoutput(DIFF_CONTENTS % (conf['new'], mrgconf))) == 0:
115
                    os.unlink(mrgconf)
115
                    os.unlink(mrgconf)
116
                    newconf = conf['new']
116
                    newconf = os.path.realpath(conf['new'])
117
                else:
117
                else:
118
                    newconf = mrgconf
118
                    newconf = mrgconf
119
            else:
119
            else:
120
                newconf = conf['new']
120
                newconf = os.path.realpath(conf['new'])
121
121
122
            same_file = len(commands.getoutput (DIFF_CONTENTS   % (conf ['current'], newconf))) == 0
122
            same_file = len(commands.getoutput (DIFF_CONTENTS   % (os.path.realpath(conf ['current']), newconf))) == 0
123
            same_cvs  = len(commands.getoutput (DIFF_CVS_INTERP % (conf ['current'], newconf))) == 0
123
            same_cvs  = len(commands.getoutput (DIFF_CVS_INTERP % (os.path.realpath(conf ['current']), newconf))) == 0
124
            same_wsc  = len(commands.getoutput (DIFF_WSCOMMENTS % (conf ['current'], newconf))) == 0
124
            same_wsc  = len(commands.getoutput (DIFF_WSCOMMENTS % (os.path.realpath(conf ['current']), newconf))) == 0
125
125
126
            # Do options permit?
126
            # Do options permit?
127
            same_cvs = same_cvs and self.options['replace-cvs'] == 'yes'
127
            same_cvs = same_cvs and self.options['replace-cvs'] == 'yes'
Lines 129-144 Link Here
129
            unmodified = unmodified and self.options['replace-unmodified'] == 'yes'
129
            unmodified = unmodified and self.options['replace-unmodified'] == 'yes'
130
130
131
            if same_file:
131
            if same_file:
132
                os.unlink (conf ['new'])
132
                os.unlink (os.path.realpath(conf ['new']))
133
                self.post_process(conf['current'])
133
                self.post_process(os.path.realpath(conf['current']))
134
                if os.path.exists(mrgconf):
134
                if os.path.exists(mrgconf):
135
                    os.unlink(mrgconf)
135
                    os.unlink(mrgconf)
136
                return False
136
                return False
137
            elif unmodified or same_cvs or same_wsc or conf ['dir'] in portage.settings ['CONFIG_PROTECT_MASK'].split ():
137
            elif unmodified or same_cvs or same_wsc or conf ['dir'] in portage.settings ['CONFIG_PROTECT_MASK'].split ():
138
                self.replace(newconf, conf['current'])
138
                self.replace(newconf, os.path.realpath(conf['current']))
139
                self.post_process(conf['current'])
139
                self.post_process(conf['current'])
140
                if newconf == mrgconf:
140
                if newconf == mrgconf:
141
                    os.unlink(conf['new'])
141
                    os.unlink(os.path.realpath(conf['new']))
142
                elif os.path.exists(mrgconf):
142
                elif os.path.exists(mrgconf):
143
                    os.unlink(mrgconf)
143
                    os.unlink(mrgconf)
144
                return False
144
                return False
Lines 154-160 Link Here
154
        for conf in confs:
154
        for conf in confs:
155
            count = count + 1
155
            count = count + 1
156
156
157
            newconf = conf['new']
157
            newconf = os.path.realpath(conf['new'])
158
	    
159
            if not os.path.exists(newconf):
160
                break
161
	    
158
            mrgconf = re.sub(r'\._cfg', '._mrg', newconf)
162
            mrgconf = re.sub(r'\._cfg', '._mrg', newconf)
159
            if os.path.exists(mrgconf):
163
            if os.path.exists(mrgconf):
160
                newconf = mrgconf
164
                newconf = mrgconf
Lines 162-171 Link Here
162
166
163
            while 1:
167
            while 1:
164
                if show_new_diff:
168
                if show_new_diff:
165
                    os.system((self.options['diff']) % (conf['new'], mrgconf))
169
                    os.system((self.options['diff']) % (os.path.realpath(conf['new']), mrgconf))
166
                    show_new_diff = 0
170
                    show_new_diff = 0
167
                else:
171
                else:
168
                    os.system((self.options['diff']) % (conf['current'], newconf))
172
                    os.system((self.options['diff']) % (os.path.realpath(conf['current']), newconf))
169
173
170
                print
174
                print
171
                print '>> (%i of %i) -- %s' % (count, len(confs), conf ['current'])
175
                print '>> (%i of %i) -- %s' % (count, len(confs), conf ['current'])
Lines 180-193 Link Here
180
                    continue
184
                    continue
181
                elif c == 't':
185
                elif c == 't':
182
                    if newconf == mrgconf:
186
                    if newconf == mrgconf:
183
                        newconf = conf['new']
187
                        newconf = os.path.realpath(conf['new'])
184
                    elif os.path.exists(mrgconf):
188
                    elif os.path.exists(mrgconf):
185
                        newconf = mrgconf
189
                        newconf = mrgconf
186
                    continue
190
                    continue
187
                elif c == 'n':
191
                elif c == 'n':
188
                    break
192
                    break
189
                elif c == 'm':
193
                elif c == 'm':
190
                    merged = SCRATCH_DIR+"/"+os.path.basename(conf['current'])
194
                    merged = SCRATCH_DIR+"/"+os.path.basename(os.path.realpath(conf['current']))
191
                    print
195
                    print
192
                    ret = os.system (self.options['merge'] % (merged, conf ['current'], newconf))
196
                    ret = os.system (self.options['merge'] % (merged, conf ['current'], newconf))
193
                    if ret:
197
                    if ret:
Lines 195-201 Link Here
195
                        continue
199
                        continue
196
                    shutil.copyfile(merged, mrgconf)
200
                    shutil.copyfile(merged, mrgconf)
197
                    os.remove(merged)
201
                    os.remove(merged)
198
                    mystat = os.lstat(conf['new'])
202
                    mystat = os.lstat(os.path.realpath(conf['new']))
199
                    os.chmod(mrgconf, mystat[ST_MODE])
203
                    os.chmod(mrgconf, mystat[ST_MODE])
200
                    os.chown(mrgconf, mystat[ST_UID], mystat[ST_GID])
204
                    os.chown(mrgconf, mystat[ST_UID], mystat[ST_GID])
201
                    newconf = mrgconf
205
                    newconf = mrgconf
Lines 214-223 Link Here
214
                        os.unlink(mrgconf)
218
                        os.unlink(mrgconf)
215
                    break
219
                    break
216
                elif c == 'u':
220
                elif c == 'u':
217
                    self.replace(newconf, conf ['current'])
221
                    self.replace(newconf, os.path.realpath(conf ['current']))
218
                    self.post_process(conf['current'])
222
                    self.post_process(conf['current'])
219
                    if newconf == mrgconf:
223
                    if newconf == mrgconf:
220
                        os.unlink(conf['new'])
224
                        os.unlink(os.path.realpath(conf['new']))
221
                    elif os.path.exists(mrgconf):
225
                    elif os.path.exists(mrgconf):
222
                        os.unlink(mrgconf)
226
                        os.unlink(mrgconf)
223
                    break
227
                    break
Lines 263-269 Link Here
263
            dir   = re.match (r'^(.+)/', nconf).group (1)
267
            dir   = re.match (r'^(.+)/', nconf).group (1)
264
268
265
            if h.has_key (conf):
269
            if h.has_key (conf):
266
                mrgconf = re.sub(r'\._cfg', '._mrg', h[conf]['new'])
270
                mrgconf = os.path.realpath(re.sub(r'\._cfg', '._mrg', h[conf]['new']))
267
                if os.path.exists(mrgconf):
271
                if os.path.exists(mrgconf):
268
                    os.unlink(mrgconf)
272
                    os.unlink(mrgconf)
269
                os.unlink(h[conf]['new'])
273
                os.unlink(h[conf]['new'])

Return to bug 129515