Merge ~slyon/network-manager:netplan-migrate-maintscript into network-manager:netplan/lunar-gu

Proposed by Lukas Märdian
Status: Merged
Merged at revision: f9372617a07831a143d32e7f4521499b7c454566
Proposed branch: ~slyon/network-manager:netplan-migrate-maintscript
Merge into: network-manager:netplan/lunar-gu
Diff against target: 35 lines (+27/-0)
1 file modified
debian/network-manager.postinst (+27/-0)
Reviewer Review Type Date Requested Status
Simon Chopin Needs Information
Danilo Egea Gondolfo Pending
Review via email: mp+440401@code.launchpad.net

Description of the change

d/network-manager.postinst: Trigger Netplan migration on install/upgrade

Modify the connection's ID (con-name) to trigger its migration.
The Netplan integration will translate the original NM keyfile from
/etc/NetworkManager/system-connections/* to a YAML file located in
/etc/netplan/90-NM-*.yaml and re-generate a corresponding keyfile in
/run/NetworkManager/system-connections/netplan-NM-*.nmconnection
After successful migration, the original ID (con-name) is restored.

To post a comment you must log in.
Revision history for this message
Simon Chopin (schopin) wrote :

question: What happens to the original keyfile?

If it's not removed, then re-running the script (cf https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html#maintainer-scripts-idempotency ) will overwrite the previous migration's yaml, which might have changed in the mean time.

review: Needs Information
Revision history for this message
Lukas Märdian (slyon) wrote (last edit ):

The original keyfile in /etc/NetworkManager/system-connections/* is being deleted by the Netplan integration automatically during the process, after it got translated into /etc/netplan/90-NM-*.yaml successfully.

I.e. that would be within the first "nmcli con mod ..." call for each connection profile.

Revision history for this message
Dave Jones (waveform) wrote :

Left a couple of comments on the version comparison line which might bear some thought (but I'm unsure if they're actually relevant without additional context).

Revision history for this message
Lukas Märdian (slyon) :
Revision history for this message
Lukas Märdian (slyon) wrote :

Thanks! Answered Dave's inline comment. I think the current implementation matches my intention.

Revision history for this message
Lukas Märdian (slyon) wrote :

Thanks all! We got some extra eyeballs, let's get this merged and deployed to the "Netplan Everywhere PPA (Lunar)" testers.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/network-manager.postinst b/debian/network-manager.postinst
index e2cb049..ba31d6b 100644
--- a/debian/network-manager.postinst
+++ b/debian/network-manager.postinst
@@ -81,3 +81,30 @@ esac
8181
82#DEBHELPER#82#DEBHELPER#
8383
84# Run "Netplan Everywhere" migration after debhelper (re-)started
85# NetworkManager.service for us
86# XXX: Shall we run this migration just on the upgrade to this specific
87# version, or on any upgrade/install?
88#if dpkg --compare-versions "$2" lt "1.42.4-1ubuntu3"; then
89DIR="/etc/NetworkManager/system-connections"
90if [ "$1" = "configure" ] && [ -d "$DIR" ]; then
91 for CON in /etc/NetworkManager/system-connections/*; do
92 TYPE=$(file -b "$CON")
93 [ "$TYPE" = "ASCII text" ] || continue # skip non-keyfiles
94 UUID=$(grep "^uuid=" "$CON" | cut -c 6-)
95 if [ -n "$UUID" ]
96 then
97 ORIG_NAME=$(nmcli --get-values connection.id con show "$UUID")
98 echo "Migrating $ORIG_NAME ($UUID) to /etc/netplan" 1>&2
99 # Modify the connection's ID (con-name) to trigger its migration.
100 # The Netplan integration will translate the original NM keyfile from
101 # /etc/NetworkManager/system-connections/* to a YAML file located in
102 # /etc/netplan/90-NM-*.yaml and re-generate a corresponding keyfile in
103 # /run/NetworkManager/system-connections/netplan-NM-*.nmconnection
104 # After successful migration, the original ID (con-name) is restored.
105 nmcli con mod "$UUID" con-name "$ORIG_NAME".NETPLAN_MIGRATE
106 nmcli con mod "$UUID" con-name "$ORIG_NAME"
107 fi
108 done
109 nmcli con reload
110fi

Subscribers

People subscribed via source and target branches

to all changes: