diff --git a/actions/upgrades b/actions/upgrades index 61bdba698..db808a51f 100755 --- a/actions/upgrades +++ b/actions/upgrades @@ -21,6 +21,7 @@ Configures or runs unattended-upgrades import argparse import os +import pathlib import re import subprocess import sys @@ -170,46 +171,10 @@ def _check_and_backports_sources(): def _add_apt_preferences(): """Setup APT preferences to upgrade selected packages from backports.""" - preferences_path = '/etc/apt/preferences.d' - old_preferences_files = map( - lambda pref_file: os.path.join(preferences_path, pref_file), - ['50freedombox.pref', '50freedombox2.pref']) - - for pref_file in old_preferences_files: - os.path.exists(pref_file) and os.remove(pref_file) - - preferences_file = '/etc/apt/preferences.d/50freedombox3.pref' - if os.path.exists(preferences_file): - print('Preferences up-to-date. Skipping update') - return - - warning = 'Explanation: This file is managed by FreedomBox, do not edit.' - - freedombox_preference = ''' -Explanation: Allow carefully selected updates to 'freedombox' from backports. -Package: freedombox -Pin: release a=buster-backports -Pin-Priority: 500 -''' - - matrix_synapse_preferences = ''' -Explanation: Allow carefully selected updates to 'matrix-synapse' from backports. -Package: matrix-synapse -Pin: version 1.2* -Pin-Priority: 500 - -Explanation: Allow carefully selected updates to 'python3-service-identity' from backports. -Package: python3-service-identity -Pin: version 18.1* -Pin-Priority: 500 -''' - - preferences = "".join( - [warning, freedombox_preference, matrix_synapse_preferences]) - - print('Updating APT preferences.') - with open(preferences_file, 'w') as file_handle: - file_handle.write(preferences) + for file_name in ['50freedombox.pref', '50freedombox2.pref']: + full_path = pathlib.Path('/etc/apt/preferences.d') / file_name + if full_path.exists(): + full_path.unlink() def subcommand_setup_repositories(_): diff --git a/plinth/modules/upgrades/data/etc/apt/preferences.d/50freedombox3.pref b/plinth/modules/upgrades/data/etc/apt/preferences.d/50freedombox3.pref new file mode 100644 index 000000000..b4a19265b --- /dev/null +++ b/plinth/modules/upgrades/data/etc/apt/preferences.d/50freedombox3.pref @@ -0,0 +1,16 @@ +Explanation: This file is managed by FreedomBox, do not edit. +Explanation: Allow carefully selected updates to 'freedombox' from backports. +Package: freedombox +Pin: release a=buster-backports +Pin-Priority: 500 + +Explanation: matrix-synapse 0.99.5 introduces room version 4. Older version +Explanation: 0.99.2 in buster won't be able join newly created rooms. +Package: matrix-synapse +Pin: release a=buster-backports +Pin-Priority: 500 + +Explanation: matrix-synapse >= 1.2 requires python3-service-identity >= 18.1 +Package: python3-service-identity +Pin: release a=buster-backports +Pin-Priority: 500