From 2528795b9db5eb29b84f34a8ec6ce1fbf8e4c181 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Tue, 26 May 2020 14:58:50 +0800 Subject: [PATCH] Make the copying of changelog lines less brittle Stop copying changelog lines when a changelog header containing the exact version is seen. Until now, random other versions that happened to contain the installed version did this. Also, any non-header lines that happened to mention the installed version also did this. This isn't the most correct fix though, the right way to do this would be to reimplement the code using proper changelog parsing from the Python debian module. --- apt_offline_core/AptOfflineCoreLib.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apt_offline_core/AptOfflineCoreLib.py b/apt_offline_core/AptOfflineCoreLib.py index f480e44..1536335 100644 --- a/apt_offline_core/AptOfflineCoreLib.py +++ b/apt_offline_core/AptOfflineCoreLib.py @@ -1135,8 +1135,17 @@ def buildChangelog(self, pkgPath, installedVersion): #Seek to beginning chlogFile.seek(0) + if 'Source' in pkgHandle: + srcname = pkgHandle['Source'] + else: + srcname = pkgHandle.pkgname + if ' ' in srcname: + srcname = srcname.split(' ', 1)[0] + installedVersion_changelog_line = "%s (%s) " % (srcname, installedVersion) + + # FIXME: replace this with parsing the changelog using the Python debian module for eachLine in chlogFile.readlines(): - if installedVersion in eachLine: + if eachLine.startswith(installedVersion_changelog_line): break else: pkgLogFile.writelines(eachLine)