mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
fix md5 failed
This commit is contained in:
parent
f2527ec2dc
commit
3cc394d09e
5 changed files with 30 additions and 18 deletions
|
@ -1,8 +1,12 @@
|
|||
Version 2.1.4-dev
|
||||
10-12-2014
|
||||
13-12-2014
|
||||
|
||||
[Feature] - Added command 'update' and remove auto update package lists.
|
||||
|
||||
[Updated] - Fix 'UnboundLocalError: local variable 'md5' referenced before assignment'
|
||||
after try update alien repository in some packages and for Slackware current
|
||||
users.
|
||||
|
||||
Version 2.1.3-dev
|
||||
06-12-2014
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ def pkg_checksum(binary, repo):
|
|||
f = open(lib_path + lib, "r")
|
||||
CHECKSUMS_md5 = f.read()
|
||||
f.close()
|
||||
md5 = str()
|
||||
for line in CHECKSUMS_md5.splitlines():
|
||||
if line.endswith(binary):
|
||||
md5 = line.split()[0]
|
||||
|
|
|
@ -25,9 +25,11 @@ import os
|
|||
import sys
|
||||
|
||||
from url_read import URL
|
||||
from toolbar import status
|
||||
from repositories import Repo
|
||||
from file_size import FileSize
|
||||
from __metadata__ import (
|
||||
color,
|
||||
log_path,
|
||||
lib_path,
|
||||
slack_rel,
|
||||
|
@ -225,14 +227,15 @@ class Initialization(object):
|
|||
'''
|
||||
FILE_TXT = ""
|
||||
if not os.path.isfile(path + files):
|
||||
# sys.stdout.write(" Update {0} ...".format(files))
|
||||
# sys.stdout.flush()
|
||||
for fu in file_url.split():
|
||||
FILE_TXT += URL(fu).reading()
|
||||
with open("{0}{1}".format(path, files), "w") as f:
|
||||
f.write(FILE_TXT)
|
||||
toolbar_width, index = 2, 0
|
||||
for line in FILE_TXT.splitlines():
|
||||
index += 1
|
||||
toolbar_width = status(index, toolbar_width, 700)
|
||||
f.write(line + "\n")
|
||||
f.close()
|
||||
# sys.stdout.write("Done\n")
|
||||
|
||||
@staticmethod
|
||||
def remote(*args):
|
||||
|
@ -249,9 +252,6 @@ class Initialization(object):
|
|||
if server != local:
|
||||
os.remove("{0}{1}".format(args[3], args[4]))
|
||||
os.remove("{0}{1}".format(args[0], args[1]))
|
||||
print(" NEWS in " + args[1])
|
||||
sys.stdout.write(" Update package list ...")
|
||||
sys.stdout.flush()
|
||||
for fu in args[5].split():
|
||||
PACKAGES_TXT += URL(fu).reading()
|
||||
CHANGELOG_TXT = URL(args[2]).reading()
|
||||
|
@ -266,7 +266,6 @@ class Initialization(object):
|
|||
with open("{0}{1}".format(args[0], args[1]), "w") as f:
|
||||
f.write(CHANGELOG_TXT)
|
||||
f.close()
|
||||
sys.stdout.write("Done\n")
|
||||
|
||||
|
||||
class Update(object):
|
||||
|
@ -285,12 +284,13 @@ class Update(object):
|
|||
'''
|
||||
Update all repositories lists
|
||||
'''
|
||||
print("") # new line at start
|
||||
for repo in repositories:
|
||||
sys.stdout.write("Update repository {0} ...".format(repo))
|
||||
sys.stdout.write("{0}Update repository {1} ...{2}".format(
|
||||
color['GREY'], repo, color['ENDC']))
|
||||
sys.stdout.flush()
|
||||
self.repos[repo]()
|
||||
sys.stdout.write("Done\n")
|
||||
sys.stdout.write("{0}Done{1}\n".format(color['GREY'],
|
||||
color['ENDC']))
|
||||
print("") # new line at end
|
||||
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class OthersUpgrade(object):
|
|||
if answer in ['y', 'Y']:
|
||||
upgrade_all.reverse()
|
||||
Download(self.tmp_path, dwn_links).start()
|
||||
upgrade(self.tmp_path, upgrade_all, self.repo)
|
||||
upgrade(self.tmp_path, upgrade_all, self.repo, self.version)
|
||||
delete(self.tmp_path, upgrade_all)
|
||||
else:
|
||||
print("No new updates in the repository '{0}'\n".format(
|
||||
|
@ -216,15 +216,18 @@ def msgs(upgrade_all):
|
|||
return msg_pkg
|
||||
|
||||
|
||||
def upgrade(tmp_path, upgrade_all, repo):
|
||||
def upgrade(tmp_path, upgrade_all, repo, version):
|
||||
'''
|
||||
Install or upgrade packages
|
||||
'''
|
||||
for pkg in upgrade_all:
|
||||
package = (tmp_path + pkg).split()
|
||||
if repo == "alien":
|
||||
if repo == "alien" and version == "stable":
|
||||
check_md5(pkg_checksum("/" + slack_ver() + "/" + pkg, repo),
|
||||
tmp_path + pkg)
|
||||
elif repo == "alien" and version == "current":
|
||||
check_md5(pkg_checksum("/" + version + "/" + pkg, repo),
|
||||
tmp_path + pkg)
|
||||
else:
|
||||
check_md5(pkg_checksum(pkg, repo), tmp_path + pkg)
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(color['YELLOW'],
|
||||
|
|
|
@ -149,7 +149,8 @@ class OthersInstall(object):
|
|||
if answer in ['y', 'Y']:
|
||||
install_all.reverse()
|
||||
Download(self.tmp_path, dwn_links).start()
|
||||
install(self.tmp_path, install_all, self.repo)
|
||||
install(self.tmp_path, install_all, self.repo,
|
||||
self.version)
|
||||
write_deps(dependencies)
|
||||
delete(self.tmp_path, install_all)
|
||||
else:
|
||||
|
@ -260,15 +261,18 @@ def msgs(install_all, uni_sum):
|
|||
return [msg_pkg, msg_2_pkg]
|
||||
|
||||
|
||||
def install(tmp_path, install_all, repo):
|
||||
def install(tmp_path, install_all, repo, version):
|
||||
'''
|
||||
Install or upgrade packages
|
||||
'''
|
||||
for install in install_all:
|
||||
package = (tmp_path + install).split()
|
||||
if repo == "alien":
|
||||
if repo == "alien" and version == "stable":
|
||||
check_md5(pkg_checksum("/" + slack_ver() + "/" + install, repo),
|
||||
tmp_path + install)
|
||||
elif repo == "alien" and version == "current":
|
||||
check_md5(pkg_checksum("/" + version + "/" + install, repo),
|
||||
tmp_path + install)
|
||||
else:
|
||||
check_md5(pkg_checksum(install, repo), tmp_path + install)
|
||||
if os.path.isfile(pkg_path + install[:-4]):
|
||||
|
|
Loading…
Reference in a new issue