Commit c03bba6e authored by pontaoski's avatar pontaoski 🌈
Browse files

kcms/keyboard: handle botched 5.21.0 migration

Since we shipped a botched migration script for 5.21.0, we need to
ship a new migration script that un-botches the effects of the 5.21.0
script. We also change the ID of the plain kcminput_repeat migration so
that we can distinguish between the botched migration and the non-botched
migration, and only reverse migrations applied by the botched migration.

BUG: 431923
FIXED-IN: 5.21.2
(cherry picked from commit b4f3a470)
parent 6273f0ba
......@@ -98,6 +98,10 @@ install(FILES kcminputrc_repeat.upd
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(PROGRAMS kcminputrc_migrate_repeat_value.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(FILES kcminputrc_fix_botched_5_21_0.upd
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
install(PROGRAMS kcminputrc_fix_botched_5_21_0.py
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR})
ecm_qt_declare_logging_category(kcm_keyboard_PART_SRCS
HEADER debug.h
......
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2021 Carson Black <uhhadd@gmail.com>
#
# SPDX-License-Identifier: LGPL-2.0-or-later
#
# 5.21.0 botched the migration by accidentally turning enabled to disabled and disabled to enabled.
# We have two choices here: we can either break key repeat for users that manually intervened
# and enabled key repeat by inverting the value, or we can enable key repeat for users that didn't
# have it enabled and fix users that had their key repeat disabled. Only one of those sentences
# contains the word "break" so we go with the one without the word "break" ;)
# Enabling key repeat for users who disabled it is less breaking than disabling key repeat for
# users who enabled it.
#
# And that brings us to the code.
#
# We'll need to import sys in order to read stdin, which is how we receive
# the old input file to look for it.
#
import sys
#
# After that, we'll need to declare ourselves a variable to hold the contents
# of the config file we read in from stdin.
#
content: str = sys.stdin.read()
#
# That brings us to checking for the presence of the old script's effects on the underlying system:
# kconfig files are annotated with a section containing all of the config scripts that have ran
# on them.
#
# They're of the form filename.upd:migration_name.
#
if "kcminputrc_repeat.upd:kcminputrc_migrate_repeat_value" in content:
#
# Now we check for the presence of a disabled key repeat in the config file contents. For 5.21.0, this
# was changed from a 0-1-2 ternary to an English-language nothing/repeat/accent.
# The config script for migrating ternary to English-language is why we're in this
# mess in the first place. We migrated 0 (enabled) -> nothing and 2 (disabled) -> repeat.
#
if "KeyRepeat=nothing" in content:
#
# Now we print the command instructing the kconfig updater to delete this field.
# A deleted field essentially means "use the default" which in this case means
# "enable key repeat." We delete instead of reassigning to "repeat" because
# we would prefer to have a deleted field act as our "default" value.
#
print("# DELETE [Keyboard]KeyRepeat")
#
# Since we created the Tmp group as a temporary way of conveying to this script what migrations
# were applied to the config file, we want to clean it up, as it serves no other purpose.
#
# We instruct KConfig to delete the Tmp group in the config file.
#
print("# DELETEGROUP Tmp")
#
# Every KConfig .upd file needs this magic header of "Version=5"
#
Version=5
#
# That brings us to our first migration script for this file, kcminputrc_fix_botched_5_21_0_pre.
# We need this pre-script before the actual fix in order to prepare information the main migration
# script uses.
#
Id=kcminputrc_fix_botched_5_21_0_pre
#
# We're operating on kcminputrc, the file we botched with the 5.21.0 upgrade.
#
File=kcminputrc
#
# Since our desired information is in the group called $Version, which KConfig's update process
# tries really hard to hide from the migration script, we need to copy it into another group,
# which KConfig is fine with showing to the migration script.
#
Group=$Version,Tmp
Options=copy
#
# The specific key in $Version that we want to make available is update_info, which contains
# all of the migrations that have ran on kcminputrc. We need this information in order to discern
# whether or not the botched migration was applied to kcminputrc.
#
Key=update_info
#
# After copying the information into the Tmp group, we can run our actual migration script now.
#
Id=kcminputrc_fix_botched_5_21_0
File=kcminputrc
Script=kcminputrc_fix_botched_5_21_0.py
Version=5
Id=kcminputrc_migrate_repeat_value
Id=kcminputrc_migrate_key_repeat
File=kcminputrc
Group=Keyboard
Script=kcminputrc_migrate_repeat_value.py
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment