fix slack --upgrade checksums

This commit is contained in:
Dimitris Zlatanidis 2014-12-16 22:18:50 +02:00
parent f4b19f790d
commit ff66e6037a
7 changed files with 47 additions and 43 deletions

View file

@ -7,6 +7,7 @@ Version 2.1.4-dev
[Updated] - Fix 'UnboundLocalError: local variable 'md5' referenced before assignment'
after try update alien repository in some packages and for Slackware current
users. Thanks to 'Jack Kiersey' for reporting.
- Fix checksums after try to update slackware packages.
Version 2.1.3-dev
06-12-2014

View file

@ -21,7 +21,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from slack.mirrors import mirrors
from url_read import URL
from __metadata__ import lib_path
@ -29,18 +31,21 @@ def pkg_checksum(binary, repo):
'''
Return checksum from CHECKSUMS.md5 file by repository
'''
repos = {
'slack': 'slack_repo/CHECKSUMS.md5',
'rlw': 'rlw_repo/CHECKSUMS.md5',
'alien': 'alien_repo/CHECKSUMS.md5',
'slacky': 'slacky_repo/CHECKSUMS.md5',
'studio': 'studio_repo/CHECKSUMS.md5'
}
lib = repos[repo]
f = open(lib_path + lib, "r")
CHECKSUMS_md5 = f.read()
f.close()
md5 = str()
md5 = "None"
if repo == "slack_patches":
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).reading()
else:
repos = {
'slack': 'slack_repo/CHECKSUMS.md5',
'rlw': 'rlw_repo/CHECKSUMS.md5',
'alien': 'alien_repo/CHECKSUMS.md5',
'slacky': 'slacky_repo/CHECKSUMS.md5',
'studio': 'studio_repo/CHECKSUMS.md5'
}
lib = repos[repo]
f = open(lib_path + lib, "r")
CHECKSUMS_md5 = f.read()
f.close()
for line in CHECKSUMS_md5.splitlines():
if line.endswith(binary):
md5 = line.split()[0]

View file

@ -70,21 +70,21 @@ class Initialization(object):
lib_file = "PACKAGES.TXT"
md5_file = "CHECKSUMS.md5"
log_file = "ChangeLog.txt"
version = slack_rel
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
packages = mirrors(lib_file, "", version)
pkg_checksums = mirrors(md5_file, "", version)
extra = mirrors(lib_file, "extra/", version)
ext_checksums = mirrors(md5_file, "extra/", version)
pasture = mirrors(lib_file, "pasture/", version)
pas_checksums = mirrors(md5_file, "pasture/", version)
packages = mirrors(lib_file, "", slack_rel)
pkg_checksums = mirrors(md5_file, "", slack_rel)
extra = mirrors(lib_file, "extra/", slack_rel)
ext_checksums = mirrors(md5_file, "extra/", slack_rel)
pasture = mirrors(lib_file, "pasture/", slack_rel)
pas_checksums = mirrors(md5_file, "pasture/", slack_rel)
packages_txt = ("{0} {1} {2}".format(packages, extra, pasture))
checksums_md5 = ("{0} {1} {2}".format(pkg_checksums, ext_checksums,
pas_checksums))
changelog_txt = mirrors(log_file, "", version)
changelog_txt = mirrors(log_file, "", slack_rel)
self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt)
@ -326,8 +326,7 @@ def check_exists_repositories():
"/ChangeLog.txt")):
update = True
if update:
print("\nPlease update packages lists. Run 'slpkg update'.\n" +
"This command must run it every time a repository is \n" +
"activated or when you want to see if there are new \n" +
"update packages to them.\n")
print("\n Please update packages lists. Run 'slpkg update'.\n" +
" This command should be used to synchronize packages\n" +
" lists from the repositories are enabled.\n")
sys.exit(0)

View file

@ -67,7 +67,7 @@ class Case(object):
SBoInstall(self.package).start()
def slack_install(self):
Slack(self.package, self.release).start()
Slack(self.package).start()
def rlw_install(self):
OthersInstall(self.package, "rlw", self.release).start()

View file

@ -52,9 +52,8 @@ from greps import slack_data
class Slack(object):
def __init__(self, slack_pkg, version):
def __init__(self, slack_pkg):
self.slack_pkg = slack_pkg
self.version = version
self.tmp_path = slpkg_tmp_packages
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
color['CYAN'], self.slack_pkg, color['ENDC']))
@ -123,8 +122,7 @@ class Slack(object):
black = BlackList().packages()
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
if self.slack_pkg in name and self.slack_pkg not in black:
dwn.append("{0}{1}/{2}".format(mirrors("", "", self.version),
loc, name))
dwn.append("{0}{1}/{2}".format(mirrors("", ""), loc, name))
install.append(name)
comp_sum.append(comp)
uncomp_sum.append(uncomp)

View file

@ -21,30 +21,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from slpkg.__metadata__ import arch
from slpkg.repositories import Repo
from slpkg.__metadata__ import (
arch,
slack_rel
)
from slack_version import slack_ver
def mirrors(name, location, version):
def mirrors(name, location):
'''
Select Slackware official mirror packages
based architecture and version.
'''
repo = Repo().slack()
if arch == "x86_64":
if version == "stable":
if slack_rel == "stable":
http = repo + "slackware64-{0}/{1}{2}".format(slack_ver(),
location, name)
else:
http = repo + "slackware64-{0}/{1}{2}".format(version,
http = repo + "slackware64-{0}/{1}{2}".format(slack_rel,
location, name)
else:
if version == "stable":
if slack_rel == "stable":
http = repo + "slackware-{0}/{1}{2}".format(slack_ver(),
location, name)
else:
http = repo + "slackware-{0}/{1}{2}".format(version,
http = repo + "slackware-{0}/{1}{2}".format(slack_rel,
location, name)
return http

View file

@ -57,13 +57,12 @@ class Patches(object):
sys.stdout.write("{0}Reading package lists ...{1}".format(
color['GREY'], color['ENDC']))
sys.stdout.flush()
if version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "patches/",
version)).reading()
if self.version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT",
"patches/")).reading()
self.step = 100
else:
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "",
version)).reading()
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).reading()
self.step = 700
def start(self):
@ -127,8 +126,7 @@ class Patches(object):
if find_package(split_package(name)[0] + "-", pkg_path):
if (not os.path.isfile(pkg_path + name[:-4]) and
split_package(name)[0] not in black):
dwn.append("{0}{1}/{2}".format(
mirrors("", "", self.version), loc, name))
dwn.append("{0}{1}/{2}".format(mirrors("", ""), loc, name))
comp_sum.append(comp)
uncomp_sum.append(uncomp)
upgrade.append(name)
@ -165,7 +163,7 @@ def upgrade(patch_path, upgrade_all):
Upgrade packages
'''
for pkg in upgrade_all:
check_md5(pkg_checksum(pkg, "slack"), patch_path + pkg)
check_md5(pkg_checksum(pkg, "slack_patches"), patch_path + pkg)
print("[ {0}upgrading{1} ] --> {2}".format(color['YELLOW'],
color['ENDC'], pkg[:-4]))
PackageManager((patch_path + pkg).split()).upgrade()