commit c5f4afaa36a2e7b0cfe0fe616910c60fa4c018ec
Author: Jan Pokorný <jpokorny(a)redhat.com>
Date: Sat Feb 25 15:10:53 2012 +0100
dist-specific part of prepare-devel.py into prepare-dist.py
For finer granularity
Signed-off-by: Jan Pokorný <jpokorny(a)redhat.com>
prepare-devel.py | 60 ----------------------------------------------
prepare-dist.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 60 deletions(-)
---
diff --git a/prepare-devel.py b/prepare-devel.py
index d7b9150..c3d0627 100644
--- a/prepare-devel.py
+++ b/prepare-devel.py
@@ -10,7 +10,6 @@ from os import walk, makedirs
from os.path import join, exists, isfile, basename, splitext, normpath, sep
from shutil import copy2
from fnmatch import fnmatch
-import re
#
# JavaScript and stylesheets
@@ -173,67 +172,8 @@ gen_file('stylesheet',
# similarly for JavaScript files (but 1:1 mapping kept)
javascript_items.make_params(PACKAGE,PUBLIC,JAVASCRIPT_ROOT)
-# distro-specific stuff (mainly handled via specific setucfg)
-# note: *cfg values are special in that they are to be used
-# for standalone ``python setupy --gen_files fedoracfg''
-# which will generate desired ``setucfg'' version
-
-def make_release(collected, distchangelog):
- dist = via(collected, 'dist')
- if dist in ('fedora', 'rhel'):
- release = re.compile('^\*.*-(?P<rel>[1-9][0-9]*)\s*$',
re.MULTILINE)
- ret = release.search(distchangelog)
- ret = ret and ret.group('rel') or ''
- else: # incl. dist == ''
- ret = ''
- return ret
-
-def make_patchapply(patchdef):
- patch_lines = re.compile('(^.*)Patch(\d+)\s+(\S+).*$', re.MULTILINE)
- patch_def2apply = (lambda m:
- m.group(1) + '%patch' + m.group(2) + ' -p1 -b ' + m.group(3)
- .replace('.patch', '')
- )
- return patch_lines.sub(patch_def2apply, patchdef)
-
-def make_longdesc(long_description):
- return (
- long_description.partition('\n\n')[2].partition('\n\n')[0]
- .replace('`', '').replace('_', '')
- )
-
-nonoptions(
- # general
- downloadurl = derive('download_url'),
- distchangelog = suffixfile('dist', 'CHANGES',
default='CHANGES.txt', mod=fread),
- release = derive('distchangelog', chain=make_release),
- # short description (one-line)
- shortdesc = derive('description'),
- # long description (shorter than full description as passed to setup)
- # - first paragraph from README (TODO: textwrap?), lazily
- longdesc = derive('long_description', mod=make_longdesc),
- docfiles = suffixfile('dist', 'README', default='',
- args=['README.txt', 'LICENSE.txt'],
mod=' '.join),
- # Fedora + RHEL
- patchdef = suffixfile('dist', 'patches', mod=fread),
- patchapply = derive('patchdef', mod=make_patchapply),
-)
gen_file('defaultcfg',
join('dist-files','setucfg'),
'setup.cfg',
subst=True, incl=False,
)
-# Fedora + RHEL
-gen_file('specfile',
- suffixfile('dist', 'dist-files','specfile.in'),
- PACKAGE + '.spec',
- subst=True, incl=False,
-)
-
-#
-# other parametrization
-#
-
-options_optional(
- disttag = "build tag",
-)
diff --git a/prepare-dist.py b/prepare-dist.py
new file mode 100644
index 0000000..a427caf
--- /dev/null
+++ b/prepare-dist.py
@@ -0,0 +1,69 @@
+# Copyright 2012 Red Hat, Inc.
+# Part of sunzi project
+# Licensed under GPLv2 (a copy included /
http://gnu.org/licenses/gpl-2.0.txt)
+
+# to be exec'd provided by necessary functions (`options`, etc.)
+if __name__ == '__main__': # __builtin__ expected (?)
+ raise RuntimeError, "Not used in an expected way"
+
+import re
+
+# distro-specific stuff (mainly handled via specific setucfg)
+# note: *cfg values are special in that they are to be used
+# for standalone ``python setupy --gen_files fedoracfg''
+# which will generate desired ``setucfg'' version
+
+def make_release(collected, distchangelog):
+ dist = via(collected, 'dist')
+ if dist in ('fedora', 'rhel'):
+ release = re.compile('^\*.*-(?P<rel>[1-9][0-9]*)\s*$',
re.MULTILINE)
+ ret = release.search(distchangelog)
+ ret = ret and ret.group('rel') or ''
+ else: # incl. dist == ''
+ ret = ''
+ return ret
+
+def make_patchapply(patchdef):
+ patch_lines = re.compile('(^.*)Patch(\d+)\s+(\S+).*$', re.MULTILINE)
+ patch_def2apply = (lambda m:
+ m.group(1) + '%patch' + m.group(2) + ' -p1 -b ' + m.group(3)
+ .replace('.patch', '')
+ )
+ return patch_lines.sub(patch_def2apply, patchdef)
+
+def make_longdesc(long_description):
+ return (
+ long_description.partition('\n\n')[2].partition('\n\n')[0]
+ .replace('`', '').replace('_', '')
+ )
+
+nonoptions(
+ # general
+ downloadurl = derive('download_url'),
+ distchangelog = suffixfile('dist', 'CHANGES',
default='CHANGES.txt', mod=fread),
+ release = derive('distchangelog', chain=make_release),
+ # short description (one-line)
+ shortdesc = derive('description'),
+ # long description (shorter than full description as passed to setup)
+ # - first paragraph from README (TODO: textwrap?), lazily
+ longdesc = derive('long_description', mod=make_longdesc),
+ docfiles = suffixfile('dist', 'README', default='',
+ args=['README.txt', 'LICENSE.txt'],
mod=' '.join),
+ # Fedora + RHEL
+ patchdef = suffixfile('dist', 'PATCHES', mod=fread),
+ patchapply = derive('patchdef', mod=make_patchapply),
+)
+# Fedora + RHEL
+gen_file('specfile',
+ suffixfile('dist', 'dist-files','specfile.in'),
+ PACKAGE + '.spec',
+ subst=True, incl=False,
+)
+
+#
+# other parametrization
+#
+
+options_optional(
+ disttag = "build tag",
+)