Exemple #1
0
def main():
    available_repositories = utils.available_repositories()
    for item in os.listdir(cst.repos):
        repo_conf = os.path.join(cst.repos, item, cst.repo_file)
        if os.access(repo_conf, os.F_OK):
            with open(repo_conf) as data:
                data = conf.ReadConfig(data.read().splitlines(), delimiter="@")
            if item in available_repositories:
                out.normal("%s [%s]" % (item, out.color("enabled", "brightgreen")))
            else:
                out.normal("%s [%s]" % (item, out.color("disabled", "brightred")))
            out.notify("system name: %s" % item)
            if hasattr(data, "name"):
                out.notify("development name: %s" % data.name)
            else:
                out.warn("development name is not defined!")
            if hasattr(data, "summary"):
                out.notify("summary: %s" % data.summary)
            else:
                out.warn("summary is not defined!")
            if hasattr(data, "maintainer"):
                out.notify("maintainer: %s" % data.maintainer)
            else:
                out.warn("maintainer is not defined!")
            out.write("\n")
Exemple #2
0
def main():
    available_repositories = utils.available_repositories()
    for item in os.listdir(cst.repos):
        repo_conf = os.path.join(cst.repos, item, cst.repo_file)
        if os.access(repo_conf, os.F_OK):
            with open(repo_conf) as data:
                data = conf.ReadConfig(data.read().splitlines(), delimiter="@")
            if item in available_repositories:
                out.normal("%s [%s]" %
                           (item, out.color("enabled", "brightgreen")))
            else:
                out.normal("%s [%s]" %
                           (item, out.color("disabled", "brightred")))
            out.notify("system name: %s" % item)
            if hasattr(data, "name"):
                out.notify("development name: %s" % data.name)
            else:
                out.warn("development name is not defined!")
            if hasattr(data, "summary"):
                out.notify("summary: %s" % data.summary)
            else:
                out.warn("summary is not defined!")
            if hasattr(data, "maintainer"):
                out.notify("maintainer: %s" % data.maintainer)
            else:
                out.warn("maintainer is not defined!")
            out.write("\n")
Exemple #3
0
def syncronization(names):
    '''Syncronizes package repositories by use of any SCM'''
    available_repositories = utils.available_repositories()
    queue = names if names else available_repositories
    for item in queue:
        if item in available_repositories:
            sync.SyncronizeRepo().run(item)
        else:
            raise InvalidRepository("%s seems an invalid repository." % item)
Exemple #4
0
def syncronization(names):
    '''Syncronizes package repositories by use of any SCM'''
    available_repositories = utils.available_repositories()
    queue = names if names else available_repositories
    for item in queue:
        if item in available_repositories:
            sync.SyncronizeRepo().run(item)
        else:
            raise InvalidRepository("%s seems an invalid repository." % item)
Exemple #5
0
 def __init__(self):
     self.news_read_file = os.path.join(cst.repos, cst.news_read)
     self.available_repositories = utils.available_repositories()
     self.data = []
Exemple #6
0
def main(params):
    # determine operation type
    repo_name = None
    if params:
        repo_name = params[0]

    # create operation object
    operation = Update()

    repo_num = 0 
    if repo_name is None:
        # firstly, lpms tries to create a copy of current repository database.
        db_backup()

        out.normal("updating repository database...")
        operation.repodb.database.begin_transaction()
        for repo_name in os.listdir(cst.repos):
            if not repo_name in utils.available_repositories():
                continue
            if os.path.isfile(os.path.join(cst.repos, repo_name, "info/repo.conf")):
                out.write(out.color(" * ", "red") + repo_name+"\n")
                
                operation.update_repository(repo_name)
                repo_num += 1

        operation.repodb.database.commit()
        out.normal("%s repository(ies) is/are updated." % repo_num)
    else:
        if repo_name == ".":
            current_path = os.getcwd()
            for repo_path in [os.path.join(cst.repos, item) \
                    for item in utils.available_repositories()]:
                if current_path == repo_path or len(current_path.split(repo_path)) == 2:
                    # convert it a valid repo_name variable from the path
                    repo_name = current_path.split(cst.repos)[1][1:]
                    break
            if repo_name == ".":
                out.warn("%s does not seem a valid repository path." % \
                        out.color(current_path, "red"))
                lpms.terminate()

        if len(repo_name.split("/")) == 2:
            out.normal("updating %s" % repo_name)
            repo, category = repo_name.split("/")
            repo_path = os.path.join(cst.repos, repo)
            
            if not repo in utils.available_repositories():
                out.error("%s is not a repository." % out.color(repo, "red"))
                lpms.terminate()

            operation.repodb.database.begin_transaction()
            for pkg in os.listdir(os.path.join(repo_path, category)):
                try:
                    operation.update_package(repo_path, category, pkg, update=True)
                except IntegrityError:
                    continue
            operation.repodb.database.commit()

        elif len(repo_name.split("/")) == 3:
            version = None
            repo, category, name = repo_name.split("/")
            
            if repo.startswith("="):
                repo = repo[1:]
                try:
                    name, version = utils.parse_pkgname(name)
                except TypeError:
                    out.error("you should give a version number")
                    lpms.terminate()
            else:
                if utils.parse_pkgname(name) is not None and len(utils.parse_pkgname(name)) == 2:
                    out.error("you must use %s" % (out.color("="+repo_name, "red")))
                    lpms.terminate()
            
            if not repo in utils.available_repositories():
                out.error("%s is not a repository." % out.color(repo, "red"))
                lpms.terminate()

            repo_path = os.path.join(cst.repos, repo)
            out.normal("updating %s/%s/%s" % (repo, category, name))
            operation.repodb.database.begin_transaction()
            operation.update_package(repo_path, category, name, my_version = version, update = True)
            operation.repodb.database.commit()
        
        else:
            if not repo_name in utils.available_repositories():
                out.error("%s is not a repository." % out.color(repo_name, "red"))
                lpms.terminate()
            
            repo_dir = os.path.join(cst.repos, repo_name)
            if os.path.isdir(repo_dir):
                repo_path = os.path.join(repo_dir, cst.repo_file)
                if os.path.isfile(repo_path):
                    operation.repodb.database.begin_transaction()
                    out.normal("updating repository: %s" % out.color(repo_name, "green"))
                    operation.update_repository(repo_name)
                    operation.repodb.database.commit()
                else:
                    lpms.terminate("repo.conf file could not found in %s" % repo_dir+"/info")
            else:
                lpms.terminate("repo.conf not found in %s" % os.path.join(cst.repos, repo_name))

    out.normal("Total %s packages have been processed." % operation.packages_num)
    
    # Drop inactive repository from the database
    for name in operation.repodb.get_repository_names():
        if not name in utils.available_repositories():
            operation.repodb.delete_repository(name, commit=True)
            out.warn("%s dropped." % name)
    
    # Close the database connection
    operation.repodb.database.close()
