Kaydet (Commit) c59d78dd authored tarafından Adınız's avatar Adınız

inary mirror feature added

üst ec0ed055
......@@ -33,6 +33,7 @@ import inary.cli.listinstalled
import inary.cli.listcomponents
import inary.cli.listavailable
import inary.cli.listnewest
import inary.cli.mirror
import inary.cli.history
import inary.cli.install
import inary.cli.info
......
# -*- coding:utf-8 -*-
#
# Copyright (C) 2017 - 2018, Suleyman POYRAZ (Zaryob)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import inary.db
import inary.context as ctx
import inary.cli.command as command
import inary.data.index as index
import optparse
import os
# Gettext Library
import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
class Fetch(command.Command, metaclass=command.autocommand):
__doc__ = _("""Mirror a repository
Usage: mirror [<package1> <package2> ... <packagen>]
<packagei>: repo name
Downloads the given inary packages to working directory
""")
def __init__(self, args):
super(Fetch, self).__init__(args)
name = ("mirror", "mr")
def options(self):
group = optparse.OptionGroup(self.parser, _("mirror options"))
group.add_option("-o", "--output-dir", action="store", default=os.path.curdir,
help=_("Output directory for the mirrored repository"))
self.parser.add_option_group(group)
def run(self):
import inary.fetcher as fetcher
packages = inary.db.packagedb.PackageDB()
self.init(database=False, write=False)
if not self.args:
self.help()
return
full_packages = []
for repo in self.args:
full_packages=packages.list_packages(repo)
for pkgname in full_packages:
pkg,repo=packages.get_package_repo(pkgname,repo)
output=os.path.join(ctx.config.options.output_dir,os.path.dirname(pkg.packageURI))
fetcher.fetch([pkgname], output,repo)
......@@ -483,7 +483,7 @@ def fetch_from_mirror(url, destdir=None, progress=None, destfile=None):
# Operation function
def fetch(packages=None, path=os.path.curdir):
def fetch(packages=None, path=os.path.curdir,repo=None):
"""
Fetches the given packages from the repository without installing, just downloads the packages.
@param packages: list of package names -> list_of_strings
......@@ -495,7 +495,7 @@ def fetch(packages=None, path=os.path.curdir):
packagedb = inary.db.packagedb.PackageDB()
repodb = inary.db.repodb.RepoDB()
for name in packages:
package, repo = packagedb.get_package_repo(name)
package, repo = packagedb.get_package_repo(name,repo)
ctx.ui.info(
_("\"{0}\" package found in \"{1}\" repository.").format(
package.name, repo))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment