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