[tracking] Simplify updatemanager job

- sed all the URI lines with a simple replacement
- document policy requirements
This commit is contained in:
Adriaan de Groot 2020-06-17 11:30:12 +02:00
parent 9433311f24
commit 756e3084dc
2 changed files with 19 additions and 15 deletions

View File

@ -134,17 +134,15 @@ TrackingMachineUpdateManagerJob::prettyStatusMessage() const
Calamares::JobResult Calamares::JobResult
TrackingMachineUpdateManagerJob::exec() TrackingMachineUpdateManagerJob::exec()
{ {
static const auto script = QStringLiteral( static const auto script = QStringLiteral( "sed -i '/^URI/s,${MACHINE_ID},'`cat /etc/machine-id`',' /etc/update-manager/meta-release || true" );
R"x(
MACHINE_ID=`cat /etc/machine-id` auto res = CalamaresUtils::System::instance()->runCommand(
sed -i "s,URI =.*,URI = http://releases.neon.kde.org/meta-release/${MACHINE_ID}," /etc/update-manager/meta-release CalamaresUtils::System::RunLocation::RunInTarget,
sed -i "s,URI_LTS =.*,URI_LTS = http://releases.neon.kde.org/meta-release-lts/${MACHINE_ID}," /etc/update-manager/meta-release QStringList { QStringLiteral( "/bin/sh" ) },
true
)x" );
int r = CalamaresUtils::System::instance()->targetEnvCall( "/bin/sh",
QString(), // Working dir QString(), // Working dir
script, script, // standard input
std::chrono::seconds( 1 ) ); std::chrono::seconds( 1 ) );
int r = res.first;
if ( r == 0 ) if ( r == 0 )
{ {

View File

@ -34,8 +34,10 @@
# Each area has a key *policy*, which is a Url to be opened when # 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 # the user clicks on the corresponding Help button for an explanation
# of the details of that particular kind of tracking. If no policy # of the details of that particular kind of tracking. If no policy
# is set, the help button is hidden. The example policy links # is set, that tracking style is disabled. The example policy links
# go to Calamares' generic user manual. # 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 # Each area may have other configuration keys, depending on the
# area and how it needs to be configured. # 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. # 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 # If blank or commented out, no link is displayed on the tracking
# page. It is recommended to either provide policy URLs for each # page. You **must** provide policy links per-area as well.
# area, *or* one general link, and not to mix them.
policy: "https://github.com/calamares/calamares/wiki/Use-Guide#installation-tracking" policy: "https://github.com/calamares/calamares/wiki/Use-Guide#installation-tracking"
# This is the default level to enable for tracking. If commented out, # 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 # needs to be done. There is currently only one valid
# style, "updatemanager", which edits two files in the installed # style, "updatemanager", which edits two files in the installed
# system to enable system-tracking. # 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: machine:
enabled: false enabled: false
style: updatemanager 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. # The user area is not yet implemented, and has no specific configuration.
user: user: