Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #pragma once
23 :
24 : #include "../../../iupdateinstaller.h"
25 :
26 : #include "modularity/ioc.h"
27 : #include "io/ifilesystem.h"
28 : #include "../../../iupdateconfiguration.h"
29 :
30 : namespace muse::update {
31 : //! NOTE: The whole application is a single AppImage file, so an update is
32 : //! nothing more than replacing that file - the downloaded package needs no
33 : //! unpacking. This only applies when we are actually running from an AppImage;
34 : //! distribution packages, Flatpak and Snap manage their own updates and a plain
35 : //! build has no single file to replace, so in-place update is reported as
36 : //! unsupported there and the caller falls back to handing the download to the
37 : //! user.
38 : class LinuxUpdateInstaller : public IUpdateInstaller, public Contextable
39 : {
40 : GlobalInject<io::IFileSystem> fileSystem;
41 : GlobalInject<IUpdateConfiguration> configuration;
42 :
43 : public:
44 0 : LinuxUpdateInstaller(const modularity::ContextPtr& iocCtx)
45 0 : : Contextable(iocCtx) {}
46 :
47 : bool isInPlaceUpdateSupported() const override;
48 : RetVal<muse::io::path_t> prepareUpdate(const muse::io::path_t& packagePath) override;
49 : Ret finalizeUpdate(const muse::io::path_t& preparedPath, const InstallProgressUi& ui) override;
50 :
51 : private:
52 : //! Path to the running AppImage file (the install location to replace), or
53 : //! empty when not running from an AppImage. Symlinks are resolved, so that
54 : //! launching through e.g. `~/.local/bin/mscore` replaces the real file and
55 : //! leaves the symlink pointing at it.
56 : muse::io::path_t currentAppImagePath() const;
57 :
58 : //! Path to the `museupdater` helper bundled next to the application binary.
59 : muse::io::path_t helperPath() const;
60 : };
61 : }
|