main

Entrypoint to this script.  This will execute the functionality as a standalone
element

def main():
    """main

Entrypoint to this script.  This will execute the functionality as a standalone
element
    """
    src_dir = sys.argv[1]
    os.chdir(src_dir)
    config = get_config(src_dir)
    cmd = 'python -c "import f5;print(f5.__version__)"'
    version = \
        subprocess.check_output([cmd], shell=True).strip()
    tmp_dist = "/var/deb_dist"
    project = config['project']
    tmp_dist = "/var/deb_dist"
    os_version = "1404"
    deb_dir = "%s/deb_dist" % config['dist_dir']
    print("Building %s debian packages..." % project)
    shutil.copyfile("%s/stdeb.cfg" % (deb_dir), "./stdeb.cfg")
    shutil.copytree(deb_dir, tmp_dist)
    cmd = 'python setup.py --command-packages=stdeb.command sdist_dsc ' + \
        '--dist-dir=%s' % tmp_dist
    print(subprocess.check_output([cmd], shell=True))
    os.chdir("%s/%s-%s" % (tmp_dist, project, version))
    cmd = 'dpkg-buildpackage -rfakeroot -uc -us'.split()
    subprocess.check_output(cmd)  # args will not show up in ps...
    os.chdir(src_dir)
    pkg = "python-%s_%s-1" % (project, version)
    os_pkg = pkg + "_%s_all.deb" % os_version
    pkg = pkg + "_all.deb"
    shutil.copyfile("%s/%s" % (tmp_dist, pkg), "%s/%s" % (deb_dir, os_pkg))
    cmd = "python %s/add_pkg_name.py deb_pkg %s/%s" % \
        (config['scripts'], deb_dir, os_pkg)