mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-15 03:41:16 +01:00
updated messages - slack
This commit is contained in:
parent
d19474bee0
commit
00376099ea
9 changed files with 65 additions and 125 deletions
|
@ -16,6 +16,7 @@ sp = "-"
|
|||
|
||||
''' temponary path '''
|
||||
tmp = "/tmp/"
|
||||
dwn_path = tmp + "slpkg/"
|
||||
|
||||
''' packages log files path '''
|
||||
packages = "/var/log/packages/"
|
||||
|
|
|
@ -1,41 +1,34 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
''' Utility to help package management in Slackware.
|
||||
Slpkg is a terminal tool in order to easy use Slackware packages.
|
||||
|
||||
|
||||
It's a quick and easy way to manage your packages in Slackware to a command.
|
||||
|
||||
|
||||
|
||||
usage: slpkg [-h] [-v] [-s script [source ...]] [-l all, sbo [all, sbo ...]]
|
||||
[-t] [-n] [-c] [-b] [-i [...]] [-u [...]] [-a [...]]
|
||||
[-r [...]] [-f [...]] [-d [...]]
|
||||
'''
|
||||
usage: main.py [-h] [-v] [-a script [source ...]] [-l all, sbo [all, sbo ...]]
|
||||
[-t] [-n] [-c sbo, slack [sbo, slack ...]] [-s] [-i [...]]
|
||||
[-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]]
|
||||
|
||||
Utility to help package management in Slackware
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-v, --verbose print version and exit
|
||||
-s script [source ...]
|
||||
-a script [source ...]
|
||||
auto build package
|
||||
-l all, sbo [all, sbo ...]
|
||||
list of installed packages
|
||||
-t tracking dependencies
|
||||
-n find from SBo repositority
|
||||
-c check if your package is up to date
|
||||
-b download, build & install pkg from SBo
|
||||
-c sbo, slack [sbo, slack ...]
|
||||
check if your package is up to date
|
||||
-s download, build & install pkg from SBo
|
||||
-i [ ...] install binary packages
|
||||
-u [ ...] install-upgrade packages with new
|
||||
-a [ ...] reinstall the same packages
|
||||
-o [ ...] reinstall the same packages
|
||||
-r [ ...] remove packages
|
||||
-f [ ...] find if packages installed
|
||||
-d [ ...] display the contents of the packages
|
||||
|
||||
'''
|
||||
|
||||
|
||||
import argparse
|
||||
|
||||
from version import *
|
||||
|
@ -51,7 +44,7 @@ from sbo.dependency import *
|
|||
from sbo.check import sbo_check
|
||||
from sbo.views import sbo_network
|
||||
|
||||
from slack.upgrade import upgrade_all
|
||||
from slack.patches import patches
|
||||
|
||||
def main():
|
||||
description = "Utility to help package management in Slackware"
|
||||
|
@ -105,11 +98,10 @@ def main():
|
|||
if "sbo" in args.c:
|
||||
sbo_check(''.join(args.c[1]))
|
||||
elif "slack" in args.c:
|
||||
if args.c[1] == "update":
|
||||
upgrade_all()
|
||||
if args.c[1] == "upgrade":
|
||||
patches()
|
||||
else:
|
||||
print ("\n{0}: invalid option: choose from check, update\n".format(__prog__))
|
||||
|
||||
else:
|
||||
print ("\n{0}: error: must enter at least two arguments\n".format(
|
||||
__prog__))
|
||||
|
|
|
@ -85,7 +85,7 @@ def pkg_remove(binary):
|
|||
for pkg in range(len(binary)):
|
||||
pkgs = find_package(binary[pkg] + sp, packages)
|
||||
if pkgs != []:
|
||||
print (colors.RED + "delete --> " + colors.ENDC + "\n ".join(pkgs))
|
||||
print (colors.RED + "[ delete ] --> " + colors.ENDC + "\n ".join(pkgs))
|
||||
count.append(pkgs)
|
||||
sum_pkgs = 0
|
||||
for i in range(len(count)):
|
||||
|
@ -126,7 +126,7 @@ def pkg_find(binary):
|
|||
bol, eol = "\n", "\n"
|
||||
pkg_not_found(bol, binary[pkg], message, eol)
|
||||
else:
|
||||
print (colors.GREEN + "found --> " + colors.ENDC + "\n ".join(
|
||||
print (colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
|
||||
find_package(binary[pkg] + sp, packages)))
|
||||
|
||||
def pkg_display(binary):
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
from functions import get_to
|
||||
from url_read import url_read
|
||||
|
||||
def dir_patches(http):
|
||||
'''
|
||||
Found directories from patches
|
||||
'''
|
||||
link = url_read(http)
|
||||
folders = []
|
||||
patch_dir = []
|
||||
dirs = ''
|
||||
for line in link.splitlines():
|
||||
if re.findall("folder", line):
|
||||
folders.append(line)
|
||||
for dirs in folders:
|
||||
folders = dirs.split()
|
||||
for folder in folders:
|
||||
if re.findall("href", folder):
|
||||
folder = folder.replace("href=\"", "")
|
||||
patch_dir.append(get_to(folder, "/"))
|
||||
return patch_dir
|
|
@ -2,16 +2,17 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __metadata__ import uname, arch
|
||||
from slack_version import slack_ver
|
||||
|
||||
def mirrors(name):
|
||||
def mirrors(name, location):
|
||||
'''
|
||||
Choose Slackware mirror based
|
||||
architecture
|
||||
Select Slackware mirror packages
|
||||
based architecture
|
||||
'''
|
||||
if arch == "x86_64":
|
||||
http = "http://mirrors.slackware.com/slackware/slackware64-14.1/patches/packages/" + name
|
||||
http = "http://mirrors.slackware.com/slackware/slackware64-{0}/{1}{2}".format(slack_ver(), location, name)
|
||||
else:
|
||||
http = "http://mirrors.slackware.com/slackware/slackware-14.1/patches/packages/" + name
|
||||
http = "http://mirrors.slackware.com/slackware/slackware-{0}/{1}{3}".format(slack_ver(), location, name)
|
||||
return http
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,26 +1,45 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import os
|
||||
|
||||
from functions import get_to
|
||||
from url_read import url_read
|
||||
from mirrors import mirrors
|
||||
from slack_version import slack_ver
|
||||
from pkg.find import find_package
|
||||
from __metadata__ import packages, dwn_path
|
||||
from colors import colors
|
||||
from pkg.manager import pkg_upgrade
|
||||
|
||||
|
||||
def patches(http):
|
||||
def patches():
|
||||
'''
|
||||
Find patches from oficial Slackware mirrors
|
||||
Install new patches from official Slackware
|
||||
'''
|
||||
link = url_read(http)
|
||||
patches = []
|
||||
pkg_patches = []
|
||||
for line in link.split():
|
||||
if line.startswith("href"):
|
||||
line = line.replace("href=\"", "")
|
||||
txz = re.findall(".txz", line)
|
||||
if txz:
|
||||
slack = get_to(line, "\"")
|
||||
if slack.endswith(".txz"):
|
||||
patches.append(slack)
|
||||
return patches
|
||||
dwn_list = []
|
||||
dwn_patches = []
|
||||
upgrade_all = []
|
||||
package_name = []
|
||||
package_location = []
|
||||
os.system("mkdir -p {0}{1}".format(dwn_path, 'patches/'))
|
||||
PACKAGE_TXT = url_read(mirrors(name='PACKAGES.TXT', location='patches/'))
|
||||
for line in PACKAGE_TXT.splitlines():
|
||||
if line.startswith('PACKAGE NAME'):
|
||||
package_name.append(line.replace('PACKAGE NAME: ', ''))
|
||||
if line.startswith('PACKAGE LOCATION'):
|
||||
package_location.append(line.replace('PACKAGE LOCATION: ./', ''))
|
||||
for loc, name in zip(package_location, package_name):
|
||||
dwn_list.append('{0}{1}/{2}'.format(mirrors('',''), loc, name))
|
||||
for pkg in package_name:
|
||||
installed_pkg = ''.join(find_package(pkg.replace('.txz', ''), packages))
|
||||
if installed_pkg == '':
|
||||
upgrade_all.append(pkg)
|
||||
if upgrade_all != []:
|
||||
print ("\nThese packages need upgrading:\n")
|
||||
for upgrade in upgrade_all:
|
||||
print ("{0}[ upgrade ] --> {1}{2}".format(colors.CYAN, colors.ENDC, upgrade))
|
||||
for dwn in dwn_list:
|
||||
if upgrade in dwn:
|
||||
dwn_patches.append(dwn)
|
||||
read = raw_input("\nWould you like to download ? [Y/y] ")
|
||||
if read == "Y" or read == "y":
|
||||
for dwn in dwn_patches:
|
||||
os.system("wget -N --directory-prefix={0}{1} {2}".format(dwn_path, 'patches/', dwn))
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
import re
|
||||
|
||||
def slack_ver():
|
||||
'''
|
||||
Slackware version
|
||||
'''
|
||||
f = open('/etc/slackware-version', 'r')
|
||||
sv = f.read()
|
||||
f.close()
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
from dir_patches import dir_patches
|
||||
from patches import patches
|
||||
from slack_version import slack_ver
|
||||
from __metadata__ import arch, packages
|
||||
from pkg.find import find_package
|
||||
from colors import colors
|
||||
from url_read import url_read
|
||||
from mirrors import mirrors
|
||||
|
||||
|
||||
def upgrade_all():
|
||||
upgrades = []
|
||||
sum_upgrades = []
|
||||
dirs = dir_patches(mirrors(name = ''))
|
||||
upgrades.append((patches(mirrors(name = ''))))
|
||||
version = slack_ver()
|
||||
tag = "slack"
|
||||
ftype = ".txz"
|
||||
updates = []
|
||||
slack_type_len = len(arch + tag + version + ftype) + 4
|
||||
ftype_len = len(ftype)
|
||||
|
||||
if dirs:
|
||||
for d in dirs:
|
||||
http = mirrors(d) + "/"
|
||||
upgrades.append((patches(http)))
|
||||
|
||||
for i in range(len(upgrades)):
|
||||
for j in range(len(upgrades[i])):
|
||||
sum_upgrades.append(upgrades[i][j])
|
||||
|
||||
|
||||
for patch in sum_upgrades:
|
||||
print patch
|
||||
patch_name = patch[:-ftype_len]
|
||||
pkg = ''.join(find_package(patch_name, packages))
|
||||
patch = patch.replace(ftype, '')
|
||||
if patch > pkg:
|
||||
updates.append(patch + ftype)
|
||||
if updates != []:
|
||||
print ("\nThese packages need upgrading:")
|
||||
for update in updates:
|
||||
print ("{0}update -->{1} {2}".format(colors.RED, colors.ENDC, update))
|
||||
read = raw_input("\nWould you like to upgrade ? [Y/y] ")
|
||||
if read == "Y" or read == "y":
|
||||
os.system("wget -N " + http + ''.join(updates))
|
||||
else:
|
||||
print ("Your Slackware system is up to date")
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import urllib2
|
||||
from __metadata__ import __prog__
|
||||
|
||||
|
@ -12,5 +13,5 @@ def url_read(link):
|
|||
f = urllib2.urlopen(link)
|
||||
return f.read()
|
||||
except urllib2.URLError:
|
||||
print ("\n{0}: error: connection refused".format(__prog__))
|
||||
print ("\n{0}: error: connection refused\n".format(__prog__))
|
||||
sys.exit()
|
||||
|
|
Loading…
Reference in a new issue