Example #1
0
 def command_repo_add(self):
     """Add custom repositories
     """
     if len(self.args) == 3 and self.args[0] == "repo-add":
         Repo().add(self.args[1], self.args[2])
     else:
         usage("")
Example #2
0
 def command_repo_remove(self):
     """Remove custom repositories
     """
     if len(self.args) == 2 and self.args[0] == "repo-remove":
         Repo().remove(self.args[1])
     else:
         usage("")
Example #3
0
 def command_repo_list(self):
     """Repositories list
     """
     if len(self.args) == 1 and self.args[0] == "repo-list":
         RepoList().repos()
     else:
         usage("")
Example #4
0
 def command_update_slpkg(self):
     """Slpkg it self update
     """
     if len(self.args) == 2 and self.args[0] == "update-slpkg":
         it_self_update()
     else:
         usage("")
Example #5
0
 def pkg_queue(self):
     """Manage packages in queue
     """
     queue = QueuePkgs()
     options = ["-q", "--queue"]
     flag = ["--add", "--remove"]
     command = ["list", "build", "install", "build-install"]
     if (len(self.args) > 2 and self.args[0] in options and
             self.args[-1] == flag[0]):
         queue.add(self.args[1:-1])
     elif (len(self.args) == 3 and self.args[0] in options and
             self.args[1] == "ALL" and self.args[-1] == flag[1]):
         queue.remove(queue.packages())
     elif (len(self.args) > 2 and self.args[0] in options and
             self.args[-1] == flag[1]):
         queue.remove(self.args[1:-1])
     elif (len(self.args) == 2 and self.args[0] in options and
             self.args[1] == command[0]):
         queue.listed()
     elif (len(self.args) == 2 and self.args[0] in options and
             self.args[1] == command[1]):
         queue.build()
     elif (len(self.args) == 2 and self.args[0] in options and
             self.args[1] == command[2]):
         queue.install()
     elif (len(self.args) == 2 and self.args[0] in options and
             self.args[1] == command[3]):
         queue.build()
         queue.install()
     else:
         usage("")
Example #6
0
 def auto_build(self):
     """Auto built tool
     """
     options = ["-a", "--autobuild"]
     if len(self.args) >= 3 and self.args[0] in options:
         BuildPackage(self.args[1], self.args[2:], self.meta.path).build()
     else:
         usage("")
Example #7
0
 def bin_find(self):
     """Find installed packages
     """
     packages = self.args[1:]
     options = ["-f", "--find"]
     if len(self.args) > 1 and self.args[0] in options:
         PackageManager(packages).find()
     else:
         usage("")
Example #8
0
 def pkg_find(self):
     """Find packages from all enabled repositories
     """
     packages = self.args[1:]
     options = ["-F", "--FIND"]
     if len(self.args) > 1 and self.args[0] in options:
         find_from_repos(packages)
     else:
         usage("")
Example #9
0
 def pkg_contents(self):
     """Print packages contents
     """
     packages = self.args[1:]
     options = ["-d", "--display"]
     if len(self.args) > 1 and self.args[0] in options:
         PackageManager(packages).display()
     else:
         usage("")
Example #10
0
 def sbo_network(self):
     """View slackbuilds packages
     """
     options = ["-n", "--network"]
     if (len(self.args) == 2 and self.args[0] in options and
             "sbo" in self.meta.repositories):
         SBoNetwork(self.args[1]).view()
     else:
         usage("")
Example #11
0
 def command_upgrade(self):
     """Recreate repositories package lists
     """
     if len(self.args) == 1 and self.args[0] == "upgrade":
         Initialization(False).upgrade(only="")
     elif (len(self.args) == 2 and self.args[0] == "upgrade" and
             self.args[1].startswith("--only=")):
         repos = self.args[1].split("=")[-1].split(",")
         Initialization(False).upgrade(repos)
     else:
         usage("")
Example #12
0
 def help_version(self):
     """Help and version info
     """
     if (len(self.args) == 1 and self.args[0] in ["-h", "--help"] and
             self.args[1:] == []):
         options()
     elif (len(self.args) == 1 and self.args[0] in ["-v", "--version"] and
             self.args[1:] == []):
         prog_version()
     else:
         usage("")
Example #13
0
 def pkg_tracking(self):
     """Tracking package dependencies
     """
     options = ["-t", "--tracking"]
     if (len(self.args) == 3 and self.args[0] in options and
             self.args[1] in self.meta.repositories):
         track_dep(self.args[2], self.args[1])
     elif (len(self.args) > 1 and self.args[0] in options and
             self.args[1] not in self.meta.repositories):
         usage(self.args[1])
     else:
         usage("")
Example #14
0
 def command_repo_info(self):
     """Repositories informations
     """
     if (len(self.args) == 2 and self.args[0] == "repo-info" and
             self.args[1] in RepoList().all_repos):
         del RepoList().all_repos
         RepoInfo().view(self.args[1])
     elif (len(self.args) > 1 and self.args[0] == "repo-info" and
             self.args[1] not in RepoList().all_repos):
         usage(self.args[1])
     else:
         usage("")
Example #15
0
 def command_update(self):
     """Update package lists repositories
     """
     if len(self.args) == 1 and self.args[0] == "update":
         Update().repository(only="")
     elif (len(self.args) == 2 and self.args[0] == "update" and
             self.args[1].startswith("--only=")):
         repos = self.args[1].split("=")[-1].split(",")
         for rp in repos:
             if rp not in self.meta.repositories:
                 repos.remove(rp)
         Update().repository(repos)
     else:
         usage("")
Example #16
0
 def congiguration(self):
     """Manage slpkg configuration file
     """
     options = ["-g", "--config"]
     command = ["print", "edit="]
     if (len(self.args) == 2 and self.args[0] in options and
             self.args[1].startswith(command[1])):
         editor = self.args[1][len(command[1]):]
         Config().edit(editor)
     elif (len(self.args) == 2 and self.args[0] in options and
             self.args[1] == (command[0])):
         Config().view()
     else:
         usage("")
Example #17
0
 def ALL(self):
     """Check ALL enabled repositories ChangeLogs
     """
     self.status_bar()
     for repo in self.meta.repositories:
         if repo in self.meta.default_repositories:
             try:
                 self.check = self.all_repos[repo]()
             except OSError:
                 usage(self.repo)
                 sys.exit(0)
         elif repo in self.meta.repositories:
             self.check = self._init.custom(repo)
         self.status()
         self.print_status(repo)
     self.summary()
Example #18
0
 def bin_upgrade(self):
     """Install-upgrade Slackware binary packages
     """
     packages = self.args[1:]
     options = ["-u", "--upgradepkg"]
     flag = ""
     flags = [
         "--dry-run",
         "--install-new",
         "--reinstall",
         "--verbose"
     ]
     if len(self.args) > 1 and self.args[0] in options:
         if self.args[1] in flags:
             flag = self.args[1]
             packages = self.args[2:]
         PackageManager(packages).upgrade(flag)
     else:
         usage("")
Example #19
0
 def run(self):
     """Run and check if new in ChangeLog.txt
     """
     if (self.repo in self.meta.default_repositories and
             self.repo in self.meta.repositories):
         try:
             self.check = self.all_repos[self.repo]()
         except OSError:
             usage(self.repo)
             sys.exit(0)
     elif self.repo in self.meta.repositories:
         self.check = self._init.custom(self.repo)
     else:
         usage(self.repo)
         sys.exit(0)
     self.status_bar()
     self.status()
     self.print_status(self.repo)
     self.summary()
Example #20
0
 def pkg_install(self):
     """Install packages by repository
     """
     options = ["-s", "--sync"]
     flag = ""
     flags = ["--resolve-off"]
     if self.args[-1] in flags:
         flag = self.args[-1]
     if len(self.args) >= 3 and self.args[0] in options:
         if (self.args[1] in self.meta.repositories and
                 self.args[1] not in ["sbo"]):
             BinaryInstall(self.args[2:], self.args[1], flag).start(
                 if_upgrade=False)
         elif (self.args[1] == "sbo" and
                 self.args[1] in self.meta.repositories):
             SBoInstall(self.args[2:], flag).start(if_upgrade=False)
         else:
             usage(self.args[1])
     else:
         usage("")
Example #21
0
 def pkg_blacklist(self):
     """Manage blacklist packages
     """
     blacklist = BlackList()
     options = ["-b", "--blacklist"]
     flag = ["--add", "--remove"]
     command = ["list"]
     if (len(self.args) == 2 and self.args[0] in options and
             self.args[1] == command[0]):
         blacklist.listed()
     elif (len(self.args) > 2 and self.args[0] in options and
             self.args[-1] == flag[0]):
         blacklist.add(self.args[1:-1])
     elif (len(self.args) == 3 and self.args[0] in options and
             self.args[1] == "ALL" and self.args[-1] == flag[1]):
         blacklist.remove(blacklist.get_black())
     elif (len(self.args) > 2 and self.args[0] in options and
             self.args[-1] == flag[1]):
         blacklist.remove(self.args[1:-1])
     else:
         usage("")
Example #22
0
 def pkg_list(self):
     """List of packages by repository
     """
     options = ["-l", "--list"]
     flag = ["--index", "--installed"]
     if (len(self.args) == 3 and self.args[0] in options and
             self.args[1] in self.meta.repositories):
         if self.args[2] == flag[0]:
             PackageManager(binary=None).package_list(self.args[1],
                                                      INDEX=True,
                                                      installed=False)
         elif self.args[2] == flag[1]:
             PackageManager(binary=None).package_list(self.args[1],
                                                      INDEX=False,
                                                      installed=True)
         else:
             usage("")
     elif (len(self.args) == 2 and self.args[0] in options and
             self.args[1] in self.meta.repositories):
         PackageManager(None).package_list(self.args[1], INDEX=False,
                                           installed=False)
     elif (len(self.args) > 1 and self.args[0] in options and
             self.args[1] not in self.meta.repositories):
         usage(self.args[1])
     else:
         usage("")
Example #23
0
 def pkg_upgrade(self):
     """Check and upgrade packages by repository
     """
     options = ["-c", "--check"]
     flags = ["--upgrade", "--skip=", "--resolve-off"]
     flags, flag, skip = self.__pkg_upgrade_flags(flags)
     if (len(self.args) == 3 and self.args[0] in options and
             self.args[2] == flags[0] and
             self.args[1] in self.meta.repositories):
         if self.args[1] not in ["slack", "sbo"]:
             BinaryInstall(pkg_upgrade(self.args[1], skip),
                           self.args[1], flag).start(if_upgrade=True)
         elif self.args[1] == "slack":
             if self.meta.only_installed in ["on", "ON"]:
                 BinaryInstall(pkg_upgrade("slack", skip),
                               "slack", flag).start(if_upgrade=True)
             else:
                 Patches(skip, flag).start()
         elif self.args[1] == "sbo":
             SBoInstall(sbo_upgrade(skip), flag).start(if_upgrade=True)
         else:
             usage(self.args[1])
     elif len(self.args) == 2 and self.args[0] in options:
         if self.args[1] == "ALL":
             Updates(repo="").ALL()
         else:
             Updates(self.args[1]).run()
     elif (len(self.args) >= 2 and self.args[0] in options and
             self.args[1] not in self.meta.repositories):
         usage(self.args[1])
     else:
         usage("")
Example #24
0
 def bin_remove(self):
     """Remove Slackware packages
     """
     packages = self.args[1:]
     options = ["-r", "--removepkg"]
     additional_options = ["--check-deps"]
     flag = extra = ""
     flags = [
         "-warn",
         "-preserve",
         "-copy",
         "-keep"
     ]
     if len(self.args) > 1 and self.args[0] in options:
         if self.args[-1] == additional_options[0]:
             extra = additional_options[0]
             packages = self.args[1:-1]
         if self.args[1] in flags:
             flag = self.args[1]
             packages = self.args[2:]
         PackageManager(packages).remove(flag, extra)
     else:
         usage("")
Example #25
0
 def bin_install(self):
     """Install Slackware binary packages
     """
     packages = self.args[1:]
     options = ["-i", "--installpkg"]
     flag = ""
     flags = [
         "--warn",
         "--md5sum",
         "--root",
         "--infobox",
         "--menu",
         "--terse",
         "--ask",
         "--priority",
         "--tagfile"
     ]
     if len(self.args) > 1 and self.args[0] in options:
         if self.args[1] in flags:
             flag = self.args[1]
             packages = self.args[2:]
         PackageManager(packages).install(flag)
     else:
         usage("")
Example #26
0
 def pkg_desc(self):
     """Print slack-desc by repository
     """
     options = ["-p", "--desc"]
     flag = ["--color="]
     colors = ["red", "green", "yellow", "cyan", "grey"]
     if (len(self.args) == 3 and self.args[0] in options and
             self.args[1] in self.meta.repositories):
         PkgDesc(self.args[2], self.args[1], paint="").view()
     elif (len(self.args) == 4 and self.args[0] in options and
             self.args[3].startswith(flag[0])):
         tag = self.args[3][len(flag[0]):]
         if self.args[1] in self.meta.repositories and tag in colors:
             PkgDesc(self.args[2], self.args[1], tag).view()
         else:
             usage(self.args[1])
     elif (len(self.args) > 1 and self.args[0] in options and
             self.args[1] not in self.meta.repositories):
         usage(self.args[1])
     else:
         usage("")
Example #27
0
File: main.py Project: omdbsd/slpkg
def main():

    # root privileges required
    s_user(getpass.getuser())
    args = sys.argv
    args.pop(0)
    repository = ["sbo", "slack"]
    blacklist = BlackList()
    queue = QueuePkgs()

    if len(args) == 0:
        usage()
    elif (len(args) == 1 and args[0] == "-h"
          or args[0] == "--help" and args[1:] == []):
        options()
    elif (len(args) == 1 and args[0] == "-v"
          or args[0] == "--version" and args[1:] == []):
        prog_version()
    elif len(args) == 3 and args[0] == "-a":
        BuildPackage(args[1], args[2:], path).build()
    elif len(args) == 2 and args[0] == "-l":
        sbo_list = ["all", "sbo", "slack", "noarch"]
        if args[1] in sbo_list:
            PackageManager(None).list(args[1])
        else:
            usage()
    elif len(args) == 3 and args[0] == "-c":
        if args[1] == repository[0] and args[2] == "--upgrade":
            SBoCheck().start()
        elif args[1] == repository[1] and args[2] == "--upgrade":
            version = "stable"
            Patches(version).start()
        else:
            usage()
    elif len(args) == 4 and args[0] == "-c":
        if args[1] == repository[1] and args[3] == "--current":
            version = "current"
            Patches(version).start()
        else:
            usage()
    elif len(args) == 3 and args[0] == "-s":
        if args[1] == repository[0]:
            SBoInstall(args[2]).start()
        elif args[1] == repository[1]:
            Slack(args[2], "stable").start()
        else:
            usage()
    elif len(args) == 4 and args[0] == "-s":
        if args[1] == repository[1] and args[3] == "--current":
            Slack(args[2], "current").start()
        else:
            usage()
    elif len(args) == 2 and args[0] == "-t":
        track_dep(args[1])
    elif len(args) == 2 and args[0] == "-n":
        SBoNetwork(args[1]).view()
    elif len(args) == 2 and args[0] == "-b" and args[1] == "--list":
        blacklist.listed()
    elif len(args) > 2 and args[0] == "-b" and args[-1] == "--add":
        blacklist.add(args[1:-1])
    elif len(args) > 2 and args[0] == "-b" and args[-1] == "--remove":
        blacklist.remove(args[1:-1])
    elif len(args) == 2 and args[0] == "-q" and args[1] == "--list":
        queue.listed()
    elif len(args) > 2 and args[0] == "-q" and args[-1] == "--add":
        queue.add(args[1:-1])
    elif len(args) > 2 and args[0] == "-q" and args[-1] == "--remove":
        queue.remove(args[1:-1])
    elif len(args) == 2 and args[0] == "-q" and args[1] == "--build":
        queue.build()
    elif len(args) == 2 and args[0] == "-q" and args[1] == "--install":
        queue.install()
    elif len(args) == 2 and args[0] == "-q" and args[1] == "--build-install":
        queue.build()
        queue.install()
    elif len(args) > 1 and args[0] == "-i":
        PackageManager(args[1:]).install()
    elif len(args) > 1 and args[0] == "-u":
        PackageManager(args[1:]).upgrade()
    elif len(args) > 1 and args[0] == "-o":
        PackageManager(args[1:]).reinstall()
    elif len(args) > 1 and args[0] == "-r":
        PackageManager(args[1:]).remove()
    elif len(args) > 1 and args[0] == "-f":
        PackageManager(args[1:]).find()
    elif len(args) > 1 and args[0] == "-d":
        PackageManager(args[1:]).display()
    else:
        usage()
Example #28
0
def main():

    Msg().s_user(getpass.getuser())
    args = sys.argv
    args.pop(0)

    argparse = ArgParse(args)

    if len(args) == 0:
        usage("")
        sys.exit(0)

    auto_detect(args)

    if len(args) == 2 and args[0] == "update" and args[1] == "slpkg":
        args[0] = "update-slpkg"

    arguments = {
        "-h": argparse.help_version,
        "--help": argparse.help_version,
        "-v": argparse.help_version,
        "--version": argparse.help_version,
        "update": argparse.command_update,
        "upgrade": argparse.command_upgrade,
        "update-slpkg": argparse.command_update_slpkg,
        "repo-list": argparse.command_repo_list,
        "repo-add": argparse.command_repo_add,
        "repo-remove": argparse.command_repo_remove,
        "repo-info": argparse.command_repo_info,
        "-a": argparse.auto_build,
        "--autobuild": argparse.auto_build,
        "-l": argparse.pkg_list,
        "--list": argparse.pkg_list,
        "-c": argparse.pkg_upgrade,
        "--check": argparse.pkg_upgrade,
        "-s": argparse.pkg_install,
        "--sync": argparse.pkg_install,
        "-t": argparse.pkg_tracking,
        "--tracking": argparse.pkg_tracking,
        "-n": argparse.sbo_network,
        "--netwotk": argparse.sbo_network,
        "-b": argparse.pkg_blacklist,
        "--blacklist": argparse.pkg_blacklist,
        "-q": argparse.pkg_queue,
        "--queue": argparse.pkg_queue,
        "-i": argparse.bin_install,
        "--installpkg": argparse.bin_install,
        "-u": argparse.bin_upgrade,
        "--upgradepkg": argparse.bin_upgrade,
        "-r": argparse.bin_remove,
        "--removepkg": argparse.bin_remove,
        "-f": argparse.bin_find,
        "--find": argparse.bin_find,
        "-F": argparse.pkg_find,
        "--FIND": argparse.pkg_find,
        "-p": argparse.pkg_desc,
        "--desc": argparse.pkg_desc,
        "-d": argparse.pkg_contents,
        "--display": argparse.pkg_contents,
        "-g": argparse.congiguration,
        "--config": argparse.congiguration
    }
    try:
        arguments[args[0]]()
    except KeyError:
        usage("")