Skip to content

Commit c2db4d3

Browse files
committed
Drop duplicate python-apt upgrade code
1 parent 165e3a4 commit c2db4d3

File tree

1 file changed

+2
-40
lines changed

1 file changed

+2
-40
lines changed

apt_offline_core/AptOfflineCoreLib.py

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ def setter(args):
15141514
Bool_SetUpgrade = True
15151515

15161516
class AptManip:
1517-
def __init__(self, OutputFile, Simulate=False, AptType="python-apt"):
1517+
def __init__(self, OutputFile, Simulate=False, AptType="apt"):
15181518

15191519
self.WriteTo = OutputFile
15201520
self.Simulate = Simulate
@@ -1664,8 +1664,6 @@ def __PythonAptUpdate(self):
16641664
writeFH.close()
16651665

16661666
def __PythonAptUpgrade(self, UpgradeType="upgrade", ReleaseType=None):
1667-
# THis doesn't work as expected. In fact, the code fails.
1668-
16691667

16701668
log.verbose("Open file %s for write" % self.WriteTo)
16711669
try:
@@ -1836,38 +1834,7 @@ def __AptInstallSrcPackages(self, SrcPackageList=None, ReleaseType=None, BuildDe
18361834
sys.exit(1)
18371835
#TODO: Use a more Pythonic way for it
18381836
if Str_SetUpgradeType == "upgrade":
1839-
if PythonApt is True:
1840-
#FIXME: Adapt the new python-apt. Ideas from debdelta
1841-
log.verbose("Using the python-apt library to generate the database.\n")
1842-
PythonAptQuery = AptPython()
1843-
try:
1844-
install_file = open( Str_SetArg, 'a' )
1845-
except IOError:
1846-
log.err( "Cannot create file %s.\n" % (Str_SetArg) )
1847-
sys.exit( 1 )
1848-
upgradable = filter( lambda p: p.isUpgradable, PythonAptQuery.cache )
1849-
log.msg( "\nGenerating database of files that are needed for an upgrade.\n" )
1850-
1851-
dup_records = []
1852-
for pkg in upgradable:
1853-
pkg._lookupRecord( True )
1854-
dpkg_params = apt_pkg.ParseSection(pkg._records.Record)
1855-
arch = dpkg_params['Architecture']
1856-
path = dpkg_params['Filename']
1857-
checksum = dpkg_params['SHA256'] #FIXME: There can be multiple checksum types
1858-
size = dpkg_params['Size']
1859-
cand = pkg._depcache.GetCandidateVer( pkg._pkg )
1860-
for ( packagefile, i ) in cand.FileList:
1861-
indexfile = PythonAptQuery.cache._list.FindIndex( packagefile )
1862-
if indexfile:
1863-
uri = indexfile.ArchiveURI( path )
1864-
localFile = uri.split( '/' )[ - 1]
1865-
if checksum.__str__() in dup_records:
1866-
continue
1867-
install_file.write( uri + ' ' + localFile + ' ' + size + ' ' + checksum + "\n" )
1868-
dup_records.append( checksum.__str__() )
1869-
else:
1870-
AptInst.Upgrade("upgrade", ReleaseType=Str_SetInstallRelease)
1837+
AptInst.Upgrade("upgrade", ReleaseType=Str_SetInstallRelease)
18711838
elif Str_SetUpgradeType == "dist-upgrade":
18721839
AptInst.Upgrade("dist-upgrade", ReleaseType=Str_SetInstallRelease)
18731840
elif Str_SetUpgradeType == "dselect-upgrade":
@@ -1896,11 +1863,6 @@ def __AptInstallSrcPackages(self, SrcPackageList=None, ReleaseType=None, BuildDe
18961863
log.err( "This argument is supported only on Unix like systems with apt installed\n" )
18971864
sys.exit( 1 )
18981865

1899-
class AptPython:
1900-
def __init__( self ):
1901-
if PythonApt:
1902-
self.cache = apt.Cache()
1903-
19041866
def main():
19051867
'''Here we basically do the sanity checks, some validations
19061868
and then accordingly call the corresponding functions.

0 commit comments

Comments
 (0)