mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-28 09:58:21 +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 '''
|
''' temponary path '''
|
||||||
tmp = "/tmp/"
|
tmp = "/tmp/"
|
||||||
|
dwn_path = tmp + "slpkg/"
|
||||||
|
|
||||||
''' packages log files path '''
|
''' packages log files path '''
|
||||||
packages = "/var/log/packages/"
|
packages = "/var/log/packages/"
|
||||||
|
|
|
@ -1,41 +1,34 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
'''
|
||||||
''' Utility to help package management in Slackware.
|
usage: main.py [-h] [-v] [-a script [source ...]] [-l all, sbo [all, sbo ...]]
|
||||||
Slpkg is a terminal tool in order to easy use Slackware packages.
|
[-t] [-n] [-c sbo, slack [sbo, slack ...]] [-s] [-i [...]]
|
||||||
|
[-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]]
|
||||||
|
|
||||||
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 [...]]
|
|
||||||
|
|
||||||
Utility to help package management in Slackware
|
Utility to help package management in Slackware
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-v, --verbose print version and exit
|
-v, --verbose print version and exit
|
||||||
-s script [source ...]
|
-a script [source ...]
|
||||||
auto build package
|
auto build package
|
||||||
-l all, sbo [all, sbo ...]
|
-l all, sbo [all, sbo ...]
|
||||||
list of installed packages
|
list of installed packages
|
||||||
-t tracking dependencies
|
-t tracking dependencies
|
||||||
-n find from SBo repositority
|
-n find from SBo repositority
|
||||||
-c check if your package is up to date
|
-c sbo, slack [sbo, slack ...]
|
||||||
-b download, build & install pkg from SBo
|
check if your package is up to date
|
||||||
|
-s download, build & install pkg from SBo
|
||||||
-i [ ...] install binary packages
|
-i [ ...] install binary packages
|
||||||
-u [ ...] install-upgrade packages with new
|
-u [ ...] install-upgrade packages with new
|
||||||
-a [ ...] reinstall the same packages
|
-o [ ...] reinstall the same packages
|
||||||
-r [ ...] remove packages
|
-r [ ...] remove packages
|
||||||
-f [ ...] find if packages installed
|
-f [ ...] find if packages installed
|
||||||
-d [ ...] display the contents of the packages
|
-d [ ...] display the contents of the packages
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from version import *
|
from version import *
|
||||||
|
@ -51,7 +44,7 @@ from sbo.dependency import *
|
||||||
from sbo.check import sbo_check
|
from sbo.check import sbo_check
|
||||||
from sbo.views import sbo_network
|
from sbo.views import sbo_network
|
||||||
|
|
||||||
from slack.upgrade import upgrade_all
|
from slack.patches import patches
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
description = "Utility to help package management in Slackware"
|
description = "Utility to help package management in Slackware"
|
||||||
|
@ -105,11 +98,10 @@ def main():
|
||||||
if "sbo" in args.c:
|
if "sbo" in args.c:
|
||||||
sbo_check(''.join(args.c[1]))
|
sbo_check(''.join(args.c[1]))
|
||||||
elif "slack" in args.c:
|
elif "slack" in args.c:
|
||||||
if args.c[1] == "update":
|
if args.c[1] == "upgrade":
|
||||||
upgrade_all()
|
patches()
|
||||||
else:
|
else:
|
||||||
print ("\n{0}: invalid option: choose from check, update\n".format(__prog__))
|
print ("\n{0}: invalid option: choose from check, update\n".format(__prog__))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print ("\n{0}: error: must enter at least two arguments\n".format(
|
print ("\n{0}: error: must enter at least two arguments\n".format(
|
||||||
__prog__))
|
__prog__))
|
||||||
|
|
|
@ -85,7 +85,7 @@ def pkg_remove(binary):
|
||||||
for pkg in range(len(binary)):
|
for pkg in range(len(binary)):
|
||||||
pkgs = find_package(binary[pkg] + sp, packages)
|
pkgs = find_package(binary[pkg] + sp, packages)
|
||||||
if pkgs != []:
|
if pkgs != []:
|
||||||
print (colors.RED + "delete --> " + colors.ENDC + "\n ".join(pkgs))
|
print (colors.RED + "[ delete ] --> " + colors.ENDC + "\n ".join(pkgs))
|
||||||
count.append(pkgs)
|
count.append(pkgs)
|
||||||
sum_pkgs = 0
|
sum_pkgs = 0
|
||||||
for i in range(len(count)):
|
for i in range(len(count)):
|
||||||
|
@ -126,7 +126,7 @@ def pkg_find(binary):
|
||||||
bol, eol = "\n", "\n"
|
bol, eol = "\n", "\n"
|
||||||
pkg_not_found(bol, binary[pkg], message, eol)
|
pkg_not_found(bol, binary[pkg], message, eol)
|
||||||
else:
|
else:
|
||||||
print (colors.GREEN + "found --> " + colors.ENDC + "\n ".join(
|
print (colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
|
||||||
find_package(binary[pkg] + sp, packages)))
|
find_package(binary[pkg] + sp, packages)))
|
||||||
|
|
||||||
def pkg_display(binary):
|
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 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __metadata__ import uname, arch
|
from __metadata__ import uname, arch
|
||||||
|
from slack_version import slack_ver
|
||||||
|
|
||||||
def mirrors(name):
|
def mirrors(name, location):
|
||||||
'''
|
'''
|
||||||
Choose Slackware mirror based
|
Select Slackware mirror packages
|
||||||
architecture
|
based architecture
|
||||||
'''
|
'''
|
||||||
if arch == "x86_64":
|
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:
|
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
|
return http
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,45 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from functions import get_to
|
|
||||||
from url_read import url_read
|
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():
|
||||||
def patches(http):
|
|
||||||
'''
|
'''
|
||||||
Find patches from oficial Slackware mirrors
|
Install new patches from official Slackware
|
||||||
'''
|
'''
|
||||||
link = url_read(http)
|
dwn_list = []
|
||||||
patches = []
|
dwn_patches = []
|
||||||
pkg_patches = []
|
upgrade_all = []
|
||||||
for line in link.split():
|
package_name = []
|
||||||
if line.startswith("href"):
|
package_location = []
|
||||||
line = line.replace("href=\"", "")
|
os.system("mkdir -p {0}{1}".format(dwn_path, 'patches/'))
|
||||||
txz = re.findall(".txz", line)
|
PACKAGE_TXT = url_read(mirrors(name='PACKAGES.TXT', location='patches/'))
|
||||||
if txz:
|
for line in PACKAGE_TXT.splitlines():
|
||||||
slack = get_to(line, "\"")
|
if line.startswith('PACKAGE NAME'):
|
||||||
if slack.endswith(".txz"):
|
package_name.append(line.replace('PACKAGE NAME: ', ''))
|
||||||
patches.append(slack)
|
if line.startswith('PACKAGE LOCATION'):
|
||||||
return patches
|
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
|
import re
|
||||||
|
|
||||||
def slack_ver():
|
def slack_ver():
|
||||||
|
'''
|
||||||
|
Slackware version
|
||||||
|
'''
|
||||||
f = open('/etc/slackware-version', 'r')
|
f = open('/etc/slackware-version', 'r')
|
||||||
sv = f.read()
|
sv = f.read()
|
||||||
f.close()
|
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
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
import urllib2
|
import urllib2
|
||||||
from __metadata__ import __prog__
|
from __metadata__ import __prog__
|
||||||
|
|
||||||
|
@ -12,5 +13,5 @@ def url_read(link):
|
||||||
f = urllib2.urlopen(link)
|
f = urllib2.urlopen(link)
|
||||||
return f.read()
|
return f.read()
|
||||||
except urllib2.URLError:
|
except urllib2.URLError:
|
||||||
print ("\n{0}: error: connection refused".format(__prog__))
|
print ("\n{0}: error: connection refused\n".format(__prog__))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
Loading…
Reference in a new issue