updated for version 1.8.4

This commit is contained in:
Dimitris Zlatanidis 2014-09-10 06:46:16 +03:00
parent 18ca7375eb
commit a5c4ee32e3
19 changed files with 190 additions and 73 deletions

View file

@ -1,7 +1,13 @@
Version 1.8.4
10-09-2014
[Feature] - Added MD5SUM check file.
- Added build time.
Version 1.8.3
08-09-2014
[Updated] - FIx messages
[Updated] - Fix messages
Version 1.8.2
08-09-2014

View file

@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: slpkg
Version: 1.8.3
Version: 1.8.4
Author: dslackw
Author-email: d zlatanidis at gmail com
Maintainer: dslackw

View file

@ -9,9 +9,9 @@
Latest Release:
- Version: 1.8.3
- Version: 1.8.4
- `Package <https://sourceforge.net/projects/slpkg/>`_
- `Source <https://github.com/dslackw/slpkg/archive/v1.8.3.tar.gz>`_
- `Source <https://github.com/dslackw/slpkg/archive/v1.8.4.tar.gz>`_
- `CHANGELOG <https://github.com/dslackw/slpkg/blob/master/CHANGELOG>`_
`Slpkg <https://github.com/dslackw/slpkg>`_ is a terminal multitool in order to easy use `Slackware <http://www.slackware.com/>`_
@ -68,10 +68,12 @@ Features
- Build and install all in a command
- Checking for updated packages
- List all installed packages
- Support MD5SUM file check
- Find installed package
- Read SlackBuilds files
- Τracking dependencies
- No dependencies
- Build log file
- Sum build time
It's a quick and easy way to manage your packages in `Slackware <http://www.slackware.com/>`_
to a command.
@ -89,8 +91,8 @@ Untar the archive and run install.sh script:
.. code-block:: bash
$ tar xvf slpkg-1.8.3.tar.gz
$ cd slpkg-1.8.3
$ tar xvf slpkg-1.8.4.tar.gz
$ cd slpkg-1.8.4
$ ./install.sh
Using `pip <https://pip.pypa.io/en/latest/>`_ :
@ -384,6 +386,8 @@ Auto tool to build package:
Slackware package /tmp/termcolor-1.1.0-x86_64-1_SBo.tgz created.
Total build time for package termcolor : 1 Sec
Upgrade, install package:
.. code-block:: bash

View file

@ -21,7 +21,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=slpkg
VERSION=${VERSION:-1.8.3}
VERSION=${VERSION:-1.8.4}
TAG=${TAG:-_dsw}
cd ..

View file

@ -1,12 +1,10 @@
Slpkg is a terminal multitool in order to easy use Slackware
packages.
Features:
Features
========
- Build third party packages from source with all dependencies
- Install packages through from official Slackware mirrors
- Find and Download packages from slackbuilds.org
- Grabs packages from slackbuilds.org in real time
- Find and Download packages from slackbuilds.org
- Automatic tool build and install packages
- Check if your distribution is up to date
- Remove packages with all dependencies
@ -15,10 +13,12 @@ Features:
- Build and install all in a command
- Checking for updated packages
- List all installed packages
- Support MD5SUM file check
- Find installed package
- Read SlackBuilds files
- Τracking dependencies
- No dependencies
- Build log file
- Sum build time
It's a quick and easy way to manage your packages in Slackware
to a command.

View file

@ -6,7 +6,7 @@
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
slpkg: slpkg (Slackware tool in Python)
slpkg: slpkg (Slackware packaging tool)
slpkg:
slpkg: Slpkg is a terminal multitool in order to easy use Slackware
slpkg: packages. It's a quick and easy way to manage your packages in

View file

@ -23,7 +23,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=slpkg
VERSION=${VERSION:-1.8.3}
VERSION=${VERSION:-1.8.4}
BUILD=${BUILD:-1}
TAG=${TAG:-_dsw}

View file

@ -1,7 +1,7 @@
PRGNAM="slpkg"
VERSION="1.8.3"
VERSION="1.8.4"
HOMEPAGE="https://github.com/dslackw/slpkg"
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v1.8.3.tar.gz"
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v1.8.4.tar.gz"
MD5SUM=""
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""

View file

@ -26,7 +26,7 @@ import subprocess
__all__ = "slpkg"
__author__ = "dslackw"
__version_info__ = (1, 8, 3)
__version_info__ = (1, 8, 4)
__version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com"

