diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-07-11 17:33:43 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-07-19 10:24:50 +0100 |
commit | bfd279de3275abbfaf3e630383ec244131e0375f (patch) | |
tree | 0d1c90461a890d21444f5d2afb13c52b302427f1 /meta/classes/update-alternatives.bbclass | |
parent | 99203edda6f0b09d817454d656c100b7a8806b18 (diff) | |
download | poky-bfd279de3275abbfaf3e630383ec244131e0375f.tar.gz |
Convert tab indentation in python functions into four-space
(From OE-Core rev: 604d46c686d06d62d5a07b9c7f4fa170f99307d8)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/update-alternatives.bbclass')
-rw-r--r-- | meta/classes/update-alternatives.bbclass | 286 |
1 files changed, 143 insertions, 143 deletions
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass index 9f2e59f584..47215add1e 100644 --- a/meta/classes/update-alternatives.bbclass +++ b/meta/classes/update-alternatives.bbclass | |||
@@ -113,13 +113,13 @@ def update_alternatives_after_parse(d): | |||
113 | # Convert old format to new format... | 113 | # Convert old format to new format... |
114 | alt_links = d.getVar('ALTERNATIVE_LINKS', True) or "" | 114 | alt_links = d.getVar('ALTERNATIVE_LINKS', True) or "" |
115 | for alt_link in alt_links.split(): | 115 | for alt_link in alt_links.split(): |
116 | alt_name = os.path.basename(alt_link) | 116 | alt_name = os.path.basename(alt_link) |
117 | 117 | ||
118 | alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or "" | 118 | alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or "" |
119 | alternative += " " + alt_name | 119 | alternative += " " + alt_name |
120 | d.setVar('ALTERNATIVE_%s' % pn, alternative) | 120 | d.setVar('ALTERNATIVE_%s' % pn, alternative) |
121 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) | 121 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) |
122 | d.setVarFlag('ALTERNATIVE_TARGET', alt_name, alt_link) | 122 | d.setVarFlag('ALTERNATIVE_TARGET', alt_name, alt_link) |
123 | return | 123 | return |
124 | 124 | ||
125 | if d.getVar('ALTERNATIVE_NAME') != None or d.getVar('ALTERNATIVE_PATH') != None: | 125 | if d.getVar('ALTERNATIVE_NAME') != None or d.getVar('ALTERNATIVE_PATH') != None: |
@@ -128,15 +128,15 @@ def update_alternatives_after_parse(d): | |||
128 | alt_path = d.getVar('ALTERNATIVE_PATH', True) | 128 | alt_path = d.getVar('ALTERNATIVE_PATH', True) |
129 | alt_link = d.getVar('ALTERNATIVE_LINK', True) or ("%s/%s" % (d.getVar('bindir', True), alt_name)) | 129 | alt_link = d.getVar('ALTERNATIVE_LINK', True) or ("%s/%s" % (d.getVar('bindir', True), alt_name)) |
130 | if alt_name == None: | 130 | if alt_name == None: |
131 | raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % d.getVar('FILE') | 131 | raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_NAME" % d.getVar('FILE') |
132 | if alt_path == None: | 132 | if alt_path == None: |
133 | raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % d.getVar('FILE') | 133 | raise bb.build.build.FuncFailed, "%s inherits update-alternatives but doesn't set ALTERNATIVE_PATH" % d.getVar('FILE') |
134 | 134 | ||
135 | alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or "" | 135 | alternative = d.getVar('ALTERNATIVE_%s' % pn, True) or "" |
136 | alternative += " " + alt_name | 136 | alternative += " " + alt_name |
137 | 137 | ||
138 | # Fix the alt_path if it's relative | 138 | # Fix the alt_path if it's relative |
139 | alt_path = os.path.join(os.path.dirname(alt_link), alt_path) | 139 | alt_path = os.path.join(os.path.dirname(alt_link), alt_path) |
140 | 140 | ||
141 | d.setVar('ALTERNATIVE_%s' % pn, alternative) | 141 | d.setVar('ALTERNATIVE_%s' % pn, alternative) |
142 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) | 142 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) |
@@ -199,144 +199,144 @@ populate_packages[vardeps] += "${UPDALTVARS} ${@gen_updatealternativesvars(d)}" | |||
199 | # the split and strip steps.. packagecopy seems to be the earliest reasonable | 199 | # the split and strip steps.. packagecopy seems to be the earliest reasonable |
200 | # place. | 200 | # place. |
201 | python perform_packagecopy_append () { | 201 | python perform_packagecopy_append () { |
202 | # Check for deprecated usage... | 202 | # Check for deprecated usage... |
203 | pn = d.getVar('BPN', True) | 203 | pn = d.getVar('BPN', True) |
204 | if d.getVar('ALTERNATIVE_LINKS', True) != None: | 204 | if d.getVar('ALTERNATIVE_LINKS', True) != None: |
205 | bb.warn('%s: Use of ALTERNATIVE_LINKS is deprecated, see update-alternatives.bbclass for more info.' % pn) | 205 | bb.warn('%s: Use of ALTERNATIVE_LINKS is deprecated, see update-alternatives.bbclass for more info.' % pn) |
206 | 206 | ||
207 | if d.getVar('ALTERNATIVE_NAME', True) != None or d.getVar('ALTERNATIVE_PATH', True) != None: | 207 | if d.getVar('ALTERNATIVE_NAME', True) != None or d.getVar('ALTERNATIVE_PATH', True) != None: |
208 | bb.warn('%s: Use of ALTERNATIVE_NAME is deprecated, see update-alternatives.bbclass for more info.' % pn) | 208 | bb.warn('%s: Use of ALTERNATIVE_NAME is deprecated, see update-alternatives.bbclass for more info.' % pn) |
209 | 209 | ||
210 | # Do actual update alternatives processing | 210 | # Do actual update alternatives processing |
211 | pkgdest = d.getVar('PKGD', True) | 211 | pkgdest = d.getVar('PKGD', True) |
212 | for pkg in (d.getVar('PACKAGES', True) or "").split(): | 212 | for pkg in (d.getVar('PACKAGES', True) or "").split(): |
213 | # If the src == dest, we know we need to rename the dest by appending ${BPN} | 213 | # If the src == dest, we know we need to rename the dest by appending ${BPN} |
214 | link_rename = {} | 214 | link_rename = {} |
215 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): | 215 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): |
216 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) | 216 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) |
217 | if not alt_link: | 217 | if not alt_link: |
218 | alt_link = "%s/%s" % (d.getVar('bindir', True), alt_name) | 218 | alt_link = "%s/%s" % (d.getVar('bindir', True), alt_name) |
219 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) | 219 | d.setVarFlag('ALTERNATIVE_LINK_NAME', alt_name, alt_link) |
220 | 220 | ||
221 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) | 221 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) |
222 | alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link | 222 | alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link |
223 | # Sometimes alt_target is specified as relative to the link name. | 223 | # Sometimes alt_target is specified as relative to the link name. |
224 | alt_target = os.path.join(os.path.dirname(alt_link), alt_target) | 224 | alt_target = os.path.join(os.path.dirname(alt_link), alt_target) |
225 | 225 | ||
226 | # If the link and target are the same name, we need to rename the target. | 226 | # If the link and target are the same name, we need to rename the target. |
227 | if alt_link == alt_target: | 227 | if alt_link == alt_target: |
228 | src = '%s/%s' % (pkgdest, alt_target) | 228 | src = '%s/%s' % (pkgdest, alt_target) |
229 | alt_target_rename = '%s.%s' % (alt_target, pn) | 229 | alt_target_rename = '%s.%s' % (alt_target, pn) |
230 | dest = '%s/%s' % (pkgdest, alt_target_rename) | 230 | dest = '%s/%s' % (pkgdest, alt_target_rename) |
231 | if os.path.lexists(dest): | 231 | if os.path.lexists(dest): |
232 | bb.note('%s: Already renamed: %s' % (pn, alt_target_rename)) | 232 | bb.note('%s: Already renamed: %s' % (pn, alt_target_rename)) |
233 | elif os.path.lexists(src): | 233 | elif os.path.lexists(src): |
234 | if os.path.islink(src): | 234 | if os.path.islink(src): |
235 | # Delay rename of links | 235 | # Delay rename of links |
236 | link_rename[alt_target] = alt_target_rename | 236 | link_rename[alt_target] = alt_target_rename |
237 | else: | 237 | else: |
238 | bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename)) | 238 | bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename)) |
239 | os.rename(src, dest) | 239 | os.rename(src, dest) |
240 | else: | 240 | else: |
241 | bb.warn("%s: alternative target (%s or %s) does not exist, skipping..." % (pn, alt_target, alt_target_rename)) | 241 | bb.warn("%s: alternative target (%s or %s) does not exist, skipping..." % (pn, alt_target, alt_target_rename)) |
242 | continue | 242 | continue |
243 | d.setVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, alt_target_rename) | 243 | d.setVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, alt_target_rename) |
244 | 244 | ||
245 | # Process delayed link names | 245 | # Process delayed link names |
246 | # Do these after other renames so we can correct broken links | 246 | # Do these after other renames so we can correct broken links |
247 | for alt_target in link_rename: | 247 | for alt_target in link_rename: |
248 | src = '%s/%s' % (pkgdest, alt_target) | 248 | src = '%s/%s' % (pkgdest, alt_target) |
249 | dest = '%s/%s' % (pkgdest, link_rename[alt_target]) | 249 | dest = '%s/%s' % (pkgdest, link_rename[alt_target]) |
250 | link = os.readlink(src) | 250 | link = os.readlink(src) |
251 | if os.path.isabs(link): | 251 | if os.path.isabs(link): |
252 | link_target = pkgdest + os.readlink(src) | 252 | link_target = pkgdest + os.readlink(src) |
253 | else: | 253 | else: |
254 | link_target = os.path.join(os.path.dirname(src), link) | 254 | link_target = os.path.join(os.path.dirname(src), link) |
255 | 255 | ||
256 | if os.path.lexists(link_target): | 256 | if os.path.lexists(link_target): |
257 | # Ok, the link_target exists, we can rename | 257 | # Ok, the link_target exists, we can rename |
258 | bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, link_rename[alt_target])) | 258 | bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, link_rename[alt_target])) |
259 | os.rename(src, dest) | 259 | os.rename(src, dest) |
260 | else: | 260 | else: |
261 | # Try to resolve the broken link to link.${BPN} | 261 | # Try to resolve the broken link to link.${BPN} |
262 | link_maybe = '%s.%s' % (os.readlink(src), pn) | 262 | link_maybe = '%s.%s' % (os.readlink(src), pn) |
263 | if os.path.lexists(os.path.join(os.path.dirname(src), link_maybe)): | 263 | if os.path.lexists(os.path.join(os.path.dirname(src), link_maybe)): |
264 | # Ok, the renamed link target exists.. create a new link, and remove the original | 264 | # Ok, the renamed link target exists.. create a new link, and remove the original |
265 | bb.note('%s: Creating new link %s -> %s' % (pn, link_rename[alt_target], link_maybe)) | 265 | bb.note('%s: Creating new link %s -> %s' % (pn, link_rename[alt_target], link_maybe)) |
266 | os.symlink(link_maybe, dest) | 266 | os.symlink(link_maybe, dest) |
267 | os.unlink(src) | 267 | os.unlink(src) |
268 | else: | 268 | else: |
269 | bb.warn('%s: Unable to resolve dangling symlink: %s' % (pn, alt_target)) | 269 | bb.warn('%s: Unable to resolve dangling symlink: %s' % (pn, alt_target)) |
270 | } | 270 | } |
271 | 271 | ||
272 | python populate_packages_prepend () { | 272 | python populate_packages_prepend () { |
273 | pn = d.getVar('BPN', True) | 273 | pn = d.getVar('BPN', True) |
274 | 274 | ||
275 | # Do actual update alternatives processing | 275 | # Do actual update alternatives processing |
276 | pkgdest = d.getVar('PKGD', True) | 276 | pkgdest = d.getVar('PKGD', True) |
277 | for pkg in (d.getVar('PACKAGES', True) or "").split(): | 277 | for pkg in (d.getVar('PACKAGES', True) or "").split(): |
278 | # Create post install/removal scripts | 278 | # Create post install/removal scripts |
279 | alt_setup_links = "" | 279 | alt_setup_links = "" |
280 | alt_remove_links = "" | 280 | alt_remove_links = "" |
281 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): | 281 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): |
282 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) | 282 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) |
283 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) | 283 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) |
284 | alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link | 284 | alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link |
285 | # Sometimes alt_target is specified as relative to the link name. | 285 | # Sometimes alt_target is specified as relative to the link name. |
286 | alt_target = os.path.join(os.path.dirname(alt_link), alt_target) | 286 | alt_target = os.path.join(os.path.dirname(alt_link), alt_target) |
287 | 287 | ||
288 | alt_priority = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name, True) | 288 | alt_priority = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name, True) |
289 | alt_priority = alt_priority or d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg, True) or d.getVar('ALTERNATIVE_PRIORITY', True) | 289 | alt_priority = alt_priority or d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg, True) or d.getVar('ALTERNATIVE_PRIORITY', True) |
290 | 290 | ||
291 | # This shouldn't trigger, as it should have been resolved earlier! | 291 | # This shouldn't trigger, as it should have been resolved earlier! |
292 | if alt_link == alt_target: | 292 | if alt_link == alt_target: |
293 | bb.note('alt_link == alt_target: %s == %s -- correcting, this should not happen!' % (alt_link, alt_target)) | 293 | bb.note('alt_link == alt_target: %s == %s -- correcting, this should not happen!' % (alt_link, alt_target)) |
294 | alt_target = '%s.%s' % (alt_target, pn) | 294 | alt_target = '%s.%s' % (alt_target, pn) |
295 | 295 | ||
296 | if not os.path.lexists('%s/%s' % (pkgdest, alt_target)): | 296 | if not os.path.lexists('%s/%s' % (pkgdest, alt_target)): |
297 | bb.warn('%s: NOT adding alternative provide %s: %s does not exist' % (pn, alt_link, alt_target)) | 297 | bb.warn('%s: NOT adding alternative provide %s: %s does not exist' % (pn, alt_link, alt_target)) |
298 | continue | 298 | continue |
299 | 299 | ||
300 | # Default to generate shell script.. eventually we may want to change this... | 300 | # Default to generate shell script.. eventually we may want to change this... |
301 | alt_target = os.path.relpath(alt_target, os.path.dirname(alt_link)) | 301 | alt_target = os.path.relpath(alt_target, os.path.dirname(alt_link)) |
302 | 302 | ||
303 | alt_setup_links += ' update-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) | 303 | alt_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (alt_link, alt_name, alt_target, alt_priority) |
304 | alt_remove_links += ' update-alternatives --remove %s %s\n' % (alt_name, alt_target) | 304 | alt_remove_links += '\tupdate-alternatives --remove %s %s\n' % (alt_name, alt_target) |
305 | 305 | ||
306 | if alt_setup_links: | 306 | if alt_setup_links: |
307 | bb.note('adding update-alternatives calls to postinst/postrm for %s' % pkg) | 307 | bb.note('adding update-alternatives calls to postinst/postrm for %s' % pkg) |
308 | bb.note('%s' % alt_setup_links) | 308 | bb.note('%s' % alt_setup_links) |
309 | postinst = (d.getVar('pkg_postinst_%s' % pkg, True) or d.getVar('pkg_postinst', True)) or '#!/bin/sh\n' | 309 | postinst = (d.getVar('pkg_postinst_%s' % pkg, True) or d.getVar('pkg_postinst', True)) or '#!/bin/sh\n' |
310 | postinst += alt_setup_links | 310 | postinst += alt_setup_links |
311 | d.setVar('pkg_postinst_%s' % pkg, postinst) | 311 | d.setVar('pkg_postinst_%s' % pkg, postinst) |
312 | 312 | ||
313 | bb.note('%s' % alt_remove_links) | 313 | bb.note('%s' % alt_remove_links) |
314 | postrm = (d.getVar('pkg_postrm_%s' % pkg, True) or d.getVar('pkg_postrm', True)) or '#!/bin/sh\n' | 314 | postrm = (d.getVar('pkg_postrm_%s' % pkg, True) or d.getVar('pkg_postrm', True)) or '#!/bin/sh\n' |
315 | postrm += alt_remove_links | 315 | postrm += alt_remove_links |
316 | d.setVar('pkg_postrm_%s' % pkg, postrm) | 316 | d.setVar('pkg_postrm_%s' % pkg, postrm) |
317 | } | 317 | } |
318 | 318 | ||
319 | python package_do_filedeps_append () { | 319 | python package_do_filedeps_append () { |
320 | pn = d.getVar('BPN', True) | 320 | pn = d.getVar('BPN', True) |
321 | pkgdest = d.getVar('PKGDEST', True) | 321 | pkgdest = d.getVar('PKGDEST', True) |
322 | 322 | ||
323 | for pkg in packages.split(): | 323 | for pkg in packages.split(): |
324 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): | 324 | for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg, True) or "").split(): |
325 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) | 325 | alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name, True) |
326 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) | 326 | alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name, True) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name, True) |
327 | alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link | 327 | alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg, True) or d.getVar('ALTERNATIVE_TARGET', True) or alt_link |
328 | 328 | ||
329 | if alt_link == alt_target: | 329 | if alt_link == alt_target: |
330 | bb.warn('alt_link == alt_target: %s == %s' % (alt_link, alt_target)) | 330 | bb.warn('alt_link == alt_target: %s == %s' % (alt_link, alt_target)) |
331 | alt_target = '%s.%s' % (alt_target, pn) | 331 | alt_target = '%s.%s' % (alt_target, pn) |
332 | 332 | ||
333 | if not os.path.lexists('%s/%s/%s' % (pkgdest, pkg, alt_target)): | 333 | if not os.path.lexists('%s/%s/%s' % (pkgdest, pkg, alt_target)): |
334 | continue | 334 | continue |
335 | 335 | ||
336 | # Add file provide | 336 | # Add file provide |
337 | trans_target = file_translate(alt_target) | 337 | trans_target = file_translate(alt_target) |
338 | d.appendVar('FILERPROVIDES_%s_%s' % (trans_target, pkg), " " + alt_link) | 338 | d.appendVar('FILERPROVIDES_%s_%s' % (trans_target, pkg), " " + alt_link) |
339 | if not trans_target in (d.getVar('FILERPROVIDESFLIST_%s' % pkg, True) or ""): | 339 | if not trans_target in (d.getVar('FILERPROVIDESFLIST_%s' % pkg, True) or ""): |
340 | d.appendVar('FILERPROVIDESFLIST_%s' % pkg, " " + trans_target) | 340 | d.appendVar('FILERPROVIDESFLIST_%s' % pkg, " " + trans_target) |
341 | } | 341 | } |
342 | 342 | ||