Exemple #7
0
 def __init__(self):
     self.news_read_file = os.path.join(cst.repos, cst.news_read)
     self.available_repositories = utils.available_repositories()
     self.data = []
Exemple #8
0
def main(params):
    # determine operation type
    repo_name = None
    if params:
        repo_name = params[0]

    # create operation object
    operation = Update()

    repo_num = 0
    if repo_name is None:
        # firstly, lpms tries to create a copy of current repository database.
        db_backup()

        out.normal("updating repository database...")
        operation.repodb.database.begin_transaction()
        for repo_name in os.listdir(cst.repos):
            if not repo_name in utils.available_repositories():
                continue
            if os.path.isfile(
                    os.path.join(cst.repos, repo_name, "info/repo.conf")):
                out.write(out.color(" * ", "red") + repo_name + "\n")

                operation.update_repository(repo_name)
                repo_num += 1

        operation.repodb.database.commit()
        out.normal("%s repository(ies) is/are updated." % repo_num)
    else:
        if repo_name == ".":
            current_path = os.getcwd()
            for repo_path in [os.path.join(cst.repos, item) \
                    for item in utils.available_repositories()]:
                if current_path == repo_path or len(
                        current_path.split(repo_path)) == 2:
                    # convert it a valid repo_name variable from the path
                    repo_name = current_path.split(cst.repos)[1][1:]
                    break
            if repo_name == ".":
                out.warn("%s does not seem a valid repository path." % \
                        out.color(current_path, "red"))
                lpms.terminate()

        if len(repo_name.split("/")) == 2:
            out.normal("updating %s" % repo_name)
            repo, category = repo_name.split("/")
            repo_path = os.path.join(cst.repos, repo)

            if not repo in utils.available_repositories():
                out.error("%s is not a repository." % out.color(repo, "red"))
                lpms.terminate()

            operation.repodb.database.begin_transaction()
            for pkg in os.listdir(os.path.join(repo_path, category)):
                try:
                    operation.update_package(repo_path,
                                             category,
                                             pkg,
                                             update=True)
                except IntegrityError:
                    continue
            operation.repodb.database.commit()

        elif len(repo_name.split("/")) == 3:
            version = None
            repo, category, name = repo_name.split("/")

            if repo.startswith("="):
                repo = repo[1:]
                try:
                    name, version = utils.parse_pkgname(name)
                except TypeError:
                    out.error("you should give a version number")
                    lpms.terminate()
            else:
                if utils.parse_pkgname(name) is not None and len(
                        utils.parse_pkgname(name)) == 2:
                    out.error("you must use %s" %
                              (out.color("=" + repo_name, "red")))
                    lpms.terminate()

            if not repo in utils.available_repositories():
                out.error("%s is not a repository." % out.color(repo, "red"))
                lpms.terminate()

            repo_path = os.path.join(cst.repos, repo)
            out.normal("updating %s/%s/%s" % (repo, category, name))
            operation.repodb.database.begin_transaction()
            operation.update_package(repo_path,
                                     category,
                                     name,
                                     my_version=version,
                                     update=True)
            operation.repodb.database.commit()

        else:
            if not repo_name in utils.available_repositories():
                out.error("%s is not a repository." %
                          out.color(repo_name, "red"))
                lpms.terminate()

            repo_dir = os.path.join(cst.repos, repo_name)
            if os.path.isdir(repo_dir):
                repo_path = os.path.join(repo_dir, cst.repo_file)
                if os.path.isfile(repo_path):
                    operation.repodb.database.begin_transaction()
                    out.normal("updating repository: %s" %
                               out.color(repo_name, "green"))
                    operation.update_repository(repo_name)
                    operation.repodb.database.commit()
                else:
                    lpms.terminate("repo.conf file could not found in %s" %
                                   repo_dir + "/info")
            else:
                lpms.terminate("repo.conf not found in %s" %
                               os.path.join(cst.repos, repo_name))

    out.normal("Total %s packages have been processed." %
               operation.packages_num)

    # Drop inactive repository from the database
    for name in operation.repodb.get_repository_names():
        if not name in utils.available_repositories():
            operation.repodb.delete_repository(name, commit=True)
            out.warn("%s dropped." % name)

    # Close the database connection
    operation.repodb.database.close()