Update check changelogs.txt

This commit is contained in:
Dimitris Zlatanidis 2015-06-15 07:14:30 +03:00
parent 3a2976258e
commit d47141bbf5
8 changed files with 131 additions and 34 deletions

View file

@ -363,7 +363,7 @@ Command Line Tool Usage
--installed packages repository, index or print --installed packages repository, index or print
only packages installed on the only packages installed on the
system. system.
-c, --check, [repository] --upgrade, Check, view and install updated -c, --check, [repository], --upgrade, Check, view and install updated
--skip=[...] --resolve--off packages from repositories. --skip=[...] --resolve--off packages from repositories.
-s, --sync, [repository] [package...], Sync packages. Install packages -s, --sync, [repository] [package...], Sync packages. Install packages
--resolve-off directly from remote repositories --resolve-off directly from remote repositories
@ -426,6 +426,12 @@ list. This command must be executed to update the package lists:
$ slpkg update --only=sbo,msb,slacky $ slpkg update --only=sbo,msb,slacky
Also you can check ChangeLog.txt for changes like:
$ slpkg -c sbo
News in ChangeLog.txt
Add and remove custom repositories: Add and remove custom repositories:
@ -651,10 +657,18 @@ and also displays installed packages:
+--5 libunique +--5 libunique
Check if your packages is up to date: Check if your packages is up to date or changes in ChangeLog.txt:
.. code-block:: bash .. code-block:: bash
You can check ChangeLog.txt for changes before with command:
$ slpkg -c sbo
News in ChangeLog.txt
And check if packages need upgrade with:
$ slpkg -c sbo --upgrade $ slpkg -c sbo --upgrade
Checking ...................Done Checking ...................Done
Reading package lists ......Done Reading package lists ......Done

View file

@ -93,6 +93,10 @@ View repository information.
.PP .PP
You can check for new versions and update slpkg itself. You can check for new versions and update slpkg itself.
.SH OPTIONS
.PP
The following arguments are available.
.SS -a, --autobuild, auto build packages .SS -a, --autobuild, auto build packages
\fBslpkg\fP \fB-a\fP <\fIscript.tar.gz\fP> <\fIsources\fP> \fBslpkg\fP \fB-a\fP <\fIscript.tar.gz\fP> <\fIsources\fP>
.PP .PP
@ -136,6 +140,9 @@ additional option "--resolve-off" switch off automatic resolve dependencies.
Slackware patches repository works independently of the others i.e not need before updating Slackware patches repository works independently of the others i.e not need before updating
the list of packages by choosing "# slpkg update", works directly with the official repository the list of packages by choosing "# slpkg update", works directly with the official repository
and so always you can have updated your system. and so always you can have updated your system.
Also you can check ChangeLog.txt for changes without option "--upgrade" like:
"# slpkg -c [repository]" or check all enabled repositories just replace repository name with
"ALL".
.SS -s, --sync, synchronize packages, download, build and install package with all dependencies .SS -s, --sync, synchronize packages, download, build and install package with all dependencies
\fBslpkg\fP \fB-s\fP <\fIrepository\fP> <\fInames of packages\fP>, \fB--resolve-off\fP \fBslpkg\fP \fB-s\fP <\fIrepository\fP> <\fInames of packages\fP>, \fB--resolve-off\fP

View file

@ -88,7 +88,7 @@ class MetaData(object):
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (2, 5, 0) __version_info__ = (2, 5, 1)
__version__ = "{0}.{1}.{2}".format(*__version_info__) __version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)" __license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com" __email__ = "d.zlatanidis@gmail.com"

View file

@ -79,7 +79,7 @@ Optional arguments:
--installed packages repository, index or print --installed packages repository, index or print
only packages installed on the only packages installed on the
system. system.
-c, --check, [repository] --upgrade, Check, view and install updated -c, --check, [repository], --upgrade, Check, view and install updated
--skip=[...] --resolve--off packages from repositories. --skip=[...] --resolve--off packages from repositories.
-s, --sync, [repository] [package...], Sync packages. Install packages -s, --sync, [repository] [package...], Sync packages. Install packages
--resolve-off directly from remote repositories --resolve-off directly from remote repositories
@ -136,7 +136,7 @@ def usage(repo):
[-q [build, install, build-install]] [-q [build, install, build-install]]
[-g [print, edit=[editor]]] [-g [print, edit=[editor]]]
[-l [repository], --index, --installed] [-l [repository], --index, --installed]
[-c [repository] --upgrade, --skip=[...] --resolve-off] [-c [repository], --upgrade, --skip=[...] --resolve-off]
[-s [repository] [package...], --resolve-off] [-s [repository] [package...], --resolve-off]
[-t [repository] [package]] [-t [repository] [package]]
[-p [repository] [package], --color=[]] [-p [repository] [package], --color=[]]

View file

@ -21,39 +21,67 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from messages import Msg
from arguments import usage from arguments import usage
from sbo.check import sbo_upgrade from init import Initialization
from slack.patches import Patches
from binary.check import pkg_upgrade
from __metadata__ import MetaData as _meta_ from __metadata__ import MetaData as _meta_
class Updates(object): class Updates(object):
"""Checking for news in ChangeLog.txt
"""
def __init__(self, repo): def __init__(self, repo):
self.repo = repo self.repo = repo
self.meta = _meta_ self.meta = _meta_
self.check = 2
self._init = Initialization(True)
self.all_repos = {
"slack": self._init.slack,
"sbo": self._init.sbo,
"rlw": self._init.rlw,
"alien": self._init.alien,
"slacky": self._init.slacky,
"studio": self._init.studio,
"slackr": self._init.slackr,
"slonly": self._init.slonly,
"ktown": self._init.ktown,
"multi": self._init.multi,
"slacke": self._init.slacke,
"salix": self._init.salix,
"slackl": self._init.slackl,
"rested": self._init.rested,
"msb": self._init.msb
}
def run(self): def run(self):
if self.repo in self.meta.repositories: """Run and check if new in ChangeLog.txt
if self.repo == "sbo": """
self.check = len(sbo_upgrade(skip="")) if self.repo in self.meta.default_repositories:
elif self.repo == "slack": try:
if self.meta.only_installed in ["on", "ON"]: self.check = self.all_repos[self.repo]()
self.check = len(pkg_upgrade(self.repo, skip="")) except OSError:
else: usage(self.repo)
self.check = Patches(skip="", flag="").store() elif self.repo in self.meta.repositories:
Msg().done() self.check = self._init.custom(self.repo)
else:
self.check = len(pkg_upgrade(self.repo, skip=""))
self.status()
else: else:
usage(self.repo) usage(self.repo)
self.status()
def ALL(self):
for repo in self.meta.repositories:
print("Repository: {0}".format(repo))
if repo in self.meta.default_repositories:
try:
self.check = self.all_repos[repo]()
except OSError:
usage(self.repo)
elif repo in self.meta.repositories:
self.check = self._init.custom(repo)
self.status()
def status(self): def status(self):
if self.check > 1: """Print messages
"""
if self.check == 1:
print("\nNews in ChangeLog.txt\n") print("\nNews in ChangeLog.txt\n")
else: elif self.check == 0:
print("\nNo changes in ChangeLog.txt\n") print("\nNo changes in ChangeLog.txt\n")

View file

@ -37,7 +37,8 @@ from slack.slack_version import slack_ver
class Initialization(object): class Initialization(object):
def __init__(self): def __init__(self, check):
self.check = check
self.meta = _meta_ self.meta = _meta_
self.conf_path = self.meta.conf_path self.conf_path = self.meta.conf_path
self.log_path = self.meta.log_path self.log_path = self.meta.log_path
@ -79,6 +80,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}".format(repo, md5_file) checksums_md5 = "{0}{1}".format(repo, md5_file)
changelog_txt = "{0}{1}".format(repo, log_file) changelog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -110,6 +113,8 @@ class Initialization(object):
checksums_md5 = ("{0} {1} {2}".format(pkg_checksums, ext_checksums, checksums_md5 = ("{0} {1} {2}".format(pkg_checksums, ext_checksums,
pas_checksums)) pas_checksums))
changelog_txt = mirrors(log_file, "") changelog_txt = mirrors(log_file, "")
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -134,6 +139,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "" checksums_md5 = ""
changelog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file) changelog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt, self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
@ -157,6 +164,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}/{2}".format(repo, slack_ver(), md5_file) checksums_md5 = "{0}{1}/{2}".format(repo, slack_ver(), md5_file)
changelog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file) changelog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -181,6 +190,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}".format(repo, md5_file) checksums_md5 = "{0}{1}".format(repo, md5_file)
changelog_txt = "{0}{1}".format(repo, log_file) changelog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -213,6 +224,8 @@ class Initialization(object):
changelog_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(), changelog_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
log_file) log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -244,6 +257,8 @@ class Initialization(object):
md5_file) md5_file)
changelog_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(), changelog_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
log_file) log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -268,6 +283,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}".format(repo, md5_file) checksums_md5 = "{0}{1}".format(repo, md5_file)
changelog_txt = "{0}{1}".format(repo, log_file) changelog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -296,6 +313,8 @@ class Initialization(object):
filelist_txt = "{0}{1}/{2}".format(repo, ar, lst_file) filelist_txt = "{0}{1}/{2}".format(repo, ar, lst_file)
checksums_md5 = "{0}{1}/{2}".format(repo, ar, md5_file) checksums_md5 = "{0}{1}/{2}".format(repo, ar, md5_file)
changelog_txt = "{0}{1}/{2}".format(repo, ar, log_file) changelog_txt = "{0}{1}/{2}".format(repo, ar, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -320,6 +339,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}".format(repo, md5_file) checksums_md5 = "{0}{1}".format(repo, md5_file)
changelog_txt = "{0}{1}".format(repo, log_file) changelog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -344,6 +365,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}".format(repo, md5_file) checksums_md5 = "{0}{1}".format(repo, md5_file)
changelog_txt = "{0}{1}".format(repo, log_file) changelog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -377,6 +400,8 @@ class Initialization(object):
repo, self.meta.slacke_sub_repo[1:-1], ar, slack_ver(), md5_file) repo, self.meta.slacke_sub_repo[1:-1], ar, slack_ver(), md5_file)
changelog_txt = "{0}slacke{1}/slackware{2}-{3}/{4}".format( changelog_txt = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, self.meta.slacke_sub_repo[1:-1], ar, slack_ver(), log_file) repo, self.meta.slacke_sub_repo[1:-1], ar, slack_ver(), log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -405,6 +430,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}/{2}/{3}".format(repo, ar, slack_ver(), md5_file) checksums_md5 = "{0}{1}/{2}/{3}".format(repo, ar, slack_ver(), md5_file)
changelog_txt = "{0}{1}/{2}/{3}".format(repo, ar, slack_ver(), log_file) changelog_txt = "{0}{1}/{2}/{3}".format(repo, ar, slack_ver(), log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -433,6 +460,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}/current/{2}".format(repo, ar, md5_file) checksums_md5 = "{0}{1}/current/{2}".format(repo, ar, md5_file)
changelog_txt = "{0}{1}/current/{2}".format(repo, ar, log_file) changelog_txt = "{0}{1}/current/{2}".format(repo, ar, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -457,6 +486,8 @@ class Initialization(object):
filelist_txt = "" filelist_txt = ""
checksums_md5 = "{0}{1}".format(repo, md5_file) checksums_md5 = "{0}{1}".format(repo, md5_file)
changelog_txt = "{0}{1}".format(repo, log_file) changelog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -487,6 +518,8 @@ class Initialization(object):
checksums_md5 = "{0}{1}/{2}/{3}/{4}".format( checksums_md5 = "{0}{1}/{2}/{3}/{4}".format(
repo, slack_ver(), self.meta.msb_sub_repo[1:-1], ar, md5_file) repo, slack_ver(), self.meta.msb_sub_repo[1:-1], ar, md5_file)
changelog_txt = "{0}{1}".format(repo, log_file) changelog_txt = "{0}{1}".format(repo, log_file)
if self.check:
return self.checks_logs(log, log_file, changelog_txt)
self.write(lib, lib_file, packages_txt) self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5) self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt) self.write(log, log_file, changelog_txt)
@ -538,9 +571,8 @@ class Initialization(object):
If the two files differ in size delete and replace all files with new. If the two files differ in size delete and replace all files with new.
""" """
PACKAGES_TXT = "" PACKAGES_TXT = ""
server = FileSize(args[2]).server() check = self.checks_logs(args[0], args[1], args[2])
local = FileSize(args[0] + args[1]).local() if check == 1:
if server != local:
# remove PACKAGES.txt # remove PACKAGES.txt
os.remove("{0}{1}".format(args[3], args[4])) os.remove("{0}{1}".format(args[3], args[4]))
# remove Changelog.txt # remove Changelog.txt
@ -569,6 +601,15 @@ class Initialization(object):
FILELIST_TXT = URL(args[9]).reading() FILELIST_TXT = URL(args[9]).reading()
self.write_file(args[3], args[8], FILELIST_TXT) self.write_file(args[3], args[8], FILELIST_TXT)
def checks_logs(self, log_path, log_file, url):
"""Checks ChangeLog.txt from changes
"""
server = FileSize(url).server()
local = FileSize(log_path + log_file).local()
if server != local:
return 1
return 0
def upgrade(self, only): def upgrade(self, only):
"""Remove all package lists with changelog and checksums files """Remove all package lists with changelog and checksums files
and create lists again""" and create lists again"""
@ -596,7 +637,7 @@ class Initialization(object):
class Update(object): class Update(object):
def __init__(self): def __init__(self):
self._init = "Initialization()" self._init = "Initialization(False)"
self.meta = _meta_ self.meta = _meta_
self.done = "{0}Done{1}\n".format(self.meta.color["GREY"], self.done = "{0}Done{1}\n".format(self.meta.color["GREY"],
self.meta.color["ENDC"]) self.meta.color["ENDC"])
@ -619,7 +660,7 @@ class Update(object):
exec("{0}.{1}()".format(self._init, repo)) exec("{0}.{1}()".format(self._init, repo))
sys.stdout.write(self.done) sys.stdout.write(self.done)
elif repo in self.meta.repositories: elif repo in self.meta.repositories:
Initialization().custom(repo) Initialization(False).custom(repo)
sys.stdout.write(self.done) sys.stdout.write(self.done)
else: else:
sys.stdout.write(self.error) sys.stdout.write(self.error)

View file

@ -28,6 +28,7 @@ import getpass
from messages import Msg from messages import Msg
from desc import PkgDesc from desc import PkgDesc
from config import Config from config import Config
from checks import Updates
from queue import QueuePkgs from queue import QueuePkgs
from repoinfo import RepoInfo from repoinfo import RepoInfo
from repolist import RepoList from repolist import RepoList
@ -131,11 +132,11 @@ class ArgParse(object):
"""Recreate repositories package lists """Recreate repositories package lists
""" """
if len(self.args) == 1 and self.args[0] == "upgrade": if len(self.args) == 1 and self.args[0] == "upgrade":
Initialization().upgrade(only="") Initialization(False).upgrade(only="")
elif (len(self.args) == 2 and self.args[0] == "upgrade" and elif (len(self.args) == 2 and self.args[0] == "upgrade" and
self.args[1].startswith("--only=")): self.args[1].startswith("--only=")):
repos = self.args[1].split("=")[-1].split(",") repos = self.args[1].split("=")[-1].split(",")
Initialization().upgrade(repos) Initialization(False).upgrade(repos)
else: else:
usage("") usage("")
@ -219,6 +220,11 @@ class ArgParse(object):
SBoInstall(sbo_upgrade(skip), flag).start(if_upgrade=True) SBoInstall(sbo_upgrade(skip), flag).start(if_upgrade=True)
else: else:
usage(self.args[1]) usage(self.args[1])
elif len(self.args) == 2 and self.args[0] in options:
if self.args[1] == "ALL":
Updates("").ALL()
else:
Updates(self.args[1]).run()
else: else:
usage("") usage("")

View file

@ -67,7 +67,7 @@ class Patches(object):
self.comp_sum = [] self.comp_sum = []
self.uncomp_sum = [] self.uncomp_sum = []
self.utils = Utils() self.utils = Utils()
Msg().reading() Msg().checking()
if self.version == "stable": if self.version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT",
"patches/")).reading() "patches/")).reading()
@ -150,6 +150,7 @@ class Patches(object):
if not find_package(repo_pkg_name, self.meta.pkg_path): if not find_package(repo_pkg_name, self.meta.pkg_path):
self.count_added += 1 self.count_added += 1
self.count_upg -= 1 self.count_upg -= 1
return self.count_upg
def views(self): def views(self):
""" """