def main():
    
    glb.bg_version = bgversion.BgVersion()
    parsea_argv()
    consolidate_glb()

    if glb.code_version:
        full_version = glb.code_version
    else:
        cmakelists_version = glb.bg_version.obtain_cmakelists_version(glb.filename)
        (ts_date, ts_time, short_hash) = glb.bg_version.obtain_git_version_info()
        glb.code_version, full_version = bgversion.assemble_code_and_full_versions(cmakelists_version, 
                                                                                   ts_date, ts_time, short_hash, glb.mode)

    # Now we create the .orig.tar.gz
    # tar --exclude=.git -z -c -v -f ../bulmages_0.14.0.20121128.1132-f070fef1.orig.tar.gz \
    # ../mtelleria-bulmages


    cur_basedir = os.path.basename(os.getcwd())
    cmdline = "tar --exclude=.git --exclude=debian -z -c -v -f ../bulmages_%s.orig.tar.gz ../%s" % (full_version, cur_basedir)

    if opt.print_only :
        print cmdline
        sys.exit(0)

    print "Cmdline: %s" % cmdline
    try:
        raw_input("Press ENTER to proceed or Ctrl^C to cancel\n")
    except KeyboardInterrupt:
        print "Aborted!"
        sys.exit(0)
    
    os.system(cmdline)
def main():

    glb.bg_version = bgversion.BgVersion()

    parse_argv()

    consolidate_glb()
    
    if opt.reset :
        # We reset the value to git's content
        glb.bg_version.reset_cmakelists_version(glb.filename)
        sys.exit(0)

    if glb.code_version :
        full_version = glb.code_version
    else:
        # We look at the version in bulmages/CMakeLists.txt
        # (temporary checkout included)
        cmakelists_version = glb.bg_version.obtain_cmakelists_version(glb.filename, glb.commit)
        (ts_date, ts_time, short_hash) = glb.bg_version.obtain_git_version_info(glb.commit)

        glb.code_version, full_version = bgversion.assemble_code_and_full_versions(cmakelists_version, 
                                                                                   ts_date, ts_time, short_hash, glb.mode)

    if opt.print_only:
        print glb.code_version
        print full_version
        sys.exit(0)

    if glb.code_version != cmakelists_version:
        glb.bg_version.set_cmakelists_version(glb.filename, glb.code_version)