Beispiel #1
0
 def __init__(self, basepath):
     self.basepath = basepath  # Base path for new projects
     self.db = ElbeDB()  # Database of projects and users
     self.worker = AsyncWorker(self.db)
     self.userid2project = {}  # (userid, ElbeProject) map of open projects
     self.builddir2userid = {}  # (builddir, userid) map of open projects
     self.lock = Lock()  # Lock protecting our data
Beispiel #2
0
    def execute(self, args):
        oparser = OptionParser(
            usage="usage: %prog db add_user [options] <username>")
        oparser.add_option("--fullname", dest="fullname")
        oparser.add_option("--password", dest="password")
        oparser.add_option("--email", dest="email")
        oparser.add_option("--admin",
                           dest="admin",
                           default=False,
                           action="store_true")

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

        if len(arg) != 1:
            print("wrong number of arguments")
            oparser.print_help()
            return

        if not opt.password:
            password = getpass('Password for the new user: ')
        else:
            password = opt.password

        db = ElbeDB()
        db.add_user(arg[0], opt.fullname, password, opt.email, opt.admin)
Beispiel #3
0
    def execute(self, args):
        if len(args) != 2:
            print "usage: elbe db set_project_version <project_dir> <version>"
            return

        db = ElbeDB()
        db.set_project_version(args[0], args[1])
Beispiel #4
0
    def execute(self, args):
        if len(args) != 2:
            print("usage: elbe db del_version <project_dir> <version>")
            return

        db = ElbeDB()
        db.del_version(args[0], args[1])
Beispiel #5
0
    def execute(self, args):
        if len(args) != 2:
            print("usage: elbe db set_xml <project_dir> <xml>")
            return

        db = ElbeDB()
        db.set_xml(args[0], args[1])
Beispiel #6
0
    def execute(self, args):
        if len(args) != 1:
            print("usage: elbe db del_project <project_dir>")
            return

        db = ElbeDB()
        db.del_project(args[0])
Beispiel #7
0
    def execute(self, args):
        if len(args) != 2:
            print("usage: elbe db print_version_xml <project_dir> <version>")
            return

        db = ElbeDB()
        filename = db.get_version_xml(args[0], args[1])
        with open(filename) as f:
            copyfileobj(f, sys.stdout)
Beispiel #8
0
    def execute(self, args):
        if len(args) != 1:
            print("usage: elbe db get_files <project_dir>")
            return

        db = ElbeDB()
        files = db.get_project_files(args[0])
        for f in files:
            if f.description:
                print("%-40s  %s" % (f.name, f.description))
            else:
                print(f.name)
Beispiel #9
0
    def execute(self, args):
        if len(args) != 1:
            print "usage: elbe db list_versions <project_dir>"
            return

        db = ElbeDB()
        versions = db.list_project_versions(args[0])

        for v in versions:
            if v.description:
                print v.version + ": " + v.description
            else:
                print v.version
Beispiel #10
0
    def execute(self, args):
        if len(args) != 1:
            print("usage: elbe db list_versions <project_dir>")
            return

        db = ElbeDB()
        versions = db.list_project_versions(args[0])

        for v in versions:
            if v.description:
                print("%s: %s" % (v.version, v.description))
            else:
                print(v.version)
Beispiel #11
0
    def execute(self, args):
        oparser = OptionParser (usage="usage: %prog db save_version <project_dir>")
        oparser.add_option ("--description", dest="description")

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

        if len(arg) != 1:
            print "wrong number of arguments"
            oparser.print_help()
            return

        db = ElbeDB()
        db.save_version( arg[0], opt.description )
Beispiel #12
0
    def execute(self, args):
        oparser = OptionParser (
                usage="usage: %prog db create_project [options] <project_dir>" )
        oparser.add_option( "--user", dest="user",
                help="user name of the designated project owner" )
        (opt, arg) = oparser.parse_args(args)

        if len (arg) != 1:
            oparser.print_help()
            return

        db = ElbeDB()
        owner_id = db.get_user_id( opt.user )
        db.create_project (arg[0], owner_id)
Beispiel #13
0
    def execute(self, args):
        oparser = OptionParser (
                usage="usage: %prog db reset_project [options] <project_dir>")
        oparser.add_option ("--clean", dest="clean", default=False,
                action="store_true")

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

        if len(arg) != 1:
            print "wrong number of arguments"
            oparser.print_help()
            return

        db = ElbeDB()
        db.reset_project (arg[0], opt.clean)
Beispiel #14
0
    def execute(self, args):
        if len (args) != 1:
            print "usage: elbe db build <project_dir>"
            return

        db = ElbeDB()
        db.set_busy( args[0], [ "empty_project", "needs_build", "has_changes",
                                "build_done", "build_failed" ] )
        try:
            ep = db.load_project( args[0] )
            ep.build( skip_debootstrap = True )
            db.update_project_files( ep )
        except Exception as e:
            db.update_project_files( ep )
            db.reset_busy( args[0], "build_failed" )
            print e
            return
        db.reset_busy( args[0], "build_done" )
