コード例 #1
0
ファイル: create.py プロジェクト: ArashJavan/elbe
def run_command( argv ):
    pack_dir = elbepack.__path__[0]
    template_dir = os.path.join( pack_dir, "mako" )

    oparser = OptionParser( usage="usage: %prog create [options] <filename>" )

    oparser.add_option( "--oldkvm", action="store_true", dest="oldkvm",
                        default=False,
                        help="We are building for an old kvm version" )

    oparser.add_option( "--debug", action="store_true", dest="debug",
                        default=False,
                        help="Enable various features to debug the build" )

    oparser.add_option( "--skip-validation", action="store_true",
                        dest="skip_validation", default=False,
                        help="Skip xml schema validation" )

    oparser.add_option( "--skip-cds", action="store_true", dest="skip_cds",
                        default=False,
                        help="Skip cd generation" )

    oparser.add_option( "--directory", dest="dir",
                        help="Write Makefile into specified directory",
                        metavar="FILE" )

    oparser.add_option( "--buildtype", dest="buildtype",
                        help="Override the buildtype" )

    oparser.add_option( "--build-source", action="store_true",
                        dest="buildsources", default=False,
                        help="Build source cdrom" )

    oparser.add_option( "--proxy", dest="proxy",
                        help="Override the http Proxy" )

    (opt,args) = oparser.parse_args(argv)

    if len(args) == 0:
        print "No Filename specified"
        oparser.print_help()
        sys.exit(20)

    if len(args) > 1:
        print "too many filenames specified"
        oparser.print_help()
        sys.exit(20)

    try:
        if not opt.skip_validation:
            if not validate_xml( args[0] ):
                print "xml validation failed. Bailing out"
                sys.exit(20)

        xml = etree( args[0] )
    except:
        print "Unable to open xml File. Bailing out"
        sys.exit(20)

    if opt.buildtype:
        buildtype = opt.buildtype
    elif xml.has( "project/buildtype" ):
        buildtype = xml.text( "/project/buildtype" )
    else:
        buildtype = "nodefaults"

    if opt.proxy:
        http_proxy = opt.proxy
    elif xml.has("project/mirror/primary_proxy"):
        http_proxy = xml.text("project/mirror/primary_proxy")
    else:
        http_proxy = ""

    defs = ElbeDefaults( buildtype )

    if xml.node("/project/mirror/url-list"):
        for n in xml.node("/project/mirror/url-list"):
           if n.has("binary"):
             if n.text("binary").find("localhost") != -1:
               print "localhost is not allowed as url - use LOCALMACHINE to refer to your system."
               sys.exit(40)
           if n.has("source"):
             if n.text("source").find("localhost") != -1:
               print "localhost is not allowed as url - use LOCALMACHINE to refer to your system."
               sys.exit(40)

    if not opt.dir:
        path = "./build"
    else:
        path = opt.dir

    try:
        os.makedirs(path)
    except:
        print 'unable to create project directory: %s' % path
        sys.exit(30)

    out_path = os.path.join(path,".elbe-in")
    try:
        os.makedirs(out_path)
    except:
        print 'unable to create subdirectory: %s' % out_path
        sys.exit(30)

    d = {"elbe_version": elbe_version,
         "opt": opt,
         "xml": xml,
         "prj": xml.node("/project"),
         "tgt": xml.node("/target"),
         "pkgs": xml.node("/target/pkg-list"),
         "fine": xml.node("/finetuning"),
         "defs": defs,
         "http_proxy": http_proxy,
         "buildchroot": False,
         "preseed": get_preseed(xml) }

    try:
        copy_kinitrd(xml, out_path, defs)
    except:
        print "Failure to download kernel/initrd debian Package"
        print "Check your source URLs"
        sys.exit(20)

    if xml.has("archive"):
        unbase( xml.text("/archive"), os.path.join(out_path,"archive.tar.bz2") )

    templates = os.listdir( template_dir )

    make_executable = [ "02pinning.mako",
                        "finetuning.sh.mako",
                        "changeroot-into-buildenv.sh.mako",
                        "cp-scipts-into-buildenv.sh.mako",
                        "create-target-rfs.sh.mako",
                        "part-target.sh.mako",
                        "post-inst.sh.mako",
                        "print_licence.sh.mako",
                        "mkcdrom.sh.mako" ]

    for t in templates:
        print t
        o = t.replace( ".mako", "" )
        if t == "Makefile.mako":
            write_template(os.path.join(path,o), os.path.join(template_dir, t), d )
        else:
            write_template(os.path.join(out_path,o), os.path.join(template_dir, t), d )

        if t in make_executable:
            os.chmod( os.path.join(out_path,o), 0755 )

    shutil.copyfile( args[0],
       os.path.join(out_path, "source.xml" ) )

    shutil.copyfile( os.path.join( pack_dir, "treeutils.py" ),
       os.path.join(out_path, "treeutils.py" ) )

    shutil.copyfile( os.path.join( pack_dir, "version.py" ),
       os.path.join(out_path, "version.py" ) )

    shutil.copyfile( os.path.join( pack_dir, "dump.py" ),
       os.path.join(out_path, "dump.py" ) )

    shutil.copyfile( os.path.join( pack_dir, "hdimg.py" ),
       os.path.join(out_path, "hdimg.py" ) )

    shutil.copyfile( os.path.join( pack_dir, "fstab.py" ),
       os.path.join(out_path, "fstab.py" ) )