32
slpkg/checksum.py Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# checksum.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg 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.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import hashlib
def md5sum(source):
'''
Calculate the md5 checksum
'''
with open(source) as file_to_check:
data = file_to_check.read()
return hashlib.md5(data).hexdigest()

View file

@ -75,9 +75,14 @@ def s_user(user):
sys.exit()
def build_FAILED(sbo_url, prgnam):
print("\n{0}<-- FAILED{1} to build the package {2}".format(colors.RED, colors.ENDC, prgnam))
print("See log file in /var/log/slpkg/logs directory or read README file:")
print("{0}{1}\n".format(sbo_url, "README"))
template(78)
print("| Build package {0} [ {1}FAILED{2} ]".format(prgnam, colors.RED, colors.ENDC))
template(78)
print("| See log file in {0}/var/log/slpkg/sbo/build_logs{1} directory or read README file:".format(
colors.CYAN, colors.ENDC))
print("| {0}{1}".format(sbo_url, "README"))
template(78)
print # new line at end
def template(max):
'''

View file

@ -28,8 +28,12 @@ import shutil
import tarfile
import subprocess
from slpkg.messages import pkg_not_found
from slpkg.colors import colors
from slpkg.checksum import md5sum
from slpkg.__metadata__ import log_path
from slpkg.messages import pkg_not_found, template
from slpkg.sbo.greps import sbo_checksum_pkg
def build_package(script, sources, path):
'''
@ -38,38 +42,79 @@ def build_package(script, sources, path):
'''
prgnam = script.replace(".tar.gz", "")
log_file = ("build_{0}_log".format(prgnam))
logs = log_path + "logs/"
sbo_logs = log_path + "sbo/"
build_logs = sbo_logs + "build_logs/"
if not os.path.exists(log_path):
os.mkdir(log_path)
if not os.path.exists(logs):
os.mkdir(logs)
log_date = time.strftime("%c")
template = ("#" * 79 + "\n\n")
if not os.path.exists(sbo_logs):
os.mkdir(sbo_logs)
if not os.path.exists(build_logs):
os.mkdir(build_logs)
log_date = time.strftime("%d/%m/%Y")
start_log_time = time.strftime("%H:%M:%S")
log_line = ("#" * 79 + "\n\n")
try:
if os.path.isfile(logs + log_file):
os.remove(logs + log_file)
if os.path.isfile(build_logs + log_file):
os.remove(build_logs + log_file)
tar = tarfile.open(script)
tar.extractall()
tar.close()
for src in sources:
sbo_md5 = sbo_checksum_pkg(prgnam)
md5 = md5sum(src)
if sbo_md5 != md5:
template(78)
print("| MD5SUM check for {0} [ {1}FAILED{2} ]".format(
src, colors.RED, colors.ENDC))
template(78)
print("| Expected: {0}".format(md5))
print("| Found: {0}".format(sbo_md5))
template(78)
read = raw_input("\nDo you want to continue [Y/n]? ")
if read == "Y" or read == "y":
pass
else:
sys.exit()
else:
template(78)
print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format(
src, colors.GREEN, colors.ENDC))
template(78)
print # new line after pass checksum
shutil.copy2(src, prgnam)
os.chdir(path + prgnam)
subprocess.call("chmod +x {0}.SlackBuild".format(prgnam), shell=True)
with open(logs + log_file, "w") as log: # write headers to log file
log.write(template)
with open(build_logs + log_file, "w") as log: # write headers to log file
log.write(log_line)
log.write("File : " + log_file + "\n")
log.write("Path : " + logs + "\n")
log.write("Date : " + log_date + "\n\n")
log.write(template)
log.write("Path : " + build_logs + "\n")
log.write("Date : " + log_date + "\n")
log.write("Time : " + start_log_time + "\n\n")
log.write(log_line)
log.close()
with open(logs + log_file, "a") as log: # append END tag to a log file
log.write(template)
log.write(" " * 38 + "E N D\n\n")
log.write(template)
subprocess.Popen("./{0}.SlackBuild 2>&1 | tee -a {1}{2}".format(
prgnam, logs, log_file), shell=True, stdout=sys.stdout).communicate()
prgnam, build_logs, log_file), shell=True, stdout=sys.stdout).communicate()
end_log_time = time.strftime("%H:%M:%S")
start_time = start_log_time.replace(":", "")
end_time = end_log_time.replace(":", "")
rmv_time = int(end_time) - int(start_time)
# calculate build time
if rmv_time <= 60:
sum_time = str(rmv_time) + " Sec"
elif rmv_time > 60:
div_time = round(float(rmv_time) / 60, 2)
rest_time = str(div_time).replace(".", " ").split()
sum_time = rest_time[0] + " Min " + rest_time[1] + " Sec"
with open(build_logs + log_file, "a") as log: # append END tag to a log file
log.seek(2) # EOF
log.write(log_line)
log.write("Time : " + end_log_time + "\n")
log.write("Total build time : " + sum_time + "\n")
log.write(" " * 38 + "E N D\n\n")
log.write(log_line)
log.close()
os.chdir(path)
print("Total build time for package {0} : {1}\n".format(prgnam, sum_time))
except (OSError, IOError):
message = "Wrong file"
pkg_not_found("\n", prgnam, message, "\n")

View file

@ -25,6 +25,7 @@ import os
from slpkg.url_read import url_read
from slpkg.__metadata__ import arch, lib_path
from search import sbo_search_pkg
def sbo_source_dwn(name):
@ -78,5 +79,21 @@ def sbo_version_pkg(name):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD VERSION: "):
if sbo_name == name:
sbo_url = sbo_search_pkg(name)
return line[20:].strip()
def sbo_checksum_pkg(name):
if arch == "x86_64":
for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
if arch == "x86_64":
if line.startswith("SLACKBUILD NAME: "):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD MD5SUM_x86_64: "):
if sbo_name == name:
if line[26:].strip():
return line[26:].strip()
for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
if line.startswith("SLACKBUILD NAME: "):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD MD5SUM: "):
if sbo_name == name:
return line[19:].strip()

View file

@ -37,54 +37,58 @@ def initialization():
/var/lib/slpkg/sbo_repo/ and ChangeLog.txt in /var/log/slpkg/ from
slackbuilds.org
'''
lib = lib_path + "sbo_repo/"
sbo_log = log_path + "sbo/"
sbo_lib = lib_path + "sbo_repo/"
if not os.path.exists(log_path):
os.mkdir(log_path)
if not os.path.exists(lib):
if not os.path.exists(lib_path):
os.mkdir(lib_path)
os.mkdir(lib)
if not os.path.exists(sbo_log):
os.mkdir(sbo_log)
if not os.path.exists(sbo_lib):
os.mkdir(sbo_lib)
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
'''
Read SLACKBUILDS.TXT from slackbuilds.org and write in /var/lib/slpkg/sbo_repo/
directory if not exist
'''
if not os.path.isfile(lib + "SLACKBUILDS.TXT"):
if not os.path.isfile(sbo_lib + "SLACKBUILDS.TXT"):
print("\nslpkg ...initialization")
sys.stdout.write("SLACKBUILDS.TXT read ...")
sys.stdout.flush()
SLACKBUILDS_TXT = url_read((
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(slack_ver())))
sys.stdout.write("Done\n")
sbo = open("{0}SLACKBUILDS.TXT".format(lib), "w")
sbo = open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w")
sbo.write(SLACKBUILDS_TXT)
sbo.close()
print("File SLACKBUILDS.TXT created in {0}".format(lib))
print("File SLACKBUILDS.TXT created in {0}".format(sbo_lib))
'''
Read ChangeLog.txt from slackbuilds.org and write in /var/log/slpkg/
Read ChangeLog.txt from slackbuilds.org and write in /var/log/slpkg/sbo/
directory if not exist
'''
if not os.path.isfile(log_path + "ChangeLog.txt"):
if not os.path.isfile(sbo_log + "ChangeLog.txt"):
print("\nslpkg initialization")
sys.stdout.write("ChangeLog.txt read ...")
sys.stdout.flush()
ChangeLog_txt = url_read((
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(slack_ver())))
sys.stdout.write("Done\n")
log = open("{0}ChangeLog.txt".format(log_path), "w")
log = open("{0}ChangeLog.txt".format(sbo_log), "w")
log.write(ChangeLog_txt)
log.close()
print("File ChangeLog.txt created in {0}".format(log_path))
print("File ChangeLog.txt created in {0}".format(sbo_log))
'''
We take the size of ChangeLog.txt from the server and locally
'''
server = int(''.join(server_file_size(sbo_url + "ChangeLog.txt")))
local = int(local_file_size(log_path + "ChangeLog.txt"))
local = int(local_file_size(sbo_log + "ChangeLog.txt"))
'''
If the two files differ in size delete and replaced with new
'''
if server != local:
os.remove("{0}sbo_repo/{1}".format(lib_path, "SLACKBUILDS.TXT"))
os.remove("{0}{1}".format(log_path, "ChangeLog.txt"))
os.remove("{0}{1}".format(sbo_lib, "SLACKBUILDS.TXT"))
os.remove("{0}{1}".format(sbo_log, "ChangeLog.txt"))
print("\nNEWS in ChangeLog.txt")
print("slpkg ...initialization")
sys.stdout.write("Files re-created ...")
@ -93,10 +97,10 @@ def initialization():
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(slack_ver())))
ChangeLog_txt = url_read((
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(slack_ver())))
sbo = open("{0}sbo_repo/SLACKBUILDS.TXT".format(lib_path), "w")
sbo = open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w")
sbo.write(SLACKBUILDS_TXT)
sbo.close()
log = open("{0}ChangeLog.txt".format(log_path), "w")
log = open("{0}ChangeLog.txt".format(sbo_log), "w")
log.write(ChangeLog_txt)
log.close()
sys.stdout.write("Done\n")

View file

@ -26,11 +26,11 @@ import os
from slpkg.url_read import url_read
from slpkg.__metadata__ import slpkg_tmp
# create tmp directory if not exist
# create directories if not exist
rdm_path = slpkg_tmp + "readme/"
if not os.path.exists(rdm_path):
if not os.path.exists(slpkg_tmp):
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)
if not os.path.exists(rdm_path):
os.mkdir(rdm_path)
def read_readme(sbo_url, name, site):

View file

@ -26,6 +26,7 @@ import sys
import subprocess
from slpkg.colors import colors
from slpkg.checksum import md5sum
from slpkg.functions import get_file
from slpkg.__metadata__ import tmp, pkg_path, build_path, log_path, sp
from slpkg.messages import pkg_not_found, pkg_found, template, build_FAILED
@ -162,9 +163,9 @@ def sbo_build(name):
print("Total {0} {1}.".format(len(dependencies), msg_ins))
print("{0} {1} will be installed, {2} allready installed and {3} {4}".format(
count_installed, msg_ins, pkg_sum, count_upgraded, msg_upg))
print("will be upgraded.")
print("will be upgraded.\n")
'''
Check if package supported by arch
Check if package supported or tested by arch
before proceed to install
'''
UNST = ["UNSUPPORTED", "UNTESTED"]
@ -173,7 +174,10 @@ def sbo_build(name):
if item == un:
print("\n{0}The package {1}{2}\n".format(colors.RED, item, ENDC))
sys.exit()
read = raw_input("\nDo you want to continue [Y/n]? ")
# exit if all packages already installed
if pkg_sum == len(dependencies):
sys.exit()
read = raw_input("Do you want to continue [Y/n]? ")
if read == "Y" or read == "y":
if not os.path.exists(build_path):
os.mkdir(build_path)

