summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bblayers
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bblayers')
-rw-r--r--bitbake/lib/bblayers/action.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/bitbake/lib/bblayers/action.py b/bitbake/lib/bblayers/action.py
index cf9470427a..b1326e5f53 100644
--- a/bitbake/lib/bblayers/action.py
+++ b/bitbake/lib/bblayers/action.py
@@ -1,7 +1,9 @@
1import fnmatch 1import fnmatch
2import logging 2import logging
3import os 3import os
4import shutil
4import sys 5import sys
6import tempfile
5 7
6import bb.utils 8import bb.utils
7 9
@@ -32,10 +34,26 @@ class ActionPlugin(LayerPlugin):
32 sys.stderr.write("Unable to find bblayers.conf\n") 34 sys.stderr.write("Unable to find bblayers.conf\n")
33 return 1 35 return 1
34 36
35 notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdir, None) 37 # Back up bblayers.conf to tempdir before we add layers
36 if notadded: 38 tempdir = tempfile.mkdtemp()
37 for item in notadded: 39 backup = tempdir + "/bblayers.conf.bak"
38 sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item) 40 shutil.copy2(bblayers_conf, backup)
41
42 try:
43 notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdir, None)
44 if not (args.force or notadded):
45 try:
46 self.tinfoil.parseRecipes()
47 except bb.tinfoil.TinfoilUIException:
48 # Restore the back up copy of bblayers.conf
49 shutil.copy2(backup, bblayers_conf)
50 bb.fatal("Parse failure with the specified layer added")
51 else:
52 for item in notadded:
53 sys.stderr.write("Specified layer %s is already in BBLAYERS\n" % item)
54 finally:
55 # Remove the back up copy of bblayers.conf
56 shutil.rmtree(tempdir)
39 57
40 def do_remove_layer(self, args): 58 def do_remove_layer(self, args):
41 """Remove a layer from bblayers.conf.""" 59 """Remove a layer from bblayers.conf."""