+import os, stat, time, subprocess, sys
+
+def getArchitecture():
+ p = subprocess.Popen(['dpkg-architecture', '-qDEB_BUILD_ARCH'], stdout=subprocess.PIPE)
+ res = p.communicate()[0] # get only stdout
+ if p.returncode != 0: raise Exception("Querying dpkg for the architecture failed")
+ return res[0:len(res)-1] # chop of the \n at the end
+
+# build-system specific part of rules file
+def writeCmakeRulesFile(f, config):
+ print >>f, "%:"
+ print >>f, "\tdh $@ --buildsystem cmake --parallel --builddirectory=build.dir" # "build" is not a good idea, as that's also the name of a target...
+ print >>f, ""
+ print >>f, "override_dh_auto_configure:"
+ print >>f, "\tmkdir -p build.dir"
+ print >>f, "\tcd build.dir && cmake ..",' '.join(['-DCMAKE_INSTALL_PREFIX=/usr', '-DCMAKE_BUILD_TYPE=Release'] + config.get('cmakeParameters', []))
+ print >>f, ""
+ print >>f, "override_dh_auto_clean:"
+ print >>f, " rm -f build.dir/CMakeCache.txt # clean old cmake cache"
+ print >>f, ""