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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#!/usr/bin/env python3
#
# Copyright (c) 2015 Jon Turney
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
#
# compare-arch - compare package sets between architectures
#
import argparse
import logging
import os
import sys
import common_constants
import maintainers
import package
#
#
#
def main(args):
packages = {}
pset = {}
union = set()
for arch in common_constants.ARCHES:
# build package list
packages[arch] = package.read_packages(args.rel_area, arch)
# make a set of the package list
pset[arch] = frozenset(packages[arch].keys())
# make the union of all the package lists
union = union.union(pset[arch])
# XXX: could filter out obsolete here
for p in sorted(union):
exists = {}
obs = {}
for arch in common_constants.ARCHES:
exists[arch] = False
obs[arch] = True
if p in packages[arch]:
exists[arch] = True
if '_obsolete' in packages[arch][p].hints.get('category', ''):
obs[arch] = True
else:
obs[arch] = False
if p.startswith('cygwin32') or p.startswith('cygwin64') or p.endswith('-debuginfo'):
continue
# packages which exist in all arches
if all(exists.values()):
# report packages which are obsolete only in some arch
if any(obs.values()) and not all(obs.values()):
print("%s is in all arches, but obsolete only in %s" % (p, [a for a in obs if obs[a]]))
continue
# ignore packages which are obsolete in all the arches they exist in
if all(obs.values()):
continue
# print(p, exists, obs)
print("%s is only in arch %s" % (p, [a for a in exists if exists[a]]))
# are there any packages which have a maintainer, but don't exist?
mlist = maintainers.read(args, getattr(args, 'orphanmaint', None))
all_packages = maintainers.all_packages(mlist)
for p in sorted(all_packages):
if p not in union:
logging.warning("package '%s' has a maintainer, but doesn't exist in any architecture" % (p))
# find the set of packages which aren't in an arch
# for arch in common_constants.ARCHES:
# diff = union.difference(pset[arch])
# print("only in %s" % arch)
# print(sorted(diff))
#
#
#
if __name__ == "__main__":
homedir_default = common_constants.HOMEDIR
pkglist_default = common_constants.PKGMAINT
relarea_default = common_constants.FTP
parser = argparse.ArgumentParser(description='Compare arch package sets')
parser.add_argument('--homedir', action='store', metavar='DIR', help="maintainer home directory (default: " + homedir_default + ")", default=homedir_default)
parser.add_argument('--pkglist', action='store', metavar='FILE', help="package maintainer list (default: " + pkglist_default + ")", default=pkglist_default)
parser.add_argument('--releasearea', action='store', metavar='DIR', help="release directory (default: " + relarea_default + ")", default=relarea_default, dest='rel_area')
parser.add_argument('-v', '--verbose', action='count', dest='verbose', help='verbose output')
(args) = parser.parse_args()
if args.verbose:
logging.getLogger().setLevel(logging.INFO)
logging.basicConfig(format=os.path.basename(sys.argv[0]) + ': %(message)s')
main(args)
|