commit: dead52fd1cd62afe00663acab1091d01f10f0300
parent adc036f58ed4722f363abebce69223af9059b0ad
Author: Michael Forney <mforney@mforney.org>
Date: Sun, 21 Jun 2020 15:53:13 -0700
Only update local.fspec if the contents changed
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/setup.lua b/setup.lua
@@ -87,8 +87,11 @@ local function gen(gendir)
f:close()
end
if next(pkg.fspec) then
- local f = assert(io.open(outdir..'/local.fspec', 'w'))
- for path, fspec in pairs(pkg.fspec) do
+ local out = outdir..'/local.fspec'
+ local tmp = out..'.tmp'
+ local f = assert(io.open(tmp, 'w'))
+ for _, path in ipairs(table.keys(pkg.fspec)) do
+ local fspec = pkg.fspec[path]
f:write(('/%s\n'):format(path))
for _, k in ipairs{'type', 'mode', 'source', 'target'} do
local v = fspec[k]
@@ -99,6 +102,11 @@ local function gen(gendir)
f:write('\n')
end
f:close()
+ if os.execute(('exec cmp -s %s %s'):format(tmp, out)) then
+ os.remove(tmp)
+ else
+ os.rename(tmp, out)
+ end
table.insert(pkg.inputs.fspec, '$outdir/local.fspec')
end
if next(pkg.inputs.perms) then