]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blob - bin/pfa-signpkg
- catch signpkg errors
[projects/pld-ftp-admin.git] / bin / pfa-signpkg
1 #!/usr/bin/env python
2 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
3
4 import sys, os
5 sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
6 import ftptree
7 from common import checkdir
8 import ftpio
9 from config import sign_key
10 from sign import is_signed, signpkgs
11
12 if len(sys.argv) < 3:
13     print >>sys.stderr, "ERR: not enough parameters given"
14     print >>sys.stderr, "sign.py tree package1 [package2...]"
15     sys.exit(1)
16
17 if sign_key == None:
18     print >>sys.stderr, "ERR: sign_key not defined in config"
19     sys.exit(1)
20
21 checkdir(sys.argv[1])
22
23 ftpio.connect('sign')
24
25 if not ftpio.lock(sys.argv[1], True):
26     print >>sys.stderr, "ERR: %s tree already locked" % sys.argv[1]
27     sys.exit(1)
28
29 files = []
30 try:
31     tree = ftptree.FtpTree(sys.argv[1])
32     tree.mark4moving(sys.argv[2:])
33     files = tree.rpmfiles()
34
35 except ftptree.SomeError:
36     # In case of problems we need to unlock the tree before exiting
37     ftpio.unlock(sys.argv[1])
38     sys.exit(1)
39
40 ftpio.unlock(sys.argv[1])
41
42 print "Checking signatures of %d files from %d packages" % (len(files), len(tree.loadedpkgs))
43 sign = []
44 for file in files:
45     if not is_signed(file):
46         sign.append(file)
47
48 if len(sign) == 0:
49     print "No files to sign"
50     sys.exit(0)
51
52 print "Signing %d files" % len(sign)
53 try:
54     signpkgs(sign)
55 except OSError, e:
56     print >>sys.stderr, "ERR: %s" % e
57     exit(1)
This page took 0.022389 seconds and 3 git commands to generate.