forked from pool/spec-cleaner
Accepting request 69282 from home:vuntz
Update to 0.2 OBS-URL: https://build.opensuse.org/request/show/69282 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Tools/spec-cleaner?expand=0&rev=3
This commit is contained in:
parent
f187597dc1
commit
7189ad629c
59
spec-cleaner
59
spec-cleaner
@ -51,7 +51,7 @@ import shlex
|
||||
|
||||
#######################################################################
|
||||
|
||||
VERSION = '0.1'
|
||||
VERSION = '0.2'
|
||||
|
||||
re_comment = re.compile('^$|^\s*#')
|
||||
re_define = re.compile('^\s*%define', re.IGNORECASE)
|
||||
@ -143,13 +143,18 @@ def replace_utils(s):
|
||||
|
||||
def replace_buildservice(s):
|
||||
for i in ['centos', 'debian', 'fedora', 'mandriva', 'meego', 'rhel', 'sles', 'suse', 'ubuntu']:
|
||||
s = s.replace('%' + i + '_version', '0%{?' + i + '_version}')
|
||||
s = s.replace('%{' + i + '_version}', '0%{?' + i + '_version}')
|
||||
s = s.replace('%' + i + '_version', '0%{?' + i + '_version}').replace('00%{','0%{')
|
||||
s = s.replace('%{' + i + '_version}', '0%{?' + i + '_version}').replace('00%{','0%{')
|
||||
return s
|
||||
|
||||
def replace_macros(s):
|
||||
def replace_preamble_macros(s):
|
||||
for i in ['name', 'version', 'release']:
|
||||
s = s.replace('%' + i, '%{' + i + '}')
|
||||
for i in map(str,range(100)):
|
||||
s = s.replace('%{P:' + i + '}', '%{PATCH' + i + '}')
|
||||
s = s.replace('%PATCH' + i, '%{PATCH' + i + '}')
|
||||
s = s.replace('%{S:' + i + '}', '%{SOURCE' + i + '}')
|
||||
s = s.replace('%SOURCE' + i, '%{SOURCE' + i + '}')
|
||||
return s
|
||||
|
||||
def replace_all(s):
|
||||
@ -159,7 +164,7 @@ def replace_all(s):
|
||||
s = replace_remove_la(s)
|
||||
s = replace_utils(s)
|
||||
s = replace_buildservice(s)
|
||||
s = replace_macros(s)
|
||||
s = replace_preamble_macros(s)
|
||||
return s
|
||||
|
||||
|
||||
@ -261,7 +266,7 @@ class RpmPreamble(RpmSection):
|
||||
re_version = re.compile('^Version:\s*(\S*)', re.IGNORECASE)
|
||||
re_release = re.compile('^Release:\s*(\S*)', re.IGNORECASE)
|
||||
re_license = re.compile('^License:\s*(.*)', re.IGNORECASE)
|
||||
re_summary = re.compile('^Summary:\s*(.*)', re.IGNORECASE)
|
||||
re_summary = re.compile('^Summary:\s*([^\.]*).*', re.IGNORECASE)
|
||||
re_url = re.compile('^Url:\s*(\S*)', re.IGNORECASE)
|
||||
re_group = re.compile('^Group:\s*(.*)', re.IGNORECASE)
|
||||
re_source = re.compile('^Source(\d*):\s*(\S*)', re.IGNORECASE)
|
||||
@ -335,7 +340,11 @@ class RpmPreamble(RpmSection):
|
||||
'GPL v2 only': 'GPLv2',
|
||||
'GPL v2 or later': 'GPLv2+',
|
||||
'GPL v3 only': 'GPLv3',
|
||||
'GPL v3 or later': 'GPLv3+'
|
||||
'GPL v3 or later': 'GPLv3+',
|
||||
'FDL 1.1': 'FDLv1.1',
|
||||
'FDL 1.2': 'FDLv1.2',
|
||||
'FDL 1.2 or later': 'FDLv1.2+',
|
||||
'FDL 1.3': 'FDLv1.3'
|
||||
}
|
||||
|
||||
categories_order = [ 'name', 'version', 'release', 'license', 'summary', 'url', 'group', 'source', 'patch', 'buildrequires', 'prereq', 'requires', 'recommends', 'suggests', 'supplements', 'provides_obsoletes', 'buildroot', 'buildarch', 'misc' ]
|
||||
@ -375,12 +384,19 @@ class RpmPreamble(RpmSection):
|
||||
def sort_helper_key(a):
|
||||
t = type(a)
|
||||
if t == str:
|
||||
return a
|
||||
key = a
|
||||
elif t == list:
|
||||
return a[-1]
|
||||
key = a[-1]
|
||||
else:
|
||||
raise RpmException('Unknown type during sort: %s' % t)
|
||||
|
||||
# Put pkgconfig()-style packages at the end of the list, after all
|
||||
# non-pkgconfig()-style packages
|
||||
if key.find('pkgconfig(') != -1:
|
||||
return '1'+key
|
||||
else:
|
||||
return '0'+key
|
||||
|
||||
for i in self.categories_order:
|
||||
if i in self.categories_with_sorted_package_tokens:
|
||||
self.paragraph[i].sort(key=sort_helper_key)
|
||||
@ -413,15 +429,20 @@ class RpmPreamble(RpmSection):
|
||||
'dbus-1-devel': 'dbus-1',
|
||||
'dbus-1-glib-devel': 'dbus-glib-1',
|
||||
'gconf2-devel': 'gconf-2.0',
|
||||
'gstreamer-0_10-devel': 'gstreamer-0.10',
|
||||
'exo-devel': 'exo-1',
|
||||
'glib2-devel': 'glib-2.0',
|
||||
'gtk2-devel': 'gtk+-2.0',
|
||||
'hal-devel': 'hal',
|
||||
'ImageMagick-devel': 'ImageMagick',
|
||||
'libapr1-devel': 'apr-1',
|
||||
'libapr-util1-devel': 'apr-util-1',
|
||||
'libexif-devel': 'libexif',
|
||||
'libgarcon-devel': 'garcon-1',
|
||||
'libglade2-devel': 'libglade-2.0',
|
||||
'libgladeui-1_0-devel': 'gladeui-1.0',
|
||||
'libgudev-1_0-devel': 'gudev-1.0',
|
||||
'libical-devel': 'libical',
|
||||
'libnotify-devel': 'libnotify',
|
||||
'libwnck-devel': 'libwnck-1.0',
|
||||
'libxfce4ui-devel': 'libxfce4ui-1',
|
||||
@ -430,7 +451,9 @@ class RpmPreamble(RpmSection):
|
||||
'libxfconf-devel': 'libxfconf-0',
|
||||
'libxklavier-devel': 'libxklavier',
|
||||
'libxml2-devel': 'libxml-2.0',
|
||||
'pango-devel': 'pango',
|
||||
'startup-notification-devel': 'libstartup-notification-1.0',
|
||||
'vte-devel': 'vte',
|
||||
'xfce4-panel-devel': 'libxfce4panel-1.0',
|
||||
}
|
||||
for i in r:
|
||||
@ -536,7 +559,7 @@ class RpmPreamble(RpmSection):
|
||||
elif self.re_patch.match(line):
|
||||
# FIXME: this is not perfect, but it's good enough for most cases
|
||||
if not self.previous_line or not re_comment.match(self.previous_line):
|
||||
self.current_group.append('# PATCH-MISSING-TAG -- See http://en.opensuse.org/Packaging/Patches')
|
||||
self.current_group.append('# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines')
|
||||
|
||||
match = self.re_patch.match(line)
|
||||
# convert Patch: to Patch0:
|
||||
@ -647,7 +670,7 @@ class RpmPrep(RpmSection):
|
||||
cmp_line = strip_useless_spaces(cmp_line)
|
||||
if cmp_line == '%setup':
|
||||
line = '%setup -q'
|
||||
if line.startswith('%patch '):
|
||||
if line.startswith('%patch ') or line == '%patch':
|
||||
line = line.replace('%patch','%patch0')
|
||||
|
||||
RpmSection.add(self, line)
|
||||
@ -663,11 +686,13 @@ class RpmBuild(RpmSection):
|
||||
|
||||
def add(self, line):
|
||||
if not re_comment.match(line):
|
||||
line = line.replace('%_smp_mflags' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{_smp_mflags}' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs:-j%jobs}' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs: -j%jobs}', '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs:-j %jobs}', '%{?_smp_mflags}')
|
||||
line = line.replace('%_smp_mflags' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{_smp_mflags}' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs:-j%jobs}' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs: -j%jobs}' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs:-j %jobs}' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs:-j%{jobs}}' , '%{?_smp_mflags}')
|
||||
line = line.replace('%{?jobs:-j %{jobs}}', '%{?_smp_mflags}')
|
||||
|
||||
RpmSection.add(self, line)
|
||||
|
||||
@ -872,7 +897,7 @@ class RpmSpecCleaner:
|
||||
self.fin = io
|
||||
self.fout = open(self.specfile, 'w')
|
||||
elif self.diff:
|
||||
self.fout = tempfile.NamedTemporaryFile(prefix=self.specfile)
|
||||
self.fout = tempfile.NamedTemporaryFile(prefix=self.specfile+'.', suffix='.spec')
|
||||
else:
|
||||
self.fout = sys.stdout
|
||||
|
||||
|
@ -1,3 +1,24 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon May 2 18:38:05 CEST 2011 - vuntz@opensuse.org
|
||||
|
||||
- Update to version 0.2:
|
||||
+ Handle suse_version
|
||||
+ Do not check for AutoReqProv in %install
|
||||
+ Replace %makeinstall by %make_install
|
||||
+ Reformat versioned package names too
|
||||
+ Remove #usedforbuild
|
||||
+ Replace Patch: with Patch0: (and %patch with %patch0)
|
||||
+ Change default .spec headers to not include any license
|
||||
+ Replace some package names with pkgconfig()-style names
|
||||
+ Add --diff and --diff-prog options
|
||||
+ Put brackets around %name, %version, %release, ...
|
||||
+ Update url for PATCH-MISSING-TAGw
|
||||
+ Cut summary after the first dot
|
||||
+ Add FDL licenses
|
||||
+ Add .spec extension to spec files created by script
|
||||
+ Put pkgconfig()-style package names at the end of their list
|
||||
+ Code improvements
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Dec 6 11:41:07 UTC 2010 - prusnak@opensuse.org
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# spec file for package spec-cleaner (version 0.1)
|
||||
# spec file for package spec-cleaner
|
||||
#
|
||||
# Copyright (c) 2010 Vincent Untz <vuntz@opensuse.org>
|
||||
#
|
||||
@ -16,7 +16,7 @@
|
||||
#
|
||||
|
||||
Name: spec-cleaner
|
||||
Version: 0.1
|
||||
Version: 0.2
|
||||
Release: 1
|
||||
License: BSD 3-Clause
|
||||
Summary: .spec file cleaner
|
||||
|
Loading…
Reference in New Issue
Block a user