]> git.e2factory.org Git - e2factory.git/commitdiff
e2-build: allow --wc-mode foo,bar and add warning
authorTobias Ulmer <tu@emlix.com>
Fri, 25 May 2018 16:44:19 +0000 (18:44 +0200)
committerTobias Ulmer <tu@emlix.com>
Fri, 25 May 2018 16:44:19 +0000 (18:44 +0200)
When specifying multiple build modes, warn if there is a default
selected result. It may or may not be what you want.

Add field splitting to build-mode options, currently , and whitespace
are supported.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2option.lua
local/e2-build.lua

index 0d3ed49730960e362fd97e434945b07e893b2a57..9aee413bcc2831fec837f752b4ebd281b576001f 100644 (file)
@@ -51,7 +51,7 @@ function e2option.flag(name, doc, func, category)
         type = "flag",
         documentation = doc or "",
         name = name,
-        proc=func,
+        proc = func,
         default = true,
         category = category
     }
index 49aa39783544d762dff182c6a13ddb5224cef507..3737324c3bac7729c6c136e9ca000366f47d0e5b 100644 (file)
@@ -47,12 +47,17 @@ local function e2_build(arg)
     local specific_result_count = 0
 
     -- insert results into their respective tables above.
-    local function option_insert_results(the_result_table)
-
-        return function(resultname)
-            if type(resultname) == "string" then
-                table.insert(the_result_table --[[closure]], resultname)
-                specific_result_count = specific_result_count + 1
+    local function option_insert_results(the_result_table, table_name)
+
+        return function(resultnames)
+            -- closure: the_result_table table_name
+            e2lib.logf(4, "option_insert_results func(%s) on %s",
+                tostring(resultnames), table_name)
+            if type(resultnames) == "string" then
+                for resultname in string.gmatch(resultnames, "[^,%s]+") do
+                    table.insert(the_result_table, resultname)
+                    specific_result_count = specific_result_count + 1
+                end
             end
             return true
         end
@@ -71,11 +76,11 @@ local function e2_build(arg)
     e2option.flag("all", "build all results (default unless for working copy)")
     policy.register_commandline_options()
     e2option.option("tag-mode", "build selected results in tag mode",
-        true, option_insert_results(tag_mode_results))
+        true, option_insert_results(tag_mode_results, "tag_mode_results"))
     e2option.option("branch-mode", "build selected results in branch mode",
-        true, option_insert_results(branch_mode_results))
+        true, option_insert_results(branch_mode_results, "branch_mode_results"))
     e2option.option("wc-mode", "build selected results in working-copy mode",
-        true, option_insert_results(wc_mode_results))
+        true, option_insert_results(wc_mode_results, "wc_mode_results"))
     e2option.flag("force-rebuild", "force rebuilding even if a result exists")
     e2option.flag("playground", "prepare environment but do not build")
     e2option.flag("keep", "do not remove chroot environment after build")
@@ -117,6 +122,11 @@ local function e2_build(arg)
         end
     end
 
+    if build_mode_count > 1 and #selected_results > 0 then
+        e2lib.warnf("WOTHER", "building package %s in default mode",
+            table.concat(selected_results, ", "))
+    end
+
     local function check_mode(option_name, cnt, opts, results, selected_results)
         if opts[option_name] then
 
@@ -222,6 +232,7 @@ local function e2_build(arg)
     end
 
     -- selected results
+    e2lib.logf(4, "selected_results=%s", table.concat(selected_results, " "))
     rc, re = e2tool.select_results(selected_results, force_rebuild,
         keep_chroot, nil, playground)
     if not rc then
@@ -229,18 +240,21 @@ local function e2_build(arg)
     end
 
     -- specific build modi
+    e2lib.logf(4, "tag_mode_results=%s", table.concat(tag_mode_results, " "))
     rc, re = e2tool.select_results(tag_mode_results, force_rebuild, keep_chroot,
         policy.default_build_mode("tag"), playground)
     if not rc then
         error(re)
     end
 
+    e2lib.logf(4, "branch_mode_results=%s", table.concat(branch_mode_results, " "))
     rc, re = e2tool.select_results(branch_mode_results, force_rebuild,
         keep_chroot, policy.default_build_mode("branch"), playground)
     if not rc then
         error(re)
     end
 
+    e2lib.logf(4, "wc_mode_results=%s", table.concat(wc_mode_results, " "))
     rc, re = e2tool.select_results(wc_mode_results, force_rebuild, keep_chroot,
         policy.default_build_mode("working-copy"), playground)
     if not rc then