How to compare dconf files of two computers and intelligently merge them with `dconf dump` or `gsettings`

I have several computers running MATE desktop and I want to merge their setup (and keep them in sync afterwards). With dconf dump / I can get configuration details, but comparing the output (with meld) is hopeless as the order in which entries are presented is not the same, thus a manual, intelligent merge is not feasible.

Alternatively, I can use gsettings list-recursively which gives a list which can be sorted and then compared, but I do not see how to write back the result (there is no command like dconf load for this file format).

I see possible approaches:

  • sort the output of dconf dump (there should be some utilities, but I could not find any)
  • a gsettings write-many function, as an inverse of gsettings list-recursively)
  • convert gsettings list into the dconf dump format
  • sort the dconf dump list.

What is easiest with existing tools? considering the discussion and here my goal of keeping configurations in sync may not be very easy.

As examples, I include short pieces of the two list formats I currently have:

gsetting produces (extract):

org.gnome.rhythmbox.podcast-source paned-position 180
org.gnome.rhythmbox.podcast-source sorting ('Feed', true)
org.blueman.transfer opp-accept false
org.blueman.transfer shared-path ''
org.mate.Caja.Sendto last-compress 0
org.mate.Caja.Sendto last-medium ''
org.gnome.evolution-data-server.calendar contacts-reminder-interval 15

and dconf dump (different extract):

[apps/light-locker]
idle-hint=false
late-locking=false
lock-after-screensaver=uint32 0
lock-on-lid=false
lock-on-suspend=false

[ca/desrt/dconf-editor]
saved-view='/org/mate/caja/'
window-height=600
window-is-maximized=false
window-width=800
3
задан 21 November 2020 в 12:09

1 ответ

Для на данный момент я нашел простое решение:

Я обнаружил, что дамп, полученный от dconf, меняется лишь незначительно при обновлении. Таким образом, достаточно начать с первоначальной загрузки дампа, а затем постепенно обновлять конфигурацию и создавать новый дамп. Начальный и окончательный дамп можно сравнить с объединением; слияние возможно.

Я использую это с ansible, имея currentTargetDump, скопированный на другие машины и загруженный.В результате все независимые хост-компьютеры будут иметь одинаковую конфигурацию.

Перед загрузкой новой конфигурации я делаю дамп текущей конфигурации. Я могу сравнить текущую конфигурацию с целевой конфигурацией с помощью Meld и объединить изменения в целевую конфигурацию и записать ее обратно, чтобы она служила будущей целевой конфигурацией, которая распространяется на все хосты.

Выглядит просто и пока работает хорошо.

2
ответ дан 22 November 2020 в 14:53

Другие вопросы по тегам:

Похожие вопросы: