mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-28 09:58:21 +01:00
Add support full Slackware options
This commit is contained in:
parent
8d80ff97ac
commit
f80032cc5a
8 changed files with 96 additions and 107 deletions
|
@ -88,7 +88,7 @@ class MetaData(object):
|
|||
|
||||
__all__ = "slpkg"
|
||||
__author__ = "dslackw"
|
||||
__version_info__ = (2, 4, 4)
|
||||
__version_info__ = (2, 5, 0)
|
||||
__version__ = "{0}.{1}.{2}".format(*__version_info__)
|
||||
__license__ = "GNU General Public License v3 (GPLv3)"
|
||||
__email__ = "d.zlatanidis@gmail.com"
|
||||
|
|
|
@ -99,16 +99,17 @@ Optional arguments:
|
|||
and prints results.
|
||||
-f, --find, [package...] Find and print installed packages
|
||||
reporting the size and the sum.
|
||||
-i, --install, [package...] Installs single or multiple
|
||||
Slackware binary packages.
|
||||
-u, --install-new, [package...] Upgrade single or multiple Slackware
|
||||
binary packages from a older to a
|
||||
newer one.
|
||||
-o, --reinstall, [package...] Reinstall signle or multiple
|
||||
Slackware binary packages with the
|
||||
same packages if the exact.
|
||||
-r, --remove, [package...] Removes a previously installed
|
||||
Slackware binary packages.
|
||||
-i, --installpkg, [options] [package...] Installs single or multiple
|
||||
options=[--warn, --md5sum, --root, Slackware binary packages designed
|
||||
--infobox, --menu, --terse, for use with the Slackware Linux
|
||||
--ask, --priority, distribution onto your system.
|
||||
--tagfile]
|
||||
-u, --upgradepkg, [options] [package...] Upgrade single or multiple Slackware
|
||||
options=[--dry-run, --install-new, binary packages from an older
|
||||
--reinstall, --verbose] version to a newer one.
|
||||
-r, --removepkg, [options] [package...] Removes a previously installed
|
||||
options=[-warn, -preserve, copy, Slackware binary packages.
|
||||
-keep]
|
||||
-d, --display, [package...] Display the installed packages
|
||||
contents and file list.
|
||||
|
||||
|
@ -137,7 +138,7 @@ def usage(repo):
|
|||
[-t [repository] [package]]
|
||||
[-p [repository] [package], --color=[]]
|
||||
[-n [SBo package]] [-F [...]] [-f [...]] [-i [...]]
|
||||
[-u [...]] [-o [...]] [-r [...]] [-d [...]]
|
||||
[-u [...]] [-r [...]] [-d [...]]
|
||||
"""
|
||||
error_repo = ""
|
||||
if repo and repo not in _meta_.repositories:
|
||||
|
|
|
@ -173,18 +173,18 @@ class BinaryInstall(object):
|
|||
print("[ {0}reinstalling{1} ] --> {2}".format(
|
||||
self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
|
||||
installs.append(pkg_ver)
|
||||
PackageManager(package).reinstall()
|
||||
PackageManager(package).upgrade("--reinstall")
|
||||
elif find_package(split_package(inst)[0] + self.meta.sp,
|
||||
self.meta.pkg_path):
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(
|
||||
self.meta.color["YELLOW"], self.meta.color["ENDC"], inst))
|
||||
upgraded.append(pkg_ver)
|
||||
PackageManager(package).upgrade()
|
||||
PackageManager(package).upgrade("--install-new")
|
||||
else:
|
||||
print("[ {0}installing{1} ] --> {2}".format(
|
||||
self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
|
||||
installs.append(pkg_ver)
|
||||
PackageManager(package).upgrade()
|
||||
PackageManager(package).upgrade("--install-new")
|
||||
return [installs, upgraded]
|
||||
|
||||
def checksums(self, install):
|
||||
|
|
125
slpkg/main.py
125
slpkg/main.py
|
@ -25,7 +25,6 @@
|
|||
import sys
|
||||
import getpass
|
||||
|
||||
from utils import Utils
|
||||
from messages import Msg
|
||||
from desc import PkgDesc
|
||||
from config import Config
|
||||
|
@ -63,33 +62,6 @@ class ArgParse(object):
|
|||
def __init__(self, args):
|
||||
self.args = args
|
||||
self.meta = _meta_
|
||||
self.packages = self.args[1:]
|
||||
if len(self.args) > 1 and self.args[0] in ["-q", "--queue", "-b",
|
||||
"--blacklist"]:
|
||||
self.packages = self.args[1:-1]
|
||||
elif len(self.packages) > 1 and self.args[0] in ["-s", "--sync", "-t",
|
||||
"--tracking", "-p",
|
||||
"--print", "-F",
|
||||
"--FIND"]:
|
||||
self.packages = self.args[2:]
|
||||
|
||||
if (len(self.args) > 1 and
|
||||
self.args[0] in ["-f", "--find", "-i", "--install", "-u",
|
||||
"--install-new", "-o", "--reinstall", "-r",
|
||||
"--remove", "-d", "--display", "-n",
|
||||
"--network"] and
|
||||
self.args[1].endswith(".pkg")):
|
||||
self.packages = Utils().read_file_pkg(self.args[1])
|
||||
elif (len(self.args) >= 3 and
|
||||
self.args[0] in ["-s", "--sync", "-t", "--tracking", "-p",
|
||||
"--print", "-F", "--FIND"] and
|
||||
self.args[1] in self.meta.repositories and
|
||||
self.args[2].endswith(".pkg")):
|
||||
self.packages = Utils().read_file_pkg(self.args[2])
|
||||
elif (len(self.args) == 3 and self.args[0] in ["-q", "--queue",
|
||||
"-b", "--blacklist"] and
|
||||
self.args[1].endswith(".pkg")):
|
||||
self.packages = Utils().read_file_pkg(self.args[1])
|
||||
|
||||
# checking if repositories exists
|
||||
if len(self.args) > 1 and self.args[0] not in [
|
||||
|
@ -231,6 +203,7 @@ class ArgParse(object):
|
|||
|
||||
def pkg_install(self):
|
||||
""" install packages by repository """
|
||||
packages = self.args[2:]
|
||||
options = ["-s", "--sync"]
|
||||
flag = ["--resolve-off"]
|
||||
resolve = True
|
||||
|
@ -239,10 +212,10 @@ class ArgParse(object):
|
|||
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.packages, self.args[1], resolve).start(
|
||||
BinaryInstall(packages, self.args[1], resolve).start(
|
||||
if_upgrade=False)
|
||||
elif self.args[1] == "sbo":
|
||||
SBoInstall(self.packages, resolve).start(
|
||||
SBoInstall(packages, resolve).start(
|
||||
if_upgrade=False)
|
||||
else:
|
||||
usage(self.args[1])
|
||||
|
@ -251,12 +224,8 @@ class ArgParse(object):
|
|||
|
||||
def pkg_tracking(self):
|
||||
""" tracking package dependencies """
|
||||
packages = "".join(self.packages)
|
||||
packages = self.args[2:]
|
||||
options = ["-t", "--tracking"]
|
||||
if len(self.packages) > 1:
|
||||
packages = self.packages[1]
|
||||
if self.args[2].endswith(".pkg"):
|
||||
packages = self.packages[0]
|
||||
if (len(self.args) == 3 and self.args[0] in options and
|
||||
self.args[1] in self.meta.repositories):
|
||||
track_dep(packages, self.args[1])
|
||||
|
@ -268,10 +237,8 @@ class ArgParse(object):
|
|||
|
||||
def sbo_network(self):
|
||||
""" view slackbuilds packages """
|
||||
packages = "".join(self.packages)
|
||||
packages = self.args[1]
|
||||
options = ["-n", "--network"]
|
||||
if len(self.packages) > 1:
|
||||
packages = self.packages[0]
|
||||
if (len(self.args) == 2 and self.args[0] in options and
|
||||
"sbo" in self.meta.repositories):
|
||||
SBoNetwork(packages).view()
|
||||
|
@ -280,6 +247,7 @@ class ArgParse(object):
|
|||
|
||||
def pkg_blacklist(self):
|
||||
""" manage blacklist packages """
|
||||
packages = self.args[1:]
|
||||
blacklist = BlackList()
|
||||
options = ["-b", "--blacklist"]
|
||||
flag = ["--add", "--remove"]
|
||||
|
@ -289,25 +257,26 @@ class ArgParse(object):
|
|||
blacklist.listed()
|
||||
elif (len(self.args) > 2 and self.args[0] in options and
|
||||
self.args[-1] == flag[0]):
|
||||
blacklist.add(self.packages)
|
||||
blacklist.add(packages)
|
||||
elif (len(self.args) > 2 and self.args[0] in options and
|
||||
self.args[-1] == flag[1]):
|
||||
blacklist.remove(self.packages)
|
||||
blacklist.remove(packages)
|
||||
else:
|
||||
usage("")
|
||||
|
||||
def pkg_queue(self):
|
||||
""" manage packages in queue """
|
||||
packages = self.args[1:]
|
||||
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.packages)
|
||||
queue.add(packages)
|
||||
elif (len(self.args) > 2 and self.args[0] in options and
|
||||
self.args[-1] == flag[1]):
|
||||
queue.remove(self.packages)
|
||||
queue.remove(packages)
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1] == command[0]):
|
||||
queue.listed()
|
||||
|
@ -326,52 +295,81 @@ class ArgParse(object):
|
|||
|
||||
def bin_install(self):
|
||||
""" install Slackware binary packages """
|
||||
options = ["-i", "--install"]
|
||||
packages = self.args[1:]
|
||||
options = ["-i", "--installpkg"]
|
||||
flag = ""
|
||||
flags = [
|
||||
"--warn",
|
||||
"--md5sum",
|
||||
"--root",
|
||||
"--infobox",
|
||||
"--menu",
|
||||
"--terse",
|
||||
"--ask",
|
||||
"--priority",
|
||||
"--tagfile"
|
||||
]
|
||||
if self.args[1] in flags:
|
||||
flag = self.args[1]
|
||||
packages = self.args[2:]
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
PackageManager(self.packages).install()
|
||||
PackageManager(packages).install(flag)
|
||||
else:
|
||||
usage("")
|
||||
|
||||
def bin_upgrade(self):
|
||||
""" install-upgrade Slackware binary packages """
|
||||
options = ["-u", "--install-new"]
|
||||
packages = self.args[1:]
|
||||
options = ["-u", "--upgradepkg"]
|
||||
flag = ""
|
||||
flags = [
|
||||
"--dry-run",
|
||||
"--install-new",
|
||||
"--reinstall",
|
||||
"--verbose"
|
||||
]
|
||||
if self.args[1] in flags:
|
||||
flag = self.args[1]
|
||||
packages = self.args[2:]
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
PackageManager(self.packages).upgrade()
|
||||
else:
|
||||
usage("")
|
||||
|
||||
def bin_reinstall(self):
|
||||
""" reinstall Slackware binary packages """
|
||||
options = ["-o", "--reinstall"]
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
PackageManager(self.packages).reinstall()
|
||||
PackageManager(packages).upgrade(flag)
|
||||
else:
|
||||
usage("")
|
||||
|
||||
def bin_remove(self):
|
||||
""" remove Slackware packages """
|
||||
options = ["-r", "--remove"]
|
||||
packages = self.args[1:]
|
||||
options = ["-r", "--removepkg"]
|
||||
flag = ""
|
||||
flags = [
|
||||
"-warn",
|
||||
"-preserve",
|
||||
"-copy",
|
||||
"-keep"
|
||||
]
|
||||
if self.args[1] in flags:
|
||||
flag = self.args[1]
|
||||
packages = self.args[2:]
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
PackageManager(self.packages).remove()
|
||||
PackageManager(packages).remove(flag)
|
||||
else:
|
||||
usage("")
|
||||
|
||||
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(self.packages).find()
|
||||
PackageManager(packages).find()
|
||||
else:
|
||||
usage("")
|
||||
|
||||
def pkg_desc(self):
|
||||
""" print slack-desc by repository"""
|
||||
packages = "".join(self.packages)
|
||||
packages = self.args[2]
|
||||
options = ["-p", "--print"]
|
||||
flag = ["--color="]
|
||||
colors = ["red", "green", "yellow", "cyan", "grey"]
|
||||
if len(self.packages) > 1:
|
||||
packages = self.packages[0]
|
||||
if (len(self.args) == 3 and self.args[0] in options and
|
||||
self.args[1] in self.meta.repositories):
|
||||
PkgDesc(packages, self.args[1], "").view()
|
||||
|
@ -398,9 +396,10 @@ class ArgParse(object):
|
|||
|
||||
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(self.packages).display()
|
||||
PackageManager(packages).display()
|
||||
else:
|
||||
usage("")
|
||||
|
||||
|
@ -466,10 +465,8 @@ def main():
|
|||
"--install": argparse.bin_install,
|
||||
"-u": argparse.bin_upgrade,
|
||||
"--install-new": argparse.bin_upgrade,
|
||||
"-o": argparse.bin_reinstall,
|
||||
"--reinstall": argparse.bin_reinstall,
|
||||
"-r": argparse.bin_remove,
|
||||
"--remove": argparse.bin_remove,
|
||||
"--removepkg": argparse.bin_remove,
|
||||
"-f": argparse.bin_find,
|
||||
"--find": argparse.bin_find,
|
||||
"-F": argparse.pkg_find,
|
||||
|
|
|
@ -44,42 +44,30 @@ class PackageManager(object):
|
|||
self.binary = binary
|
||||
self.meta = _meta_
|
||||
|
||||
def install(self):
|
||||
def install(self, flag):
|
||||
"""
|
||||
Install Slackware binary packages
|
||||
"""
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("installpkg {0}".format(
|
||||
pkg), shell=True))
|
||||
subprocess.call("installpkg {0} {1}".format(flag, pkg),
|
||||
shell=True)
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
self._not_found("Can't install", self.binary, pkg)
|
||||
|
||||
def upgrade(self):
|
||||
def upgrade(self, flag):
|
||||
"""
|
||||
Upgrade Slackware binary packages
|
||||
Upgrade Slackware binary packages with new
|
||||
"""
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("upgradepkg --install-new "
|
||||
"{0}".format(pkg), shell=True))
|
||||
subprocess.call("upgradepkg {0} {1}".format(flag, pkg),
|
||||
shell=True)
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
self._not_found("Can't upgrade", self.binary, pkg)
|
||||
|
||||
def reinstall(self):
|
||||
"""
|
||||
Reinstall Slackware binary packages
|
||||
"""
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output(
|
||||
"upgradepkg --reinstall {0}".format(pkg), shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
self._not_found("Can't reinstall", self.binary, pkg)
|
||||
|
||||
def _not_found(self, message, binary, pkg):
|
||||
if len(binary) > 1:
|
||||
bol = eol = ""
|
||||
|
@ -87,10 +75,11 @@ class PackageManager(object):
|
|||
bol = eol = "\n"
|
||||
Msg().pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def remove(self):
|
||||
def remove(self, flag):
|
||||
"""
|
||||
Remove Slackware binary packages
|
||||
"""
|
||||
self.flag = flag
|
||||
dep_path = self.meta.log_path + "dep/"
|
||||
dependencies, rmv_list = [], []
|
||||
removed = self._view_removed()
|
||||
|
@ -188,8 +177,8 @@ class PackageManager(object):
|
|||
deps.append(package)
|
||||
for dep in deps:
|
||||
if find_package(dep + self.meta.sp, self.meta.pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(dep),
|
||||
shell=True))
|
||||
subprocess.call("removepkg {0} {1}".format(self.flag, dep),
|
||||
shell=True)
|
||||
removes.append(dep)
|
||||
os.remove(path + package)
|
||||
return removes
|
||||
|
@ -199,8 +188,8 @@ class PackageManager(object):
|
|||
Remove one signle package
|
||||
"""
|
||||
if find_package(package + self.meta.sp, self.meta.pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(package),
|
||||
shell=True))
|
||||
subprocess.call("removepkg {0} {1}".format(self.flag, package),
|
||||
shell=True)
|
||||
return package.split()
|
||||
|
||||
def _reference_rmvs(self, removes):
|
||||
|
|
|
@ -337,5 +337,5 @@ class SBoInstall(object):
|
|||
print("{0}[ Installing ] --> {1}{2}".format(
|
||||
self.meta.color["GREEN"], self.meta.color["ENDC"], pkg))
|
||||
installs.append(prgnam)
|
||||
PackageManager(binary).upgrade()
|
||||
PackageManager(binary).upgrade("--install-new")
|
||||
return installs, upgraded
|
||||
|
|
|
@ -222,4 +222,4 @@ class SBoNetwork(object):
|
|||
print("[ {0}Installing{1} ] --> {2}".format(_meta_.color["GREEN"],
|
||||
_meta_.color["ENDC"],
|
||||
self.name))
|
||||
PackageManager(binary).upgrade()
|
||||
PackageManager(binary).upgrade("--install-new")
|
||||
|
|
|
@ -178,13 +178,15 @@ class Patches(object):
|
|||
print("[ {0}upgrading{1} ] --> {2}".format(
|
||||
self.meta.color["YELLOW"], self.meta.color["ENDC"],
|
||||
pkg[:-4]))
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade()
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade(
|
||||
"--install-new")
|
||||
self.upgraded.append(pkg_ver)
|
||||
else:
|
||||
print("[ {0}installing{1} ] --> {2}".format(
|
||||
self.meta.color["GREEN"], self.meta.color["ENDC"],
|
||||
pkg[:-4]))
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade()
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade(
|
||||
"--install-new")
|
||||
self.installed.append(pkg_ver)
|
||||
|
||||
def kernel(self):
|
||||
|
|
Loading…
Reference in a new issue