View file

@ -43,11 +43,12 @@ def install(slack_pkg):
comp_sum, uncomp_sum = [], []
dwn_list, comp_size, uncomp_size = [], [], []
install_all, package_name, package_location = [], [], []
tmp_path = slpkg_tmp + "packages/"
pkg_sum, arch, COLOR, ENDC = 0, "", "", colors.ENDC
if not os.path.exists(tmp_path):
# create directories if not exist
tmp_path = slpkg_tmp + "packages/"
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)
if not os.path.exists(tmp_path):
os.mkdir(tmp_path)
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
colors.CYAN, slack_pkg, ENDC))

View file

@ -26,7 +26,7 @@ from slack_version import slack_ver
def mirrors(name, location):
'''
Select Slackware mirror packages
Select Slackware official mirror packages
based architecture
'''
if arch == "x86_64":

View file

@ -29,8 +29,7 @@ import subprocess
from slpkg.colors import colors
from slpkg.url_read import url_read
from slpkg.messages import template
from slpkg.__metadata__ import (pkg_path, slpkg_tmp,
slack_archs)
from slpkg.__metadata__ import pkg_path, slpkg_tmp, slack_archs
from slpkg.pkg.manager import pkg_upgrade
@ -48,9 +47,9 @@ def patches():
GREEN, RED, ENDC = colors.GREEN, colors.RED, colors.ENDC
patch_path = slpkg_tmp + "patches/"
slack_arch = ""
if not os.path.exists(patch_path):
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)
if not os.path.exists(patch_path):
os.mkdir(patch_path)
sys.stdout.write ("Reading package lists ...")
sys.stdout.flush()