forked from rpm-software-management/rpmlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpmdiff
executable file
·75 lines (61 loc) · 2.27 KB
/
rpmdiff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
#
# Copyright (C) 2006 Mandriva; 2009 Red Hat, Inc.; 2009 Ville Skyttä
# Authors: Frederic Lepied, Florian Festi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; version 2 only
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import getopt
import os.path
import sys
if os.path.isdir("/usr/share/rpmlint"):
import site
site.addsitedir("/usr/share/rpmlint")
import Pkg # noqa: E402
import Rpmdiff
def _usage(exit=1):
print('''Usage: %s [<options>] <old package> <new package>
Options:
-h, --help Output this message and exit
-i, --ignore File property to ignore when calculating differences (may be
used multiple times); valid values are: S (size), M (mode),
5 (checksum), D (device), N (inode), L (number of links),
V (vflags), U (user), G (group), F (digest), T (time)'''
% sys.argv[0])
sys.exit(exit)
def main():
ignore_tags = []
try:
opts, args = getopt.getopt(sys.argv[1:],
"hti:", ["help", "ignore-times", "ignore="])
except getopt.GetoptError as e:
Pkg.warn("Error: %s" % e)
_usage()
for option, argument in opts:
if option in ("-h", "--help"):
_usage(0)
if option in ("-t", "--ignore-times"):
# deprecated; --ignore=T should be used instead
ignore_tags.append("T")
if option in ("-i", "--ignore"):
ignore_tags.append(argument)
if len(args) != 2:
_usage()
d = Rpmdiff.Rpmdiff(args[0], args[1], ignore=ignore_tags)
textdiff = d.textdiff()
if textdiff:
print(textdiff)
sys.exit(int(d.differs()))
if __name__ == '__main__':
main()