Пример #1
0
    def create_database(self):
        os.chdir(paths.mirror)

        if len(conf.updated) == 0:
            return

        print(title("Create database") + "\n")

        strict_execute("""
        rm -f {path}/{database}.old;
        rm -f {path}/{database}.files;
        rm -f {path}/{database}.files.tar.gz;
        rm -f {path}/{database}.files.tar.gz.old;
        """.format(database=conf.db, path=paths.mirror))

        for package in conf.updated:
            name = package["name"]
            version = package["version"]

            strict_execute(f"""
            repo-add \
                --nocolor \
                --remove \
                {paths.mirror}/{conf.db}.db.tar.gz \
                {paths.mirror}/{name}-{version}-*.pkg.tar.xz
            """)
Пример #2
0
    def __init__(self, name, is_dependency=False, is_testing=False):
        self.errors = []

        if is_testing:
            strict_execute(f"cp -r {paths.pkg}/{name} {paths.tmp}")
            self.path = os.path.join(paths.tmp, name)
        else:
            self.path = os.path.join(paths.pkg, name)

        self.name = name
        self.is_testing = is_testing
        self.module = load_source(name + ".package",
                                  os.path.join(self.path, "package.py"))
        self.is_dependency = is_dependency
Пример #3
0
    def commit_readme(self):
        path = paths.base + "/README.md"

        if (has_git_changes(path) is False or len(conf.updated) == 0):
            return

        print(bold("Build README.md and mirror page:"))

        commit_msg = "Doc: Bump " + ", ".join(
            conf.updated) + " in packages information table"
        strict_execute(f"""
        git add {path};
        git commit -m "{commit_msg}";
        """)
Пример #4
0
    def _deploy_ssh(self):
        print(title("Deploy to host remote") + "\n")

        strict_execute(f"""
        rsync \
            --archive \
            --copy-links \
            --delete \
            --recursive \
            --update \
            --verbose \
            --progress -e 'ssh -i {paths.base}/deploy_key -p {conf.ssh_port}' \
            {paths.mirror}/ \
            {conf.ssh_user}@{conf.ssh_host}:{conf.ssh_path}
        """)
Пример #5
0
    def _commit_readme(self):
        path = paths.base + "/README.md"
        packages = []

        if (has_git_changes(path) is False or len(conf.updated) == 0):
            return

        print(title("Build README.md and mirror page:") + "\n")

        for package in conf.updated:
            packages.append(package["name"])

        commit_msg = "Doc: Bump " + ", ".join(packages) + " in packages information table"
        strict_execute(f"""
        git add {path};
        git commit -m "{commit_msg}";
        """)
Пример #6
0
    def clean_database(self):
        in_directory = []
        in_database = output("pacman -Slq %s | sort" % conf.db)

        if in_database.startswith("error: repository"):
            return
        else:
            in_database = in_database.split("\n")

        for name in conf.packages:
            directory = paths.pkg + "/" + name

            try:
                open(directory + "/PKGBUILD")
            except FileNotFoundError:
                continue

            in_directory = in_directory + extract(directory,
                                                  "pkgname").split(" ")

        os.chdir(paths.mirror)
        useless_packages = set(in_database) - set(in_directory)

        if len(useless_packages) == 0:
            return

        print("Remove packages in database:")

        for name in (set(in_database) - set(in_directory)):
            schema = self._get_schema(name)
            path = name + "-" + schema["version"]

            strict_execute(f"""
            repo-remove \
                --nocolor \
                --remove \
                {paths.mirror}/{conf.db}.db.tar.gz \
                {name}
            """)
Пример #7
0
    def prepare_mirror(self):
        remote = output("git ls-files " + paths.mirror +
                        " | awk -F / '{print $2}'").split("\n")
        files = os.listdir(paths.mirror)

        for f in ["validation_token", "packages_checked"]:
            if f in files:
                files.remove(f)

        if len(files) != len(remote) or not remote_repository():
            return

        print(bold("Pull remote mirror directory files:"))

        strict_execute(f"""
        scp -i {paths.base}/deploy_key -P {conf.ssh_port} \
            {conf.ssh_user}@{conf.ssh_host}:{conf.ssh_path}/* \
            {paths.mirror}/;

        ssh -i {paths.base}/deploy_key -p {conf.ssh_port} \
            {conf.ssh_user}@{conf.ssh_host} \
            touch {conf.ssh_path}/*;
        """)
Пример #8
0
def set_directories():
    strict_execute(f"""
    mkdir -p {paths.log};
    mkdir -p {paths.tmp};
    mkdir -p {paths.mirror};
    """)