summaryrefslogtreecommitdiff
path: root/site_scons/SConsRevision.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-24 09:57:09 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-24 09:57:09 +0200
commitc7665433b2004d2b404d6fb9d6fd064998486f63 (patch)
tree8525ef6d24f7c6ceb238945ebb2cc997c7afc905 /site_scons/SConsRevision.py
parente48d2727885efda8369c7edbc2e3929a59532adc (diff)
parent6e228c305122f0564eda1e67d56651f8386d24d7 (diff)
Merge branch 'release/debian/3.1.0+repack-1'debian/3.1.0+repack-1
Diffstat (limited to 'site_scons/SConsRevision.py')
-rw-r--r--site_scons/SConsRevision.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/site_scons/SConsRevision.py b/site_scons/SConsRevision.py
new file mode 100644
index 0000000..11de670
--- /dev/null
+++ b/site_scons/SConsRevision.py
@@ -0,0 +1,40 @@
+import os
+
+def SCons_revision(target, source, env):
+ """Interpolate specific values from the environment into a file.
+
+ This is used to copy files into a tree that gets packaged up
+ into the source file package.
+ """
+ t = str(target[0])
+ s = source[0].rstr()
+
+ try:
+ with open(s, 'r') as fp:
+ contents = fp.read()
+
+
+ # Note: We construct the __*__ substitution strings here
+ # so that they don't get replaced when this file gets
+ # copied into the tree for packaging.
+ contents = contents.replace('__BUILD' + '__', env['BUILD'])
+ contents = contents.replace('__BUILDSYS' + '__', env['BUILDSYS'])
+ contents = contents.replace('__COPYRIGHT' + '__', env['COPYRIGHT'])
+ contents = contents.replace('__DATE' + '__', env['DATE'])
+ contents = contents.replace('__DEB_DATE' + '__', env['DEB_DATE'])
+
+ contents = contents.replace('__DEVELOPER' + '__', env['DEVELOPER'])
+ contents = contents.replace('__FILE' + '__', str(source[0]).replace('\\', '/'))
+ contents = contents.replace('__MONTH_YEAR'+ '__', env['MONTH_YEAR'])
+ contents = contents.replace('__REVISION' + '__', env['REVISION'])
+ contents = contents.replace('__VERSION' + '__', env['VERSION'])
+ contents = contents.replace('__NULL' + '__', '')
+ open(t, 'w').write(contents)
+ except UnicodeDecodeError as e:
+ print("Error decoding file:%s just copying no revision edit")
+ with open(s, 'rb') as fp:
+ contents = fp.read()
+ open(t, 'wb').write(contents)
+
+
+ os.chmod(t, os.stat(s)[0]) \ No newline at end of file