Beispiel #15
0
    def execute(self, args):
        oparser = OptionParser(
            usage="usage: %prog db del_user [options] <userid>")
        oparser.add_option("--delete-projects",
                           dest="delete_projects",
                           default=False,
                           action="store_true")
        oparser.add_option("--quiet",
                           dest="quiet",
                           default=False,
                           action="store_true")

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

        if len(arg) != 1:
            print("usage: elbe db del_user <userid>")
            return

        try:
            userid = int(arg[0])
        except ValueError as E:
            print("userid must be an integer - %s" % E)
            return

        db = ElbeDB()

        projects = db.del_user(userid)

        if projects:
            if not opt.quiet:
                if opt.delete_projects:
                    print("removing projects owned by the deleted user:"******"keeping projects owned by the deleted user:"******"%s: %s [%s] %s" %
                      (p.builddir, p.name, p.version, p.edit))
            if opt.delete_projects:
                try:
                    db.del_project(p.builddir)
                except ElbeDBError as e:
                    print("  ==> %s " % str(e))
Beispiel #16
0
    def execute(self, args):
        oparser = OptionParser(
            usage="usage: %prog db del_user [options] <userid>")
        oparser.add_option("--delete-projects",
                           dest="delete_projects",
                           default=False,
                           action="store_true")
        oparser.add_option("--quiet",
                           dest="quiet",
                           default=False,
                           action="store_true")

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

        if len(arg) != 1:
            print "usage: elbe db del_user <userid>"
            return

        try:
            userid = int(arg[0])
        except:
            print "userid must be an integer"
            return

        db = ElbeDB()

        projects = db.del_user(userid)

        if projects:
            if not opt.quiet:
                if opt.delete_projects:
                    print "removing projects owned by the deleted user:"******"keeping projects owned by the deleted user:"******":", p.name, "[", p.version, "]", p.edit
            if opt.delete_projects:
                try:
                    db.del_project(p.builddir)
                except ElbeDBError as e:
                    print "  ==> ", e
Beispiel #17
0
    def execute(self, args):
        if len(args) != 1:
            print("usage: elbe db build <project_dir>")
            return

        db = ElbeDB()
        db.set_busy(args[0], [
            "empty_project", "needs_build", "has_changes", "build_done",
            "build_failed"
        ])
        try:
            ep = db.load_project(args[0])
            ep.build()
            db.update_project_files(ep)
        # pylint: disable=broad-except
        except Exception as e:
            db.update_project_files(ep)
            db.reset_busy(args[0], "build_failed")
            print(str(e))
            return
        db.reset_busy(args[0], "build_done")
Beispiel #18
0
    def execute(self, args):
        db = ElbeDB()
        projects = db.list_projects()

        for p in projects:
            print p.builddir + ":", p.name, "[", p.version, "]", p.edit
Beispiel #19
0
    def execute(self, args):
        db = ElbeDB()
        users = db.list_users()

        for u in users:
            print u.name + ":", u.fullname, "<" + u.email + ">"
Beispiel #20
0
    def execute(self, _args):
        db = ElbeDB()
        users = db.list_users()

        for u in users:
            print("%s: %s <%s>" % (u.name, u.fullname, u.email))
Beispiel #21
0
def run_command( argv ):
    oparser = OptionParser(usage="usage: %prog buildchroot [options] <xmlfile>")

    oparser.add_option( "-t", "--target", dest="target",
                        help="directoryname of target" )

    oparser.add_option( "-o", "--output", dest="output",
                        help="name of logfile" )

    oparser.add_option( "-n", "--name", dest="name",
                        help="name of the project (included in the report)" )

    oparser.add_option( "--skip-pbuild", action="store_true",
                        dest="skip_pbuild", default=False,
                        help="skip building packages from <pbuilder> list" )

    oparser.add_option( "--build-bin", action="store_true",
                        dest="build_bin", default=False,
                        help="Build Binary Repository CDROM, for exact Reproduction" )

    oparser.add_option( "--build-sources", action="store_true",
                        dest="build_sources", default=False,
                        help="Build Source CD" )

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

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

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

    oparser.add_option( "--cdrom-size", action="store",
                        dest="cdrom_size", default=CDROM_SIZE, help="ISO CD size in MB" )

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

    oparser.add_option( "--skip-debootstrap", action="store_true",
                        dest="skip_debootstrap", default=False,
                        help="Skip debootstrap" )

    oparser.add_option( "--skip-pkglist", action="store_true",
                        dest="skip_pkglist", default=False,
                        help="ignore changes of the package list" )

    oparser.add_option( "--skip-cdrom", action="store_true",
                        dest="skip_cdrom", default=False,
                        help="(now obsolete) Skip cdrom iso generation" )

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

    if len(args) != 1:
        print "wrong number of arguments"
        oparser.print_help()
        sys.exit(20)

    if not opt.target:
        print "No target specified"
        sys.exit(20)

    if opt.skip_cdrom:
        print "WARNING: Skip CDROMS is now the default, use --build-bin to build binary CDROM"

    try:
        project = ElbeProject( opt.target, args[0], opt.output, opt.name,
                opt.buildtype, opt.skip_validation )
    except ValidationError as e:
        print str(e)
        print "xml validation failed. Bailing out"
        sys.exit(20)

    try:
        project.build( opt.skip_debootstrap, opt.build_bin,
                opt.build_sources, opt.cdrom_size, opt.debug, opt.skip_pkglist,
                opt.skip_pbuild )
    except CommandError as ce:
        print "command in project build failed:", ce.cmd
        sys.exit(20)

    try:
        db = ElbeDB()
        db.save_project (project)
    except OperationalError:
        print "failed to save project in database"
        sys.exit(20)
Beispiel #22
0
    def execute(self, _args):
        db = ElbeDB()
        projects = db.list_projects()

        for p in projects:
            print("%s: %s [%s] %s" % (p.builddir, p.name, p.version, p.edit))