upgrades: Fix sources list for dist upgrade from buster

- Check apt sources list regardless of whether we are upgrading to
stable or testing.

- Replace stable code name with new stable code name.

- When testing, also replace "stable" with code name to be tested.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2020-11-28 21:29:14 -08:00
1 parent 4f92e985d3
commit d794b575e1
1 file changed
+14 -9
+14 -9
View File
@@ -358,17 +358,22 @@ def _check_and_dist_upgrade(develop=False, test_upgrade=False):
return
print(f'Upgrading from {dist} to {codename}...')
if check_dist == 'testing':
with open(SOURCES_LIST, 'r') as sources_list:
lines = sources_list.readlines()
with open(SOURCES_LIST, 'r') as sources_list:
lines = sources_list.readlines()
with open(SOURCES_LIST, 'w') as sources_list:
for line in lines:
new_line = line.replace('stable', codename)
if 'security' in new_line:
new_line = new_line.replace('/updates', '-security')
with open(SOURCES_LIST, 'w') as sources_list:
for line in lines:
# E.g. replace 'buster' with 'bullseye'.
new_line = line.replace(dist, codename)
if check_dist == 'testing':
# E.g. replace 'stable' with 'bullseye'.
new_line = new_line.replace('stable', codename)
sources_list.write(new_line)
# Security suite name renamed starting with bullseye
if 'security' in new_line:
new_line = new_line.replace('/updates', '-security')
sources_list.write(new_line)
print('Dist upgrade in progress. Setting flag.')
dist_upgrade_flag.touch(mode=0o660)