use base "installedtest"; use strict; use testapi; use utils; # This script tests that we can update (and downgrade) flatpaks. We will # use a test repository with a Dummy application. sub run { my $self = shift; $self->root_console(tty => 3); # To downgrade the application, we need to know the number of the commit. # There are different commits for different architectures. my $commit = '8ab3ee91f3467a0cc15449e5bf218bc8c02b803d7fe0cd2afbe0b6d7e52f61d7'; if (get_var('ARCH') eq 'aarch64') { $commit = '2e1b4e7f4e7ce0b08a0d053e287d39ed0ded48e1ee83c04b4edd465897be60ad'; } # We will need Flathub to pull dependencies. # Flathub is not set as a Flatpak remote by default, only when Third Party Repos # are enabled. To make sure, we have it enabled, we will use the following command to # add the Flathub repository. assert_script_run("sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo", timeout => 120); # We will also add the test repository. assert_script_run("flatpak remote-add --if-not-exists flatpaktest https://lruzicka.fedorapeople.org/flatpaktest/flatpaktest.flatpakrepo", timeout => 120); # Install the Dummy application. assert_script_run("http_proxy=http://flatpak-cache01.iad2.fedoraproject.org:3128 flatpak install -y org.flatpak.Dummy", timeout => 600); # Check that the application has been installed assert_script_run("flatpak list | grep org.flatpak.Dummy"); # The application is installed in version 2. Let's check the output. validate_script_output("flatpak run org.flatpak.Dummy", sub { m/Dummy flatpak: version 2/ }); # Now, we will attempt to downgrade the application to force the previous commit assert_script_run("flatpak update -y --commit=$commit org.flatpak.Dummy"); # If that was successful, the output of the application will show version 1. validate_script_output("flatpak run org.flatpak.Dummy", sub { m/Dummy flatpak: version 1/ }); # Now we can update the application again, using the standard command, which will update to the # newest version (version 2) of the application again. assert_script_run("flatpak update -y org.flatpak.Dummy"); # Let's check the application now provides the correct output. validate_script_output("flatpak run org.flatpak.Dummy", sub { m/Dummy flatpak: version 2/ }); # Now, remove the package and test that it is not listed and that it cannot be run. assert_script_run("flatpak remove -y org.flatpak.Dummy"); validate_script_output("flatpak list", sub { $_ !~ m/org\.flatpak\.Dummy/ }); assert_script_run("! flatpak run org.flatpak.Dummy", sub { $_ !~ m/Dummy flatpak: version 2/ }); } sub test_flags { return {fatal => 1}; } 1; # vim: set sw=4 et: