source: soft/build_system/build_system/upload/robot/trunk/check-distrib @ 1

Last change on this file since 1 was 1, checked in by fasma, 13 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 2.1 KB
Line 
1#!/usr/bin/env python
2#---------------------------------------------------------------
3# Project         : Linux-Mandrake
4# Module          : rpm-rebuilder
5# File            : check-distrib
6# Version         : $Id: check-distrib 1276 2006-08-09 17:34:38Z mandrake $
7# Author          : Frederic Lepied
8# Created On      : Tue May 16 06:55:15 2000
9#---------------------------------------------------------------
10
11import os
12import rpm
13import sys
14
15def check(srcdir, bindir, arch):
16    srpms = os.listdir(srcdir)
17    rpms = os.listdir(bindir)
18    invalid_srpms = srpms[:]
19
20    for p in rpms.sort():
21        if p[-4:] != '.rpm':
22            continue
23        try:
24            # Create a package object from the file name
25            fd = os.open(bindir + "/" + p, os.O_RDONLY)
26            (header, is_source) = rpm.headerFromPackage(fd)
27            os.close(fd)
28        except:
29            print "E: invalid-file", p
30            continue
31       
32        try:
33            src = header[rpm.RPMTAG_SOURCERPM]
34            if src in srpms:
35                try:
36                    invalid_srpms.remove(src)
37                except ValueError:
38                    pass
39            else:
40                print "E: no-source", p
41        except:
42            print "E: invalid-binary", p
43
44    for p in invalid_srpms.sort():
45        try:
46            # Create a package object from the file name
47            fd = os.open(srcdir + "/" + p, os.O_RDONLY)
48            (header, is_source) = rpm.headerFromPackage(fd)
49            os.close(fd)
50        except:
51            print "E: invalid-file", p
52            continue
53
54        try:
55            exclusivearch = header[rpm.RPMTAG_EXCLUSIVEARCH]
56            if exclusivearch == None or arch in exclusivearch:
57                print "E: no-binary", p
58        except:
59            print "E: invalid-source", p
60
61if len(sys.argv) != 4:
62    print "usage:", sys.argv[0], "<src dir> <bin dir> <arch>"
63    print "check coherence of binary and source rpms"
64    sys.exit(1)
65   
66check(sys.argv[1], sys.argv[2], sys.argv[3])
67
68# Local variables:
69# mode: python
70# End:
71#
72# check-distrib ends here
Note: See TracBrowser for help on using the repository browser.