diff --git a/1011-hwdb-parse_hwdb_dot_py.patch b/1011-hwdb-parse_hwdb_dot_py.patch new file mode 100644 index 0000000000000000000000000000000000000000..f002bb1ee38124ba0b7c8edd94d6b7895bf64b09 --- /dev/null +++ b/1011-hwdb-parse_hwdb_dot_py.patch @@ -0,0 +1,290 @@ +From: rpm-build +Date: Thu, 28 Apr 2022 01:49:39 +0000 +Subject: [PATCH] Update upstream parse_hwdb.py to fix parse-hwdb error + +--- +diff -uNrp systemd-239.orig/hwdb/parse_hwdb.py systemd-239/hwdb/parse_hwdb.py +--- systemd-239.orig/hwdb/parse_hwdb.py 2022-04-28 11:32:08.740731756 +0800 ++++ systemd-239/hwdb/parse_hwdb.py 2022-04-28 11:32:08.741731786 +0800 +@@ -1,6 +1,5 @@ + #!/usr/bin/env python3 +-# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */ +-# SPDX-License-Identifier: MIT ++# SPDX-License-Identifier: MIT + # + # This file is distributed under the MIT license, see below. + # +@@ -30,12 +29,11 @@ import sys + import os + + try: +- from pyparsing import (Word, White, Literal, ParserElement, Regex, +- LineStart, LineEnd, ++ from pyparsing import (Word, White, Literal, ParserElement, Regex, LineEnd, + OneOrMore, Combine, Or, Optional, Suppress, Group, + nums, alphanums, printables, +- stringEnd, pythonStyleComment, QuotedString, +- ParseBaseException) ++ stringEnd, pythonStyleComment, ++ ParseBaseException, __diag__) + except ImportError: + print('pyparsing is not available') + sys.exit(77) +@@ -52,33 +50,61 @@ except ImportError: + # don't do caching on old python + lru_cache = lambda: (lambda f: f) + ++__diag__.warn_multiple_tokens_in_named_alternation = True ++__diag__.warn_ungrouped_named_tokens_in_collection = True ++__diag__.warn_name_set_on_empty_Forward = True ++__diag__.warn_on_multiple_string_args_to_oneof = True ++__diag__.enable_debug_on_named_expressions = True ++ + EOL = LineEnd().suppress() + EMPTYLINE = LineEnd() + COMMENTLINE = pythonStyleComment + EOL + INTEGER = Word(nums) +-STRING = QuotedString('"') + REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER)) + SIGNED_REAL = Combine(Optional(Word('-+')) + REAL) + UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_') + ++# Those patterns are used in type-specific matches + TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'), + 'evdev': ('name', 'atkbd', 'input'), ++ 'fb': ('pci'), + 'id-input': ('modalias'), + 'touchpad': ('i8042', 'rmi', 'bluetooth', 'usb'), + 'joystick': ('i8042', 'rmi', 'bluetooth', 'usb'), + 'keyboard': ('name', ), + 'sensor': ('modalias', ), ++ 'ieee1394-unit-function' : ('node', ), ++ 'camera': ('usb'), + } + ++# Patterns that are used to set general properties on a device ++GENERAL_MATCHES = {'acpi', ++ 'bluetooth', ++ 'usb', ++ 'pci', ++ 'sdio', ++ 'vmbus', ++ 'OUI', ++ 'ieee1394', ++ } ++ ++def upperhex_word(length): ++ return Word(nums + 'ABCDEF', exact=length) ++ + @lru_cache() + def hwdb_grammar(): + ParserElement.setDefaultWhitespaceChars('') + + prefix = Or(category + ':' + Or(conn) + ':' + for category, conn in TYPES.items()) +- matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL ++ ++ matchline_typed = Combine(prefix + Word(printables + ' ' + '®')) ++ matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables + ' ' + '®')) ++ matchline = (matchline_typed | matchline_general) + EOL ++ + propertyline = (White(' ', exact=1).suppress() + +- Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.!-;, "') - Optional(pythonStyleComment)) + ++ Combine(UDEV_TAG - '=' - Optional(Word(alphanums + '_=:@*.!-;, "/')) ++ - Optional(pythonStyleComment)) + + EOL) + propertycomment = White(' ', exact=1) + pythonStyleComment + EOL + +@@ -87,7 +113,7 @@ def hwdb_grammar(): + (EMPTYLINE ^ stringEnd()).suppress()) + commentgroup = OneOrMore(COMMENTLINE).suppress() - EMPTYLINE.suppress() + +- grammar = OneOrMore(group('GROUPS*') ^ commentgroup) + stringEnd() ++ grammar = OneOrMore(Group(group)('GROUPS*') ^ commentgroup) + stringEnd() + + return grammar + +@@ -95,39 +121,57 @@ def hwdb_grammar(): + def property_grammar(): + ParserElement.setDefaultWhitespaceChars(' ') + +- dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*') ++ dpi_setting = Group(Optional('*')('DEFAULT') + INTEGER('DPI') + Optional(Suppress('@') + INTEGER('HZ')))('SETTINGS*') + mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL +- mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') ++ mount_matrix = Group(mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') ++ xkb_setting = Optional(Word(alphanums + '+-/@._')) ++ ++ # Although this set doesn't cover all of characters in database entries, it's enough for test targets. ++ name_literal = Word(printables + ' ') + + props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))), + ('MOUSE_WHEEL_CLICK_ANGLE', INTEGER), + ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER), + ('MOUSE_WHEEL_CLICK_COUNT', INTEGER), + ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER), +- ('ID_INPUT', Literal('1')), +- ('ID_INPUT_ACCELEROMETER', Literal('1')), +- ('ID_INPUT_JOYSTICK', Literal('1')), +- ('ID_INPUT_KEY', Literal('1')), +- ('ID_INPUT_KEYBOARD', Literal('1')), +- ('ID_INPUT_MOUSE', Literal('1')), +- ('ID_INPUT_POINTINGSTICK', Literal('1')), +- ('ID_INPUT_SWITCH', Literal('1')), +- ('ID_INPUT_TABLET', Literal('1')), +- ('ID_INPUT_TABLET_PAD', Literal('1')), +- ('ID_INPUT_TOUCHPAD', Literal('1')), +- ('ID_INPUT_TOUCHSCREEN', Literal('1')), +- ('ID_INPUT_TRACKBALL', Literal('1')), +- ('MOUSE_WHEEL_TILT_HORIZONTAL', Literal('1')), +- ('MOUSE_WHEEL_TILT_VERTICAL', Literal('1')), ++ ('ID_AUTOSUSPEND', Or((Literal('0'), Literal('1')))), ++ ('ID_AV_PRODUCTION_CONTROLLER', Or((Literal('0'), Literal('1')))), ++ ('ID_PERSIST', Or((Literal('0'), Literal('1')))), ++ ('ID_PDA', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_ACCELEROMETER', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_JOYSTICK', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_KEY', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_KEYBOARD', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_MOUSE', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_POINTINGSTICK', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_SWITCH', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TABLET', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TABLET_PAD', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TOUCHPAD', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TOUCHSCREEN', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TRACKBALL', Or((Literal('0'), Literal('1')))), ++ ('ID_SIGNAL_ANALYZER', Or((Literal('0'), Literal('1')))), + ('POINTINGSTICK_SENSITIVITY', INTEGER), + ('POINTINGSTICK_CONST_ACCEL', REAL), + ('ID_INPUT_JOYSTICK_INTEGRATION', Or(('internal', 'external'))), + ('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))), +- ('XKB_FIXED_LAYOUT', STRING), +- ('XKB_FIXED_VARIANT', STRING), ++ ('XKB_FIXED_LAYOUT', xkb_setting), ++ ('XKB_FIXED_VARIANT', xkb_setting), ++ ('XKB_FIXED_MODEL', xkb_setting), + ('KEYBOARD_LED_NUMLOCK', Literal('0')), + ('KEYBOARD_LED_CAPSLOCK', Literal('0')), + ('ACCEL_MOUNT_MATRIX', mount_matrix), ++ ('ACCEL_LOCATION', Or(('display', 'base'))), ++ ('PROXIMITY_NEAR_LEVEL', INTEGER), ++ ('IEEE1394_UNIT_FUNCTION_MIDI', Or((Literal('0'), Literal('1')))), ++ ('IEEE1394_UNIT_FUNCTION_AUDIO', Or((Literal('0'), Literal('1')))), ++ ('IEEE1394_UNIT_FUNCTION_VIDEO', Or((Literal('0'), Literal('1')))), ++ ('ID_VENDOR_FROM_DATABASE', name_literal), ++ ('ID_MODEL_FROM_DATABASE', name_literal), ++ ('ID_TAG_MASTER_OF_SEAT', Literal('1')), ++ ('ID_INFRARED_CAMERA', Or((Literal('0'), Literal('1')))), ++ ('ID_CAMERA_DIRECTION', Or(('front', 'rear'))), + ) + fixed_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE') + for name, val in props] +@@ -165,8 +209,29 @@ def parse(fname): + return [] + return [convert_properties(g) for g in parsed.GROUPS] + +-def check_match_uniqueness(groups): ++def check_matches(groups): + matches = sum((group[0] for group in groups), []) ++ ++ # This is a partial check. The other cases could be also done, but those ++ # two are most commonly wrong. ++ grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4) + Optional(':')) + '*', ++ 'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8) + Optional(':')) + '*', ++ } ++ ++ for match in matches: ++ prefix, rest = match.split(':', maxsplit=1) ++ gr = grammars.get(prefix) ++ if gr: ++ # we check this first to provide an easy error message ++ if rest[-1] not in '*:': ++ error('pattern {} does not end with "*" or ":"', match) ++ ++ try: ++ gr.parseString(rest) ++ except ParseBaseException as e: ++ error('Pattern {!r} is invalid: {}', rest, e) ++ continue ++ + matches.sort() + prev = None + for match in matches: +@@ -196,15 +261,25 @@ def check_one_mount_matrix(prop, value): + def check_one_keycode(prop, value): + if value != '!' and ecodes is not None: + key = 'KEY_' + value.upper() +- if key not in ecodes: +- key = value.upper() +- if key not in ecodes: +- error('Keycode {} unknown', key) ++ if not (key in ecodes or ++ value.upper() in ecodes or ++ # new keys added in kernel 5.5 ++ 'KBD_LCD_MENU' in key): ++ error('Keycode {} unknown', key) ++ ++def check_wheel_clicks(properties): ++ pairs = (('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_COUNT'), ++ ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE'), ++ ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL'), ++ ('MOUSE_WHEEL_CLICK_COUNT', 'MOUSE_WHEEL_CLICK_ANGLE')) ++ for pair in pairs: ++ if pair[0] in properties and pair[1] not in properties: ++ error('{} requires {} to be specified', *pair) + + def check_properties(groups): + grammar = property_grammar() + for matches, props in groups: +- prop_names = set() ++ seen_props = {} + for prop in props: + # print('--', prop) + prop = prop.partition('#')[0].rstrip() +@@ -214,30 +289,35 @@ def check_properties(groups): + error('Failed to parse: {!r}', prop) + continue + # print('{!r}'.format(parsed)) +- if parsed.NAME in prop_names: ++ if parsed.NAME in seen_props: + error('Property {} is duplicated', parsed.NAME) +- prop_names.add(parsed.NAME) ++ seen_props[parsed.NAME] = parsed.VALUE + if parsed.NAME == 'MOUSE_DPI': + check_one_default(prop, parsed.VALUE.SETTINGS) + elif parsed.NAME == 'ACCEL_MOUNT_MATRIX': + check_one_mount_matrix(prop, parsed.VALUE) + elif parsed.NAME.startswith('KEYBOARD_KEY_'): +- check_one_keycode(prop, parsed.VALUE) ++ val = parsed.VALUE if isinstance(parsed.VALUE, str) else parsed.VALUE[0] ++ check_one_keycode(prop, val) ++ ++ check_wheel_clicks(seen_props) + + def print_summary(fname, groups): ++ n_matches = sum(len(matches) for matches, props in groups) ++ n_props = sum(len(props) for matches, props in groups) + print('{}: {} match groups, {} matches, {} properties' +- .format(fname, +- len(groups), +- sum(len(matches) for matches, props in groups), +- sum(len(props) for matches, props in groups))) ++ .format(fname, len(groups), n_matches, n_props)) ++ ++ if n_matches == 0 or n_props == 0: ++ error('{}: no matches or props'.format(fname)) + + if __name__ == '__main__': +- args = sys.argv[1:] or glob.glob(os.path.dirname(sys.argv[0]) + '/[67]0-*.hwdb') ++ args = sys.argv[1:] or sorted(glob.glob(os.path.dirname(sys.argv[0]) + '/[678][0-9]-*.hwdb')) + + for fname in args: + groups = parse(fname) + print_summary(fname, groups) +- check_match_uniqueness(groups) ++ check_matches(groups) + check_properties(groups) + + sys.exit(ERROR) diff --git a/systemd.spec b/systemd.spec index f30f1a58b05cd95b894f9b73b4a7d3e948197d53..947a1601352e7bee236cb2246cedce9bae81c2eb 100644 --- a/systemd.spec +++ b/systemd.spec @@ -752,6 +752,10 @@ Patch1009: 1009-core-add-a-config-item-to-support-setting-the-value-.patch Patch1010: 1010-systemd-anolis-support-loongarch64.patch Patch1011: 1011-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch +# update upstream parse_hwdb.py to fix parse-hwdb fail +# https://github.com/systemd/systemd/blob/f2c36c0e2445fa95ba109017d4b768b2fd825c43/hwdb.d/parse_hwdb.py +Patch1011: 1011-hwdb-parse_hwdb_dot_py.patch + %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 %endif @@ -1379,6 +1383,7 @@ fi %changelog * Tue May 17 2022 Yuanhong Peng - 239-51.5.0.2 - test-catalog: Fix coredump when compiled under GCC10 +- hwdb: update upstream latest parse_hwdb.py to fix parse_hwdb error * Wed Mar 16 2022 Yuanhong Peng - 239-51.5.0.1 - core: fix a null reference case in load_from_path()