コード例 #2
0
def run_command(argv):
    pack_dir = elbepack.__path__[0]
    template_dir = os.path.join(pack_dir, "mako")

    oparser = OptionParser(usage="usage: %prog create [options] <filename>")

    oparser.add_option("--oldkvm",
                       action="store_true",
                       dest="oldkvm",
                       default=False,
                       help="We are building for an old kvm version")

    oparser.add_option("--debug",
                       action="store_true",
                       dest="debug",
                       default=False,
                       help="Enable various features to debug the build")

    oparser.add_option("--skip-validation",
                       action="store_true",
                       dest="skip_validation",
                       default=False,
                       help="Skip xml schema validation")

    oparser.add_option("--skip-cds",
                       action="store_true",
                       dest="skip_cds",
                       default=False,
                       help="Skip cd generation")

    oparser.add_option("--directory",
                       dest="dir",
                       help="Write Makefile into specified directory",
                       metavar="FILE")

    oparser.add_option("--buildtype",
                       dest="buildtype",
                       help="Override the buildtype")

    oparser.add_option("--build-source",
                       action="store_true",
                       dest="buildsources",
                       default=False,
                       help="Build source cdrom")

    oparser.add_option("--proxy", dest="proxy", help="Override the http Proxy")

    (opt, args) = oparser.parse_args(argv)

    if len(args) == 0:
        print "No Filename specified"
        oparser.print_help()
        sys.exit(20)

    if len(args) > 1:
        print "too many filenames specified"
        oparser.print_help()
        sys.exit(20)

    try:
        if not opt.skip_validation:
            if not validate_xml(args[0]):
                print "xml validation failed. Bailing out"
                sys.exit(20)

        xml = etree(args[0])
    except:
        print "Unable to open xml File. Bailing out"
        sys.exit(20)

    if opt.buildtype:
        buildtype = opt.buildtype
    elif xml.has("project/buildtype"):
        buildtype = xml.text("/project/buildtype")
    else:
        buildtype = "nodefaults"

    if opt.proxy:
        http_proxy = opt.proxy
    elif xml.has("project/mirror/primary_proxy"):
        http_proxy = xml.text("project/mirror/primary_proxy")
    else:
        http_proxy = ""

    defs = ElbeDefaults(buildtype)

    if xml.node("/project/mirror/url-list"):
        for n in xml.node("/project/mirror/url-list"):
            if n.has("binary"):
                if n.text("binary").find("localhost") != -1:
                    print "localhost is not allowed as url - use LOCALMACHINE to refer to your system."
                    sys.exit(40)
            if n.has("source"):
                if n.text("source").find("localhost") != -1:
                    print "localhost is not allowed as url - use LOCALMACHINE to refer to your system."
                    sys.exit(40)

    if not opt.dir:
        path = "./build"
    else:
        path = opt.dir

    try:
        os.makedirs(path)
    except:
        print 'unable to create project directory: %s' % path
        sys.exit(30)

    out_path = os.path.join(path, ".elbe-in")
    try:
        os.makedirs(out_path)
    except:
        print 'unable to create subdirectory: %s' % out_path
        sys.exit(30)

    d = {
        "elbe_version": elbe_version,
        "opt": opt,
        "xml": xml,
        "prj": xml.node("/project"),
        "tgt": xml.node("/target"),
        "pkgs": xml.node("/target/pkg-list"),
        "fine": xml.node("/finetuning"),
        "defs": defs,
        "http_proxy": http_proxy,
        "buildchroot": False,
        "preseed": get_preseed(xml)
    }

    try:
        copy_kinitrd(xml, out_path, defs)
    except:
        print "Failure to download kernel/initrd debian Package"
        print "Check your source URLs"
        sys.exit(20)

    if xml.has("archive"):
        unbase(xml.text("/archive"), os.path.join(out_path, "archive.tar.bz2"))

    templates = os.listdir(template_dir)

    make_executable = [
        "02pinning.mako", "finetuning.sh.mako",
        "changeroot-into-buildenv.sh.mako", "cp-scipts-into-buildenv.sh.mako",
        "create-target-rfs.sh.mako", "part-target.sh.mako",
        "post-inst.sh.mako", "print_licence.sh.mako", "mkcdrom.sh.mako"
    ]

    for t in templates:
        print t
        o = t.replace(".mako", "")
        if t == "Makefile.mako":
            write_template(os.path.join(path, o),
                           os.path.join(template_dir, t), d)
        else:
            write_template(os.path.join(out_path, o),
                           os.path.join(template_dir, t), d)

        if t in make_executable:
            os.chmod(os.path.join(out_path, o), 0755)

    shutil.copyfile(args[0], os.path.join(out_path, "source.xml"))

    shutil.copyfile(os.path.join(pack_dir, "treeutils.py"),
                    os.path.join(out_path, "treeutils.py"))

    shutil.copyfile(os.path.join(pack_dir, "version.py"),
                    os.path.join(out_path, "version.py"))

    shutil.copyfile(os.path.join(pack_dir, "dump.py"),
                    os.path.join(out_path, "dump.py"))

    shutil.copyfile(os.path.join(pack_dir, "hdimg.py"),
                    os.path.join(out_path, "hdimg.py"))

    shutil.copyfile(os.path.join(pack_dir, "fstab.py"),
                    os.path.join(out_path, "fstab.py"))
コード例 #3
0
ファイル: create.py プロジェクト: epplerc/elbe
def run_command( argv ):
    pack_dir = elbepack.__path__[0]
    template_dir = os.path.join( pack_dir, "mako" )

    oparser = OptionParser( usage="usage: %prog create [options] <filename>" )

    oparser.add_option( "--oldkvm", action="store_true", dest="oldkvm",
                        default=False,
                        help="We are building for an old kvm version" )

    oparser.add_option( "--debug", action="store_true", dest="debug",
                        default=False,
                        help="Enable various features to debug the build" )

    oparser.add_option( "--skip-validation", action="store_true",
                        dest="skip_validation", default=False,
                        help="Skip xml schema validation" )

    oparser.add_option( "--skip-cds", action="store_true", dest="skip_cds",
                        default=False,
                        help="Skip cd generation" )

    oparser.add_option( "--directory", dest="dir",
                        help="Write Makefile into specified directory",
                        metavar="FILE" )

    oparser.add_option( "--build-source", action="store_true",
                        dest="buildsources", default=False,
                        help="Build source cdrom" )

    (opt,args) = oparser.parse_args(argv)

    if len(args) == 0:
        print "No Filename specified"
        oparser.print_help()
        sys.exit(20)

    if len(args) > 1:
        print "too many filenames specified"
        oparser.print_help()
        sys.exit(20)

    try:
        if not opt.skip_validation:
            if not validate_xml( args[0] ):
                print "xml validation failed. Bailing out"
                sys.exit(20)

        xml = etree( args[0] )
    except:
        print "Unable to open xml File. Bailing out"
        sys.exit(20)

    if not opt.dir:
        path = "./build"
    else:
        path = opt.dir

    try:
        os.makedirs(path)
    except:
        print 'unable to create project directory: %s' % path
        sys.exit(30)

    d = {"opt": opt,
         "xml": xml,
         "prj": xml.node("/project"),
         "tgt": xml.node("/target"),
         "pkgs": xml.node("/target/pkg-list"),
         "fine": xml.node("/finetuning"),
         "preseed": get_preseed(xml) }

    try:
        copy_kinitrd(xml, path)
    except:
        print "Failure to download kernel/initrd debian Package"
        print "Check your source URLs"
        sys.exit(20)

    if xml.has("archive"):
        unbase( xml.text("/archive"), os.path.join(path,"archive.tar.bz2") )

    templates = os.listdir( template_dir )

    make_executable = [ "02pinning.mako",
                        "finetuning.sh.mako",
                        "changeroot-into-buildenv.sh.mako",
                        "cp-scipts-into-buildenv.sh.mako",
                        "create-target-rfs.sh.mako",
                        "part-target.sh.mako",
                        "post-inst.sh.mako",
                        "print_licence.sh.mako",
                        "purge.sh.mako",
                        "mkcdrom.sh.mako" ]

    for t in templates:
        print t
        o = t.replace( ".mako", "" )
        write_template(os.path.join(path,o), os.path.join(template_dir, t), d )

        if t in make_executable:
            os.chmod( os.path.join(path,o), 0755 )

    shutil.copyfile( args[0],
       os.path.join(path, "source.xml" ) )

    shutil.copyfile( os.path.join( pack_dir, "treeutils.py" ),
       os.path.join(path, "treeutils.py" ) )

    shutil.copyfile( os.path.join( pack_dir, "dump.py" ),
       os.path.join(path, "dump.py" ) )
コード例 #4
0
ファイル: init.py プロジェクト: lwalewski/elbe
        "defs": defs,
        "opt": opt,
        "xml": xml,
        "prj": xml.node("/initvm"),
        "http_proxy": http_proxy,
        "pkgs": xml.node("/initvm/pkg-list") or [],
        "preseed": get_initvm_preseed(xml)
    }

    if http_proxy != "":
        os.putenv("http_proxy", http_proxy)
        os.putenv("https_proxy", http_proxy)
        os.putenv("no_proxy", "localhost,127.0.0.1")

    try:
        copy_kinitrd(xml.node("/initvm"), out_path, defs, arch="amd64")
    except NoKinitrdException as e:
        print "Failure to download kernel/initrd debian Package:"
        print
        print e.message
        print
        print "Check Mirror configuration"
        sys.exit(20)

    templates = os.listdir(init_template_dir)

    make_executable = ["init-elbe.sh.mako", "preseed.cfg.mako"]

    for t in templates:
        o = t.replace(".mako", "")
コード例 #5
0
ファイル: init.py プロジェクト: atoz-chevara/elbe
    d = {"elbe_version": elbe_version,
         "defs": defs,
         "opt": opt,
         "xml": xml,
         "prj": xml.node("/initvm"),
         "http_proxy": http_proxy,
         "pkgs": xml.node("/initvm/pkg-list") or [],
         "preseed": get_initvm_preseed(xml) }

    if http_proxy != "":
        os.putenv ("http_proxy", http_proxy)
        os.putenv ("https_proxy", http_proxy)
        os.putenv ("no_proxy", "localhost,127.0.0.1")

    try:
        copy_kinitrd(xml.node("/initvm"), out_path, defs, arch="amd64")
    except NoKinitrdException as e:
        print "Failure to download kernel/initrd debian Package:"
        print
        print e.message
        print
        print "Check Mirror configuration"
        sys.exit(20)

    templates = os.listdir( init_template_dir )

    make_executable = [ "init-elbe.sh.mako",
                        "preseed.cfg.mako" ]

    for t in templates:
        o = t.replace( ".mako", "" )