~allanlesage/uci-engine/coverage-extractor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# Ubuntu CI Engine
# Copyright 2014 Canonical Ltd.

# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License version 3, as
# published by the Free Software Foundation.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import argparse
import logging
import subprocess
import sys

from cupstream2distro.settings import BOT_KEY


def parse_args():
    logging.basicConfig(level=logging.INFO)
    parser = argparse.ArgumentParser(description="Resign source packages "
                                                 "with the key with right "
                                                 "creds")
    parser.add_argument("-k", "--gnupg-keyid",
                        default=BOT_KEY,
                        help="Bot GPG key ID")
    parser.add_argument("-l", "--content-url", required=True,
                        help="The url where the changes is stored")
    parser.add_argument("-d", "--debug", action="store_true",
                        default=False, help="Enable debug infos")
    args = parser.parse_args()
    return args


def main(args):
    logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO,
                        format="%(asctime)s %(levelname)s %(message)s")
    cmd = ["debsign", "-k{}".format(args.gnupg_keyid), "--re-sign",
           args.content_url]
    try:
        logging.info("Running command {}".format(cmd))
        subprocess.check_call(cmd)
    except:
        logging.exception("Signing failed")


if __name__ == '__main__':
    args = parse_args()
    main(args)