]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - bin/pfa-checksign
make sure scripts are always executable
[projects/pld-ftp-admin.git] / bin / pfa-checksign
CommitLineData
785198f5
JR
1#!/usr/bin/env python
2# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
3
4import sys, os
5import getopt
6sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
7import ftptree
8import getpass
9from common import checkdir
10import ftpio
11from config import sign_key
12from sign import is_signed, signpkgs
13
14try:
15 opts, args = getopt.getopt(sys.argv[1:], '')
16except getopt.GetoptError:
17 print >>sys.stderr, "ERR: options error"
18 print >>sys.stderr, "checksign.py tree package1 [package2...]"
19 sys.exit(1)
20
21if len(args) < 1:
22 print >>sys.stderr, "ERR: missing tree name"
23 print >>sys.stderr, "checksign.py tree package1 [package2...]"
24 sys.exit(1)
25
26if sign_key == None:
27 print >>sys.stderr, "ERR: sign_key not defined in config"
28 sys.exit(1)
29
30treename = args[0]
31packages = args[1:]
32
33checkdir(treename)
34
35ftpio.connect('sign')
36
37if not ftpio.lock(treename, True):
38 print >>sys.stderr, "ERR: %s tree already locked" % treename
39 sys.exit(1)
40
41files = []
42try:
43 if len(packages) < 1:
44 loadall = True
45 else:
46 loadall = False
47
48 # if no files specified, grab whole tree contents
49 tree = ftptree.FtpTree(treename, loadall = loadall)
50 if loadall:
51 # this is hack, should be a param, not access private .loadedpkgs element
52 tree.mark4moving(tree.loadedpkgs)
53 else:
54 tree.mark4moving(packages)
55
56except ftptree.SomeError:
57 # In case of problems we need to unlock the tree before exiting
58 ftpio.unlock(treename)
59 sys.exit(1)
60
61ftpio.unlock(treename)
62
63print "Checking signatures of %d packages" % len(tree.loadedpkgs)
64sign = []
65for pkg in tree.marked4moving:
66 unsigned = 0
67 for file in pkg.rpmfiles():
68 if not is_signed(file):
69 unsigned += 1
70
71 if unsigned != 0:
72 print '%s: %d files NOT signed' % (pkg.nvr, unsigned)
73 else:
74 print '%s signed' % pkg.nvr
75
76sys.exit(0)
This page took 0.104334 seconds and 4 git commands to generate.