~coreygoldberg/uci-engine/subunit-results

« back to all changes in this revision

Viewing changes to cupstream2distro/resignpackage

Merge trunk, resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Ubuntu CI Engine
 
3
# Copyright 2014 Canonical Ltd.
 
4
 
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU Affero General Public License version 3, as
 
7
# published by the Free Software Foundation.
 
8
 
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
12
# PURPOSE.  See the GNU Affero General Public License for more details.
 
13
 
 
14
# You should have received a copy of the GNU Affero General Public License
 
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
import argparse
 
18
import logging
 
19
import subprocess
 
20
import sys
 
21
 
 
22
from cupstream2distro.settings import BOT_KEY
 
23
 
 
24
 
 
25
def parse_args():
 
26
    logging.basicConfig(level=logging.INFO)
 
27
    parser = argparse.ArgumentParser(description="Resign source packages "
 
28
                                                 "with the key with right "
 
29
                                                 "creds")
 
30
    parser.add_argument("-k", "--gnupg-keyid",
 
31
                        default=BOT_KEY,
 
32
                        help="Bot GPG key ID")
 
33
    parser.add_argument("-l", "--content-url", required=True,
 
34
                        help="The url where the changes is stored")
 
35
    parser.add_argument("-d", "--debug", action="store_true",
 
36
                        default=False, help="Enable debug infos")
 
37
    args = parser.parse_args()
 
38
    return args
 
39
 
 
40
 
 
41
def main(args):
 
42
    logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO,
 
43
                        format="%(asctime)s %(levelname)s %(message)s")
 
44
    cmd = ["debsign", "-k{}".format(args.gnupg_keyid), "--re-sign",
 
45
           args.content_url]
 
46
    try:
 
47
        logging.info("Running command {}".format(cmd))
 
48
        subprocess.check_call(cmd)
 
49
    except:
 
50
        logging.exception("Signing failed")
 
51
 
 
52
 
 
53
if __name__ == '__main__':
 
54
    args = parse_args()
 
55
    main(args)