aboutsummaryrefslogblamecommitdiff
path: root/scripts/build-debian-control-files.py
blob: cb679b2aabbb523da81e0d009e822538ff5a568f (plain) (tree)


























                                                                                                             



                                      
                       


                                
                                 





















                                                                                                                        

                                           
                                                       
#!/usr/bin/env python

import subprocess
import argparse
import sys
import os

parser = argparse.ArgumentParser()
parser.add_argument("--debemail",    required = True)
parser.add_argument("--package",     required = True)
parser.add_argument("--newversion",  required = True)
parser.add_argument("--description", default = "Software and firmware for Cryptech Alpha development board.")
parser.add_argument("--conflicts",   nargs = "*")

args = parser.parse_args()

if os.path.exists("debian/control") and os.path.exists("debian/changelog"):
    sys.exit(0)

control_template= '''\
Source: {args.package}
Maintainer: {args.debemail}
Section: misc
Priority: optional
Standards-Version: 3.9.6
Build-Depends: debhelper (>= 9),
               dh-python,
               python (>= 2.7),
               python-yaml
Homepage: http://trac.cryptech.is/wiki

Package: {args.package}
Architecture: any
Depends: python,
         python-serial (>= 3.0),
         python-tornado (>= 4.0),
         ${{misc:Depends}},
         ${{python:Depends}},
         ${{shlibs:Depends}}
{conflicts}\
Description: Cryptech Project open-source cryptographic software and firmware.
 {args.description}
'''

if args.conflicts:
    conflicts = "Conflicts: {}\n".format(" ".join(args.conflicts))
else:
    conflicts = ""

subprocess.check_call(("dch", "--create", "--package", args.package, "--newversion", args.newversion, args.description),
                      env = dict(os.environ,
                                 EDITOR   = "/bin/true",
                                 VISUAL   = "/bin/true",
                                 TZ       = "UTC",
                                 DEBEMAIL = args.debemail))

with open("debian/control", "w") as f:
    f.write(control_template.format(args = args, conflicts = conflicts))

with open("cryptech_version.py", "w") as f:
    f.write("VERSION = '{}'\n".format(args.newversion))