From d042c3c60c0ec9d7e3df070c88f08828eadc5908 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Wed, 1 Jul 2020 17:12:30 -0400 Subject: [PATCH] upgrades: Use codename to pin freedombox from backports Skip writing apt preferences when running sid. Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- actions/upgrades | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/actions/upgrades b/actions/upgrades index c582b563e..5ffcc4af5 100755 --- a/actions/upgrades +++ b/actions/upgrades @@ -26,7 +26,7 @@ BACKPORTS_RELEASE_FILE_URL = \ APT_PREFERENCES = '''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: release a={}-backports Pin-Priority: 500 Explanation: matrix-synapse 0.99.5 introduces room version 4. Older version @@ -243,8 +243,15 @@ def _add_apt_preferences(): # Don't try to remove 50freedombox3.pref as this file is shipped with the # Debian package and is removed using maintainer scripts. - with open(base_path / '50freedombox4.pref', 'w') as file_handle: - file_handle.write(APT_PREFERENCES) + dist = subprocess.check_output(['lsb_release', '--codename', + '--short']).decode().strip() + if dist == 'sid': + print(f'System distribution is {dist}. Skip setting apt preferences ' + 'for backports.') + else: + print('Setting apt preferences for backports.') + with open(base_path / '50freedombox4.pref', 'w') as file_handle: + file_handle.write(APT_PREFERENCES.format(dist)) def subcommand_setup(_):