Use a sorted list of files in kickstarter to avoid unnecessary rebuilds. 82/85882/1 accepted/tizen/common/20160901.143249 submit/tizen/20160831.230944
authorJunghyun Kim <jh0822.kim@samsung.com>
Mon, 29 Aug 2016 10:46:59 +0000 (19:46 +0900)
committerJunghyun Kim <jh0822.kim@samsung.com>
Mon, 29 Aug 2016 10:46:59 +0000 (19:46 +0900)
- PROBLEM
We use OBS to build packages in Tizen.
There is a mechanism not to rebuild when the result binary is the same.
For example, there is a dependency graph: A->B->C.
If A is modified, B would be built.
If the result RPM of B is not changed, OBS does not trigger a build of C.
To effectively use this mechanism, each packages make sure that
the result binary should be the same if the input source is the same.

There is a reason we found is that the file list given by
python(os.walk(), os.listdir()), widely used executable(find),
and system call(readdir()) is unordered.
In this case, different OBS workers can make different results
because of the file list in different order.

The same thing happens in kickstarter.
tools/kickstarter uses os.listdir() which returns an unordered list of files.

- SOLUTION
Use sorted(os.listdir()).
We can obtain a sorted list of files when using sorted().

Change-Id: I9047ca08f748a938557ced46e350c24c378d439d
Signed-off-by: Junghyun Kim <jh0822.kim@samsung.com>
tools/kickstarter

index 7acc485..2739c78 100755 (executable)
@@ -69,7 +69,7 @@ def create_xml(image_meta, external_configs=[]):
     if image_meta.has_key('ExternalConfigs') and image_meta['ExternalConfigs']:
         external = external + image_meta['ExternalConfigs']
     for path in external:
-        for f in os.listdir(path):
+        for f in sorted(os.listdir(path)):
             if f.endswith('.yaml'):
                 local = yamlload_safe('%s/%s' %(path, f))
                 conf = ks.parse(local)