4 import SENFSCons, os, os.path, pwd, time, string
6 ###########################################################################
8 def updateRevision(target, source, env):
9 rev = env['ENV']['REVISION'][1:]
12 print "Working copy not clean. Run 'svn update'"
15 if 'm' in rev and not ARGUMENTS.get('force_deb'):
17 print "Working copy contains local changes. Commit first"
25 for line in os.popen("svn info"):
26 elts=line.split(':',1)
31 version = url.rsplit('/',1)[-1].split('_',1)[0]
32 if version[0] not in string.digits:
35 version = '1:0r%s' % rev
36 changelog = file('debian/changelog.template').read() % {
39 'user': pwd.getpwuid(os.getuid()).pw_gecos.split(',')[0].strip(),
40 'date': time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) }
41 file('debian/changelog','w').write(changelog)
44 try: return os.stat(f).st_size > 0
45 except OSError: return False
47 def checkLocalConf(target, source, env):
48 if [ True for f in env['LOCAL_CONFIG_FILES'] if nonemptyFile(f) ]:
50 print "You have made local modifications to one of the following local configuration"
52 for f in env['LOCAL_CONFIG_FILES']:
55 print "Building a debian package would remove those files."
57 print "To continue, remove the offending file(s) and try again. Alternatively,"
58 print "build a source package using 'scons debsrc' and may then build debian"
59 print "binary packages from this source-package without disrupting your local"
60 print "configuration."
64 if os.environ.get('debian_build'):
65 rev = os.popen("dpkg-parsechangelog | awk '/^Version:/{print $2}'").read().strip()
67 rev = 'r' + os.popen("svnversion").read().strip().lower()
68 if rev == 'rexported':
69 rev = 'r' + os.popen("gitsvnversion").read().strip().lower()
73 logname = os.environ.get('LOGNAME')
75 logname = pwd.getpwuid(os.getuid()).pw_name
77 def dpkgIgnoredFilesOpts(target, source, env, for_signature):
78 return [ '-I%s' % (('/' in f) and (os.path.split(os.getcwd())[1])+f or f)
79 for f in env.subst('$DPKG_IGNORED_FILES').split() ]
83 'LOGNAME' : logname, # needed by the debian build scripts
84 'CONCURRENCY_LEVEL' : env.GetOption('num_jobs') or "1",
89 LOCAL_CONFIG_FILES = [ '/Doxyfile.local', '/SConscript.local', '/senf/local_config.hh' ],
90 DPKG_IGNORED_FILES = [ '$LOCAL_CONFIG_FILES', '.svn', '/_templates' ],
91 DPKG_IGNORED_FILES_OPTS = dpkgIgnoredFilesOpts,
92 BUILDPACKAGE_COMMAND = "dpkg-buildpackage -us -uc -rfakeroot $DPKG_IGNORED_FILES_OPTS",
95 env.PhonyTarget('deb', [], [
98 "$BUILDPACKAGE_COMMAND",
99 "fakeroot ./debian/rules debclean"
102 env.PhonyTarget('debsrc', [], [
104 "$BUILDPACKAGE_COMMAND -S",
107 env.PhonyTarget('debbin', [], [
110 "$BUILDPACKAGE_COMMAND -b",
111 "fakeroot ./debian/rules debclean"
114 env.Clean(env.Alias('all'), 'changelog')