From 756e3084dc421a2db0cc3e0bb1110b3d3751df8d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 17 Jun 2020 11:30:12 +0200 Subject: [PATCH] [tracking] Simplify updatemanager job - sed all the URI lines with a simple replacement - document policy requirements --- src/modules/tracking/TrackingJobs.cpp | 20 +++++++++----------- src/modules/tracking/tracking.conf | 14 ++++++++++---- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/modules/tracking/TrackingJobs.cpp b/src/modules/tracking/TrackingJobs.cpp index 70e45e2eb..3d8ea27f1 100644 --- a/src/modules/tracking/TrackingJobs.cpp +++ b/src/modules/tracking/TrackingJobs.cpp @@ -134,17 +134,15 @@ TrackingMachineUpdateManagerJob::prettyStatusMessage() const Calamares::JobResult TrackingMachineUpdateManagerJob::exec() { - static const auto script = QStringLiteral( - R"x( -MACHINE_ID=`cat /etc/machine-id` -sed -i "s,URI =.*,URI = http://releases.neon.kde.org/meta-release/${MACHINE_ID}," /etc/update-manager/meta-release -sed -i "s,URI_LTS =.*,URI_LTS = http://releases.neon.kde.org/meta-release-lts/${MACHINE_ID}," /etc/update-manager/meta-release -true -)x" ); - int r = CalamaresUtils::System::instance()->targetEnvCall( "/bin/sh", - QString(), // Working dir - script, - std::chrono::seconds( 1 ) ); + static const auto script = QStringLiteral( "sed -i '/^URI/s,${MACHINE_ID},'`cat /etc/machine-id`',' /etc/update-manager/meta-release || true" ); + + auto res = CalamaresUtils::System::instance()->runCommand( + CalamaresUtils::System::RunLocation::RunInTarget, + QStringList { QStringLiteral( "/bin/sh" ) }, + QString(), // Working dir + script, // standard input + std::chrono::seconds( 1 ) ); + int r = res.first; if ( r == 0 ) { diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf index 8569f0935..88d1e7b59 100644 --- a/src/modules/tracking/tracking.conf +++ b/src/modules/tracking/tracking.conf @@ -34,8 +34,10 @@ # Each area has a key *policy*, which is a Url to be opened when # the user clicks on the corresponding Help button for an explanation # of the details of that particular kind of tracking. If no policy -# is set, the help button is hidden. The example policy links -# go to Calamares' generic user manual. +# is set, that tracking style is disabled. The example policy links +# go to Calamares' generic user manual (which is a terrible idea +# for distro's: you have GDPR obligations under most of these tracking +# styles, so do your homework). # # Each area may have other configuration keys, depending on the # area and how it needs to be configured. @@ -48,8 +50,7 @@ --- # This is the global policy; it is displayed as a link on the page. # If blank or commented out, no link is displayed on the tracking -# page. It is recommended to either provide policy URLs for each -# area, *or* one general link, and not to mix them. +# page. You **must** provide policy links per-area as well. policy: "https://github.com/calamares/calamares/wiki/Use-Guide#installation-tracking" # This is the default level to enable for tracking. If commented out, @@ -79,9 +80,14 @@ install: # needs to be done. There is currently only one valid # style, "updatemanager", which edits two files in the installed # system to enable system-tracking. +# +# Per-style documentation: +# - updatemanager replaces the literal string "${MACHINE_ID}" with the contents of +# /etc/machine-id, in lines starting with "URI" in the file /etc/update-manager/meta-release machine: enabled: false style: updatemanager + policy: "https://github.com/calamares/calamares/wiki/Use-Guide#machine-tracking" # The user area is not yet implemented, and has no specific configuration. user: