├── .editorconfig ├── .flake8 ├── .gitignore ├── .reuse └── dep5 ├── COPYING ├── LICENSES ├── CC-BY-SA-4.0.txt ├── CC0-1.0.txt ├── LGPL-2.1-or-later.txt └── MIT.txt ├── README.md ├── debian ├── changelog ├── control ├── copyright ├── docs ├── eos-updater-dev.install ├── eos-updater-tests.install ├── eos-updater-tools.install ├── eos-updater.install ├── eos-updater.postinst ├── gbp.conf ├── gir1.2-eos-updater-0.install ├── libeos-updater-flatpak-installer-0-tests.install ├── libeos-updater-util-0-tests.install ├── rules ├── source │ └── format └── tests │ ├── control │ ├── gnome-desktop-testing │ └── gnome-desktop-testing-root ├── eos-autoupdater ├── docs │ ├── eos-autoupdater.8 │ └── eos-autoupdater.conf.5 ├── eos-autoupdater.conf ├── eos-autoupdater.service.in ├── eos-autoupdater.timer.in ├── main.c └── meson.build ├── eos-update-server ├── docs │ ├── eos-update-server.8 │ └── eos-update-server.conf.5 ├── eos-update-server.c ├── eos-update-server.conf ├── eos-update-server.service.in ├── eos-update-server.socket.in └── meson.build ├── eos-updater-avahi ├── docs │ └── eos-updater-avahi.8 ├── eos-updater-avahi.c ├── eos-updater-avahi.path.in ├── eos-updater-avahi.service.in └── meson.build ├── eos-updater-ctl ├── docs │ └── eos-updater-ctl.8 ├── eos-updater-ctl └── meson.build ├── eos-updater-flatpak-installer ├── docs │ ├── eos-updater-flatpak-autoinstall.d.5 │ └── eos-updater-flatpak-installer.8 ├── eos-updater-autoinstall.schema.json ├── eos-updater-flatpak-installer-fallback.service.in ├── eos-updater-flatpak-installer-fallback.timer.in ├── eos-updater-flatpak-installer.service.in ├── main.c └── meson.build ├── eos-updater-prepare-volume ├── docs │ └── eos-updater-prepare-volume.8 ├── eos-updater-prepare-volume └── meson.build ├── eos-updater-test-checkpoint ├── docs │ └── eos-updater-test-checkpoint.8 ├── main.c └── meson.build ├── eos-updater ├── apply.c ├── apply.h ├── com.endlessm.Updater.conf ├── com.endlessm.Updater.service ├── com.endlessm.Updater.xml ├── data.c ├── data.h ├── docs │ ├── eos-updater.8 │ └── eos-updater.conf.5 ├── eos-updater-autocleanup.service.in ├── eos-updater.conf ├── eos-updater.gresource.xml ├── eos-updater.service.in ├── fetch.c ├── fetch.h ├── finalize-autocleanup.conf.in ├── live-boot.c ├── live-boot.h ├── main.c ├── meson.build ├── object.c ├── object.h ├── poll-common.c ├── poll-common.h ├── poll.c ├── poll.h └── tests │ ├── eos_updater.py │ └── meson.build ├── libeos-update-server ├── config.c ├── config.h ├── libeos-update-server.gresource.xml ├── meson.build ├── repo.c ├── repo.h ├── server.c └── server.h ├── libeos-updater-flatpak-installer ├── determine-flatpak-actions.c ├── installer.h ├── meson.build ├── perform-flatpak-actions.c └── tests │ ├── installer.c │ └── meson.build ├── libeos-updater-util ├── avahi-service-file.c ├── avahi-service-file.h ├── checkpoint-private.h ├── checkpoint.c ├── config-util.c ├── config-util.h ├── flatpak-util.c ├── flatpak-util.h ├── meson.build ├── metrics-private.h ├── ostree-bloom-private.h ├── ostree-bloom.c ├── ostree-util.c ├── ostree-util.h ├── tests │ ├── avahi-service-file.c │ ├── checkpoint.c │ ├── config-test-invalid.conf │ ├── config-test.conf │ ├── config-util.c │ ├── config.gresource.xml │ ├── flatpak-util.c │ ├── meson.build │ └── ostree-util.c ├── types.c ├── types.h ├── util.c └── util.h ├── meson.build ├── meson_options.txt ├── template.test.in ├── test-common ├── convenience.c ├── convenience.h ├── flatpak-spawn.c ├── flatpak-spawn.h ├── gpg.c ├── gpg.h ├── httpd.c ├── httpd.h ├── meson.build ├── misc-utils.c ├── misc-utils.h ├── ostree-spawn.c ├── ostree-spawn.h ├── spawn-utils.c ├── spawn-utils.h ├── utils.c └── utils.h └── tests ├── eos-update-server.py ├── eos-updater-avahi.py ├── gpghome ├── C1EB8F4E.asc ├── keyid ├── pubring.gpg ├── random_seed └── secring.gpg ├── meson.build ├── services ├── meson.build └── org.freedesktop.Flatpak.SystemHelper.service.in ├── taptestrunner.py ├── test-autoupdater.c ├── test-update-broken-delta.c ├── test-update-cleanup-workaround.c ├── test-update-direct.c ├── test-update-from-lan.c ├── test-update-from-main.c ├── test-update-from-volume.c ├── test-update-install-flatpaks.c ├── test-update-missing-deployed-commit.c ├── test-update-refspec-checkpoint.c └── test-update-refspec-endoflife.c /.editorconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: CC0-1.0 3 | root = true 4 | 5 | [*] 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | 10 | [debian/rules] 11 | indent_style = tab 12 | 13 | [meson.build] 14 | indent_size = 2 15 | 16 | [*.py] 17 | indent_size = 4 18 | max_line_length = 88 19 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [flake8] 5 | # The default is 79 characters. Black, a popular auto-formatter, defaults to 88 6 | # based on empirical research. 7 | # https://black.readthedocs.io/en/stable/the_black_code_style.html#line-length 8 | max-line-length = 88 9 | 10 | # Check python scripts without a .py suffix. 11 | filename = 12 | *.py, 13 | ./eos-updater-ctl/eos-updater-ctl, 14 | ./eos-updater-prepare-volume/eos-updater-prepare-volume 15 | 16 | # Ignore vendored scripts. 17 | extend-exclude = 18 | ./tests/taptestrunner.py 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: CC0-1.0 3 | /debian/*.debhelper.log 4 | /debian/*.postrm.debhelper 5 | /debian/*.substvars 6 | /debian/.debhelper/ 7 | /debian/debhelper-build-stamp 8 | /debian/eos-updater-dev/ 9 | /debian/eos-updater-tests/ 10 | /debian/eos-updater-tools/ 11 | /debian/eos-updater/ 12 | /debian/files 13 | /debian/gir1.2-eos-updater-0/ 14 | /debian/libeos-updater-flatpak-installer-0-tests/ 15 | /debian/libeos-updater-util-0-tests/ 16 | /debian/tmp/ 17 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: eos-updater 3 | Upstream-Contact: Philip Withnall 4 | Source: github.com/endlessm/eos-updater 5 | 6 | # These test files are too simple to be copyrightable, but adding 7 | # copyright/licensing headers to them (or beside them in a .license file) may 8 | # affect the tests 9 | Files: 10 | libeos-updater-util/tests/config-test-invalid.conf 11 | libeos-updater-util/tests/config-test.conf 12 | tests/gpghome/C1EB8F4E.asc 13 | tests/gpghome/keyid 14 | tests/gpghome/pubring.gpg 15 | tests/gpghome/random_seed 16 | tests/gpghome/secring.gpg 17 | Copyright: See individual files 18 | License: CC0-1.0 19 | 20 | # Debian packaging is under the same license as the package but the file formats 21 | # don’t easily allow copyright/license data to be added 22 | Files: 23 | debian/** 24 | Copyright: See individual files 25 | License: LGPL-2.1-or-later 26 | 27 | # The JSON Schema format doesn’t easily allow copyright/license data to be added 28 | Files: 29 | eos-updater-flatpak-installer/eos-updater-autoinstall.schema.json 30 | Copyright: Copyright 2017 Endless Mobile, Inc. 31 | License: LGPL-2.1-or-later 32 | 33 | # Putting copyright/licensing information at the top of README.md makes it 34 | # less readable 35 | Files: 36 | README.md 37 | Copyright: Copyright 2013, 2016, 2017, 2020 Endless OS Foundation, LLC 38 | License: LGPL-2.1-or-later -------------------------------------------------------------------------------- /LICENSES/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | eos-updater 2 | =========== 3 | 4 | Overview 5 | -------- 6 | 7 | System component of the OSTree based updater 8 | 9 | This repo contains the automatic update tool eos-autoupdater and the 10 | eos-updater daemon. eos-autoupdater is run by a systemd timer, and once 11 | running, communicates with eos-updater to initiate as much of the update 12 | process as is set to be automatic. Once that part of the process is 13 | complete, it exits. 14 | 15 | The user interface component will also monitor eos-updater's state and 16 | prompt the user once the automatic part of the update has completed. 17 | 18 | Also included in the repository are eos-update-server and eos-updater-avahi, 19 | which coordinate to advertise OSTree updates to computers on the local network. 20 | 21 | For documentation about the updater, see the man pages for each program and 22 | for the various configuration files it uses: 23 | - eos-autoupdater(8) 24 | - eos-update-server(8) 25 | - eos-updater(8) 26 | - eos-updater-avahi(8) 27 | - eos-updater-ctl(8) 28 | - eos-updater-prepare-volume(8) 29 | - eos-autoupdater.conf(5) 30 | - eos-update-server.conf(5) 31 | - eos-updater.conf(5) 32 | 33 | Licensing 34 | --------- 35 | 36 | eos-updater is licensed under the LGPL-2.1+. 37 | 38 | Testing 39 | ------- 40 | 41 | eos-updater comes with a number of unit and integration tests which can be run 42 | using `meson test`; and some installed-only tests which can be run using 43 | `gnome-desktop-testing-runner libeos-updater-util-0 libeos-updater-flatpak-installer-0` and 44 | `sudo gnome-desktop-testing-runner eos-updater-0` in your installation prefix 45 | _after_ installing eos-updater. 46 | 47 | For the post-install tests you need `gnome-desktop-testing-runner` 48 | installed (eg. `sudo apt-get install gnome-desktop-testing`) and 49 | to configure the build like this: 50 | 51 | ``` 52 | meson setup -Dinstalled_tests=true builddir 53 | ``` 54 | 55 | Bug reports 56 | ----------- 57 | 58 | Please file bug reports on https://support.endlessm.com/, and include the 59 | output of `eos-diagnostics --verbose`. 60 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | eos-updater (0-1) UNRELEASED; urgency=low 2 | 3 | * Initial release (Closes: #1144) 4 | 5 | -- John Hiesey Fri, 04 Oct 2013 11:44:06 -0700 6 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: eos-updater 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Philip Withnall 5 | Standards-Version: 3.9.6 6 | Build-Depends: 7 | debhelper-compat (= 13), 8 | dh-python, 9 | eos-metrics-0-dev, 10 | flake8, 11 | flatpak (>= 1.3.3+dev37.20fb7d1-0), 12 | gir1.2-flatpak-1.0, 13 | gir1.2-glib-2.0, 14 | gir1.2-ostree-1.0, 15 | gnupg, 16 | gobject-introspection (>= 1.30.0), 17 | gtk-doc-tools (>= 1.14), 18 | libavahi-client-dev (>= 0.6.31), 19 | libavahi-glib-dev (>= 0.6.31), 20 | libflatpak-dev (>= 0.11.6), 21 | libgirepository1.0-dev (>= 1.30.0), 22 | libglib2.0-dev (>= 2.70.0), 23 | libjson-glib-dev (>= 1.2.6-1endless2), 24 | libmogwai-schedule-client-0-dev, 25 | libnm-dev (>= 1.2.0), 26 | libostree-dev (>= 2019.2), 27 | libsoup-3.0-dev (>= 3.2), 28 | libsystemd-dev, 29 | meson (>= 0.60.0), 30 | ostree (>= 2017.12), 31 | python3-gi, 32 | 33 | Package: eos-updater 34 | Section: misc 35 | Architecture: any 36 | Multi-arch: no 37 | Depends: 38 | gir1.2-glib-2.0, 39 | mogwai-scheduled, 40 | ostree, 41 | python3-gi, 42 | systemd (>= 200), 43 | ${misc:Depends}, 44 | ${shlibs:Depends}, 45 | Description: Updater for Endless OS 46 | This package contains the components for keeping Endless OS up to date. 47 | 48 | Package: eos-updater-dev 49 | Section: libdevel 50 | Architecture: any 51 | Multi-arch: same 52 | Depends: 53 | eos-updater (= ${binary:Version}) 54 | ${misc:Depends} 55 | Description: Updater for Endless OS - development files 56 | This package contains the components for keeping Endless OS up to date. 57 | . 58 | This package contains development headers. 59 | 60 | Package: eos-updater-tests 61 | Section: misc 62 | Architecture: any 63 | Depends: 64 | eos-updater (= ${binary:Version}), 65 | eos-updater-tools (= ${binary:Version}), 66 | flatpak (>= 0.11.6), 67 | gir1.2-glib-2.0, 68 | python3-gi, 69 | ${misc:Depends}, 70 | ${python3:Depends}, 71 | ${shlibs:Depends}, 72 | Description: Updater for Endless OS - tests 73 | This package contains the components for keeping Endless OS up to date. 74 | . 75 | This package contains integration tests for the updater and core tools. 76 | 77 | Package: eos-updater-tools 78 | Section: misc 79 | Architecture: any 80 | Multi-arch: no 81 | Depends: 82 | eos-updater (= ${binary:Version}), 83 | gir1.2-flatpak-1.0, 84 | gir1.2-glib-2.0, 85 | gir1.2-ostree-1.0, 86 | gir1.2-eos-updater-0, 87 | python3-gi, 88 | ${misc:Depends}, 89 | ${python3:Depends}, 90 | ${shlibs:Depends}, 91 | Description: Updater for Endless OS - tools 92 | This package contains the components for keeping Endless OS up to date. 93 | . 94 | This package contains tools for preparing updates for distribution 95 | using USB sticks. 96 | 97 | Package: libeos-updater-flatpak-installer-0-tests 98 | Section: misc 99 | Architecture: any 100 | Depends: 101 | ${misc:Depends}, 102 | ${shlibs:Depends}, 103 | Description: Updater for Endless OS - flatpak installer tests 104 | This package contains the components for keeping Endless OS up to date. 105 | . 106 | This package contains unit tests for the APIs used by the flatpak installer. 107 | 108 | Package: libeos-updater-util-0-tests 109 | Section: misc 110 | Architecture: any 111 | Depends: 112 | ${misc:Depends}, 113 | ${shlibs:Depends}, 114 | Description: Updater for Endless OS - utility tests 115 | This package contains the components for keeping Endless OS up to date. 116 | . 117 | This package contains unit tests for the APIs used by the updater and 118 | other update packaging tools. 119 | 120 | Package: gir1.2-eos-updater-0 121 | Section: introspection 122 | Architecture: any 123 | Multi-arch: same 124 | Depends: 125 | ${gir:Depends}, 126 | ${misc:Depends}, 127 | Description: Updater for Endless OS - introspection bindings 128 | This package contains the components for keeping Endless OS up to date. 129 | . 130 | This package contains a machine-readable API description for both 131 | libeos-updater-util and libeos-updater-flatpak-installer for use by the 132 | updater and other update packaging tools. 133 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /debian/eos-updater-dev.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/libeos-updater-util-0.so 2 | usr/lib/*/libeos-updater-flatpak-installer-0.so 3 | usr/share/gir-1.0/EosUpdaterUtil-0.gir 4 | usr/share/gir-1.0/EosUpdaterFlatpakInstaller-0.gir 5 | usr/share/python-dbusmock/templates/eos_updater.py 6 | -------------------------------------------------------------------------------- /debian/eos-updater-tests.install: -------------------------------------------------------------------------------- 1 | usr/libexec/installed-tests/eos-updater-0 2 | usr/share/installed-tests/eos-updater-0 3 | -------------------------------------------------------------------------------- /debian/eos-updater-tools.install: -------------------------------------------------------------------------------- 1 | usr/bin/eos-updater-ctl 2 | usr/bin/eos-updater-prepare-volume 3 | usr/share/eos-updater/schemas/eos-updater-autoinstall.schema.json 4 | usr/share/man/man8/eos-updater-ctl.8 5 | usr/share/man/man8/eos-updater-prepare-volume.8 6 | -------------------------------------------------------------------------------- /debian/eos-updater.install: -------------------------------------------------------------------------------- 1 | lib/systemd/system/eos-autoupdater.service 2 | lib/systemd/system/eos-autoupdater.timer 3 | lib/systemd/system/eos-updater-avahi.path 4 | lib/systemd/system/eos-updater-avahi.service 5 | lib/systemd/system/eos-updater-autocleanup.service 6 | lib/systemd/system/eos-updater-flatpak-installer.service 7 | lib/systemd/system/eos-updater-flatpak-installer-fallback.service 8 | lib/systemd/system/eos-updater-flatpak-installer-fallback.timer 9 | lib/systemd/system/eos-updater.service 10 | lib/systemd/system/eos-update-server.service 11 | lib/systemd/system/eos-update-server.socket 12 | lib/systemd/system/ostree-finalize-staged.service.d/autocleanup.conf 13 | usr/libexec/eos-updater 14 | usr/libexec/eos-autoupdater 15 | usr/libexec/eos-updater-avahi 16 | usr/libexec/eos-updater-flatpak-installer 17 | usr/libexec/eos-updater-test-checkpoint 18 | usr/libexec/eos-update-server 19 | usr/lib/*/libeos-updater-flatpak-installer-0.so.* 20 | usr/lib/*/libeos-updater-util-0.so.* 21 | usr/share/dbus-1/interfaces/com.endlessm.Updater.xml 22 | usr/share/dbus-1/system.d/com.endlessm.Updater.conf 23 | usr/share/dbus-1/system-services/com.endlessm.Updater.service 24 | usr/share/eos-updater/eos-autoupdater.conf 25 | usr/share/eos-updater/eos-updater.conf 26 | usr/share/eos-updater/eos-update-server.conf 27 | usr/share/man/man5/eos-autoupdater.conf.5 28 | usr/share/man/man5/eos-updater.conf.5 29 | usr/share/man/man5/eos-updater-flatpak-autoinstall.d.5 30 | usr/share/man/man5/eos-update-server.conf.5 31 | usr/share/man/man8/eos-autoupdater.8 32 | usr/share/man/man8/eos-updater.8 33 | usr/share/man/man8/eos-updater-avahi.8 34 | usr/share/man/man8/eos-updater-flatpak-installer.8 35 | usr/share/man/man8/eos-updater-test-checkpoint.8 36 | usr/share/man/man8/eos-update-server.8 -------------------------------------------------------------------------------- /debian/eos-updater.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | #DEBHELPER# 6 | 7 | # Convert from eos-updater.{service,timer} being an alias for 8 | # eos-autoupdater.{service,timer}. eos-updater.timer should now never exist. 9 | grep -qs "ExecStart=.*eos-autoupdater" /etc/systemd/system/eos-updater.service && \ 10 | rm /etc/systemd/system/eos-updater.service 11 | rm -f /etc/systemd/system/eos-updater.timer 12 | -------------------------------------------------------------------------------- /debian/gbp.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | debian-tag = Version_%(version)s 3 | debian-branch = master 4 | 5 | [dch] 6 | ignore-branch = True 7 | -------------------------------------------------------------------------------- /debian/gir1.2-eos-updater-0.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/girepository-1.0/EosUpdaterFlatpakInstaller-0.* 2 | usr/lib/*/girepository-1.0/EosUpdaterUtil-0.* 3 | -------------------------------------------------------------------------------- /debian/libeos-updater-flatpak-installer-0-tests.install: -------------------------------------------------------------------------------- 1 | usr/libexec/installed-tests/libeos-updater-flatpak-installer-0 2 | usr/share/installed-tests/libeos-updater-flatpak-installer-0 3 | -------------------------------------------------------------------------------- /debian/libeos-updater-util-0-tests.install: -------------------------------------------------------------------------------- 1 | usr/libexec/installed-tests/libeos-updater-util-0 2 | usr/share/installed-tests/libeos-updater-util-0 3 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all 13 | 14 | override_dh_auto_configure: 15 | dh_auto_configure \ 16 | -- \ 17 | -Dinstalled_tests=true \ 18 | -Dmetrics=enabled \ 19 | $(NULL) 20 | 21 | override_dh_strip: 22 | dh_strip --dbgsym-migration='eos-updater-dbg (<< 3.0.12)' 23 | 24 | # Don't start the services on install 25 | override_dh_installsystemd: 26 | dh_installsystemd -peos-updater --no-start \ 27 | eos-autoupdater.service \ 28 | eos-update-server.service \ 29 | eos-updater-flatpak-installer.service \ 30 | eos-updater-flatpak-installer-fallback.service \ 31 | $(NULL) 32 | dh_installsystemd -peos-updater \ 33 | eos-autoupdater.timer \ 34 | eos-update-server.socket \ 35 | eos-updater-avahi.path \ 36 | eos-updater-flatpak-installer-fallback.timer \ 37 | $(NULL) 38 | 39 | %: 40 | dh $@ --with gir,python3 41 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/tests/control: -------------------------------------------------------------------------------- 1 | Tests: gnome-desktop-testing 2 | Depends: 3 | gnome-desktop-testing, 4 | libeos-updater-util-0-tests, 5 | 6 | Tests: gnome-desktop-testing-root 7 | Depends: 8 | eos-updater-tests, 9 | gnome-desktop-testing, 10 | Restrictions: needs-root 11 | -------------------------------------------------------------------------------- /debian/tests/gnome-desktop-testing: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Run the eos-updater installed-tests which do not require root privileges. 4 | 5 | # Copyright © 2017 Endless Mobile, Inc. 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2.1 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | set -e 22 | exec 2>&1 23 | 24 | exec gnome-desktop-testing-runner libeos-updater-util-0 libeos-updater-flatpak-installer-0 25 | -------------------------------------------------------------------------------- /debian/tests/gnome-desktop-testing-root: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Run the eos-updater installed-tests which require root privileges. 4 | 5 | # Copyright © 2017 Endless Mobile, Inc. 6 | # 7 | # This library is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU Lesser General Public 9 | # License as published by the Free Software Foundation; either 10 | # version 2.1 of the License, or (at your option) any later version. 11 | # 12 | # This library is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | # Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public 18 | # License along with this library; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | 21 | set -e 22 | exec 2>&1 23 | 24 | exec gnome-desktop-testing-runner eos-updater-0 25 | -------------------------------------------------------------------------------- /eos-autoupdater/docs/eos-autoupdater.8: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-autoupdater. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright © 2017 Endless Mobile, Inc. 4 | .TH man 8 "28 Feb 2017" "1.0" "eos\-autoupdater man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-autoupdater — Endless OS Automatic Updater 9 | .\" 10 | .SH SYNOPSIS 11 | .IX Header "SYNOPSIS" 12 | .\" 13 | \fBeos\-autoupdater [\-\-force\-update] [\-\-from\-volume \fPpath\fB]\fP 14 | .\" 15 | .SH DESCRIPTION 16 | .IX Header "DESCRIPTION" 17 | .\" 18 | \fBeos\-autoupdater\fP is a service which couples with \fBeos\-updater\fP(8) to 19 | automate downloading and applying updates. While \fBeos\-updater\fP(8) provides 20 | the implementation of polling for, fetching, and applying updates; 21 | \fBeos\-autoupdater\fP provides the policy of when to poll, and how many steps 22 | of the process should be done automatically. It controls the D\-Bus API exposed 23 | by \fBeos\-updater\fP(8). 24 | .PP 25 | \fBeos\-autoupdater\fP is designed to be run by \fBsystemd\fP(1) on a timer 26 | (the \fBeos\-autoupdater.timer\fP unit) which is set to poll for updates around 27 | once an hour. \fBeos\-autoupdater\fP should not typically be run manually, but 28 | can be triggered by starting the \fBeos\-autoupdater.service\fP unit. This will 29 | trigger a poll for updates (and it potentially fetches and applies any which 30 | are found). See \fBsystemctl\fP(1). 31 | .PP 32 | To interact with \fBeos\-updater\fP more directly, use the 33 | \fBeos\-updater\-ctl\fP(8) tool. 34 | .PP 35 | Updates are retrieved in several stages; see \fBeos\-updater\fP(8). The 36 | autoupdater controls the transitions between these stages, automatically 37 | advancing as far as it can up to (and including) the stage specified by 38 | \fILastAutomaticStep=\fP in \fBeos\-autoupdater.conf\fP(5), but no further. 39 | The user must manually trigger further stages. 40 | .PP 41 | The \fBeos\-autoupdater.conf\fP(5) configuration file allows several policies 42 | to be specified to control when updates are polled for. Use the 43 | \fB\-\-force\-update\fP option to ignore these policies and unconditionally 44 | poll for an update. 45 | .PP 46 | To apply Endless OS updates from a USB drive which is not configured in 47 | \fBeos\-updater.conf\fP(5), use the \fB\-\-from\-volume\fP option to provide 48 | the USB drive mount path. By default, updates on USB drives will be ignored. 49 | Use \fBeos\-updater\-prepare\-volume\fP(8) to put updates onto a USB drive. 50 | .PP 51 | If the computer has been converted to not use OSTree, automatic updates are 52 | permanently disabled. 53 | .\" 54 | .SH OPTIONS 55 | .IX Header "OPTIONS" 56 | .\" 57 | .IP "\fB\-\-force\-update\fP" 58 | Force the updater to poll for an update (and potentially fetch and apply it), 59 | regardless of the policies configured in \fBeos\-autoupdater.conf\fP(5). 60 | .\" 61 | .IP "\fB\-\-force\-fetch\fP" 62 | Force eos-updater to fetch an update even if the download scheduler would 63 | prevent it. This option is implied by the \fB\-\-force\-update\fP option. 64 | .\" 65 | .IP "\fB\-\-from\-volume=\fP" 66 | Path to a mounted USB drive which contains Endless OS updates prepared using 67 | \fBeos\-updater\-prepare\-volume\fP(8). Force the updater to poll for updates 68 | from the USB drive, and fetch and apply them locally if they are more recent 69 | than the booted operating system. 70 | .IP 71 | If \fB\-\-from\-volume\fP is provided, \fB\-\-force\-update\fP is assumed. 72 | .\" 73 | .SH "ENVIRONMENT" 74 | .IX Header "ENVIRONMENT" 75 | .\" 76 | \fPeos\-autoupdater\fP supports the standard GLib environment variables for 77 | debugging. These variables are \fBnot\fP intended to be used in production: 78 | .\" 79 | .IP \fI$G_MESSAGES_DEBUG\fP 4 80 | .IX Item "$G_MESSAGES_DEBUG" 81 | This variable can contain one or more debug domain names to display debug output 82 | for. The value \fIall\fP will enable all debug output. The default is for no 83 | debug output to be enabled. 84 | .\" 85 | .SH "EXIT STATUS" 86 | .IX Header "EXIT STATUS" 87 | .\" 88 | \fBeos\-autoupdater\fP may return one of several error codes if it encounters 89 | problems. 90 | .\" 91 | .IP "0" 4 92 | .IX Item "0" 93 | No problems occurred. The updater ran successfully, and either polled for 94 | updates, or determined not to based on policies configured in 95 | \fBeos\-autoupdater.conf\fP(5). 96 | .\" 97 | .IP "1" 4 98 | .IX Item "1" 99 | There was a D\-Bus error while running the updater, or the updater entered an 100 | error state after a poll, fetch or apply operation. 101 | .\" 102 | .IP "2" 4 103 | .IX Item "2" 104 | An invalid option was passed to \fBeos\-autoupdater\fP on startup. 105 | .\" 106 | .IP "3" 4 107 | .IX Item "3" 108 | The configuration file for \fBeos\-autoupdater\fP could not be loaded or 109 | parsed. 110 | .\" 111 | .SH "FILES" 112 | .IX Header "FILES" 113 | .\" 114 | .IP \fI/etc/eos\-updater/eos\-autoupdater.conf\fP 4 115 | .IX Item "/etc/eos\-updater/eos\-autoupdater.conf" 116 | .IX Item "/usr/local/share/eos\-updater/eos\-autoupdater.conf" 117 | .IX Item "/usr/share/eos\-updater/eos\-autoupdater.conf" 118 | Configuration file for \fBeos\-autoupdater\fP. Defaults are loaded from 119 | \fI/usr/local/share/eos\-updater/eos\-autoupdater.conf\fP (if present) or 120 | \fI/usr/share/eos\-updater/eos\-autoupdater.conf\fP. See 121 | \fBeos\-autoupdater.conf\fP(5). 122 | .\" 123 | .IP \fI/lib/systemd/system/eos\-autoupdater.timer\fP 4 124 | .IX Item "/lib/systemd/system/eos\-autoupdater.timer" 125 | \fBsystemd\fP(1) timer file which triggers \fBeos\-autoupdater\fP to run 126 | at regular intervals. See \fBsystemd.timer\fP(5). 127 | .\" 128 | .IP \fI/lib/systemd/system/eos\-autoupdater.service\fP 4 129 | .IX Item "/lib/systemd/system/eos\-autoupdater.service" 130 | \fBsystemd\fP(1) service file which specifies the runtime environment for 131 | \fBeos\-autoupdater\fP. See \fBsystemd.service\fP(5). 132 | .\" 133 | .SH "SEE ALSO" 134 | .IX Header "SEE ALSO" 135 | .\" 136 | \fBeos\-autoupdater.conf\fP(5), 137 | \fBeos\-updater\fP(8), 138 | \fBeos\-updater\-ctl\fP(8), 139 | \fBeos\-updater\-prepare\-volume\fP(8) 140 | .\" 141 | .SH BUGS 142 | .IX Header "BUGS" 143 | .\" 144 | Any bugs which are found should be reported on the project website: 145 | .br 146 | \fIhttps://support.endlessm.com/\fP 147 | .\" 148 | .SH AUTHOR 149 | .IX Header "AUTHOR" 150 | .\" 151 | Endless Mobile, Inc. 152 | .\" 153 | .SH COPYRIGHT 154 | .IX Header "COPYRIGHT" 155 | .\" 156 | Copyright © 2017 Endless Mobile, Inc. 157 | -------------------------------------------------------------------------------- /eos-autoupdater/docs/eos-autoupdater.conf.5: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-autoupdater.conf. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright © 2017 Endless Mobile, Inc. 4 | .TH man 5 "28 Feb 2017" "1.0" "eos\-autoupdater.conf man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-autoupdater.conf — Endless OS Automatic Updater Configuration 9 | .\" 10 | .SH SYNOPSIS 11 | .IX Header "SYNOPSIS" 12 | .\" 13 | \fB/etc/eos\-updater/eos\-autoupdater.conf\fP 14 | .br 15 | \fB/usr/local/share/eos\-updater/eos\-autoupdater.conf\fP 16 | .br 17 | \fB/usr/share/eos\-updater/eos\-autoupdater.conf\fP 18 | .\" 19 | .SH DESCRIPTION 20 | .IX Header "DESCRIPTION" 21 | .\" 22 | \fBeos\-autoupdater.conf\fP provides the configuration for 23 | \fBeos\-autoupdater\fP(8). It sets the policies for how often the updater will 24 | check for updates, how far through the update process it goes automatically, 25 | and what network connections to download updates over. 26 | .PP 27 | The configuration file contains a single section, \fI[Automatic Updates]\fP, 28 | whose keys are described below. 29 | .PP 30 | Default values are stored in 31 | \fI/usr/share/eos\-updater/eos\-autoupdater.conf\fP, which must always exist. 32 | To override the configuration, copy it to \fI/usr/local/share/eos\-updater/\fP 33 | or \fI/etc/eos\-updater/\fP. Configuration in \fI/etc\fP overrides that in 34 | \fI/usr\fP. 35 | .PP 36 | This configuration file used to be installed as \fI/etc/eos\-updater.conf\fP. 37 | If that file is present, its values will be overridden by any in 38 | \fI/etc/eos\-updater/eos\-autoupdater.conf\fP, but it will override any 39 | configuration in \fI/usr\fP. 40 | .\" 41 | .SH [Automatic Updates] SECTION OPTIONS 42 | .IX Header "[Automatic Updates] SECTION OPTIONS" 43 | .\" 44 | .IP "\fILastAutomaticStep=\fP" 45 | .IX Item "LastAutomaticStep=" 46 | Identifier for the last stage of the update process which will be run 47 | automatically by \fBeos\-autoupdater\fP(8) — stages after this require manual 48 | triggering by the user. Use \fI0\fP for no automatic progress; \fI1\fP to poll 49 | for updates; \fI2\fP to poll and fetch updates; and \fI3\fP to poll, fetch and 50 | apply updates automatically. 51 | .\" 52 | .IP "\fIIntervalDays=\fP" 53 | .IX Item "IntervalDays=" 54 | Number of days to wait between checks for updates. If \fBeos\-autoupdater\fP(8) 55 | is triggered earlier than this number of days after the most recent successful 56 | update, it will exit. It must be \fI0\fP or greater. An interval of \fI0\fP 57 | days means that checks for updates are not rate limited. 58 | .\" 59 | .IP "\fIRandomizedDelayDays=\fP" 60 | .IX Item "RandomizedDelayDays=" 61 | Maximum number of days to add to the wait between checks for updates. This is a 62 | random interval, uniformly distributed between 0 and the number of days set in 63 | this option. It must be \fI0\fP or greater. An interval of \fI0\fP days means 64 | that the wait is always exactly \fIIntervalDays=\fP long. 65 | .\" 66 | .IP "\fIUserVisibleUpdateDelayDays=\fP" 67 | .IX Item "UserVisibleUpdateDelayDays=" 68 | Number of days to wait until applying a ‘user visible’ update. If 69 | \fBeos\-autoupdater\fP(8) is triggered earlier than this number of days since a 70 | user visible update was seen, it will exit. It must be \fI0\fP or greater. An 71 | interval of \fI0\fP days means that user visible updates will be applied 72 | immediately. If \fBeos\-autoupdater\fP(8) is executed with the 73 | \fB\-\-force\-update\fP option, this setting is ignored. 74 | .\" 75 | .IP "\fIUpdateOnMobile=\fP" 76 | .IX Item "UpdateOnMobile=" 77 | Deprecated. The value of this setting is ignored. 78 | .\" 79 | .SH "SEE ALSO" 80 | .IX Header "SEE ALSO" 81 | .\" 82 | \fBeos\-autoupdater\fP(8), 83 | \fBeos\-updater\fP(8) 84 | .\" 85 | .SH AUTHOR 86 | .IX Header "AUTHOR" 87 | .\" 88 | Endless Mobile, Inc. 89 | .\" 90 | .SH COPYRIGHT 91 | .IX Header "COPYRIGHT" 92 | .\" 93 | Copyright © 2017 Endless Mobile, Inc. 94 | -------------------------------------------------------------------------------- /eos-autoupdater/eos-autoupdater.conf: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # This configuration file contains the default values for all configuration 5 | # keys. To customise it, copy it to /etc/eos-updater/eos-autoupdater.conf 6 | # and edit it. 7 | [Automatic Updates] 8 | 9 | # Last update step to perform automatically before requiring user interaction: 10 | # 0 - none 11 | # 1 - poll for updates 12 | # 2 - fetch updates 13 | # 3 - apply updates 14 | LastAutomaticStep=3 15 | IntervalDays=14 16 | RandomizedDelayDays=0 17 | UserVisibleUpdateDelayDays=14 18 | -------------------------------------------------------------------------------- /eos-autoupdater/eos-autoupdater.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Automatic Updater 6 | Documentation=man:eos-autoupdater(8) 7 | After=network.target 8 | 9 | [Service] 10 | Type=simple 11 | ExecStart=@libexecdir@/eos-autoupdater 12 | 13 | # Sandboxing 14 | # FIXME: Enable more of these options once we have systemd > 229 15 | CapabilityBoundingSet= 16 | Environment=GIO_USE_VFS=local 17 | Environment=GVFS_DISABLE_FUSE=1 18 | Environment=GVFS_REMOTE_VOLUME_MONITOR_IGNORE=1 19 | Environment=GSETTINGS_BACKEND=memory 20 | #MemoryDenyWriteExecute=yes 21 | NoNewPrivileges=yes 22 | PrivateDevices=yes 23 | PrivateNetwork=yes 24 | PrivateTmp=yes 25 | #PrivateUsers=yes 26 | #ProtectControlGroups=yes 27 | ProtectHome=yes 28 | #ProtectKernelModules=yes 29 | #ProtectKernelTunables=yes 30 | #ProtectSystem=strict 31 | ProtectSystem=full 32 | RestrictAddressFamilies=AF_UNIX 33 | #RestrictRealtime=yes 34 | #SystemCallErrorNumber=EPERM 35 | #SystemCallFilter=@basic-io @io-event @ipc @network-io 36 | 37 | [Install] 38 | Also=eos-autoupdater.timer 39 | -------------------------------------------------------------------------------- /eos-autoupdater/eos-autoupdater.timer.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018, 2019 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Automatic Update Timer 6 | Documentation=man:eos-autoupdater(8) 7 | ConditionKernelCommandLine=!endless.live_boot 8 | ConditionKernelCommandLine=ostree 9 | 10 | [Timer] 11 | # After 3 minutes the network connection has likely been set up, but we don't 12 | # have a hard requirement; offline updates need to work too 13 | OnActiveSec=3m 14 | OnUnitInactiveSec=1h 15 | RandomizedDelaySec=30min 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /eos-autoupdater/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | eos_autoupdater_sources = [ 5 | 'main.c', 6 | ] + eos_updater_resources 7 | 8 | eos_autoupdater_deps = [ 9 | gio_dep, 10 | glib_dep, 11 | gobject_dep, 12 | libnm_dep, 13 | libeos_updater_dbus_dep, 14 | libeos_updater_util_dep, 15 | ] 16 | 17 | eos_autoupdater_cppflags = [ 18 | '-DG_LOG_DOMAIN="eos-autoupdater"', 19 | ] 20 | 21 | executable('eos-autoupdater', 22 | eos_autoupdater_sources, 23 | c_args: eos_autoupdater_cppflags, 24 | dependencies: eos_autoupdater_deps, 25 | include_directories: root_inc, 26 | install: true, 27 | install_dir: get_option('libexecdir'), 28 | ) 29 | 30 | # systemd files 31 | config = configuration_data() 32 | config.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir'))) 33 | 34 | configure_file( 35 | input: 'eos-autoupdater.service.in', 36 | output: 'eos-autoupdater.service', 37 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 38 | configuration: config, 39 | ) 40 | configure_file( 41 | input: 'eos-autoupdater.timer.in', 42 | output: 'eos-autoupdater.timer', 43 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 44 | configuration: config, 45 | ) 46 | 47 | # Example configuration 48 | install_data( 49 | files('eos-autoupdater.conf'), 50 | install_dir: sysconfexampledir, 51 | ) 52 | 53 | # Documentation 54 | install_man('docs/eos-autoupdater.conf.5') 55 | install_man('docs/eos-autoupdater.8') 56 | -------------------------------------------------------------------------------- /eos-update-server/docs/eos-update-server.conf.5: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-update-server.conf. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright © 2017 Endless Mobile, Inc. 4 | .TH man 5 "13 Apr 2017" "1.0" "eos\-update\-server.conf man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-update\-server.conf — Endless OS OSTree Server Configuration 9 | .\" 10 | .SH SYNOPSIS 11 | .IX Header "SYNOPSIS" 12 | .\" 13 | \fB/etc/eos\-updater/eos\-update\-server.conf\fP 14 | .br 15 | \fB/usr/local/share/eos\-updater/eos\-update\-server.conf\fP 16 | .br 17 | \fB/usr/share/eos\-updater/eos\-update\-server.conf\fP 18 | .\" 19 | .SH DESCRIPTION 20 | .IX Header "DESCRIPTION" 21 | .\" 22 | \fBeos\-update\-server.conf\fP provides the configuration for 23 | \fBeos\-update\-server\fP(8) and \fBeos\-updater\-avahi\fP(8). It determines 24 | whether the server and its DNS\-SD adverts are enabled to distribute Endless OS 25 | updates to other computers on the local network, and the details of any 26 | additional repositories to serve. 27 | .PP 28 | The configuration file contains a single mandatory section, 29 | \fI[Local Network Updates]\fP, and zero or more optional sections, 30 | \fI[Repository 0–65535]\fP, whose keys are described below. Each 31 | \fI[Repository 0–65535]\fP section describes a repository to serve; if there are no 32 | such sections, the default \fI/ostree/repo\fP repository is served with its 33 | \fIRemoteName=\fP set to the value of the \fB\-\-serve\-remote=\fP option passed 34 | to \fBeos\-update\-server\fP(8). Each section must be numbered uniquely; its 35 | index forms the root of the HTTP paths for requesting content from the 36 | repository. The indexes don’t have to be ordered or contiguous, and up to 65536 37 | repositories are supported (the maximum index is 65535). Index 0 is treated 38 | specially: it indicates a root with no prefix, and is intended to be used for 39 | the ‘main’ repository on a server. 40 | .PP 41 | Default values are stored in 42 | \fI/usr/share/eos\-updater/eos\-update\-server.conf\fP, which must always 43 | exist. To override the configuration, copy it to 44 | \fI/usr/local/share/eos\-updater/\fP or \fI/etc/eos\-updater/\fP. Configuration 45 | in \fI/etc\fP overrides that in \fI/usr\fP. 46 | .\" 47 | .SH [Local Network Updates] SECTION OPTIONS 48 | .IX Header "[Local Network Updates] SECTION OPTIONS" 49 | .\" 50 | .IP "\fIAdvertiseUpdates=\fP" 51 | .IX Item "AdvertiseUpdates=" 52 | Whether to advertise and distribute updates over the local network. This may be 53 | \fItrue\fP or \fIfalse\fP. If \fItrue\fP, \fBeos\-update\-server\fP(8) and 54 | \fBeos\-updater\-avahi\fP(8) are enabled; otherwise, they will both refuse to 55 | advertise or distribute updates. 56 | \" 57 | .SH [Repository 0–65535] SECTION OPTIONS 58 | .IX Header "[Repository 0–65535] SECTION OPTIONS" 59 | .\" 60 | .IP "\fIPath=\fP" 61 | .IX Item "Path=" 62 | Path to the repository on the local file system which is to be served over the 63 | network. 64 | .\" 65 | .IP "\fIRemoteName=\fP" 66 | .IX Item "RemoteName=" 67 | Name of the OSTree remote to mirror as the local repository. If a head ref is 68 | requested which is not in the local repository, it will be resolved using this 69 | remote. If the default repository configuration is used, the value of the 70 | \fB\-\-serve\-remote=\fP option to \fBeos\-update\-server\fP(8) will be used. 71 | .\" 72 | .SH "SEE ALSO" 73 | .IX Header "SEE ALSO" 74 | .\" 75 | \fBeos\-updater\fP(8), 76 | \fBeos\-updater\-avahi\fP(8), 77 | \fBeos\-update\-server\fP(8) 78 | .\" 79 | .SH AUTHOR 80 | .IX Header "AUTHOR" 81 | .\" 82 | Endless Mobile, Inc. 83 | .\" 84 | .SH COPYRIGHT 85 | .IX Header "COPYRIGHT" 86 | .\" 87 | Copyright © 2017 Endless Mobile, Inc. 88 | -------------------------------------------------------------------------------- /eos-update-server/eos-update-server.conf: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # This configuration file contains the default values for all configuration 5 | # keys. To customise it, copy it to /etc/eos-updater/eos-update-server.conf 6 | # and edit it. 7 | [Local Network Updates] 8 | AdvertiseUpdates=false 9 | 10 | # Default repository configuration. Add more [Repository 0–65535] sections to 11 | # advertise more repositories. Uncomment this one to edit its properties. 12 | # [Repository 0] 13 | # Path=/ostree/repo 14 | # RemoteName=eos 15 | -------------------------------------------------------------------------------- /eos-update-server/eos-update-server.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Local Update Server 6 | Documentation=man:eos-update-server(8) 7 | After=network.target 8 | 9 | # Only run when Avahi is advertising the port. 10 | ConditionPathExistsGlob=@sysconfdir@/avahi/services/eos-ostree-updater-*.service 11 | 12 | [Service] 13 | Type=simple 14 | ExecStart=@libexecdir@/eos-update-server 15 | 16 | # Deprioritise the process to reduce UI impact if clients are downloading from 17 | # this machine. Numbers are chosen fairly arbitrarily. 18 | Nice=15 19 | IOSchedulingClass=idle 20 | 21 | # Sandboxing 22 | # FIXME: Enable more of these options once we have systemd > 229 23 | CapabilityBoundingSet=CAP_DAC_READ_SEARCH 24 | Environment=GIO_USE_VFS=local 25 | Environment=GVFS_DISABLE_FUSE=1 26 | Environment=GVFS_REMOTE_VOLUME_MONITOR_IGNORE=1 27 | Environment=GSETTINGS_BACKEND=memory 28 | #MemoryDenyWriteExecute=yes 29 | NoNewPrivileges=yes 30 | PrivateDevices=yes 31 | PrivateNetwork=no 32 | PrivateTmp=yes 33 | #PrivateUsers=yes 34 | #ProtectControlGroups=yes 35 | ProtectHome=yes 36 | #ProtectKernelModules=yes 37 | #ProtectKernelTunables=yes 38 | #ProtectSystem=strict 39 | ProtectSystem=full 40 | RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 41 | #RestrictRealtime=yes 42 | #SystemCallErrorNumber=EPERM 43 | #SystemCallFilter=@basic-io @io-event @ipc @network-io 44 | 45 | [Install] 46 | Also=eos-update-server.socket 47 | -------------------------------------------------------------------------------- /eos-update-server/eos-update-server.socket.in: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Socket for Endless OS Automatic Updater 6 | Documentation=man:eos-update-server(8) 7 | ConditionPathExistsGlob=@sysconfdir@/avahi/services/eos-ostree-updater-*.service 8 | After=eos-updater-avahi.service 9 | 10 | # We want all the default dependencies except Before=sockets.target, otherwise 11 | # we get an ordering loop with eos-updater-avahi.service, basic.target and 12 | # sockets.target. We definitely want to be ordered after 13 | # eos-updater-avahi.service so that our ConditionPathExists is re-evaluated 14 | # each time it’s run. 15 | DefaultDependencies=no 16 | 17 | After=sysinit.target 18 | Requires=sysinit.target 19 | After=-.slice 20 | Requires=-.slice 21 | Before=shutdown.target 22 | Conflicts=shutdown.target 23 | 24 | [Socket] 25 | ListenStream=@server_port@ 26 | 27 | [Install] 28 | WantedBy=sockets.target 29 | -------------------------------------------------------------------------------- /eos-update-server/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | eos_update_server_sources = [ 5 | 'eos-update-server.c', 6 | ] 7 | 8 | eos_update_server_deps = [ 9 | gio_dep, 10 | glib_dep, 11 | gobject_dep, 12 | libsoup_dep, 13 | libsystemd_dep, 14 | ostree_dep, 15 | libeos_update_server_dep, 16 | libeos_updater_util_dep, 17 | ] 18 | 19 | eos_update_server_cppflags = [ 20 | '-DG_LOG_DOMAIN="eos-update-server"', 21 | ] 22 | 23 | executable('eos-update-server', 24 | eos_update_server_sources, 25 | c_args: eos_update_server_cppflags, 26 | dependencies: eos_update_server_deps, 27 | include_directories: root_inc, 28 | install: true, 29 | install_dir: get_option('libexecdir'), 30 | ) 31 | 32 | # systemd files 33 | config = configuration_data() 34 | config.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir'))) 35 | config.set('server_port', get_option('server_port')) 36 | config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir'))) 37 | 38 | configure_file( 39 | input: 'eos-update-server.service.in', 40 | output: 'eos-update-server.service', 41 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 42 | configuration: config, 43 | ) 44 | configure_file( 45 | input: 'eos-update-server.socket.in', 46 | output: 'eos-update-server.socket', 47 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 48 | configuration: config, 49 | ) 50 | 51 | # Example configuration 52 | install_data( 53 | files('eos-update-server.conf'), 54 | install_dir: sysconfexampledir, 55 | ) 56 | 57 | # Documentation 58 | install_man('docs/eos-update-server.conf.5') 59 | install_man('docs/eos-update-server.8') 60 | -------------------------------------------------------------------------------- /eos-updater-avahi/eos-updater-avahi.path.in: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Avahi Advertisement Updater 6 | Documentation=man:eos-updater-avahi(8) 7 | 8 | [Path] 9 | # Deployments 10 | # These are the ref files which indicate which ref the various deployments we 11 | # have are at. They are in the format: 12 | # ostree/$bootversion/$subbootversion/$deployindex 13 | # See generate_deployment_refs() in ostree.git. 14 | # The $bootversion and $subbootversion can both only ever be 0 or 1. The 15 | # deployment index is an unbounded non-negative integer, but since we only 16 | # ever expect two deployments (current booted one, and the previous or next 17 | # one on upgrade), we just list 0 and 1. 18 | PathChanged=/ostree/repo/refs/heads/ostree/0/0/0 19 | PathChanged=/ostree/repo/refs/heads/ostree/0/0/1 20 | PathChanged=/ostree/repo/refs/heads/ostree/0/1/0 21 | PathChanged=/ostree/repo/refs/heads/ostree/0/1/1 22 | PathChanged=/ostree/repo/refs/heads/ostree/1/0/0 23 | PathChanged=/ostree/repo/refs/heads/ostree/1/0/1 24 | PathChanged=/ostree/repo/refs/heads/ostree/1/1/0 25 | PathChanged=/ostree/repo/refs/heads/ostree/1/1/1 26 | 27 | # Configuration files 28 | PathChanged=@sysconfdir@/eos-updater/eos-update-server.conf 29 | PathChanged=@datadir@/eos-updater/eos-update-server.conf 30 | PathChanged=@prefix@/local/share/eos-updater/eos-update-server.conf 31 | 32 | [Install] 33 | WantedBy=paths.target 34 | -------------------------------------------------------------------------------- /eos-updater-avahi/eos-updater-avahi.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Avahi Advertisement Updater 6 | Documentation=man:eos-updater-avahi(8) 7 | Wants=avahi-daemon.service 8 | 9 | # Try to start the update server socket after updating the Avahi service file, 10 | # since eos-update-server.socket has a ConditionPathExists on it. 11 | Wants=eos-update-server.socket 12 | 13 | [Service] 14 | Type=oneshot 15 | RemainAfterExit=no 16 | ExecStart=@libexecdir@/eos-updater-avahi 17 | 18 | # Sandboxing 19 | # FIXME: Enable more of these options once we have systemd > 229 20 | CapabilityBoundingSet= 21 | Environment=GIO_USE_VFS=local 22 | Environment=GVFS_DISABLE_FUSE=1 23 | Environment=GVFS_REMOTE_VOLUME_MONITOR_IGNORE=1 24 | Environment=GSETTINGS_BACKEND=memory 25 | #MemoryDenyWriteExecute=yes 26 | NoNewPrivileges=yes 27 | PrivateDevices=yes 28 | PrivateNetwork=yes 29 | PrivateTmp=yes 30 | #PrivateUsers=yes 31 | #ProtectControlGroups=yes 32 | ProtectHome=yes 33 | #ProtectKernelModules=yes 34 | #ProtectKernelTunables=yes 35 | #ProtectSystem=strict 36 | ProtectSystem=true 37 | #ReadWritePaths=@sysconfdir@/avahi/services/ 38 | #RestrictRealtime=yes 39 | #SystemCallErrorNumber=EPERM 40 | #SystemCallFilter=@basic-io @io-event @ipc 41 | 42 | [Install] 43 | Also=eos-update-server.service eos-updater-avahi.path 44 | WantedBy=multi-user.target 45 | -------------------------------------------------------------------------------- /eos-updater-avahi/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | eos_updater_avahi_sources = [ 5 | 'eos-updater-avahi.c', 6 | ] 7 | 8 | eos_updater_avahi_deps = [ 9 | gio_dep, 10 | glib_dep, 11 | gobject_dep, 12 | ostree_dep, 13 | libeos_update_server_dep, 14 | libeos_updater_util_dep, 15 | ] 16 | 17 | eos_updater_avahi_cppflags = [ 18 | '-DG_LOG_DOMAIN="eos-updater-avahi"', 19 | ] 20 | 21 | executable('eos-updater-avahi', 22 | eos_updater_avahi_sources, 23 | c_args: eos_updater_avahi_cppflags, 24 | dependencies: eos_updater_avahi_deps, 25 | include_directories: root_inc, 26 | install: true, 27 | install_dir: get_option('libexecdir'), 28 | ) 29 | 30 | # systemd files 31 | config = configuration_data() 32 | config.set('datadir', join_paths(get_option('prefix'), get_option('datadir'))) 33 | config.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir'))) 34 | config.set('prefix', get_option('prefix')) 35 | config.set('sysconfdir', join_paths(get_option('prefix'), get_option('sysconfdir'))) 36 | 37 | configure_file( 38 | input: 'eos-updater-avahi.path.in', 39 | output: 'eos-updater-avahi.path', 40 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 41 | configuration: config, 42 | ) 43 | configure_file( 44 | input: 'eos-updater-avahi.service.in', 45 | output: 'eos-updater-avahi.service', 46 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 47 | configuration: config, 48 | ) 49 | 50 | # Documentation 51 | install_man('docs/eos-updater-avahi.8') 52 | -------------------------------------------------------------------------------- /eos-updater-ctl/docs/eos-updater-ctl.8: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-updater-ctl. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright © 2017 Endless Mobile, Inc. 4 | .TH man 8 "28 Feb 2017" "1.0" "eos\-updater\-ctl man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-updater\-ctl — Endless OS Updater Controller 9 | .\" 10 | .SH SYNOPSIS 11 | .IX Header "SYNOPSIS" 12 | .\" 13 | \fBeos\-updater\-ctl [\fPcommand\fB] 14 | .\" 15 | .SH DESCRIPTION 16 | .IX Header "DESCRIPTION" 17 | .\" 18 | \fBeos\-updater\-ctl\fP is a utility to manually control the update process of 19 | \fBeos\-updater\fP(8), triggering it to move through states in the update 20 | sequence. It accepts three main commands: \fBpoll\fP, \fBfetch\fP and 21 | \fBapply\fP. 22 | These correspond with the states described in \fBeos\-updater\fP(8), with each 23 | command triggering a progression to the named state. Normally, the updater is 24 | moved through these states automatically by \fBeos\-autoupdater\fP(8) — 25 | \fBeos\-updater\-ctl\fP allows this to be done manually. Execution of the 26 | command will block on successful progression through the named state unless the 27 | \fB\-\-no\-block\fP option is provided: for example, the \fBfetch\fP command 28 | will wait for an update to be downloaded rather than completing immediately. 29 | .PP 30 | If the \fBupdate\fP command is given, all three states will be moved through 31 | in sequence. 32 | .PP 33 | If the \fBmonitor\fP command is given (or if no command is given), 34 | \fBeos\-updater\-ctl\fP will monitor the state of 35 | \fBeos\-updater\fP(8) until interrupted, printing out its D\-Bus properties 36 | every time they change. If the updater disappears off the system bus, 37 | \fBeos\-updater\-ctl\fP will wait until it reappears and will resume 38 | monitoring. 39 | .PP 40 | The \fBserver\fP command is used to control the configuration of 41 | \fBeos\-update\-server\fP(8). Its \fBenable\fP and \fBdisable\fP subcommands 42 | make the necessary configuration and update changes to enable or disable 43 | advertising and serving updates to computers on the local network. 44 | .\" 45 | .SH COMMANDS 46 | .IX Header "COMMANDS" 47 | .\" 48 | .IP "\fBapply\fP" 49 | Deploy updates which were downloaded in the previous \fBfetch\fP stage, and 50 | ready the computer to boot into an updated OSTree deployment when next rebooted. 51 | This command does not reboot the computer. 52 | .\" 53 | .IP "\fBfetch\fP [\fB\-\-force\fP] [\fB\-\-timeout=\fPSECONDS]" 54 | Download updates which were found in the previous \fBpoll\fP stage. 55 | .IP 56 | If \fB\-\-force\fP is specified, the download will proceed even if on a metered 57 | network connection (when it might otherwise be paused according to the download 58 | schedule; see \fBmogwai\-scheduled\fP(8)). 59 | .IP 60 | If \fB\-\-timeout\fP is specified, the client will wait at most the given 61 | number of seconds to get permission to download from the scheduler. If 62 | permission is not given before the timeout expires, an error will be returned. 63 | A timeout of zero (the default) means to wait indefinitely. 64 | .\" 65 | .IP "\fBmonitor\fP" 66 | Monitor the status of \fBeos\-updater\fP(8), printing its state changes and 67 | D\-Bus name changes. Run until killed. 68 | .\" 69 | .IP "\fBpoll\fP" 70 | Check all configured update sources for available updates. 71 | .\" 72 | .IP "\fBserver\fP [\fBenable\fP|\fBdisable\fP]\fP" 73 | Enable or disable advertising and serving updates to the local network using 74 | \fBeos\-update\-server\fP(8). 75 | .\" 76 | .IP "\fBupdate\fP [\fB\-\-force\fP] [\fB\-\-timeout=\fPSECONDS]" 77 | Run all three update stages in sequence: poll, fetch, apply. 78 | .IP 79 | The \fB\-\-force\fP and \fB\-\-timeout\fP options apply only to the fetch stage 80 | of the update process, and have the same meanings as for the \fBfetch\fP 81 | command. 82 | .\" 83 | .SH OPTIONS 84 | .IX Header "OPTIONS" 85 | .\" 86 | .IP "\fB\-\-no\-block\fP" 87 | Do not wait for the given command to result in a state change in 88 | \fBeos\-updater\fP(8); instead, return immediately. This is understood by the 89 | \fBpoll\fP, \fBfetch\fP and \fBapply\fP commands. 90 | .\" 91 | .IP "\fB\-\-quiet\fP" 92 | Output no informational messages; only errors. 93 | .\" 94 | .SH EXAMPLES 95 | .IX Header "EXAMPLES" 96 | .\" 97 | Example of updating a computer manually using \fBeos\-updater\-ctl\fP: 98 | .PP 99 | .nf 100 | .RS 101 | $ eos\-updater\-ctl update 102 | .RE 103 | .fi 104 | .PP 105 | Example of polling for updates manually: 106 | .PP 107 | .nf 108 | .RS 109 | $ eos\-updater\-ctl poll 110 | .RE 111 | .fi 112 | .\" 113 | .SH "EXIT STATUS" 114 | .IX Header "EXIT STATUS" 115 | .\" 116 | \fBeos\-updater\-ctl\fP may return one of several error codes if it encounters 117 | problems. 118 | .\" 119 | .IP "0" 4 120 | .IX Item "0" 121 | No problems occurred. The specified command was successfully sent to the 122 | updater; or there were no problems in monitoring the updater’s state. 123 | .\" 124 | .IP "1" 4 125 | .IX Item "1" 126 | There was an error while communicating with the updater or the requested 127 | command resulted in an error state in the updater. 128 | .\" 129 | .IP "2" 4 130 | .IX Item "2" 131 | An invalid option was passed to \fBeos\-updater\-ctl\fP on startup. 132 | .\" 133 | .SH "SEE ALSO" 134 | .IX Header "SEE ALSO" 135 | .\" 136 | \fBeos\-autoupdater\fP(8), 137 | \fBeos\-updater\fP(8), 138 | \fBmogwai\-scheduled\fP(8) 139 | .\" 140 | .SH BUGS 141 | .IX Header "BUGS" 142 | .\" 143 | Any bugs which are found should be reported on the project website: 144 | .br 145 | \fIhttps://support.endlessm.com/\fP 146 | .\" 147 | .SH AUTHOR 148 | .IX Header "AUTHOR" 149 | .\" 150 | Endless Mobile, Inc. 151 | .\" 152 | .SH COPYRIGHT 153 | .IX Header "COPYRIGHT" 154 | .\" 155 | Copyright © 2017 Endless Mobile, Inc. 156 | -------------------------------------------------------------------------------- /eos-updater-ctl/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # Python program 5 | install_data('eos-updater-ctl', 6 | install_dir: bindir, 7 | install_mode: 'rwxr-xr-x', 8 | ) 9 | 10 | # lint check 11 | test( 12 | 'flake8', 13 | flake8, 14 | args: [files('eos-updater-ctl')], 15 | suite: 'eos-updater-ctl', 16 | workdir: meson.current_source_dir(), 17 | ) 18 | 19 | # Documentation 20 | install_man('docs/eos-updater-ctl.8') 21 | -------------------------------------------------------------------------------- /eos-updater-flatpak-installer/docs/eos-updater-flatpak-installer.8: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-updater-flatpak-installer. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright © 2017 Endless Mobile, Inc. 4 | .TH man 8 "18 Dec 2020" "1.1" "eos\-updater\-flatpak\-installer man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-updater\-flatpak\-installer — Endless OS Updater Flatpak Installer 9 | .\" 10 | .SH SYNOPSIS 11 | .IX Header "SYNOPSIS" 12 | .\" 13 | \fBeos\-updater\-flatpak\-installer [\-m \fPmode\fB] [\-p] 14 | .PP 15 | \fBeos\-updater\-flatpak\-installer \-\-dry\-run 16 | .\" 17 | .SH DESCRIPTION 18 | .IX Header "DESCRIPTION" 19 | .\" 20 | \fBeos\-updater\-flatpak\-installer\fP installs downloaded flatpaks on Endless OS 21 | updates upon booting into the new OS deployment. It is the part of the system that 22 | ensures that when new flatpaks are installed on OS updates, they are 23 | only made available when rebooting into the new OS deployment and not while 24 | the old OS deployment is still running. 25 | .PP 26 | It is normally run by \fBeos\-updater\-flatpak\-installer.service\fP on the 27 | first boot after an OS upgrade. It is also run periodically during normal 28 | computer use by \fBeos\-updater\-flatpak\-installer\-fallback\fP as a fallback 29 | in case flatpak download or installation during OS upgrade fails. 30 | .PP 31 | .SH OPTIONS 32 | .IX Header "OPTIONS" 33 | .\" 34 | .IP "\fB\-\-dry\-run\fP" 35 | Print the actions that would be taken without this option. The mode used affects 36 | this output. 37 | .\" 38 | .IP "\fB\-m\fP, \fB\-\-mode=\fP" 39 | Which mode to run the flatpak installer in. (Default: \fBperform\fP.) 40 | \". 41 | When set to \fBperform\fP, the installer will examine the list of applications 42 | in the directories specified by \fBeos\-updater\-flatpak\-autoinstall.d\fP(5) 43 | and the counter state in 44 | \fI/var/lib/eos\-application\-tools/flatpak\-autoinstall.progress\fP, then for 45 | each basename, perform only newly updated actions and save the most up to date 46 | serial number for each file in the counter state file. 47 | \". 48 | When set to \fBstamp\fP, \fBeos\-updater\-flatpak\-installer\fP will only save 49 | the updated actions to 50 | \fI/var/lib/eos\-application\-tools/flatpak\-autoinstall.progress\fP. 51 | \". 52 | When set to \fBcheck\fP, the tool will check to see if all actions are applied (e.g., that 53 | applications that should have been installed are installed and every app that 54 | should have been uninstalled is not installed). 55 | .\" 56 | .IP "\fB\-p\fP, \fB\-\-pull\fP" 57 | Pull flatpaks as well as deploying them. By default, flatpaks are 58 | not pulled during this step; it is expected that they will be pulled by 59 | \fBeos\-updater\fP(8) when it fetches and applies system updates. 60 | .\" 61 | .SH "ENVIRONMENT" 62 | .IX Header "ENVIRONMENT" 63 | .\" 64 | \fPeos\-updater\-flatpak\-installer\fP supports the standard GLib environment 65 | variables for debugging. These variables are \fBnot\fP intended to be used in 66 | production: 67 | .\" 68 | .IP \fI$G_MESSAGES_DEBUG\fP 4 69 | .IX Item "$G_MESSAGES_DEBUG" 70 | This variable can contain one or more debug domain names to display debug output 71 | for. The value \fIall\fP will enable all debug output. The default is for no 72 | debug output to be enabled. 73 | .\" 74 | .SH "KERNEL COMMAND LINE" 75 | .IX Header "KERNEL COMMAND LINE" 76 | .\" 77 | If the \fBeos\-updater\-flatpak\-installer.service\fP unit is started when 78 | the kernel command line contains \fBeos\-updater\-disable\fP, then 79 | it will exit immediately. If started manually, it will execute as normal, 80 | regardless of the kernel command line. 81 | .\" 82 | .SH "EXIT STATUS" 83 | .IX Header "EXIT STATUS" 84 | .\" 85 | \fBeos\-updater\-flatpak\-installer\fP may return one of several error codes 86 | if it encounters problems. 87 | .\" 88 | .IP "0" 4 89 | .IX Item "0" 90 | No problems occurred. The check, stamp or perform operation completed 91 | successfully. 92 | .\" 93 | .IP "1" 4 94 | .IX Item "1" 95 | There was an error while loading or manipulating the flatpak installation. 96 | .\" 97 | .IP "2" 4 98 | .IX Item "2" 99 | An invalid option was passed to \fBeos\-updater\-flatpak\-installer\fP on 100 | startup. 101 | .\" 102 | .IP "3" 4 103 | .IX Item "3" 104 | The \fBcheck\fP operation found an inconsistency. Only returned with 105 | \fB\-\-mode=check\fP. 106 | .\" 107 | .IP "4" 4 108 | .IX Item "4" 109 | The \fBperform\fP operation failed to apply one or more actions. Only returned 110 | with \fB\-\-mode=perform\fP. 111 | .\" 112 | .SH "FILES" 113 | .IX Header "FILES" 114 | .\" 115 | .IP \fI/var/lib/eos\-application\-tools/flatpak\-autoinstall.d/*\fP 4 116 | .IX Item "/etc/eos\-application\-tools/flatpak\-autoinstall.d/*" 117 | .IX Item "/var/lib/eos\-applications\-tools/flatpak\-autoinstall.d/*" 118 | .IX Item "/usr/share/eos\-application\-tools/flatpak\-autoinstall.d/*" 119 | Each of the files in this directory contain a list of actions to be applied 120 | by the installer. Files are also loaded from matching subdirectories in 121 | \fI/etc\fP and \fI/usr/share\fP. See 122 | \fBeos\-updater\-flatpak\-autoinstall.d\fP(5). 123 | .\" 124 | .IP \fI/var/lib/eos\-application\-tools/flatpak\-autoinstall.progress\fP 4 125 | .IX Item "/etc/eos\-application\-tools/flatpak\-autoinstall.progress" 126 | Local state file storing the serial numbers of the latest applied actions for 127 | each basename in the \fIautoinstall.d\fP directories. 128 | .\" 129 | .SH "SEE ALSO" 130 | .IX Header "SEE ALSO" 131 | .\" 132 | \fBeos\-updater.service\fP(8), 133 | \fBeos\-updater\fP(8), 134 | \fBeos\-updater\-flatpak\-autoinstall.d\fP(5), 135 | \fBflatpak\fP(1) 136 | .\" 137 | .SH BUGS 138 | .IX Header "BUGS" 139 | .\" 140 | Any bugs which are found should be reported on the project website: 141 | .br 142 | \fIhttps://support.endlessm.com/\fP 143 | .\" 144 | .SH AUTHOR 145 | .IX Header "AUTHOR" 146 | .\" 147 | Endless Mobile, Inc. 148 | .\" 149 | .SH COPYRIGHT 150 | .IX Header "COPYRIGHT" 151 | .\" 152 | Copyright © 2017 Endless Mobile, Inc. 153 | -------------------------------------------------------------------------------- /eos-updater-flatpak-installer/eos-updater-flatpak-installer-fallback.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2020, 2021 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Fallback Flatpak Installer 6 | Documentation=man:eos-updater-flatpak-installer(8) 7 | # /home is a symlink to /var/home; /var/home is a symlink to /sysroot/home. The 8 | # second symlink is created by systemd-tmpfiles. Since we use ProtectHome=yes, 9 | # we must explicitly order this unit after tmpfiles are created. 10 | Requires=local-fs.target systemd-tmpfiles-setup.service 11 | After=local-fs.target systemd-tmpfiles-setup.service 12 | ConditionKernelCommandLine=!eos-updater-disable 13 | DefaultDependencies=no 14 | Conflicts=shutdown.target 15 | 16 | # Unlike eos-updater-flatpak-installer.service, this service can run outside 17 | # of the normal update process. 18 | 19 | [Service] 20 | Type=oneshot 21 | ExecStart=@libexecdir@/eos-updater-flatpak-installer --pull --mode=perform 22 | Restart=no 23 | 24 | # Flatpak checks parental controls at deploy time. In order to do this, it 25 | # needs to talk to accountsservice on the system bus, neither of which are 26 | # running when this job runs. 27 | Environment=FLATPAK_SKIP_PARENTAL_CONTROLS_NO_SYSTEM_BUS=1 28 | 29 | # Sandboxing 30 | # flatpak triggers use bwrap which requires net/sys admin and chroot 31 | CapabilityBoundingSet=CAP_NET_ADMIN CAP_SYS_ADMIN CAP_SYS_CHROOT 32 | Environment=GIO_USE_VFS=local 33 | Environment=GVFS_DISABLE_FUSE=1 34 | Environment=GVFS_REMOTE_VOLUME_MONITOR_IGNORE=1 35 | Environment=GSETTINGS_BACKEND=memory 36 | MemoryDenyWriteExecute=yes 37 | NoNewPrivileges=yes 38 | PrivateDevices=yes 39 | # This differs from eos-updater-flatpak-installer.service, as the fallback needs to be able to --pull 40 | PrivateNetwork=no 41 | PrivateTmp=yes 42 | PrivateUsers=yes 43 | ProtectControlGroups=yes 44 | ProtectHome=yes 45 | ProtectKernelModules=yes 46 | # bwrap also mounts /proc 47 | ProtectKernelTunables=no 48 | ProtectSystem=no 49 | # This differs from eos-updater-flatpak-installer.service, as the fallback needs to be able to --pull 50 | RestrictAddressFamilies= 51 | RestrictRealtime=yes 52 | SystemCallArchitectures=native 53 | SystemCallErrorNumber=EPERM 54 | # @network-io is required for logging to the journal to work 55 | # @privileged and @chown are required for certain ostree operations 56 | # @mount is required for bwrap 57 | SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @obsolete @raw-io @resources 58 | 59 | [Install] 60 | Also=eos-updater-flatpak-installer-fallback.timer 61 | WantedBy=multi-user.target 62 | -------------------------------------------------------------------------------- /eos-updater-flatpak-installer/eos-updater-flatpak-installer-fallback.timer.in: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Fallback Flatpak Installer Timer 6 | Documentation=man:eos-updater-flatpak-installer(8) 7 | ConditionKernelCommandLine=!endless.live_boot 8 | ConditionKernelCommandLine=!eos-updater-disable 9 | 10 | [Timer] 11 | # After 5 minutes the network connection has likely been set up, but we don't 12 | # have a hard requirement 13 | OnActiveSec=5m 14 | OnUnitInactiveSec=1day 15 | RandomizedDelaySec=30min 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /eos-updater-flatpak-installer/eos-updater-flatpak-installer.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2017, 2018, 2019 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Post-Boot Flatpak Installer 6 | Documentation=man:eos-updater-flatpak-installer(8) 7 | # /home is a symlink to /var/home; /var/home is a symlink to /sysroot/home. The 8 | # second symlink is created by systemd-tmpfiles. Since we use ProtectHome=yes, 9 | # we must explicitly order this unit after tmpfiles are created. 10 | Requires=local-fs.target systemd-tmpfiles-setup.service 11 | After=local-fs.target systemd-tmpfiles-setup.service 12 | ConditionKernelCommandLine=!eos-updater-disable 13 | DefaultDependencies=no 14 | Conflicts=shutdown.target 15 | 16 | # Only on updates 17 | Before=multi-user.target systemd-update-done.service 18 | ConditionNeedsUpdate=/var 19 | 20 | [Service] 21 | Type=oneshot 22 | RemainAfterExit=true 23 | ExecStart=@libexecdir@/eos-updater-flatpak-installer 24 | Restart=no 25 | 26 | # Flatpak checks parental controls at deploy time. In order to do this, it 27 | # needs to talk to accountsservice on the system bus, neither of which are 28 | # running when this job runs. 29 | Environment=FLATPAK_SKIP_PARENTAL_CONTROLS_NO_SYSTEM_BUS=1 30 | 31 | # Sandboxing 32 | # flatpak triggers use bwrap which requires net/sys admin and chroot 33 | CapabilityBoundingSet=CAP_NET_ADMIN CAP_SYS_ADMIN CAP_SYS_CHROOT 34 | Environment=GIO_USE_VFS=local 35 | Environment=GVFS_DISABLE_FUSE=1 36 | Environment=GVFS_REMOTE_VOLUME_MONITOR_IGNORE=1 37 | Environment=GSETTINGS_BACKEND=memory 38 | MemoryDenyWriteExecute=yes 39 | NoNewPrivileges=yes 40 | PrivateDevices=yes 41 | PrivateNetwork=yes 42 | PrivateTmp=yes 43 | PrivateUsers=yes 44 | ProtectControlGroups=yes 45 | ProtectHome=yes 46 | ProtectKernelModules=yes 47 | # bwrap also mounts /proc 48 | ProtectKernelTunables=no 49 | ProtectSystem=no 50 | RestrictAddressFamilies=AF_NETLINK AF_UNIX 51 | RestrictRealtime=yes 52 | SystemCallArchitectures=native 53 | SystemCallErrorNumber=EPERM 54 | # @network-io is required for logging to the journal to work 55 | # @privileged and @chown are required for certain ostree operations 56 | # @mount is required for bwrap 57 | SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @obsolete @raw-io @resources 58 | 59 | [Install] 60 | WantedBy=multi-user.target 61 | -------------------------------------------------------------------------------- /eos-updater-flatpak-installer/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | eos_update_flatpak_installer_sources = [ 5 | 'main.c', 6 | ] 7 | 8 | eos_update_flatpak_installer_deps = [ 9 | flatpak_dep, 10 | gio_dep, 11 | glib_dep, 12 | gobject_dep, 13 | json_glib_dep, 14 | ostree_dep, 15 | libeos_updater_flatpak_installer_dep, 16 | libeos_updater_util_dep, 17 | eosmetrics_dep, 18 | ] 19 | 20 | eos_update_flatpak_installer_cppflags = [ 21 | '-DG_LOG_DOMAIN="eos-updater-flatpak-installer"', 22 | ] 23 | 24 | 25 | executable('eos-updater-flatpak-installer', 26 | eos_update_flatpak_installer_sources, 27 | c_args: eos_update_flatpak_installer_cppflags, 28 | dependencies: eos_update_flatpak_installer_deps, 29 | include_directories: root_inc, 30 | install: true, 31 | install_dir: get_option('libexecdir'), 32 | ) 33 | 34 | # systemd files 35 | config = configuration_data() 36 | config.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir'))) 37 | 38 | configure_file( 39 | input: 'eos-updater-flatpak-installer.service.in', 40 | output: 'eos-updater-flatpak-installer.service', 41 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 42 | configuration: config, 43 | ) 44 | 45 | configure_file( 46 | input: 'eos-updater-flatpak-installer-fallback.service.in', 47 | output: 'eos-updater-flatpak-installer-fallback.service', 48 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 49 | configuration: config, 50 | ) 51 | 52 | configure_file( 53 | input: 'eos-updater-flatpak-installer-fallback.timer.in', 54 | output: 'eos-updater-flatpak-installer-fallback.timer', 55 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 56 | configuration: config, 57 | ) 58 | 59 | # JSON Schema file 60 | install_data( 61 | files('eos-updater-autoinstall.schema.json'), 62 | install_dir: join_paths(get_option('prefix'), get_option('datadir'), 'eos-updater', 'schemas'), 63 | ) 64 | 65 | # Documentation 66 | install_man('docs/eos-updater-flatpak-autoinstall.d.5') 67 | install_man('docs/eos-updater-flatpak-installer.8') 68 | -------------------------------------------------------------------------------- /eos-updater-prepare-volume/docs/eos-updater-prepare-volume.8: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-updater-prepare-volume. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright © 2017 Endless Mobile, Inc. 4 | .TH man 8 "03 Oct 2017" "1.0" "eos\-updater\-prepare\-volume man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-updater\-prepare\-volume — Endless OS Updater USB Drive Preparation Tool 9 | .\" 10 | .SH SYNOPSIS 11 | .IX Header "SYNOPSIS" 12 | .\" 13 | \fBeos\-updater\-prepare\-volume [\-q] \fPvolume-directory\fB [\fPflatpak\-ref\fB …] 14 | .\" 15 | .SH DESCRIPTION 16 | .IX Header "DESCRIPTION" 17 | .\" 18 | \fBeos\-updater\-prepare\-volume\fP is a utility to prepare a USB drive with a 19 | copy of the computer’s Endless OS updates and flatpak apps, so those apps and 20 | updates can be applied to another computer running Endless OS, bringing it up 21 | to date. 22 | .PP 23 | It will always include a copy of the Endless OS. Any flatpak applications that 24 | have been configured to autoinstall upon update will also be included 25 | unconditionally (see \fBeos\-updater-flatpak-installer\fP(8)). Additionally, 26 | any apps listed on the command line will be included. Each app must be 27 | specified as a flatpak ref, followed by the flatpak ref of the next app, etc. 28 | .PP 29 | The updates will be put in an OSTree repository in the \fB.ostree/repo\fP 30 | directory on the USB drive. The path of the mounted drive must be passed as the 31 | first argument to the program. Other files on the drive will not be affected. 32 | .PP 33 | The runtimes needed for the flatpak apps will be put on the USB drive as well. 34 | No additional locales or other extensions will be added unless explicitly 35 | listed. 36 | .PP 37 | \fBeos\-updater\-prepare\-volume\fP is designed to be run manually by system 38 | administrators as a tool for updating computers which otherwise cannot be 39 | updated. It is not intended to be used for routine updates of computers. 40 | .PP 41 | If the computer has been converted to not use OSTree, its OS updates cannot be 42 | copied onto a USB drive using this tool. 43 | .\" 44 | .SH OPTIONS 45 | .IX Header "OPTIONS" 46 | .\" 47 | .IP "\fB\-\-preserve\-permissions\fP" 48 | Don't make \fBvolume-directory\fP world readable (by other user IDs) so it can 49 | be used on another computer even if it uses a filesystem like ext4 that 50 | preserves Linux permissions. You generally don't want to use this option. 51 | .\" 52 | .IP "\fB\-q\fP, \fB\-\-quiet\fP" 53 | Do not print informational output. 54 | .\" 55 | .SH EXAMPLES 56 | .IX Header "EXAMPLES" 57 | .\" 58 | Example of updating \fIold\-machine\fP from \fInew\-machine\fP: 59 | .PP 60 | .nf 61 | .RS 62 | new\-machine$ # List available apps 63 | new\-machine$ flatpak list \-\-app 64 | new\-machine$ sudo eos\-updater\-prepare\-volume /run/media/user/some\-volume \\ 65 | .br 66 | app/com.endlessm.photos/x86_64/master 67 | .RE 68 | .fi 69 | .PP 70 | On \fIold\-machine\fP, the updates can be applied automatically by running the 71 | following after inserting the USB drive: 72 | .PP 73 | .nf 74 | .RS 75 | old\-machine$ eos\-autoupdater \-\-from\-volume /run/media/user/some\-volume 76 | .RE 77 | .fi 78 | .PP 79 | Alternatively, to do things manually, copy \fIeos\-updater.conf\fP from 80 | \fI/usr/share/eos\-updater/\fP to \fI/etc/eos\-updater/\fP on 81 | \fIold\-machine\fP, and edit it to look like: 82 | .PP 83 | .nf 84 | .RS 85 | [Download] 86 | Order=volume;main; # add the ‘volume’ source 87 | .RE 88 | .fi 89 | .PP 90 | Then run the following commands: 91 | .PP 92 | .nf 93 | .RS 94 | old\-machine$ eos\-updater\-ctl update 95 | .RE 96 | .fi 97 | .PP 98 | Finally, reboot \fIold\-machine\fP to finish applying the updates. Remove the 99 | USB drive before or after rebooting. 100 | .\" 101 | .SH "ENVIRONMENT" 102 | .IX Header "ENVIRONMENT" 103 | .\" 104 | \fPeos\-updater\-prepare\-volume\fP supports the standard GLib environment 105 | variables for debugging. These variables are \fBnot\fP intended to be used in 106 | production: 107 | .\" 108 | .IP \fI$G_MESSAGES_DEBUG\fP 4 109 | .IX Item "$G_MESSAGES_DEBUG" 110 | This variable can contain one or more debug domain names to display debug output 111 | for. The value \fIall\fP will enable all debug output. The default is for no 112 | debug output to be enabled. 113 | .\" 114 | .SH "EXIT STATUS" 115 | .IX Header "EXIT STATUS" 116 | .\" 117 | \fBeos\-updater\-prepare\-volume\fP may return one of several error codes if it 118 | encounters problems. 119 | .\" 120 | .IP "0" 4 121 | .IX Item "0" 122 | No problems occurred. The repository was successfully created on the USB drive. 123 | .\" 124 | .IP "1" 4 125 | .IX Item "1" 126 | There was an error while creating the repository. 127 | .\" 128 | .IP "2" 4 129 | .IX Item "2" 130 | An invalid option was passed to \fBeos\-updater\-prepare\-volume\fP on startup. 131 | .\" 132 | .IP "3" 4 133 | .IX Item "3" 134 | \fBeos\-updater\-prepare\-volume\fP was not run as root. 135 | .\" 136 | .SH "SEE ALSO" 137 | .IX Header "SEE ALSO" 138 | .\" 139 | \fBeos\-autoupdater\fP(8), 140 | \fBeos\-updater\fP(8), 141 | \fBeos\-updater.conf\fP(5), 142 | .\" 143 | .SH BUGS 144 | .IX Header "BUGS" 145 | .\" 146 | Any bugs which are found should be reported on the project website: 147 | .br 148 | \fIhttps://support.endlessm.com/\fP 149 | .\" 150 | .SH AUTHOR 151 | .IX Header "AUTHOR" 152 | .\" 153 | Endless Mobile, Inc. 154 | .\" 155 | .SH COPYRIGHT 156 | .IX Header "COPYRIGHT" 157 | .\" 158 | Copyright © 2017 Endless Mobile, Inc. 159 | -------------------------------------------------------------------------------- /eos-updater-prepare-volume/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # Python program 5 | install_data('eos-updater-prepare-volume', 6 | install_dir: bindir, 7 | install_mode: 'rwxr-xr-x', 8 | ) 9 | 10 | # lint check 11 | test( 12 | 'flake8', 13 | flake8, 14 | args: [files('eos-updater-prepare-volume')], 15 | suite: 'eos-updater-prepare-volume', 16 | workdir: meson.current_source_dir(), 17 | ) 18 | 19 | # Documentation 20 | install_man('docs/eos-updater-prepare-volume.8') 21 | -------------------------------------------------------------------------------- /eos-updater-test-checkpoint/docs/eos-updater-test-checkpoint.8: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-updater-checkpoint-test. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright 2024 Endless OS Foundation LLC 4 | .TH man 8 "19 Mar 2024" "1.0" "eos\-updater\-test\-checkpoint man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-updater\-test\-checkpoint — test Endless OS Updater checkpoint checks 9 | .\" 10 | .SH SYNOPSIS 11 | .B eos\-updater\-test\-checkpoint 12 | \fI\,SOURCE_REF\/\fR \fI\,TARGET_REF\/\fR 13 | .SH DESCRIPTION 14 | .IX Header "DESCRIPTION" 15 | .\" 16 | Tests whether \fBeos\-updater\fP(8) would allow the current system to follow a 17 | checkpoint on SOURCE_REF and upgrade to its TARGET_REF, or whether it would 18 | block the upgrade. Typically systems are prevented from crossing a checkpoint 19 | if their hardware configuration is no longer supported on the new OS branch. 20 | .PP 21 | This tool is primarily for use during development of Endless OS. 22 | .\" 23 | .SH "EXIT STATUS" 24 | .IX Header "EXIT STATUS" 25 | .\" 26 | .B eos\-updater\-test\-checkpoint 27 | may return one of several error codes if it encounters 28 | problems. 29 | .\" 30 | .IP "0" 4 31 | .IX Item "0" 32 | No problems occurred. 33 | .\" 34 | .IP "1" 4 35 | .IX Item "1" 36 | Some problem occurred, such as the system not being an OSTree system. 37 | .\" 38 | .IP "2" 4 39 | .IX Item "2" 40 | Invalid options were passed to \fBeos\-updater\-test\-checkpoint\fP. 41 | .\" 42 | .SH "SEE ALSO" 43 | .IX Header "SEE ALSO" 44 | .\" 45 | \fBeos\-updater\fP(8), 46 | .\" 47 | .SH AUTHOR 48 | .IX Header "AUTHOR" 49 | .\" 50 | Endless OS Foundation LLC 51 | .\" 52 | .SH COPYRIGHT 53 | .IX Header "COPYRIGHT" 54 | .\" 55 | Copyright 2024 Endless OS Foundation LLC 56 | -------------------------------------------------------------------------------- /eos-updater-test-checkpoint/main.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2024 Endless OS Foundation LLC 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this library; if not, see . 17 | * 18 | * SPDX-License-Identifier: LGPL-2.1-or-later 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | /* main() exit codes. */ 26 | enum 27 | { 28 | EXIT_OK = EXIT_SUCCESS, 29 | EXIT_FAILED = 1, 30 | EXIT_INVALID_ARGUMENTS = 2, 31 | }; 32 | 33 | 34 | gint 35 | main (gint argc, 36 | gchar *argv[]) 37 | { 38 | g_autoptr(GError) error = NULL; 39 | g_autoptr(GOptionContext) context = NULL; 40 | GOptionEntry entries[] = { 41 | { 0 } 42 | }; 43 | const char *source_ref, *target_ref; 44 | g_autoptr(OstreeSysroot) sysroot = NULL; 45 | 46 | setlocale (LC_ALL, ""); 47 | 48 | context = g_option_context_new ("SOURCE_REF TARGET_REF"); 49 | g_option_context_add_main_entries (context, entries, NULL); 50 | g_option_context_set_summary (context, 51 | "Checks whether crossing a checkpoint between " 52 | "SOURCE_REF and TARGET_REF would be permitted " 53 | "or blocked."); 54 | 55 | if (!g_option_context_parse (context, &argc, &argv, &error)) 56 | { 57 | g_printerr ("Error parsing command line arguments: %s\n", error->message); 58 | return EXIT_INVALID_ARGUMENTS; 59 | } 60 | 61 | switch (argc) 62 | { 63 | case 1: 64 | g_printerr ("SOURCE_REF and TARGET_REF are required\n"); 65 | return EXIT_INVALID_ARGUMENTS; 66 | case 2: 67 | g_printerr ("TARGET_REF is required\n"); 68 | return EXIT_INVALID_ARGUMENTS; 69 | case 3: 70 | source_ref = argv[1]; 71 | target_ref = argv[2]; 72 | break; 73 | default: 74 | g_printerr ("Too many arguments\n"); 75 | return EXIT_INVALID_ARGUMENTS; 76 | } 77 | 78 | sysroot = ostree_sysroot_new_default (); 79 | if (!ostree_sysroot_load (sysroot, NULL, &error)) 80 | { 81 | g_printerr ("Couldn't open sysroot (not an ostree system?): %s\n", 82 | error->message); 83 | return EXIT_FAILED; 84 | } 85 | 86 | if (euu_should_follow_checkpoint (sysroot, source_ref, target_ref, &error)) 87 | { 88 | g_message ("This system would upgrade from %s to %s", 89 | source_ref, 90 | target_ref); 91 | return EXIT_OK; 92 | } 93 | else if (error->domain == EUU_CHECKPOINT_BLOCK) 94 | { 95 | g_message ("This system would not upgrade from %s to %s due to %s: %s", 96 | source_ref, 97 | target_ref, 98 | euu_checkpoint_block_to_string ((EuuCheckpointBlock) error->code), 99 | error->message); 100 | return EXIT_OK; 101 | } 102 | else 103 | { 104 | g_printerr ("%s\n", error->message); 105 | return EXIT_FAILED; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /eos-updater-test-checkpoint/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | eos_updater_test_checkpoint_sources = [ 5 | 'main.c' 6 | ] 7 | 8 | eos_updater_test_checkpoint_deps = [ 9 | ostree_dep, 10 | libeos_updater_util_dep, 11 | ] 12 | 13 | executable('eos-updater-test-checkpoint', 14 | eos_updater_test_checkpoint_sources, 15 | c_args: [ 16 | '-DG_LOG_DOMAIN="eos-updater-test-checkpoint"' 17 | ], 18 | dependencies: eos_updater_test_checkpoint_deps, 19 | include_directories: root_inc, 20 | install: true, 21 | install_dir: get_option('libexecdir'), 22 | ) 23 | 24 | install_man('docs/eos-updater-test-checkpoint.8') 25 | -------------------------------------------------------------------------------- /eos-updater/apply.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Vivek Dasmohapatra 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | gboolean handle_apply (EosUpdater *updater, 33 | GDBusMethodInvocation *call, 34 | gpointer user_data); 35 | 36 | G_END_DECLS 37 | -------------------------------------------------------------------------------- /eos-updater/com.endlessm.Updater.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /eos-updater/com.endlessm.Updater.service: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [D-BUS Service] 5 | Name=com.endlessm.Updater 6 | Exec=/usr/bin/eos-updater 7 | User=root 8 | SystemdService=eos-updater.service 9 | -------------------------------------------------------------------------------- /eos-updater/data.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | void 30 | eos_updater_data_init (EosUpdaterData *data, 31 | OstreeRepo *repo) 32 | { 33 | g_return_if_fail (data != NULL); 34 | g_return_if_fail (OSTREE_IS_REPO (repo)); 35 | 36 | memset (data, 0, sizeof *data); 37 | data->repo = g_object_ref (repo); 38 | data->cancellable = g_cancellable_new (); 39 | } 40 | 41 | void 42 | eos_updater_data_clear (EosUpdaterData *data) 43 | { 44 | g_return_if_fail (data != NULL); 45 | 46 | g_clear_pointer (&data->results, ostree_repo_finder_result_freev); 47 | g_clear_pointer (&data->overridden_urls, g_strfreev); 48 | g_clear_object (&data->repo); 49 | g_clear_object (&data->cancellable); 50 | } 51 | 52 | void 53 | eos_updater_data_reset_cancellable (EosUpdaterData *data) 54 | { 55 | /* from the documentation, using g_cancellable_reset is not recommended, so, 56 | * if the cancellable is canceled, we just unref the object and create a 57 | * new one */ 58 | if (!g_cancellable_is_cancelled (data->cancellable)) 59 | return; 60 | 61 | g_object_unref (data->cancellable); 62 | data->cancellable = g_cancellable_new (); 63 | } 64 | -------------------------------------------------------------------------------- /eos-updater/data.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | typedef struct EosUpdaterData EosUpdaterData; 32 | 33 | struct EosUpdaterData 34 | { 35 | OstreeRepo *repo; 36 | 37 | /* fields below are meant to be shared between some update stages; 38 | * when adding a new one, document it. 39 | */ 40 | 41 | /* overridden_urls field is filled with some of the results of the 42 | * polling stage and it is used during fetch stage to select a 43 | * server to download the data from. 44 | */ 45 | gchar **overridden_urls; 46 | 47 | /* The results from ostree_repo_find_remotes_async(), which contain different 48 | * possible sources of the given refs. If LAN/USB OstreeRepoFinders were 49 | * configured at the poll stage, and any updates were found in them, this 50 | * array contains only results from those sources. Otherwise it contains 51 | * results from the Internet. 52 | * This needs to be passed from poll() to fetch(). 53 | * May be NULL if using the fallback code in poll(). */ 54 | OstreeRepoFinderResult **results; 55 | 56 | /* This is TRUE if the results array above only contains offline (LAN/USB) 57 | * sources for refs, which implies that the fetch can be done without 58 | * consulting the update scheduler. */ 59 | gboolean offline_results_only; 60 | 61 | /* The object to pass to the tasks performed by the updater, in order to be 62 | * able to cancel them. Upon cancellation (which is done by the Cancel() 63 | * method), the object is renewed (unreffed + replaced by a new instance). */ 64 | GCancellable *cancellable; 65 | }; 66 | 67 | #define EOS_UPDATER_DATA_CLEARED { NULL, NULL, NULL, FALSE, NULL } 68 | 69 | void eos_updater_data_init (EosUpdaterData *data, 70 | OstreeRepo *repo); 71 | 72 | void eos_updater_data_clear (EosUpdaterData *data); 73 | 74 | void eos_updater_data_reset_cancellable (EosUpdaterData *data); 75 | 76 | G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (EosUpdaterData, eos_updater_data_clear) 77 | 78 | G_END_DECLS 79 | -------------------------------------------------------------------------------- /eos-updater/docs/eos-updater.conf.5: -------------------------------------------------------------------------------- 1 | .\" Manpage for eos-updater.conf. 2 | .\" SPDX-License-Identifier: CC-BY-SA-4.0 3 | .\" SPDX-FileCopyrightText: Copyright © 2017 Endless Mobile, Inc. 4 | .TH man 5 "28 Feb 2017" "1.0" "eos\-updater.conf man page" 5 | .\" 6 | .SH NAME 7 | .IX Header "NAME" 8 | eos\-updater.conf — Endless OS Updater Configuration 9 | .\" 10 | .SH SYNOPSIS 11 | .IX Header "SYNOPSIS" 12 | .\" 13 | \fB/etc/eos\-updater/eos\-updater.conf\fP 14 | .br 15 | \fB/usr/local/share/eos\-updater/eos\-updater.conf\fP 16 | .br 17 | \fB/usr/share/eos\-updater/eos\-updater.conf\fP 18 | .\" 19 | .SH DESCRIPTION 20 | .IX Header "DESCRIPTION" 21 | .\" 22 | \fBeos\-updater.conf\fP provides the configuration for \fBeos\-updater\fP(8). 23 | It determines which sources the updater should check for updates from, and 24 | provides the necessary configuration for sources which need it. 25 | .PP 26 | The configuration file contains a single mandatory section, \fI[Download]\fP, 27 | whose keys are described below. 28 | .PP 29 | Default values are stored in \fI/usr/share/eos\-updater/eos\-updater.conf\fP, 30 | which must always exist. To override the configuration, copy it to 31 | \fI/usr/local/share/eos\-updater/\fP or \fI/etc/eos\-updater/\fP. Configuration 32 | in \fI/etc\fP overrides that in \fI/usr\fP. 33 | .\" 34 | .SH [Download] SECTION OPTIONS 35 | .IX Header "[Download] SECTION OPTIONS" 36 | .\" 37 | .IP "\fIOrder=\fP" 38 | .IX Item "Order=" 39 | A semicolon\-separated list of sources to check for updates, with the most 40 | important listed first. The available sources are \fImain\fP, \fIlan\fP and 41 | \fIvolume\fP; corresponding to updates from the Endless Mobile servers on the 42 | internet, updates from other computers on the local network (see 43 | \fBeos\-update\-server\fP(8)) and updates from a connected USB drive (see 44 | \fBeos\-updater\-prepare\-volume\fP(8)). 45 | .\" 46 | .SH "SEE ALSO" 47 | .IX Header "SEE ALSO" 48 | .\" 49 | \fBeos\-autoupdater\fP(8), 50 | \fBeos\-updater\fP(8) 51 | .\" 52 | .SH AUTHOR 53 | .IX Header "AUTHOR" 54 | .\" 55 | Endless Mobile, Inc. 56 | .\" 57 | .SH COPYRIGHT 58 | .IX Header "COPYRIGHT" 59 | .\" 60 | Copyright © 2017 Endless Mobile, Inc. 61 | -------------------------------------------------------------------------------- /eos-updater/eos-updater-autocleanup.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Automatically cleanup after staged Endless OS Updater deployment 6 | Documentation=man:ostree-admin-cleanup(1) man:eos-updater(8) 7 | 8 | # Run ostree admin cleanup only if /sysroot/.cleanup is present and then 9 | # delete it when cleanup is successful. 10 | # 11 | # FIXME: Drop this when https://github.com/ostreedev/ostree/issues/2510 12 | # is resolved. 13 | ConditionPathExists=/sysroot/.cleanup 14 | 15 | # We want this to be triggered by multi-user.target but not block it via 16 | # the default After added to target units since pruning the repo can be 17 | # slow. See the Default Dependencies sections in systemd.service(5) and 18 | # systemd.target(5). 19 | DefaultDependencies=no 20 | Requires=sysinit.target 21 | After=sysinit.target basic.target 22 | Conflicts=shutdown.target 23 | Before=shutdown.target 24 | 25 | [Service] 26 | Type=oneshot 27 | RemainAfterExit=yes 28 | ExecStart=@ostree@ admin cleanup 29 | ExecStart=/bin/rm -f /sysroot/.cleanup 30 | 31 | # Only /sysroot and /boot need to be written to. 32 | ProtectSystem=strict 33 | ReadWritePaths=/sysroot /boot 34 | 35 | # This will be allowed to run in the background, so try to make it less 36 | # disruptive while it prunes the repo. 37 | IOSchedulingClass=idle 38 | 39 | [Install] 40 | WantedBy=multi-user.target 41 | -------------------------------------------------------------------------------- /eos-updater/eos-updater.conf: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # This configuration file contains the default values for all configuration 5 | # keys. To customise it, copy it to /etc/eos-updater/eos-updater.conf 6 | # and edit it. 7 | [Download] 8 | Order=volume;main; 9 | OverrideUris= 10 | -------------------------------------------------------------------------------- /eos-updater/eos-updater.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | ../eos-autoupdater/eos-autoupdater.conf 7 | ../eos-updater/eos-updater.conf 8 | 9 | 10 | -------------------------------------------------------------------------------- /eos-updater/eos-updater.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Unit] 5 | Description=Endless OS Updater 6 | Documentation=man:eos-updater(8) 7 | After=network.target 8 | 9 | [Service] 10 | ExecStart=@libexecdir@/eos-updater 11 | Type=dbus 12 | BusName=com.endlessm.Updater 13 | IOSchedulingClass=idle 14 | 15 | # Sandboxing 16 | # FIXME: Enable more of these options once we have systemd > 229 17 | #CapabilityBoundingSet=(some list of capabilities) 18 | Environment=GIO_USE_VFS=local 19 | Environment=GVFS_DISABLE_FUSE=1 20 | Environment=GVFS_REMOTE_VOLUME_MONITOR_IGNORE=1 21 | Environment=GSETTINGS_BACKEND=memory 22 | #MemoryDenyWriteExecute=yes 23 | NoNewPrivileges=yes 24 | PrivateDevices=yes 25 | PrivateNetwork=no 26 | PrivateTmp=yes 27 | #PrivateUsers=yes 28 | #ProtectControlGroups=yes 29 | ProtectHome=yes 30 | #ProtectKernelModules=yes 31 | #ProtectKernelTunables=yes 32 | #ProtectSystem=strict 33 | ProtectSystem=no 34 | RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK 35 | #RestrictRealtime=yes 36 | #SystemCallErrorNumber=EPERM 37 | #SystemCallFilter=@basic-io @io-event @ipc @network-io 38 | -------------------------------------------------------------------------------- /eos-updater/fetch.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Vivek Dasmohapatra 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | gboolean handle_fetch (EosUpdater *updater, 33 | GDBusMethodInvocation *call, 34 | gpointer user_data); 35 | gboolean handle_fetch_full (EosUpdater *updater, 36 | GDBusMethodInvocation *call, 37 | GVariant *options, 38 | gpointer user_data); 39 | 40 | G_END_DECLS 41 | -------------------------------------------------------------------------------- /eos-updater/finalize-autocleanup.conf.in: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # This is a drop-in file for ostree-finalize-staged.service. 5 | # 6 | # FIXME: Drop this when https://github.com/ostreedev/ostree/issues/2510 7 | # is resolved. 8 | 9 | [Service] 10 | # After finalizing the staged deployment, touch the .cleanup file so 11 | # that the cleanup can be completed on the next boot. 12 | ExecStop=-/bin/touch /sysroot/.cleanup 13 | -------------------------------------------------------------------------------- /eos-updater/live-boot.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Endless Mobile 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Will Thompson 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #define LIVE_BOOT_MESSAGE "Updater disabled on live systems" 29 | 30 | gboolean 31 | is_installed_system (GError **error_out) 32 | { 33 | const gchar *force = g_getenv ("EU_FORCE_LIVE_BOOT"); 34 | GError *error = NULL; 35 | g_autofree gchar *cmdline = NULL; 36 | 37 | if (!g_file_get_contents ("/proc/cmdline", &cmdline, NULL, &error)) 38 | { 39 | g_printerr ("unable to read /proc/cmdline: %s\n", error->message); 40 | g_error_free (error); 41 | return TRUE; 42 | } 43 | 44 | if (g_regex_match_simple ("\\bendless\\.live_boot\\b", cmdline, 0, 0) || 45 | (force != NULL && *force != '\0')) 46 | { 47 | g_set_error_literal (error_out, 48 | EOS_UPDATER_ERROR, EOS_UPDATER_ERROR_LIVE_BOOT, 49 | LIVE_BOOT_MESSAGE); 50 | return FALSE; 51 | } 52 | 53 | return TRUE; 54 | } 55 | 56 | /* Note: We cannot rely on the value of @user_data, since this callback is used 57 | * for various signals with differing numbers of parameters. We can only rely 58 | * on @updater and @call. */ 59 | gboolean 60 | handle_on_live_boot (EosUpdater *updater, 61 | GDBusMethodInvocation *call, 62 | gpointer user_data) 63 | { 64 | g_dbus_method_invocation_return_error_literal (call, 65 | EOS_UPDATER_ERROR, EOS_UPDATER_ERROR_LIVE_BOOT, LIVE_BOOT_MESSAGE); 66 | return TRUE; 67 | } 68 | -------------------------------------------------------------------------------- /eos-updater/live-boot.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Endless Mobile 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Will Thompson 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | G_BEGIN_DECLS 32 | 33 | gboolean is_installed_system (GError **error); 34 | gboolean handle_on_live_boot (EosUpdater *updater, 35 | GDBusMethodInvocation *call, 36 | gpointer user_data); 37 | 38 | G_END_DECLS 39 | -------------------------------------------------------------------------------- /eos-updater/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020, 2022 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # D-Bus helper library 5 | libeos_updater_dbus_codegen_sources = gnome.gdbus_codegen( 6 | 'dbus', 7 | sources: 'com.endlessm.Updater.xml', 8 | interface_prefix: 'com.endlessm.', 9 | namespace: 'Eos', 10 | object_manager: true, 11 | autocleanup: 'all', 12 | ) 13 | 14 | libeos_updater_dbus_sources = [ 15 | 'object.c', 16 | ] 17 | libeos_updater_dbus_headers = [ 18 | 'object.h', 19 | ] 20 | 21 | libeos_updater_dbus_cppflags = [ 22 | '-DG_LOG_DOMAIN="eos-updater-dbus"', 23 | ] 24 | 25 | libeos_updater_dbus_deps = [ 26 | avahi_client_dep, 27 | avahi_glib_dep, 28 | eosmetrics_dep, 29 | flatpak_dep, 30 | gio_dep, 31 | gio_unix_dep, 32 | glib_dep, 33 | gobject_dep, 34 | mogwai_dep, 35 | ostree_dep, 36 | libeos_updater_util_dep, 37 | ] 38 | 39 | libeos_updater_dbus = static_library('eos-updater-dbus', 40 | libeos_updater_dbus_sources + libeos_updater_dbus_headers + libeos_updater_dbus_codegen_sources, 41 | c_args: libeos_updater_dbus_cppflags, 42 | dependencies: libeos_updater_dbus_deps, 43 | include_directories: root_inc, 44 | install: false, 45 | ) 46 | libeos_updater_dbus_dep = declare_dependency( 47 | link_with: libeos_updater_dbus, 48 | include_directories: root_inc, 49 | sources: libeos_updater_dbus_headers + [libeos_updater_dbus_codegen_sources[1]], 50 | ) 51 | 52 | # eos-updater daemon 53 | eu_api_version = '0' 54 | 55 | eos_updater_resources = gnome.compile_resources( 56 | 'resources', 57 | 'eos-updater.gresource.xml', 58 | c_name: 'eos_updater_resources', 59 | ) 60 | 61 | eos_updater_sources = [ 62 | 'apply.c', 63 | 'apply.h', 64 | 'data.c', 65 | 'data.h', 66 | 'fetch.c', 67 | 'fetch.h', 68 | 'live-boot.c', 69 | 'live-boot.h', 70 | 'main.c', 71 | 'poll.c', 72 | 'poll.h', 73 | 'poll-common.c', 74 | 'poll-common.h', 75 | ] + eos_updater_resources 76 | 77 | eos_updater_deps = libeos_updater_dbus_deps + [libeos_updater_dbus_dep] 78 | 79 | eos_updater_cppflags = [ 80 | '-DG_LOG_DOMAIN="eos-updater"', 81 | ] 82 | 83 | executable('eos-updater', 84 | eos_updater_sources, 85 | c_args: eos_updater_cppflags, 86 | dependencies: eos_updater_deps, 87 | include_directories: root_inc, 88 | install: true, 89 | install_dir: get_option('libexecdir'), 90 | ) 91 | 92 | # D-Bus files 93 | install_data( 94 | files('com.endlessm.Updater.conf'), 95 | install_dir: dbusconfdir, 96 | ) 97 | install_data( 98 | files('com.endlessm.Updater.service'), 99 | install_dir: dbussystemservicedir, 100 | ) 101 | install_data( 102 | files('com.endlessm.Updater.xml'), 103 | install_dir: dbusinterfacesdir, 104 | ) 105 | 106 | # systemd files 107 | config = configuration_data() 108 | config.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir'))) 109 | config.set('ostree', find_program('ostree').full_path()) 110 | 111 | configure_file( 112 | input: 'eos-updater.service.in', 113 | output: 'eos-updater.service', 114 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 115 | configuration: config, 116 | ) 117 | 118 | configure_file( 119 | input: 'eos-updater-autocleanup.service.in', 120 | output: 'eos-updater-autocleanup.service', 121 | install_dir: systemd_dep.get_variable('systemdsystemunitdir'), 122 | configuration: config, 123 | ) 124 | 125 | configure_file( 126 | input: 'finalize-autocleanup.conf.in', 127 | output: 'autocleanup.conf', 128 | install_dir: join_paths(systemd_dep.get_variable('systemdsystemunitdir'), 'ostree-finalize-staged.service.d'), 129 | configuration: config, 130 | ) 131 | 132 | # Example configuration 133 | install_data( 134 | files('eos-updater.conf'), 135 | install_dir: sysconfexampledir, 136 | ) 137 | 138 | # Documentation 139 | install_man('docs/eos-updater.conf.5') 140 | install_man('docs/eos-updater.8') 141 | 142 | subdir('tests') 143 | -------------------------------------------------------------------------------- /eos-updater/object.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * Copyright © 2016 Kinvolk GmbH 5 | * Copyright © 2017 Endless Mobile, Inc. 6 | * 7 | * SPDX-License-Identifier: LGPL-2.1-or-later 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library 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 GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * Authors: 24 | * - Vivek Dasmohapatra 25 | * - Krzesimir Nowak 26 | * - Philip Withnall 27 | */ 28 | 29 | #include "config.h" 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #ifdef HAS_EOSMETRICS_0 38 | #include 39 | #endif /* HAS_EOSMETRICS_0 */ 40 | 41 | static void 42 | eos_updater_set_state_changed (EosUpdater *updater, EosUpdaterState state) 43 | { 44 | eos_updater_set_state (updater, state); 45 | eos_updater_emit_state_changed (updater, state); 46 | } 47 | 48 | void 49 | eos_updater_set_error (EosUpdater *updater, 50 | const GError *error) 51 | { 52 | g_autoptr(GError) local_error = NULL; 53 | g_autofree gchar *error_name = NULL; 54 | 55 | g_warn_if_fail (error != NULL); 56 | 57 | if (error == NULL) 58 | { 59 | /* This case should never be hit. If it is, there’s a bug in eos-updater; 60 | * but we’d prefer eos-updater to continue running and report some error 61 | * state rather than abort or not report any error state. */ 62 | g_set_error_literal (&local_error, G_IO_ERROR, G_IO_ERROR_FAILED, 63 | "Error in updater: error state set without appropriate message"); 64 | error = local_error; 65 | } 66 | 67 | error_name = g_dbus_error_encode_gerror (error); 68 | 69 | g_message ("Changing to error state: %s, %d, %s", 70 | error_name, error->code, error->message); 71 | 72 | eos_updater_set_error_name (updater, error_name); 73 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS 74 | eos_updater_set_error_code (updater, (guint) error->code); 75 | G_GNUC_END_IGNORE_DEPRECATIONS 76 | eos_updater_set_error_message (updater, error->message); 77 | eos_updater_set_state_changed (updater, EOS_UPDATER_STATE_ERROR); 78 | 79 | /* Report a metric. */ 80 | #ifdef HAS_EOSMETRICS_0 81 | if (euu_get_metrics_enabled () && 82 | !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) && 83 | !g_error_matches (error, EOS_UPDATER_ERROR, EOS_UPDATER_ERROR_LIVE_BOOT) && 84 | !g_error_matches (error, EOS_UPDATER_ERROR, EOS_UPDATER_ERROR_NOT_OSTREE_SYSTEM) && 85 | !g_error_matches (error, EOS_UPDATER_ERROR, EOS_UPDATER_ERROR_METERED_CONNECTION)) 86 | { 87 | emtr_event_recorder_record_event_sync (emtr_event_recorder_get_default (), 88 | EOS_UPDATER_METRIC_FAILURE, 89 | g_variant_new ("(ss)", 90 | "eos-updater", 91 | error->message)); 92 | } 93 | #endif 94 | } 95 | 96 | /* This must only be called from the main thread. All mutual exclusion of access 97 | * to the #EosUpdaterData structure, and the #OstreeRepo (and other things) is 98 | * based on the current updater state. To maintain safety, that must only be 99 | * modified from the main thread, and only one worker thread must be alive at 100 | * once, mutexed on this state. 101 | * 102 | * See https://phabricator.endlessm.com/T15923 */ 103 | void 104 | eos_updater_clear_error (EosUpdater *updater, 105 | EosUpdaterState state) 106 | { 107 | if (g_strcmp0 (eos_updater_get_error_name (updater), "") != 0) 108 | g_message ("Clearing error state and changing to state %s", 109 | eos_updater_state_to_string (state)); 110 | else 111 | g_message ("Changing to state %s", eos_updater_state_to_string (state)); 112 | 113 | eos_updater_set_error_name (updater, ""); 114 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS 115 | eos_updater_set_error_code (updater, 0); 116 | G_GNUC_END_IGNORE_DEPRECATIONS 117 | eos_updater_set_error_message (updater, ""); 118 | eos_updater_set_state_changed (updater, state); 119 | } 120 | -------------------------------------------------------------------------------- /eos-updater/object.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * Copyright © 2016 Kinvolk GmbH 5 | * Copyright © 2017 Endless Mobile, Inc. 6 | * 7 | * SPDX-License-Identifier: LGPL-2.1-or-later 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library 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 GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * Authors: 24 | * - Vivek Dasmohapatra 25 | * - Krzesimir Nowak 26 | * - Philip Withnall 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | G_BEGIN_DECLS 36 | 37 | void eos_updater_set_error (EosUpdater *updater, 38 | const GError *error); 39 | void eos_updater_clear_error (EosUpdater *updater, 40 | EosUpdaterState state); 41 | 42 | G_END_DECLS 43 | -------------------------------------------------------------------------------- /eos-updater/poll.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Vivek Dasmohapatra 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | gboolean handle_poll (EosUpdater *updater, 33 | GDBusMethodInvocation *call, 34 | gpointer user_data); 35 | gboolean handle_poll_volume (EosUpdater *updater, 36 | GDBusMethodInvocation *call, 37 | const gchar *path, 38 | gpointer user_data); 39 | 40 | G_END_DECLS 41 | -------------------------------------------------------------------------------- /eos-updater/tests/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | install_data('eos_updater.py', 5 | install_dir : datadir / 'python-dbusmock' / 'templates', 6 | install_tag : 'devel', 7 | ) 8 | 9 | # lint check 10 | test( 11 | 'flake8', 12 | flake8, 13 | args: [files('eos_updater.py')], 14 | suite: 'eos-updater', 15 | workdir: meson.current_source_dir(), 16 | ) 17 | -------------------------------------------------------------------------------- /libeos-update-server/config.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * Copyright © 2017 Endless Mobile, Inc. 5 | * 6 | * SPDX-License-Identifier: LGPL-2.1-or-later 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * Authors: 23 | * - Krzesimir Nowak 24 | * - Philip Withnall 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | G_BEGIN_DECLS 34 | 35 | /** 36 | * EusRepoConfig: 37 | * @index: index from the `[Repository 0–65535]` group name 38 | * @path: value of the `Path=` option 39 | * @remote_name: value of the `RemoteName=` option 40 | * 41 | * Structure containing a local repository configuration loaded from the 42 | * config file (a `[Repository 0–65535]` section). This is enough information to 43 | * create an #EosRepo for the repository. 44 | * 45 | * For more information about the config options, see the 46 | * [`eos-update-server.conf(5)` man page](man:eos-update-server.conf(5)). 47 | * 48 | * Since: UNRELEASED 49 | */ 50 | typedef struct 51 | { 52 | guint16 index; 53 | gchar *path; 54 | gchar *remote_name; 55 | } EusRepoConfig; 56 | 57 | void eus_repo_config_free (EusRepoConfig *config); 58 | 59 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (EusRepoConfig, eus_repo_config_free) 60 | 61 | gboolean eus_read_config_file (const gchar *config_file_path, 62 | gboolean *out_advertise_updates, 63 | GPtrArray **out_repository_configs, 64 | GError **error); 65 | 66 | G_END_DECLS 67 | -------------------------------------------------------------------------------- /libeos-update-server/libeos-update-server.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | ../eos-update-server/eos-update-server.conf 7 | 8 | 9 | -------------------------------------------------------------------------------- /libeos-update-server/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # Server utility library 5 | eus_api_version = '0' 6 | 7 | resources = gnome.compile_resources( 8 | 'resources', 9 | 'libeos-update-server.gresource.xml', 10 | c_name: 'eus_resources', 11 | ) 12 | 13 | libeos_update_server_sources = [ 14 | 'config.c', 15 | 'repo.c', 16 | 'server.c', 17 | ] 18 | 19 | libeos_update_server_headers = [ 20 | 'config.h', 21 | 'repo.h', 22 | 'server.h', 23 | ] 24 | 25 | libeos_update_server_cppflags = [ 26 | '-DG_LOG_DOMAIN="libeos-update-server"', 27 | ] 28 | 29 | libeos_update_server_deps = [ 30 | gio_dep, 31 | glib_dep, 32 | gobject_dep, 33 | libsoup_dep, 34 | libsystemd_dep, 35 | ostree_dep, 36 | libeos_updater_util_dep, 37 | ] 38 | 39 | libeos_update_server = static_library('eos-update-server-' + eus_api_version, 40 | libeos_update_server_sources + libeos_update_server_headers + resources, 41 | c_args: libeos_update_server_cppflags, 42 | dependencies: libeos_update_server_deps, 43 | include_directories: root_inc, 44 | install: false, 45 | ) 46 | libeos_update_server_dep = declare_dependency( 47 | link_with: libeos_update_server, 48 | include_directories: root_inc, 49 | sources: libeos_update_server_headers + [resources[1]], 50 | ) 51 | -------------------------------------------------------------------------------- /libeos-update-server/repo.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * Copyright © 2017 Endless Mobile, Inc. 5 | * 6 | * SPDX-License-Identifier: LGPL-2.1-or-later 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * Authors: 23 | * - Krzesimir Nowak 24 | * - Philip Withnall 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | 35 | G_BEGIN_DECLS 36 | 37 | #define EUS_TYPE_REPO eus_repo_get_type () 38 | G_DECLARE_FINAL_TYPE (EusRepo, eus_repo, EUS, REPO, GObject) 39 | 40 | EusRepo *eus_repo_new (OstreeRepo *repo, 41 | const gchar *root_path, 42 | const gchar *served_remote, 43 | GCancellable *cancellable, 44 | GError **error); 45 | 46 | void eus_repo_connect (EusRepo *self, 47 | SoupServer *server); 48 | void eus_repo_disconnect (EusRepo *self); 49 | 50 | G_END_DECLS 51 | -------------------------------------------------------------------------------- /libeos-update-server/server.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2017 Endless Mobile, Inc. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Philip Withnall 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | G_BEGIN_DECLS 35 | 36 | #define EUS_TYPE_SERVER eus_server_get_type () 37 | G_DECLARE_FINAL_TYPE (EusServer, eus_server, EUS, SERVER, GObject) 38 | 39 | EusServer *eus_server_new (SoupServer *server); 40 | 41 | void eus_server_add_repo (EusServer *self, 42 | EusRepo *repo); 43 | 44 | void eus_server_disconnect (EusServer *self); 45 | 46 | guint eus_server_get_pending_requests (EusServer *self); 47 | gint64 eus_server_get_last_request_time (EusServer *self); 48 | 49 | G_END_DECLS 50 | -------------------------------------------------------------------------------- /libeos-updater-flatpak-installer/installer.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2017 Endless Mobile, Inc. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Sam Spilsbury 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | G_BEGIN_DECLS 32 | 33 | gboolean eufi_check_ref_actions_applied (FlatpakInstallation *installation, 34 | GPtrArray *actions, 35 | GError **error); 36 | 37 | gboolean eufi_apply_flatpak_ref_actions (FlatpakInstallation *installation, 38 | const gchar *state_counter_path, 39 | GPtrArray *actions, 40 | EosUpdaterInstallerMode mode, 41 | EosUpdaterInstallerFlags flags, 42 | GError **error); 43 | 44 | GHashTable *eufi_determine_flatpak_ref_actions_to_check (GStrv directories_to_search, 45 | GError **error); 46 | 47 | GHashTable *eufi_determine_flatpak_ref_actions_to_apply (GStrv directories_to_search, 48 | GError **error); 49 | 50 | G_END_DECLS 51 | -------------------------------------------------------------------------------- /libeos-updater-flatpak-installer/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # Flatpak installer utility library 5 | eufi_api_version = '0' 6 | 7 | libeos_updater_flatpak_installer_sources = [ 8 | 'determine-flatpak-actions.c', 9 | 'perform-flatpak-actions.c', 10 | ] 11 | 12 | libeos_updater_flatpak_installer_headers = [ 13 | 'installer.h', 14 | ] 15 | 16 | libeos_updater_flatpak_installer_cppflags = [ 17 | '-DG_LOG_DOMAIN="libeos-updater-flatpak-installer"', 18 | ] 19 | 20 | libeos_updater_flatpak_installer_deps = [ 21 | flatpak_dep, 22 | gio_dep, 23 | glib_dep, 24 | gobject_dep, 25 | json_glib_dep, 26 | ostree_dep, 27 | libeos_updater_util_dep, 28 | ] 29 | 30 | libeos_updater_flatpak_installer = library('eos-updater-flatpak-installer-' + eufi_api_version, 31 | libeos_updater_flatpak_installer_sources + libeos_updater_flatpak_installer_headers, 32 | c_args: libeos_updater_flatpak_installer_cppflags, 33 | dependencies: libeos_updater_flatpak_installer_deps, 34 | include_directories: root_inc, 35 | install: true, 36 | # FIXME: Library versioning should be tidied up when ABI is next broken: 37 | soversion: eufi_api_version, 38 | version: '0.0.0', 39 | ) 40 | libeos_updater_flatpak_installer_dep = declare_dependency( 41 | link_with: libeos_updater_flatpak_installer, 42 | include_directories: root_inc, 43 | sources: libeos_updater_flatpak_installer_headers, 44 | ) 45 | 46 | libeos_updater_flatpak_installer_gir = gnome.generate_gir(libeos_updater_flatpak_installer, 47 | sources: libeos_updater_flatpak_installer_sources + libeos_updater_flatpak_installer_headers, 48 | nsversion: eufi_api_version, 49 | namespace: 'EosUpdaterFlatpakInstaller', 50 | symbol_prefix: 'eufi', 51 | identifier_prefix: 'Eufi', 52 | header: 'libeos-updater-flatpak-installer/installer.h', 53 | includes: [ 54 | 'Flatpak-1.0', 55 | 'Gio-2.0', 56 | 'GObject-2.0', 57 | libeos_updater_util_gir[0], 58 | ], 59 | install: true, 60 | dependencies: libeos_updater_flatpak_installer_dep, 61 | fatal_warnings: true, 62 | ) 63 | 64 | subdir('tests') 65 | -------------------------------------------------------------------------------- /libeos-updater-flatpak-installer/tests/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | deps = [ 5 | flatpak_dep, 6 | gio_dep, 7 | glib_dep, 8 | gobject_dep, 9 | json_glib_dep, 10 | ostree_dep, 11 | libeos_updater_flatpak_installer_dep, 12 | libeos_updater_test_common_dep, 13 | libeos_updater_util_dep, 14 | ] 15 | 16 | c_args = [ 17 | '-DG_LOG_DOMAIN="libeos-updater-flatpak-installer-tests"', 18 | ] 19 | 20 | envs = test_env + [ 21 | 'G_TEST_SRCDIR=' + meson.current_source_dir(), 22 | 'G_TEST_BUILDDIR=' + meson.current_build_dir(), 23 | ] 24 | 25 | test_programs = { 26 | 'installer': { 27 | 'slow': true, 28 | }, 29 | } 30 | 31 | installed_tests_metadir = join_paths(datadir, 'installed-tests', 32 | 'libeos-updater-flatpak-installer-' + eufi_api_version) 33 | installed_tests_execdir = join_paths(libexecdir, 'installed-tests', 34 | 'libeos-updater-flatpak-installer-' + eufi_api_version) 35 | 36 | foreach test_name, extra_args : test_programs 37 | source = extra_args.get('source', test_name + '.c') 38 | install = enable_installed_tests and extra_args.get('install', true) 39 | 40 | if install 41 | test_conf = configuration_data() 42 | test_conf.set('installed_tests_dir', installed_tests_execdir) 43 | test_conf.set('program', test_name) 44 | test_conf.set('env', '') 45 | configure_file( 46 | input: installed_tests_template, 47 | output: test_name + '.test', 48 | install_dir: installed_tests_metadir, 49 | configuration: test_conf, 50 | ) 51 | endif 52 | 53 | exe = executable(test_name, source, 54 | c_args : c_args + extra_args.get('c_args', []), 55 | link_args : extra_args.get('link_args', []), 56 | dependencies : deps + extra_args.get('dependencies', []), 57 | install_dir: installed_tests_execdir, 58 | install: install, 59 | ) 60 | 61 | suite = ['libeos-updater-flatpak-installer'] + extra_args.get('suite', []) 62 | test( 63 | test_name, 64 | exe, 65 | env: envs, 66 | suite: suite, 67 | timeout: extra_args.get('slow', false) ? 360 : 60, 68 | protocol: 'tap', 69 | ) 70 | endforeach 71 | -------------------------------------------------------------------------------- /libeos-updater-util/checkpoint-private.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright 2024 Endless OS Foundation LLC 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, see . 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | G_BEGIN_DECLS 26 | 27 | #define EUU_CHECKPOINT_BLOCK (euu_checkpoint_block_quark ()) 28 | GQuark euu_checkpoint_block_quark (void); 29 | 30 | /** 31 | * EuuCheckpointBlock: 32 | * @EUU_CHECKPOINT_BLOCK_NVME_REMAP: The system uses the nvme-remap driver 33 | * 34 | * Reasons why eos-updater may block the system from crossing a checkpoint. 35 | */ 36 | typedef enum { 37 | EUU_CHECKPOINT_BLOCK_FORCED, 38 | EUU_CHECKPOINT_BLOCK_NVME_REMAP, 39 | } EuuCheckpointBlock; 40 | 41 | const char *euu_checkpoint_block_to_string (EuuCheckpointBlock reason); 42 | 43 | gboolean euu_should_follow_checkpoint (OstreeSysroot *sysroot, 44 | const gchar *booted_ref, 45 | const gchar *target_ref, 46 | GError **error); 47 | G_END_DECLS 48 | -------------------------------------------------------------------------------- /libeos-updater-util/checkpoint.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright 2024 Endless OS Foundation LLC 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with this library; if not, see . 17 | * 18 | * SPDX-License-Identifier: LGPL-2.1-or-later 19 | */ 20 | 21 | #include "config.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | G_DEFINE_QUARK (euu-checkpoint-block-quark, euu_checkpoint_block) 28 | 29 | /** 30 | * euu_checkpoint_block_to_string: 31 | * @reason: An element of #EuuCheckpointBlock 32 | * 33 | * Helper function to get the nickname of @reason. 34 | * 35 | * Returns: the nickname of @reason, such as "forced" 36 | */ 37 | const char * 38 | euu_checkpoint_block_to_string (EuuCheckpointBlock reason) 39 | { 40 | g_autoptr(GEnumClass) enum_class = G_ENUM_CLASS (g_type_class_ref (EUU_TYPE_CHECKPOINT_BLOCK)); 41 | GEnumValue *value = g_enum_get_value (enum_class, (gint) reason); 42 | 43 | g_return_val_if_fail (value != NULL, NULL); 44 | return value->value_nick; 45 | } 46 | 47 | static gboolean 48 | is_nvme_remap_in_use (OstreeSysroot *sysroot) 49 | { 50 | g_autoptr(GFile) driver_dir = NULL; 51 | g_autoptr(GFileEnumerator) enumerator = NULL; 52 | g_autoptr(GError) error = NULL; 53 | GFileInfo *info = NULL; 54 | 55 | driver_dir = g_file_resolve_relative_path (ostree_sysroot_get_path (sysroot), "sys/bus/pci/drivers/intel-nvme-remap"); 56 | enumerator = g_file_enumerate_children (driver_dir, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK, G_FILE_QUERY_INFO_NONE, NULL, &error); 57 | 58 | if (enumerator == NULL) 59 | { 60 | if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) 61 | g_warning ("Failed to enumerate %s: %s", g_file_peek_path (driver_dir), error->message); 62 | return FALSE; 63 | } 64 | 65 | while (TRUE) 66 | { 67 | if (!g_file_enumerator_iterate (enumerator, &info, NULL, NULL, &error)) 68 | { 69 | g_warning ("Error while enumerating %s: %s", g_file_peek_path (driver_dir), error->message); 70 | /* The driver is present, and something went wrong: assume it's in use */ 71 | return TRUE; 72 | } 73 | 74 | if (info == NULL) 75 | break; 76 | 77 | const char *name = g_file_info_get_name (info); 78 | g_debug ("Considering '%s'", name); 79 | if (g_file_info_get_is_symlink (info) && 80 | g_str_has_prefix (name, "0000:")) 81 | { 82 | g_debug ("Symbolic link %s indicates that nvme-remap is in use", name); 83 | return TRUE; 84 | } 85 | 86 | g_debug ("'%s' not a symlink or doesn't begin with '0000:', the search continues", name); 87 | } 88 | 89 | return FALSE; 90 | } 91 | 92 | /** 93 | * euu_should_follow_checkpoint: 94 | * @sysroot: the filesystem root of the system being upgraded 95 | * @booted_ref: the currently-booted ref 96 | * @target_ref: the candidate new ref to move to 97 | * @error: (out): an error with domain #EUU_CHECKPOINT_BLOCK 98 | * 99 | * Whether the upgrade should follow the given checkpoint and move to the given 100 | * @target_ref for the upgrade deployment. The default for this is %TRUE, but 101 | * there are various systems for which support has been withdrawn, which need 102 | * to stay on old branches. In those cases, this function will return %FALSE 103 | * and will set @error with domain #EUU_CHECKPOINT_BLOCK, a code from 104 | * #EuuCheckpointBlock, and a human-readable reason as the message. 105 | */ 106 | gboolean 107 | euu_should_follow_checkpoint (OstreeSysroot *sysroot, 108 | const gchar *booted_ref, 109 | const gchar *target_ref, 110 | GError **error) 111 | { 112 | g_return_val_if_fail (OSTREE_IS_SYSROOT (sysroot), FALSE); 113 | g_return_val_if_fail (booted_ref != NULL, FALSE); 114 | g_return_val_if_fail (target_ref != NULL, FALSE); 115 | g_return_val_if_fail (error == NULL || *error == NULL, FALSE); 116 | 117 | /* Allow an override in case the logic below is incorrect or doesn’t age well. */ 118 | if (g_strcmp0 (g_getenv ("EOS_UPDATER_FORCE_FOLLOW_CHECKPOINT"), "1") == 0) 119 | { 120 | g_message ("Forcing checkpoint target ‘%s’ to be used as EOS_UPDATER_FORCE_FOLLOW_CHECKPOINT=1 is set", 121 | target_ref); 122 | return TRUE; 123 | } 124 | 125 | /* And an override in the opposite direction, for testing */ 126 | if (g_strcmp0 (g_getenv ("EOS_UPDATER_FORCE_FOLLOW_CHECKPOINT"), "0") == 0) 127 | { 128 | g_message ("Forcing checkpoint target ‘%s’ not to be used as EOS_UPDATER_FORCE_FOLLOW_CHECKPOINT=0 is set", 129 | target_ref); 130 | g_set_error (error, EUU_CHECKPOINT_BLOCK, EUU_CHECKPOINT_BLOCK_FORCED, 131 | "EOS_UPDATER_FORCE_FOLLOW_CHECKPOINT=0 is set"); 132 | return FALSE; 133 | } 134 | 135 | if (is_nvme_remap_in_use (sysroot)) 136 | { 137 | g_set_error (error, EUU_CHECKPOINT_BLOCK, EUU_CHECKPOINT_BLOCK_NVME_REMAP, 138 | _("This device uses remapped NVME storage, which is not supported in Endless OS 6")); 139 | return FALSE; 140 | } 141 | 142 | /* Checkpoint can be followed. */ 143 | return TRUE; 144 | } 145 | 146 | -------------------------------------------------------------------------------- /libeos-updater-util/config-util.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * Copyright © 2016 Kinvolk GmbH 5 | * Copyright © 2017 Endless Mobile, Inc. 6 | * 7 | * SPDX-License-Identifier: LGPL-2.1-or-later 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library 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 GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * Authors: 24 | * - Vivek Dasmohapatra 25 | * - Krzesimir Nowak 26 | * - Philip Withnall 27 | */ 28 | 29 | #pragma once 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | G_BEGIN_DECLS 36 | 37 | #define EUU_TYPE_CONFIG_FILE euu_config_file_get_type () 38 | G_DECLARE_FINAL_TYPE (EuuConfigFile, euu_config_file, EUU, CONFIG_FILE, GObject) 39 | 40 | EuuConfigFile *euu_config_file_new (const gchar * const *key_file_paths, 41 | GResource *default_resource, 42 | const gchar *default_path); 43 | 44 | guint euu_config_file_get_uint (EuuConfigFile *self, 45 | const gchar *group_name, 46 | const gchar *key_name, 47 | guint min_value, 48 | guint max_value, 49 | GError **error); 50 | gboolean euu_config_file_get_boolean (EuuConfigFile *self, 51 | const gchar *group_name, 52 | const gchar *key_name, 53 | GError **error); 54 | gchar *euu_config_file_get_string (EuuConfigFile *self, 55 | const gchar *group_name, 56 | const gchar *key_name, 57 | GError **error); 58 | gchar **euu_config_file_get_strv (EuuConfigFile *self, 59 | const gchar *group_name, 60 | const gchar *key_name, 61 | gsize *n_elements_out, 62 | GError **error); 63 | 64 | gchar **euu_config_file_get_groups (EuuConfigFile *self, 65 | gsize *n_groups_out, 66 | GError **error); 67 | 68 | G_END_DECLS 69 | -------------------------------------------------------------------------------- /libeos-updater-util/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020, 2022 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # Utility library 5 | euu_api_version = '0' 6 | 7 | libeos_updater_util_sources = [ 8 | 'avahi-service-file.c', 9 | 'checkpoint.c', 10 | 'config-util.c', 11 | 'flatpak-util.c', 12 | 'ostree-bloom.c', 13 | 'ostree-util.c', 14 | 'types.c', 15 | 'util.c', 16 | ] 17 | 18 | libeos_updater_util_headers = [ 19 | 'avahi-service-file.h', 20 | 'config-util.h', 21 | 'flatpak-util.h', 22 | 'ostree-util.h', 23 | 'types.h', 24 | 'util.h', 25 | ] 26 | 27 | libeos_updater_util_private_headers = [ 28 | 'checkpoint-private.h', 29 | 'metrics-private.h', 30 | 'ostree-bloom-private.h', 31 | ] 32 | 33 | libeos_updater_util_cppflags = [ 34 | '-DG_LOG_DOMAIN="libeos-updater-util"', 35 | ] 36 | 37 | libeos_updater_util_deps = [ 38 | flatpak_dep, 39 | gio_dep, 40 | glib_dep, 41 | gobject_dep, 42 | json_glib_dep, 43 | ostree_dep, 44 | ] 45 | 46 | enums = gnome.mkenums_simple('enums', 47 | sources: [ 48 | libeos_updater_util_headers, 49 | libeos_updater_util_private_headers, 50 | ], 51 | install_header: false, 52 | ) 53 | 54 | libeos_updater_util = library('eos-updater-util-' + euu_api_version, 55 | libeos_updater_util_sources + libeos_updater_util_headers + libeos_updater_util_private_headers + enums, 56 | c_args: libeos_updater_util_cppflags, 57 | dependencies: libeos_updater_util_deps, 58 | include_directories: root_inc, 59 | install: true, 60 | # FIXME: Library versioning should be tidied up when ABI is next broken: 61 | soversion: euu_api_version, 62 | version: '0.0.0', 63 | ) 64 | libeos_updater_util_dep = declare_dependency( 65 | link_with: libeos_updater_util, 66 | include_directories: root_inc, 67 | sources: libeos_updater_util_headers + [enums[1]], 68 | ) 69 | 70 | libeos_updater_util_gir = gnome.generate_gir(libeos_updater_util, 71 | sources: libeos_updater_util_sources + libeos_updater_util_headers + enums, 72 | nsversion: euu_api_version, 73 | namespace: 'EosUpdaterUtil', 74 | symbol_prefix: 'euu', 75 | identifier_prefix: 'Euu', 76 | extra_args: [ 77 | '--symbol-prefix=eos_updater', 78 | '--symbol-prefix=eos_ostree_avahi', 79 | '--symbol-prefix=eos_avahi', 80 | '--identifier-prefix=EosUpdater', 81 | '--identifier-prefix=EosOstreeAvahi', 82 | '--identifier-prefix=EosAvahi', 83 | ], 84 | header: 'libeos-updater-util/util.h', 85 | includes: [ 86 | 'Flatpak-1.0', 87 | 'Gio-2.0', 88 | 'GObject-2.0', 89 | 'OSTree-1.0', 90 | ], 91 | install: true, 92 | dependencies: libeos_updater_util_dep, 93 | fatal_warnings: true, 94 | ) 95 | 96 | subdir('tests') 97 | -------------------------------------------------------------------------------- /libeos-updater-util/metrics-private.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2020 Endless OS Foundation LLC 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | * 22 | * Authors: 23 | * - Philip Withnall 24 | */ 25 | 26 | #pragma once 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | /* 35 | * Records a failure in the updater. The payload is an `(ss)` of the updater 36 | * component, and the error message. 37 | */ 38 | static const gchar *const EOS_UPDATER_METRIC_FAILURE = "927d0f61-4890-4912-a513-b2cb0205908f"; 39 | 40 | /* 41 | * Aggregate event, recorded when the system is blocked from crossing a checkpoint. 42 | * 43 | * The payload is a 5-tuple of strings: hardware vendor name, hardware product 44 | * name, current OSTree ref, target OSTree ref, and the stringified value of 45 | * EuuCheckpointBlock describing why the update was blocked. 46 | * 47 | * The count is to be ignored: it will be incremented whenever the system tries 48 | * and fails to update, but since this is a static condition the number of times 49 | * doesn't really matter. It is aggregated so each system only reports the event 50 | * once per day and month. 51 | */ 52 | static const gchar *const EOS_UPDATER_METRIC_CHECKPOINT_BLOCKED = "e3609b7e-88aa-4ba5-90f9-418bf9234139"; 53 | 54 | /** 55 | * euu_get_metrics_enabled: 56 | * 57 | * Check whether metrics are enabled at runtime. They can be disabled using an 58 | * environment variable for the unit tests. 59 | * 60 | * Returns: %TRUE if metrics are enabled, %FALSE otherwise 61 | */ 62 | static inline gboolean 63 | euu_get_metrics_enabled (void) 64 | { 65 | #ifdef HAS_EOSMETRICS_0 66 | const gchar *disable_metrics = g_getenv ("EOS_DISABLE_METRICS"); 67 | return (disable_metrics == NULL || !g_str_equal (disable_metrics, "1")); 68 | #else 69 | return FALSE; 70 | #endif 71 | } 72 | 73 | G_END_DECLS 74 | -------------------------------------------------------------------------------- /libeos-updater-util/ostree-bloom-private.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2017 Endless Mobile, Inc. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 | * Boston, MA 02111-1307, USA. 21 | * 22 | * Authors: 23 | * - Philip Withnall 24 | */ 25 | 26 | #pragma once 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | G_BEGIN_DECLS 33 | 34 | /** 35 | * OstreeBloom: 36 | * 37 | * An implementation of a [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter) 38 | * which is suitable for building a filter and looking keys up in an existing 39 | * filter. 40 | * 41 | * Since: 2017.8 42 | */ 43 | typedef struct _OstreeBloom OstreeBloom; 44 | 45 | /** 46 | * OstreeBloomHashFunc: 47 | * @element: a pointer to the element to hash 48 | * @k: hash function parameter 49 | * 50 | * Function prototype for a 51 | * [universal hash function](https://en.wikipedia.org/wiki/Universal_hashing), 52 | * parameterised on @k, which hashes @element to a #guint64 hash value. 53 | * 54 | * It is up to the implementer of the hash function whether %NULL is valid for 55 | * @element. 56 | * 57 | * Since: 2017.8 58 | */ 59 | typedef guint64 (*OstreeBloomHashFunc) (gconstpointer element, 60 | guint8 k); 61 | 62 | #define OSTREE_TYPE_BLOOM (ostree_bloom_get_type ()) 63 | 64 | G_GNUC_INTERNAL 65 | GType ostree_bloom_get_type (void); 66 | 67 | G_GNUC_INTERNAL 68 | OstreeBloom *ostree_bloom_new (gsize n_bytes, 69 | guint8 k, 70 | OstreeBloomHashFunc hash_func); 71 | 72 | G_GNUC_INTERNAL 73 | OstreeBloom *ostree_bloom_new_from_bytes (GBytes *bytes, 74 | guint8 k, 75 | OstreeBloomHashFunc hash_func); 76 | 77 | G_GNUC_INTERNAL 78 | OstreeBloom *ostree_bloom_ref (OstreeBloom *bloom); 79 | G_GNUC_INTERNAL 80 | void ostree_bloom_unref (OstreeBloom *bloom); 81 | 82 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (OstreeBloom, ostree_bloom_unref) 83 | 84 | G_GNUC_INTERNAL 85 | gboolean ostree_bloom_maybe_contains (OstreeBloom *bloom, 86 | gconstpointer element); 87 | 88 | G_GNUC_INTERNAL 89 | GBytes *ostree_bloom_seal (OstreeBloom *bloom); 90 | 91 | G_GNUC_INTERNAL 92 | void ostree_bloom_add_element (OstreeBloom *bloom, 93 | gconstpointer element); 94 | 95 | G_GNUC_INTERNAL 96 | gsize ostree_bloom_get_size (OstreeBloom *bloom); 97 | G_GNUC_INTERNAL 98 | guint8 ostree_bloom_get_k (OstreeBloom *bloom); 99 | G_GNUC_INTERNAL 100 | OstreeBloomHashFunc ostree_bloom_get_hash_func (OstreeBloom *bloom); 101 | 102 | G_GNUC_INTERNAL 103 | guint64 ostree_str_bloom_hash (gconstpointer element, 104 | guint8 k); 105 | 106 | G_GNUC_INTERNAL 107 | guint64 ostree_collection_ref_bloom_hash (gconstpointer element, 108 | guint8 k); 109 | G_END_DECLS 110 | -------------------------------------------------------------------------------- /libeos-updater-util/ostree-util.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2017 Endless Mobile, Inc. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Philip Withnall 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | gboolean eos_updater_sysroot_get_advertisable_commit (OstreeSysroot *sysroot, 33 | gchar **commit_checksum, 34 | gchar **commit_ostree_path, 35 | guint64 *commit_timestamp, 36 | GError **error); 37 | 38 | OstreeRepo *eos_updater_local_repo (GError **error); 39 | 40 | OstreeDeployment *eos_updater_get_booted_deployment_from_loaded_sysroot (OstreeSysroot *sysroot, 41 | GError **error); 42 | 43 | OstreeDeployment *eos_updater_get_booted_deployment (GError **error); 44 | 45 | gchar *eos_updater_get_booted_checksum (GError **error); 46 | 47 | gboolean eos_updater_get_ostree_path (OstreeRepo *repo, 48 | const gchar *osname, 49 | gchar **ostree_path, 50 | GError **error); 51 | 52 | G_END_DECLS 53 | -------------------------------------------------------------------------------- /libeos-updater-util/tests/config-test-invalid.conf: -------------------------------------------------------------------------------- 1 | this ent a valid conf file 2 | -------------------------------------------------------------------------------- /libeos-updater-util/tests/config-test.conf: -------------------------------------------------------------------------------- 1 | [Test] 2 | File=1000 3 | FileDefault=true 4 | 5 | [DefaultGroup] 6 | -------------------------------------------------------------------------------- /libeos-updater-util/tests/config.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | config-test.conf 7 | config-test-invalid.conf 8 | 9 | 10 | -------------------------------------------------------------------------------- /libeos-updater-util/tests/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | deps = [ 5 | flatpak_dep, 6 | gio_dep, 7 | glib_dep, 8 | gobject_dep, 9 | json_glib_dep, 10 | ostree_dep, 11 | libeos_updater_util_dep, 12 | ] 13 | 14 | c_args = [ 15 | '-DG_LOG_DOMAIN="libeos-updater-util-tests"', 16 | ] 17 | 18 | envs = test_env + [ 19 | 'G_TEST_SRCDIR=' + meson.current_source_dir(), 20 | 'G_TEST_BUILDDIR=' + meson.current_build_dir(), 21 | ] 22 | 23 | config_resources = gnome.compile_resources( 24 | 'resources', 25 | 'config.gresource.xml', 26 | c_name: 'euu_tests_resources', 27 | ) 28 | 29 | test_programs = { 30 | 'avahi-service-file': {}, 31 | 'checkpoint': {}, 32 | 'config-util': { 33 | 'source': ['config-util.c'] + config_resources, 34 | }, 35 | 'flatpak-util': {}, 36 | 'ostree-util': {}, 37 | } 38 | 39 | installed_tests_metadir = join_paths(datadir, 'installed-tests', 40 | 'libeos-updater-util-' + euu_api_version) 41 | installed_tests_execdir = join_paths(libexecdir, 'installed-tests', 42 | 'libeos-updater-util-' + euu_api_version) 43 | 44 | foreach test_name, extra_args : test_programs 45 | source = extra_args.get('source', test_name + '.c') 46 | install = enable_installed_tests and extra_args.get('install', true) 47 | 48 | if install 49 | test_conf = configuration_data() 50 | test_conf.set('installed_tests_dir', installed_tests_execdir) 51 | test_conf.set('program', test_name) 52 | test_conf.set('env', '') 53 | configure_file( 54 | input: installed_tests_template, 55 | output: test_name + '.test', 56 | install_dir: installed_tests_metadir, 57 | configuration: test_conf, 58 | ) 59 | endif 60 | 61 | exe = executable(test_name, source, 62 | c_args : c_args + extra_args.get('c_args', []), 63 | link_args : extra_args.get('link_args', []), 64 | dependencies : deps + extra_args.get('dependencies', []), 65 | install_dir: installed_tests_execdir, 66 | install: install, 67 | ) 68 | 69 | suite = ['libeos-updater-util'] + extra_args.get('suite', []) 70 | test(test_name, exe, env : envs, suite : suite, protocol : 'tap') 71 | endforeach 72 | -------------------------------------------------------------------------------- /libeos-updater-util/tests/ostree-util.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2017 Endless Mobile, Inc. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Philip Withnall 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | typedef struct 32 | { 33 | GFile *tmp_dir; /* owned */ 34 | OstreeSysroot *sysroot; /* owned */ 35 | } Fixture; 36 | 37 | /* Set up a temporary directory with a loaded sysroot in. */ 38 | static void 39 | setup (Fixture *fixture, 40 | gconstpointer user_data G_GNUC_UNUSED) 41 | { 42 | g_autoptr(GError) error = NULL; 43 | g_autofree gchar *tmp_dir = NULL; 44 | g_autoptr(GFile) boot_id_file = NULL; 45 | 46 | tmp_dir = g_dir_make_tmp ("eos-updater-util-tests-ostree-XXXXXX", &error); 47 | g_assert_no_error (error); 48 | 49 | fixture->tmp_dir = g_file_new_for_path (tmp_dir); 50 | 51 | /* Set up the sysroot. */ 52 | fixture->sysroot = ostree_sysroot_new (fixture->tmp_dir); 53 | 54 | ostree_sysroot_ensure_initialized (fixture->sysroot, NULL, &error); 55 | g_assert_no_error (error); 56 | 57 | ostree_sysroot_load (fixture->sysroot, NULL, &error); 58 | g_assert_no_error (error); 59 | 60 | /* Make the util.c code think that the first deployment is the booted one. */ 61 | g_setenv ("EOS_UPDATER_TEST_UPDATER_DEPLOYMENT_FALLBACK", "1", TRUE); 62 | } 63 | 64 | /* GIO equivalent of `rm -rf`. */ 65 | static gboolean 66 | file_delete_recursive (GFile *file, 67 | GCancellable *cancellable, 68 | GError **error) 69 | { 70 | g_autoptr(GFileEnumerator) enumerator = NULL; 71 | g_autoptr(GError) local_error = NULL; 72 | 73 | enumerator = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME, 74 | G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, 75 | cancellable, &local_error); 76 | 77 | if (local_error != NULL && 78 | !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY)) 79 | { 80 | g_propagate_error (error, g_steal_pointer (&local_error)); 81 | return FALSE; 82 | } 83 | else if (local_error == NULL) 84 | { 85 | while (TRUE) 86 | { 87 | GFile *child; 88 | 89 | if (!g_file_enumerator_iterate (enumerator, NULL, &child, 90 | cancellable, error)) 91 | return FALSE; 92 | if (child == NULL) 93 | break; 94 | if (!file_delete_recursive (child, cancellable, error)) 95 | return FALSE; 96 | } 97 | } 98 | 99 | return g_file_delete (file, cancellable, error); 100 | } 101 | 102 | /* Inverse of setup(). */ 103 | static void 104 | teardown (Fixture *fixture, 105 | gconstpointer user_data G_GNUC_UNUSED) 106 | { 107 | g_autoptr(GError) error = NULL; 108 | 109 | g_unsetenv ("EOS_UPDATER_TEST_UPDATER_DEPLOYMENT_FALLBACK"); 110 | 111 | g_clear_object (&fixture->sysroot); 112 | 113 | file_delete_recursive (fixture->tmp_dir, NULL, &error); 114 | g_assert_no_error (error); 115 | g_clear_object (&fixture->tmp_dir); 116 | } 117 | 118 | /* Test that listing commits from a sysroot with no deployments errors. */ 119 | static void 120 | test_ostree_no_deployments (Fixture *fixture, 121 | gconstpointer user_data G_GNUC_UNUSED) 122 | { 123 | g_autoptr(GError) error = NULL; 124 | gboolean retval; 125 | g_autofree gchar *commit_checksum = NULL; 126 | g_autofree gchar *commit_ostree_path = NULL; 127 | guint64 commit_timestamp = 0; 128 | 129 | retval = eos_updater_sysroot_get_advertisable_commit (fixture->sysroot, 130 | &commit_checksum, 131 | &commit_ostree_path, 132 | &commit_timestamp, 133 | &error); 134 | g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND); 135 | g_assert_false (retval); 136 | 137 | g_assert_null (commit_checksum); 138 | g_assert_null (commit_ostree_path); 139 | g_assert_cmpuint (commit_timestamp, ==, 0); 140 | } 141 | 142 | int 143 | main (int argc, 144 | char *argv[]) 145 | { 146 | setlocale (LC_ALL, ""); 147 | 148 | g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL); 149 | 150 | g_test_add ("/ostree/no-deployments", Fixture, NULL, setup, 151 | test_ostree_no_deployments, teardown); 152 | /* TODO: More */ 153 | 154 | return g_test_run (); 155 | } 156 | -------------------------------------------------------------------------------- /libeos-updater-util/types.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * Copyright © 2016 Kinvolk GmbH 5 | * Copyright © 2017 Endless Mobile, Inc. 6 | * 7 | * SPDX-License-Identifier: LGPL-2.1-or-later 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | * 14 | * This library 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 GNU 17 | * Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * Authors: 24 | * - Vivek Dasmohapatra 25 | * - Krzesimir Nowak 26 | * - Philip Withnall 27 | */ 28 | 29 | #include 30 | #include 31 | 32 | #include "types.h" 33 | 34 | static const GDBusErrorEntry eos_updater_error_entries[] = { 35 | { EOS_UPDATER_ERROR_WRONG_STATE, "com.endlessm.Updater.Error.WrongState" }, 36 | { EOS_UPDATER_ERROR_LIVE_BOOT, "com.endlessm.Updater.Error.LiveBoot" }, 37 | { EOS_UPDATER_ERROR_WRONG_CONFIGURATION, "com.endlessm.Updater.Error.WrongConfiguration" }, 38 | { EOS_UPDATER_ERROR_NOT_OSTREE_SYSTEM, "com.endlessm.Updater.Error.NotOstreeSystem" }, 39 | { EOS_UPDATER_ERROR_FETCHING, "com.endlessm.Updater.Error.Fetching" }, 40 | { EOS_UPDATER_ERROR_MALFORMED_AUTOINSTALL_SPEC, "com.endlessm.Updater.Error.MalformedAutoinstallSpec" }, 41 | { EOS_UPDATER_ERROR_UNKNOWN_ENTRY_IN_AUTOINSTALL_SPEC, "com.endlessm.Updater.Error.UnknownEntryInAutoinstallSpec" }, 42 | { EOS_UPDATER_ERROR_FLATPAK_REMOTE_CONFLICT, "com.endlessm.Updater.Error.FlatpakRemoteConflict" }, 43 | { EOS_UPDATER_ERROR_METERED_CONNECTION, "com.endlessm.Updater.Error.MeteredConnection" }, 44 | }; 45 | 46 | /* Ensure that every error code has an associated D-Bus error name */ 47 | G_STATIC_ASSERT (G_N_ELEMENTS (eos_updater_error_entries) == EOS_UPDATER_ERROR_LAST + 1); 48 | 49 | GQuark 50 | eos_updater_error_quark (void) 51 | { 52 | static gsize quark = 0; 53 | g_dbus_error_register_error_domain ("eos-updater-error-quark", 54 | &quark, 55 | eos_updater_error_entries, 56 | G_N_ELEMENTS (eos_updater_error_entries)); 57 | return (GQuark) quark; 58 | } 59 | 60 | static const gchar * state_str[] = { 61 | "None", 62 | "Ready", 63 | "Error", 64 | "Polling", 65 | "UpdateAvailable", 66 | "Fetching", 67 | "UpdateReady", 68 | "ApplyUpdate", 69 | "UpdateApplied" 70 | }; 71 | 72 | G_STATIC_ASSERT (G_N_ELEMENTS (state_str) == EOS_UPDATER_STATE_LAST + 1); 73 | 74 | const gchar * 75 | eos_updater_state_to_string (EosUpdaterState state) 76 | { 77 | g_assert (state <= EOS_UPDATER_STATE_LAST); 78 | 79 | return state_str[state]; 80 | }; 81 | -------------------------------------------------------------------------------- /libeos-updater-util/types.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Vivek Dasmohapatra 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | typedef enum { 32 | EOS_UPDATER_ERROR_WRONG_STATE, 33 | EOS_UPDATER_ERROR_LIVE_BOOT, 34 | EOS_UPDATER_ERROR_WRONG_CONFIGURATION, 35 | EOS_UPDATER_ERROR_NOT_OSTREE_SYSTEM, 36 | EOS_UPDATER_ERROR_FETCHING, 37 | EOS_UPDATER_ERROR_MALFORMED_AUTOINSTALL_SPEC, 38 | EOS_UPDATER_ERROR_UNKNOWN_ENTRY_IN_AUTOINSTALL_SPEC, 39 | EOS_UPDATER_ERROR_FLATPAK_REMOTE_CONFLICT, 40 | EOS_UPDATER_ERROR_METERED_CONNECTION, 41 | EOS_UPDATER_ERROR_LAST = EOS_UPDATER_ERROR_METERED_CONNECTION, /*< skip >*/ 42 | } EosUpdaterError; 43 | 44 | #define EOS_UPDATER_ERROR (eos_updater_error_quark ()) 45 | GQuark eos_updater_error_quark (void); 46 | 47 | typedef enum { 48 | EOS_UPDATER_STATE_NONE = 0, 49 | EOS_UPDATER_STATE_READY, 50 | EOS_UPDATER_STATE_ERROR, 51 | EOS_UPDATER_STATE_POLLING, 52 | EOS_UPDATER_STATE_UPDATE_AVAILABLE, 53 | EOS_UPDATER_STATE_FETCHING, 54 | EOS_UPDATER_STATE_UPDATE_READY, 55 | EOS_UPDATER_STATE_APPLYING_UPDATE, 56 | EOS_UPDATER_STATE_UPDATE_APPLIED, 57 | EOS_UPDATER_STATE_LAST = EOS_UPDATER_STATE_UPDATE_APPLIED, /*< skip > */ 58 | } EosUpdaterState; 59 | 60 | const gchar *eos_updater_state_to_string (EosUpdaterState state); 61 | 62 | /** 63 | * EosUpdaterInstallerMode: 64 | * @EU_INSTALLER_MODE_PERFORM: Actually perform actions in the installer 65 | * installing or uninstalling flatpaks as necessary, 66 | * this is the default mode. 67 | * @EU_INSTALLER_MODE_STAMP: Just update the counter files to the most 68 | * up-to-date counter for each of the auto-install 69 | * files but don't perform actions. This is typically 70 | * used by the image builder to keep the auto-install 71 | * state in sync with the installed flatpaks. 72 | * @EU_INSTALLER_MODE_CHECK: Check that flatpak ref actions up to a 73 | * certain serial number are applied on the system, 74 | * that is that all flatpaks that should have been 75 | * installed are installed and all flatpaks that 76 | * should have been uninstalled are not installed. 77 | * Note that this mode is not useful as a debugging 78 | * tool, because a user can legitimately uninstall 79 | * or install flatpaks of the same name after 80 | * an update has occurred. 81 | * 82 | * Enum values used to specify the mode that the flatpak-installer runs in. 83 | */ 84 | typedef enum { 85 | EU_INSTALLER_MODE_PERFORM = 0, 86 | EU_INSTALLER_MODE_STAMP = 1, 87 | EU_INSTALLER_MODE_CHECK = 2 88 | } EosUpdaterInstallerMode; 89 | 90 | /** 91 | * EosUpdaterInstallerFlags 92 | * @EU_INSTALLER_FLAGS_NONE: Just run the installer normally. 93 | * @EU_INSTALLER_FLAGS_ALSO_PULL: Pull flatpaks as well as deploying them. This 94 | * is not something that would run on normal 95 | * operation, rather it is a tool for developers 96 | * to keep installed flatpaks up to date with 97 | * their system without having to use the 98 | * regular updater. 99 | * 100 | * Flags to change the behaviour of the flatpak-instasller. 101 | */ 102 | typedef enum { 103 | EU_INSTALLER_FLAGS_NONE = 0, 104 | EU_INSTALLER_FLAGS_ALSO_PULL = (1 << 0) 105 | } EosUpdaterInstallerFlags; 106 | 107 | G_END_DECLS 108 | -------------------------------------------------------------------------------- /libeos-updater-util/util.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2013 Collabora Ltd. 4 | * Copyright © 2016 Kinvolk GmbH 5 | * 6 | * SPDX-License-Identifier: LGPL-2.1-or-later 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | * Authors: 23 | * - Vivek Dasmohapatra 24 | * - Krzesimir Nowak 25 | */ 26 | 27 | #pragma once 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | G_BEGIN_DECLS 34 | 35 | static inline GPtrArray * 36 | object_array_new (void) 37 | { 38 | return g_ptr_array_new_with_free_func (g_object_unref); 39 | } 40 | 41 | /* id returned by g_bus_own_name */ 42 | typedef guint EuuBusNameID; 43 | G_DEFINE_AUTO_CLEANUP_FREE_FUNC(EuuBusNameID, g_bus_unown_name, 0) 44 | 45 | const gchar *eos_updater_get_envvar_or (const gchar *envvar, 46 | const gchar *default_value); 47 | 48 | gboolean eos_updater_read_file_to_bytes (GFile *file, 49 | GCancellable *cancellable, 50 | GBytes **out_bytes, 51 | GError **error); 52 | 53 | #define EUU_TYPE_QUIT_FILE euu_quit_file_get_type () 54 | G_DECLARE_FINAL_TYPE (EuuQuitFile, euu_quit_file, EUU, QUIT_FILE, GObject) 55 | 56 | typedef enum 57 | { 58 | EUU_QUIT_FILE_QUIT, 59 | EUU_QUIT_FILE_KEEP_CHECKING 60 | } EuuQuitFileCheckResult; 61 | 62 | typedef EuuQuitFileCheckResult (* EuuQuitFileCheckCallback) (gpointer user_data); 63 | 64 | EuuQuitFile *eos_updater_setup_quit_file (const gchar *path, 65 | EuuQuitFileCheckCallback check_callback, 66 | gpointer user_data, 67 | GDestroyNotify notify, 68 | guint timeout_seconds, 69 | GError **error); 70 | 71 | typedef enum 72 | { 73 | EOS_UPDATER_FILE_FILTER_IGNORE = 0, 74 | EOS_UPDATER_FILE_FILTER_HANDLE = 1, 75 | } EosUpdaterFileFilterReturn; 76 | 77 | typedef EosUpdaterFileFilterReturn (*EosUpdaterFileFilterFunc) (GFile *file, 78 | GFileInfo *file_info); 79 | 80 | gboolean eos_updater_remove_recursive (GFile *topdir, 81 | EosUpdaterFileFilterFunc filter_func, 82 | GError **error); 83 | 84 | G_END_DECLS 85 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | project('eos-updater', 'c', 5 | version : '1.4.0', 6 | meson_version : '>= 0.60.0', 7 | license: ['LGPL-2.1-or-later'], 8 | default_options : [ 9 | 'buildtype=debugoptimized', 10 | 'warning_level=2', 11 | 'c_std=gnu11', 12 | ] 13 | ) 14 | 15 | gnome = import('gnome') 16 | cc = meson.get_compiler('c') 17 | py3_mod = import('python') 18 | py3 = py3_mod.find_installation( 19 | 'python3', 20 | ) 21 | flake8 = find_program( 22 | 'flake8', 23 | required : false, 24 | disabler : true, 25 | ) 26 | 27 | prefix = get_option('prefix') 28 | bindir = join_paths(prefix, get_option('bindir')) 29 | datadir = join_paths(prefix, get_option('datadir')) 30 | includedir = join_paths(prefix, get_option('includedir')) 31 | libdir = join_paths(prefix, get_option('libdir')) 32 | libexecdir = join_paths(prefix, get_option('libexecdir')) 33 | localstatedir = join_paths(prefix, get_option('localstatedir')) 34 | sysconfdir = join_paths(prefix, get_option('sysconfdir')) 35 | sysconfexampledir = join_paths(prefix, get_option('datadir'), 'eos-updater') 36 | 37 | dbus = dependency('dbus-1') 38 | dbusconfdir = join_paths(datadir, 'dbus-1', 'system.d') 39 | dbussystemservicedir = dbus.get_variable('system_bus_services_dir', 40 | pkgconfig_define: ['datadir', datadir]) 41 | dbusinterfacesdir = dbus.get_variable('interfaces_dir', 42 | pkgconfig_define: ['datadir', datadir]) 43 | 44 | # Common dependencies 45 | avahi_client_dep = dependency('avahi-client', version: '>= 0.6.31') 46 | avahi_glib_dep = dependency('avahi-glib', version: '>= 0.6.31') 47 | eosmetrics_dep = dependency('eosmetrics-0', required: get_option('metrics')) 48 | flatpak_dep = dependency('flatpak', version: '>= 1.1.2') 49 | glib_dep = dependency('glib-2.0', version: '>= 2.70') 50 | gio_dep = dependency('gio-2.0', version: '>= 2.62') 51 | gio_unix_dep = dependency('gio-unix-2.0', version: '>= 2.62') 52 | gobject_dep = dependency('gobject-2.0', version: '>= 2.62') 53 | json_glib_dep = dependency('json-glib-1.0', version: '>= 1.2.6') 54 | libnm_dep = dependency('libnm', version: '>= 1.2.0') 55 | libsoup_dep = dependency('libsoup-3.0', version: '>= 3.2') 56 | libsystemd_dep = dependency('libsystemd') 57 | mogwai_dep = dependency('mogwai-schedule-client-0') 58 | ostree_dep = dependency('ostree-1', version: '>= 2019.2') 59 | systemd_dep = dependency('systemd') 60 | 61 | config_h = configuration_data() 62 | config_h.set('EOS_AVAHI_PORT', get_option('server_port')) 63 | config_h.set_quoted('GETTEXT_PACKAGE', 'eos-updater') 64 | config_h.set_quoted('PACKAGE_LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir'))) 65 | config_h.set_quoted('VERSION', meson.project_version()) 66 | config_h.set('HAVE_OSTREE_COMMIT_GET_OBJECT_SIZES', cc.has_function('ostree_commit_get_object_sizes', dependencies: [ostree_dep])) 67 | config_h.set('HAS_EOSMETRICS_0', eosmetrics_dep.found()) 68 | configure_file( 69 | output: 'config.h', 70 | configuration: config_h, 71 | ) 72 | root_inc = include_directories('.') 73 | 74 | # Common compilation options 75 | add_project_arguments( 76 | [ 77 | '-DOSTREE_WITH_AUTOCLEANUPS', 78 | '-DSYSCONFDIR="@0@"'.format(sysconfdir), 79 | '-DLOCALSTATEDIR="@0@"'.format(localstatedir), 80 | '-DDATADIR="@0@"'.format(datadir), 81 | '-DPREFIX="@0@"'.format(prefix), 82 | '-DG_LOG_USE_STRUCTURED', 83 | ], 84 | language: 'c', 85 | ) 86 | 87 | # Enable warning flags 88 | test_c_args = [ 89 | '-fno-strict-aliasing', 90 | '-fstack-protector-strong', 91 | '-Waggregate-return', 92 | '-Wall', 93 | '-Wunused', 94 | '-Warray-bounds', 95 | '-Wcast-align', 96 | '-Wclobbered', 97 | '-Wconversion', 98 | '-Wno-declaration-after-statement', 99 | '-Wdiscarded-qualifiers', 100 | '-Wduplicated-branches', 101 | '-Wduplicated-cond', 102 | '-Wempty-body', 103 | '-Wformat=2', 104 | '-Wformat-nonliteral', 105 | '-Wformat-security', 106 | '-Wformat-signedness', 107 | '-Wignored-qualifiers', 108 | '-Wimplicit-function-declaration', 109 | '-Wincompatible-pointer-types', 110 | '-Wincompatible-pointer-types-discards-qualifiers', 111 | '-Winit-self', 112 | '-Wint-conversion', 113 | '-Wlogical-op', 114 | '-Wmisleading-indentation', 115 | '-Wmissing-declarations', 116 | '-Wmissing-format-attribute', 117 | '-Wmissing-include-dirs', 118 | '-Wmissing-noreturn', 119 | '-Wmissing-parameter-type', 120 | '-Wmissing-prototypes', 121 | '-Wnested-externs', 122 | '-Wno-error=cpp', 123 | '-Wmissing-field-initializers', 124 | '-Wno-suggest-attribute=format', 125 | '-Wno-unused-parameter', 126 | '-Wnull-dereference', 127 | '-Wold-style-definition', 128 | '-Woverflow', 129 | '-Woverride-init', 130 | '-Wparentheses', 131 | '-Wpointer-arith', 132 | '-Wredundant-decls', 133 | '-Wreturn-type', 134 | '-Wshadow', 135 | '-Wsign-compare', 136 | '-Wstrict-aliasing=2', 137 | '-Wstrict-prototypes', 138 | '-Wswitch-default', 139 | '-Wswitch-enum', 140 | '-Wtype-limits', 141 | '-Wundef', 142 | '-Wuninitialized', 143 | '-Wunused-but-set-variable', 144 | '-Wunused-result', 145 | '-Wunused-variable', 146 | '-Wwrite-strings' 147 | ] 148 | cc = meson.get_compiler('c') 149 | add_project_arguments(cc.get_supported_arguments(test_c_args), language: 'c') 150 | 151 | enable_installed_tests = get_option('installed_tests') 152 | installed_tests_template = files('template.test.in') 153 | test_env = [ 154 | 'G_DEBUG=gc-friendly,fatal-warnings', 155 | 'MALLOC_CHECK_=2', 156 | 'LC_ALL=C.UTF-8', 157 | ] 158 | 159 | subdir('libeos-updater-util') 160 | subdir('test-common') 161 | subdir('libeos-update-server') 162 | subdir('libeos-updater-flatpak-installer') 163 | subdir('eos-updater') 164 | subdir('eos-autoupdater') 165 | subdir('eos-update-server') 166 | subdir('eos-updater-avahi') 167 | subdir('eos-updater-test-checkpoint') 168 | subdir('eos-updater-ctl') 169 | subdir('eos-updater-flatpak-installer') 170 | subdir('eos-updater-prepare-volume') 171 | subdir('tests') 172 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | option( 5 | 'installed_tests', 6 | type: 'boolean', 7 | value: false, 8 | description: 'enable installed tests' 9 | ) 10 | option( 11 | 'metrics', 12 | type: 'feature', 13 | value: 'enabled', 14 | description: 'enable metrics support' 15 | ) 16 | option( 17 | 'server_port', 18 | type: 'integer', 19 | value: 43381, 20 | description: 'port number for the update server', 21 | ) 22 | -------------------------------------------------------------------------------- /template.test.in: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [Test] 5 | Type=session 6 | Exec=@env@@installed_tests_dir@/@program@ 7 | Output=TAP 8 | -------------------------------------------------------------------------------- /test-common/convenience.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2017 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | /* Holds the single server and client, used by the functions 32 | * below. Normally you define a variable of this type on the stack and 33 | * pass an address to it to the etc_ functions. 34 | */ 35 | typedef struct 36 | { 37 | EosUpdaterFixture *fixture; 38 | EosTestServer *server; 39 | EosTestSubserver *subserver; 40 | EosTestClient *client; 41 | GHashTable *additional_directories_for_commit; 42 | GHashTable *additional_files_for_commit; 43 | GHashTable *additional_metadata_for_commit; 44 | } EtcData; 45 | 46 | void etc_data_init (EtcData *data, 47 | EosUpdaterFixture *fixture); 48 | 49 | void etc_data_clear (EtcData *data); 50 | 51 | G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(EtcData, etc_data_clear); 52 | 53 | void etc_set_up_server (EtcData *data); 54 | 55 | void etc_set_up_client_synced_to_server (EtcData *data); 56 | 57 | void etc_update_server (EtcData *data, 58 | guint commit); 59 | 60 | void etc_update_client (EtcData *data); 61 | void etc_update_client_expect_failure (EtcData *data); 62 | void etc_update_client_with_warnings (EtcData *data, 63 | const gchar *expected_updater_warnings); 64 | 65 | void etc_delete_object (GFile *repo, 66 | const gchar *object); 67 | 68 | void etc_delete_all_client_commits (EtcData *data); 69 | 70 | G_END_DECLS 71 | -------------------------------------------------------------------------------- /test-common/flatpak-spawn.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include "spawn-utils.h" 30 | 31 | G_BEGIN_DECLS 32 | 33 | gboolean flatpak_init (GFile *updater_dir, 34 | GError **error); 35 | 36 | gboolean flatpak_remote_add (GFile *updater_dir, 37 | const gchar *repo_name, 38 | const gchar *repo_directory, 39 | GFile *gpg_key, 40 | GError **error); 41 | 42 | gboolean flatpak_install (GFile *updater_dir, 43 | const gchar *remote, 44 | const gchar *app_id, 45 | GError **error); 46 | 47 | gboolean flatpak_uninstall (GFile *updater_dir, 48 | const gchar *app_id, 49 | GError **error); 50 | 51 | gboolean flatpak_build_init (GFile *updater_dir, 52 | const gchar *bundle_path, 53 | const gchar *app_id, 54 | const gchar *runtime_name, 55 | const gchar *branch, 56 | GError **error); 57 | 58 | gboolean flatpak_build_export (GFile *updater_dir, 59 | const gchar *bundle_path, 60 | const gchar *repo_path, 61 | const gchar *branch, 62 | const gchar *collection_id, 63 | gboolean is_runtime, 64 | GFile *gpg_home_dir, 65 | const gchar *key_id, 66 | GError **error); 67 | 68 | gboolean flatpak_build_finish (GFile *updater_dir, 69 | const gchar *bundle_path, 70 | const gchar *binary, 71 | GError **error); 72 | 73 | gboolean flatpak_list (GFile *updater_dir, 74 | CmdResult *cmd, 75 | GError **error); 76 | 77 | gboolean flatpak_populate_app (GFile *updater_dir, 78 | GFile *app_directory_path, 79 | const gchar *app_name, 80 | const gchar *runtime_name, 81 | const gchar *branch, 82 | GPtrArray *extension_infos, 83 | const gchar *repo_directory, 84 | const gchar *repo_collection_id, 85 | GFile *gpg_home_dir, 86 | const gchar *keyid, 87 | GError **error); 88 | 89 | gboolean flatpak_populate_runtime (GFile *updater_dir, 90 | GFile *runtime_directory_path, 91 | const gchar *repo_directory, 92 | const gchar *name, 93 | const gchar *runtime_name, 94 | const gchar *branch, 95 | GPtrArray *extension_infos, 96 | const gchar *repo_collection_id, 97 | GFile *gpg_home_dir, 98 | const gchar *keyid, 99 | GError **error); 100 | 101 | gboolean flatpak_populate_extension (GFile *updater_dir, 102 | GFile *extension_directory, 103 | const gchar *repo_directory, 104 | const gchar *name, 105 | const gchar *runtime_name, 106 | const gchar *branch, 107 | const gchar *extension_of_ref, 108 | const gchar *repo_collection_id, 109 | GFile *gpg_homedir, 110 | const gchar *keyid, 111 | GError **error); 112 | 113 | G_END_DECLS 114 | -------------------------------------------------------------------------------- /test-common/gpg.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #ifndef GPG_BINARY 34 | #error "GPG_BINARY is not defined" 35 | #endif 36 | 37 | GFile * 38 | create_gpg_keys_directory (GFile *containing_directory, 39 | const gchar *source_gpg_home_path) 40 | { 41 | gsize i; 42 | const gchar * const gpg_home_files[] = 43 | { 44 | "C1EB8F4E.asc", 45 | "keyid", 46 | "pubring.gpg", 47 | "random_seed", 48 | "secring.gpg", 49 | }; 50 | g_autoptr(GError) error = NULL; 51 | g_autoptr(GFile) gpg_home = g_file_get_child (containing_directory, "gpghome"); 52 | 53 | g_file_make_directory (gpg_home, NULL, &error); 54 | g_assert_no_error (error); 55 | 56 | g_file_set_attribute_uint32 (gpg_home, G_FILE_ATTRIBUTE_UNIX_MODE, 57 | 0700, G_FILE_QUERY_INFO_NONE, NULL, &error); 58 | g_assert_no_error (error); 59 | 60 | /* Copy the GPG files from the source directory into the fixture directory, 61 | * as running GPG with them as its homedir might alter them; we don’t want 62 | * that to happen in the source directory, which might be read-only (and in 63 | * any case, we want determinism). */ 64 | for (i = 0; i < G_N_ELEMENTS (gpg_home_files); i++) 65 | { 66 | g_autofree gchar *source_path = NULL; 67 | g_autoptr (GFile) source = NULL, destination = NULL; 68 | 69 | source_path = g_build_filename (source_gpg_home_path, 70 | gpg_home_files[i], 71 | NULL); 72 | source = g_file_new_for_path (source_path); 73 | destination = g_file_get_child (gpg_home, gpg_home_files[i]); 74 | 75 | g_file_copy (source, destination, 76 | G_FILE_COPY_NONE, NULL, NULL, NULL, 77 | &error); 78 | g_assert_no_error (error); 79 | 80 | g_file_set_attribute_uint32 (destination, G_FILE_ATTRIBUTE_UNIX_MODE, 81 | 0600, G_FILE_QUERY_INFO_NONE, NULL, &error); 82 | g_assert_no_error (error); 83 | } 84 | 85 | return g_steal_pointer (&gpg_home); 86 | } 87 | 88 | gchar * 89 | get_keyid (GFile *gpg_home) 90 | { 91 | g_autoptr(GFile) keyid = g_file_get_child (gpg_home, "keyid"); 92 | g_autoptr(GBytes) bytes = NULL; 93 | g_autoptr(GError) error = NULL; 94 | gsize len; 95 | 96 | load_to_bytes (keyid, &bytes, &error); 97 | g_assert_no_error (error); 98 | len = g_bytes_get_size (bytes); 99 | g_assert (len == 8); 100 | 101 | return g_strndup (g_bytes_get_data (bytes, NULL), len); 102 | } 103 | 104 | void 105 | kill_gpg_agent (GFile *gpg_home) 106 | { 107 | g_autoptr(GError) error = NULL; 108 | g_autofree gchar *gpg_home_path = g_file_get_path (gpg_home); 109 | g_auto(CmdResult) cmd = CMD_RESULT_CLEARED; 110 | const gchar *argv[] = 111 | { 112 | "gpg-connect-agent", 113 | "--homedir", 114 | gpg_home_path, 115 | "killagent", 116 | "/bye", 117 | NULL 118 | }; 119 | 120 | /* kill the gpg-agent in order because if too many get spawned, it will 121 | * result in connections getting refused... */ 122 | if (!test_spawn ((const gchar * const *) argv, NULL, &cmd, &error) || 123 | !cmd_result_ensure_ok (&cmd, &error)) 124 | { 125 | g_warning ("Failed to kill gpg-agent %s: %s", gpg_home_path, 126 | error->message); 127 | g_clear_error (&error); 128 | } 129 | } 130 | 131 | GFile * 132 | get_gpg_key_file_for_keyid (GFile *gpg_home, const gchar *keyid) 133 | { 134 | g_autofree gchar *filename = g_strdup_printf ("%s.asc", keyid); 135 | 136 | return g_file_get_child (gpg_home, filename); 137 | } -------------------------------------------------------------------------------- /test-common/gpg.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | gchar *get_keyid (GFile *gpg_home); 32 | GFile * create_gpg_keys_directory (GFile *containing_directory, 33 | const gchar *source_gpg_home_path); 34 | void kill_gpg_agent (GFile *gpg_home); 35 | GFile * get_gpg_key_file_for_keyid (GFile *gpg_home, const gchar *keyid); 36 | 37 | G_END_DECLS 38 | -------------------------------------------------------------------------------- /test-common/httpd.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2023 Endless OS Foundation, LLC 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | * 02110-1301 USA 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | 27 | G_BEGIN_DECLS 28 | 29 | typedef struct _Httpd Httpd; 30 | 31 | Httpd *httpd_new (GFile *root); 32 | 33 | void httpd_free (Httpd *httpd); 34 | 35 | gboolean httpd_start (Httpd *httpd, 36 | GError **error); 37 | 38 | gboolean httpd_stop (Httpd *httpd, 39 | GError **error); 40 | 41 | const gchar *httpd_get_url (Httpd *httpd); 42 | 43 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (Httpd, httpd_free) 44 | 45 | G_END_DECLS 46 | -------------------------------------------------------------------------------- /test-common/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # Test helper library 5 | libeos_updater_test_common_sources = [ 6 | 'convenience.c', 7 | 'flatpak-spawn.c', 8 | 'gpg.c', 9 | 'httpd.c', 10 | 'misc-utils.c', 11 | 'ostree-spawn.c', 12 | 'spawn-utils.c', 13 | 'utils.c', 14 | ] 15 | 16 | libeos_updater_test_common_headers = [ 17 | 'convenience.h', 18 | 'flatpak-spawn.h', 19 | 'gpg.h', 20 | 'httpd.h', 21 | 'misc-utils.h', 22 | 'ostree-spawn.h', 23 | 'spawn-utils.h', 24 | 'utils.h', 25 | ] 26 | 27 | libeos_updater_test_common_cppflags = [ 28 | '-DFLATPAK_BINARY="@0@"'.format(find_program('flatpak').full_path()), 29 | '-DG_LOG_DOMAIN="eos-updater-test-common"', 30 | '-DGPG_BINARY="@0@"'.format(find_program('gpg').full_path()), 31 | '-DOSTREE_BINARY="@0@"'.format(find_program('ostree').full_path()), 32 | '-DOSTREE_WITH_AUTOCLEANUPS', 33 | ] 34 | 35 | libeos_updater_test_common_deps = [ 36 | gio_dep, 37 | gio_unix_dep, 38 | glib_dep, 39 | gobject_dep, 40 | libsoup_dep, 41 | ostree_dep, 42 | libeos_updater_util_dep, 43 | ] 44 | 45 | libeos_updater_test_common = static_library('eos-updater-test-common', 46 | libeos_updater_test_common_sources + libeos_updater_test_common_headers, 47 | c_args: libeos_updater_test_common_cppflags, 48 | dependencies: libeos_updater_test_common_deps, 49 | include_directories: root_inc, 50 | install: false, 51 | ) 52 | libeos_updater_test_common_dep = declare_dependency( 53 | link_with: libeos_updater_test_common, 54 | include_directories: root_inc, 55 | sources: libeos_updater_test_common_headers, 56 | ) 57 | -------------------------------------------------------------------------------- /test-common/misc-utils.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | static inline GPtrArray * 32 | string_array_new (void) 33 | { 34 | return g_ptr_array_new_with_free_func (g_free); 35 | } 36 | 37 | gboolean load_to_bytes (GFile *file, 38 | GBytes **bytes, 39 | GError **error); 40 | 41 | gboolean create_file (GFile *path, 42 | GBytes* bytes, 43 | GError **error); 44 | 45 | gboolean create_directory (GFile *path, 46 | GError **error); 47 | 48 | gboolean create_symlink (const gchar *target, 49 | GFile *link, 50 | GError **error); 51 | 52 | gboolean load_key_file (GFile *file, 53 | GKeyFile **out_keyfile, 54 | GError **error); 55 | 56 | gboolean save_key_file (GFile *file, 57 | GKeyFile *keyfile, 58 | GError **error); 59 | 60 | GDateTime *days_ago (guint days); 61 | 62 | gboolean input_stream_to_string (GInputStream *stream, 63 | gchar **out_str, 64 | GError **error); 65 | 66 | gboolean cp (GFile *source, 67 | GFile *target, 68 | GError **error); 69 | 70 | gboolean read_port_file (GFile *port_file, 71 | guint16 *out_port, 72 | GError **error); 73 | 74 | G_END_DECLS 75 | -------------------------------------------------------------------------------- /test-common/spawn-utils.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2016 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | G_BEGIN_DECLS 30 | 31 | typedef struct 32 | { 33 | gchar *cmdline; 34 | gchar *standard_output; 35 | gchar *standard_error; 36 | gint wait_status; 37 | } CmdResult; 38 | 39 | #define CMD_RESULT_CLEARED { NULL, NULL, NULL, 0 } 40 | 41 | void cmd_result_clear (CmdResult *cmd); 42 | void cmd_result_free (CmdResult *cmd); 43 | 44 | G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (CmdResult, cmd_result_clear) 45 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (CmdResult, cmd_result_free) 46 | 47 | gboolean cmd_result_ensure_ok (CmdResult *cmd, 48 | GError **error); 49 | 50 | gboolean cmd_result_ensure_ok_verbose (CmdResult *cmd); 51 | 52 | gboolean cmd_result_ensure_all_ok_verbose (GPtrArray *cmds); 53 | 54 | void cmd_results_allow_failure_verbose (GPtrArray *cmds); 55 | 56 | gchar *cmd_result_dump (CmdResult *cmd); 57 | 58 | typedef struct 59 | { 60 | gchar *cmdline; 61 | GOutputStream *in_stream; 62 | GInputStream *out_stream; 63 | GInputStream *err_stream; 64 | GPid pid; 65 | } CmdAsyncResult; 66 | 67 | #define CMD_ASYNC_RESULT_CLEARED { NULL, NULL, NULL, NULL, 0 } 68 | 69 | void cmd_async_result_clear (CmdAsyncResult *cmd); 70 | void cmd_async_result_free (CmdAsyncResult *cmd); 71 | 72 | G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (CmdAsyncResult, cmd_async_result_clear) 73 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (CmdAsyncResult, cmd_async_result_free) 74 | 75 | gboolean test_spawn_cwd_async (const gchar *cwd, 76 | const gchar * const *argv, 77 | const gchar * const *envp, 78 | gboolean autoreap, 79 | CmdAsyncResult *cmd, 80 | GError **error); 81 | 82 | gboolean test_spawn_async (const gchar * const *argv, 83 | const gchar * const *envp, 84 | gboolean autoreap, 85 | CmdAsyncResult *cmd, 86 | GError **error); 87 | 88 | gboolean test_spawn_cwd_full (const gchar *cwd, 89 | const gchar * const *argv, 90 | const gchar * const *envp, 91 | gboolean to_dev_null, 92 | CmdResult *cmd, 93 | GError **error); 94 | 95 | gboolean test_spawn_cwd (const gchar *cwd, 96 | const gchar * const *argv, 97 | const gchar * const *envp, 98 | CmdResult *cmd, 99 | GError **error); 100 | 101 | gboolean test_spawn (const gchar * const *argv, 102 | const gchar * const *envp, 103 | CmdResult *cmd, 104 | GError **error); 105 | 106 | gchar **merge_parent_and_child_env (const gchar * const *child_env); 107 | 108 | static inline gchar * 109 | flag (const gchar *name, 110 | const gchar *value) 111 | { 112 | return g_strdup_printf ("--%s=%s", name, value); 113 | } 114 | 115 | static inline gchar * 116 | envvar (const gchar *key, 117 | const gchar *value) 118 | { 119 | return g_strdup_printf ("%s=%s", key, value); 120 | } 121 | 122 | gboolean reap_async_cmd (CmdAsyncResult *cmd, 123 | CmdResult *reaped, 124 | GError **error); 125 | 126 | typedef struct 127 | { 128 | const gchar *flag_name; 129 | const gchar *value; 130 | } CmdArg; 131 | 132 | static inline GArray * 133 | cmd_arg_array_new (void) 134 | { 135 | return g_array_new (/* zero-terminated: */ FALSE, 136 | /* cleared: */ FALSE, 137 | sizeof (CmdArg)); 138 | } 139 | 140 | static inline CmdArg * 141 | cmd_arg_array_raw (GArray *cmd_arg_array) 142 | { 143 | /* void* cast needed to avoid -Wcast-align. The allocation should be 144 | * sizeof(CmdArg)-aligned as per cmd_arg_array_new(). */ 145 | return (CmdArg *) ((void *) cmd_arg_array->data); 146 | } 147 | 148 | gchar ** 149 | build_cmd_args (CmdArg *args); 150 | 151 | typedef struct 152 | { 153 | const gchar *name; 154 | /* only one of those should be set */ 155 | const gchar *raw_value; 156 | GFile *file_value; 157 | } CmdEnvVar; 158 | 159 | gchar ** 160 | build_cmd_env (CmdEnvVar *vars); 161 | 162 | G_END_DECLS 163 | -------------------------------------------------------------------------------- /tests/eos-update-server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright © 2017 Endless Mobile, Inc. 5 | # 6 | # SPDX-License-Identifier: LGPL-2.1-or-later 7 | # 8 | # This library is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU Lesser General Public 10 | # License as published by the Free Software Foundation; either 11 | # version 2.1 of the License, or (at your option) any later version. 12 | # 13 | # This library is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | # Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public 19 | # License along with this library; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 | 22 | """Integration tests for eos-update-server.""" 23 | 24 | import os 25 | import subprocess 26 | import tempfile 27 | import time 28 | import unittest 29 | 30 | import taptestrunner 31 | 32 | 33 | class TestEosUpdateServer(unittest.TestCase): 34 | """Integration test for eos-update-server. 35 | 36 | It can only be run when installed, due to requiring all the systemd unit 37 | files to be in place. 38 | 39 | It must be run as root in order to be able to modify all the files it needs 40 | to touch. 41 | """ 42 | 43 | def setUp(self): 44 | self.timeout_seconds = 10 # seconds per test 45 | self.__config_file = '/etc/eos-updater/eos-update-server.conf' 46 | self.__eos_update_server = \ 47 | os.path.join('/', 'usr', 'libexec', 'eos-update-server') 48 | 49 | def tearDown(self): 50 | try: 51 | os.unlink(self.__config_file) 52 | except OSError: 53 | pass 54 | 55 | # Explicitly stop the service so it isn’t running when the next test 56 | # starts, which could confuse things. 57 | subprocess.check_call(['systemctl', 'stop', '--quiet', 58 | 'eos-update-server.service']) 59 | 60 | # And wait for a second to avoid triggering systemd’s rate limiting 61 | # for start requests. 62 | time.sleep(1) 63 | 64 | @unittest.skipIf(os.geteuid() != 0, "Must be run as root") 65 | def test_enable_via_configuration_file(self): 66 | """Test enabling the configuration file allows the server to run.""" 67 | os.makedirs('/etc/eos-updater/', mode=0o755, exist_ok=True) 68 | with open(self.__config_file, 'w') as conf_file: 69 | conf_file.write( 70 | '[Local Network Updates]\n' 71 | 'AdvertiseUpdates=true\n' 72 | ) 73 | 74 | # Pass --port-file to force the server to open a local port rather 75 | # than expecting a socket from systemd. 76 | port_file = tempfile.NamedTemporaryFile( 77 | prefix='eos-update-server-test') 78 | status = subprocess.call([self.__eos_update_server, 79 | '--port-file=' + port_file.name, 80 | '--timeout=1']) 81 | self.assertEqual(status, 0) 82 | 83 | @unittest.skipIf(os.geteuid() != 0, "Must be run as root") 84 | def test_disable_via_configuration_file(self): 85 | """ 86 | Test disabling the configuration file causes the server to not start. 87 | """ 88 | os.makedirs('/etc/eos-updater/', mode=0o755, exist_ok=True) 89 | with open(self.__config_file, 'w') as conf_file: 90 | conf_file.write( 91 | '[Local Network Updates]\n' 92 | 'AdvertiseUpdates=false\n' 93 | ) 94 | 95 | status = subprocess.call([self.__eos_update_server, 96 | '--timeout=1']) 97 | self.assertEqual(status, 4) # EXIT_DISABLED 98 | 99 | @unittest.skipIf(os.geteuid() != 0, "Must be run as root") 100 | @unittest.expectedFailure 101 | def test_disable_via_configuration_file_at_runtime(self): 102 | """ 103 | Test disabling the configuration file at runtime causes the server to 104 | quit. 105 | 106 | FIXME: This is expected to fail until the server is modified to monitor 107 | its config file. 108 | """ 109 | os.makedirs('/etc/eos-updater/', mode=0o755, exist_ok=True) 110 | with open(self.__config_file, 'w') as conf_file: 111 | conf_file.write( 112 | '[Local Network Updates]\n' 113 | 'AdvertiseUpdates=true\n' 114 | ) 115 | 116 | # Pass --port-file to force the server to open a local port rather 117 | # than expecting a socket from systemd. 118 | port_file = tempfile.NamedTemporaryFile( 119 | prefix='eos-update-server-test') 120 | proc = subprocess.Popen([self.__eos_update_server, 121 | '--port-file=' + port_file.name, 122 | '--timeout=' + str(self.timeout_seconds)]) 123 | 124 | # Give it a bit of time to start up (this is technically racy) 125 | time.sleep(2) 126 | 127 | with open(self.__config_file, 'w') as conf_file: 128 | conf_file.write( 129 | '[Local Network Updates]\n' 130 | 'AdvertiseUpdates=false\n' 131 | ) 132 | 133 | proc.wait(timeout=self.timeout_seconds) 134 | self.assertEqual(proc.returncode, 4) # EXIT_DISABLED 135 | 136 | 137 | if __name__ == '__main__': 138 | unittest.main(testRunner=taptestrunner.TAPTestRunner()) 139 | -------------------------------------------------------------------------------- /tests/gpghome/C1EB8F4E.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v1 3 | 4 | mQENBFdQTHYBCADd0d6uPOi/gxIY2V9VSGNWW8w/ecNW1oxMnkOxtCiOABw0LQ+q 5 | InQxhoDQJ1i4QRmEvdJFlGmX4QAkQhWwZHHi9lJOL3WK2k+1gtoEoH4Y3Lvs84o/ 6 | KtcpLr0yrUQj1ItXD39gDnWRrmbsV0F98mk/BZWzWd2nj3SK2VS0Dek5xPz/Hy0i 7 | 5JtxloDUTBL0P1J4JmpHZlSvhOX2HSymKPTQe12VZcEcjSUwiyJQpLYdenVMElS5 8 | 1FDDKjAtNNSSDRBLxU2tvnabZMeIUoxl2VNvazzqDNWq0GcAeyaOJ1hYlt42FvXc 9 | 1eaCwoUjtXFTybIOwqAuDUyb3O/EUU1LfkFpABEBAAG0RVVwZGF0ZXIgVGVzdCAo 10 | S2V5IGZvciB0ZXN0aW5nIGVvcy11cGRhdGVyKSA8dXBkYXRlci10ZXN0QGV4YW1w 11 | bGUuY29tPokBOAQTAQIAIgUCV1BMdgIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgEC 12 | F4AACgkQXX542MHrj04cggf/ca+vgndrrKwNXyWarZwTFJ+enL9kTLtvbYUlZ1Lj 13 | KSt1QbJFOim1GIQdN1yu/jWEVrKQ9rLWjecTDiD6wvpe+giCQ955w2J4zPTyqIBc 14 | kmHHZ25uHUAFv08z11hhBP3H0QXeCbZPk530w6cyvavyMLwT7T/vITyiwfNJeeGH 15 | Y5D3XHhBt0ZKvcuFj4XnMY6YphgkFYMAksgPE5YwMNRceTkxBGp9ySQYSLSZNp8f 16 | EX2vl2vN8gLNqswxbne8n67WqxBHdZU7Ttx7zc7C/m2J/uoa+csZDV4C1hvT6m6G 17 | 7ggEHbSWm2C3dSDiFUUE3bSpN9AiBFMkXs+NFPdSf3NOT7kBDQRXUEx2AQgApOWc 18 | GlyQN9Wi50aL9BwXigke2fTukOj27i328UVdz/KKX/MbEITYsapwlBsvfRoD6ZLk 19 | 9eHmYXrj0bhjrEWLE75PLGpcAyi1G6vckvPX7G9aDPxRC7fy59ukO7hFar15PrRi 20 | u2HHy7baFkm18+3/fYG9UG93qWTHp68jUJ6cGxaAkkSo89S0R06gf5kMlWNTPDji 21 | jtIqwkDa7FbR5RYAfpP7ZQmyD5j7yCNs5ezRCrmGZXNC8aYun+EL62N+etAjzZ/5 22 | DOl3OFVb14by4JcWgHNpF9Kf5SRxeudEdzMQF1XOAnfO27DQRQUPbi8uNT/zYeTd 23 | /1/wVIA4zHPekdOJCQARAQABiQEfBBgBAgAJBQJXUEx2AhsMAAoJEF1+eNjB649O 24 | R4UIAJYRh5TMYE3fQZoMSPK4QChNl8X1LtqOyqTWnnHI+FtDS/6aUAQgLmxASYup 25 | UasAO8ZMHpqazhfEY+gHyjPvZpV7cbd9QTu7JPhSo4DuG+W8MOgUNvuG5Tyw0wgP 26 | 5QU0LqcDUOryQkhExJzuoSph0M8ykPzwpmduA+w7xjXGiuc/sftCDh7+GO029ssG 27 | bEK042nATkErfHt8PXyWeL/FP7fhXI+ydqzBf7QPVOq9jKhZFjFcvK5afJqYssT8 28 | EYbD/uT8ETRaNf7cU8Z/KrLNxqdROvvSLdPhJ6veuoCC1L9MiEK6LeSkH+7Y8OWm 29 | AQ5hrRQ8ma+dv9lxe3EXR6jL5hQ= 30 | =VyKx 31 | -----END PGP PUBLIC KEY BLOCK----- 32 | -------------------------------------------------------------------------------- /tests/gpghome/keyid: -------------------------------------------------------------------------------- 1 | C1EB8F4E -------------------------------------------------------------------------------- /tests/gpghome/pubring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/endlessm/eos-updater/ab693943203082ab01adc68751ca91c38c7c3233/tests/gpghome/pubring.gpg -------------------------------------------------------------------------------- /tests/gpghome/random_seed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/endlessm/eos-updater/ab693943203082ab01adc68751ca91c38c7c3233/tests/gpghome/random_seed -------------------------------------------------------------------------------- /tests/gpghome/secring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/endlessm/eos-updater/ab693943203082ab01adc68751ca91c38c7c3233/tests/gpghome/secring.gpg -------------------------------------------------------------------------------- /tests/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | deps = [ 5 | gio_dep, 6 | glib_dep, 7 | gobject_dep, 8 | ostree_dep, 9 | libeos_updater_test_common_dep, 10 | libeos_updater_util_dep, 11 | ] 12 | 13 | c_args = [ 14 | '-DG_LOG_DOMAIN="eos-updater-tests"', 15 | ] 16 | 17 | envs = test_env + [ 18 | 'G_TEST_SRCDIR=' + meson.current_source_dir(), 19 | 'G_TEST_BUILDDIR=' + meson.current_build_dir(), 20 | 'OSTREE_SYSROOT_DEBUG=mutable-deployments', 21 | ] 22 | 23 | # FIXME: Ensure these tests can be run installed as well. 24 | # FIXME: None of them support running in parallel due to shared server resources; fix that. 25 | test_programs = { 26 | 'test-update-from-main': { 27 | 'install': false, 28 | 'parallel': false, 29 | }, 30 | 'test-update-from-lan': { 31 | 'install': false, 32 | 'parallel': false, 33 | }, 34 | 'test-update-from-volume': { 35 | 'install': false, 36 | 'parallel': false, 37 | }, 38 | 'test-update-cleanup-workaround': { 39 | 'install': false, 40 | 'parallel': false, 41 | }, 42 | 'test-update-broken-delta': { 43 | 'install': false, 44 | 'parallel': false, 45 | }, 46 | 'test-update-install-flatpaks': { 47 | 'install': false, 48 | 'parallel': false, 49 | 'slow': true, 50 | 'dependencies': [ 51 | flatpak_dep, 52 | json_glib_dep, 53 | ], 54 | }, 55 | 'test-update-missing-deployed-commit': { 56 | 'install': false, 57 | 'parallel': false, 58 | }, 59 | 'test-update-refspec-checkpoint': { 60 | 'install': false, 61 | 'parallel': false, 62 | 'slow': true, 63 | }, 64 | 'test-update-refspec-endoflife': { 65 | 'install': false, 66 | 'parallel': false, 67 | }, 68 | 'test-update-direct': { 69 | 'install': false, 70 | 'parallel': false, 71 | 'dependencies': [ 72 | libeos_updater_dbus_dep, 73 | ], 74 | }, 75 | 'test-autoupdater': { 76 | 'install': false, 77 | 'parallel': false, 78 | }, 79 | } 80 | 81 | installed_tests_metadir = join_paths(datadir, 'installed-tests', 82 | 'eos-updater-' + eu_api_version) 83 | installed_tests_execdir = join_paths(libexecdir, 'installed-tests', 84 | 'eos-updater-' + eu_api_version) 85 | 86 | foreach test_name, extra_args : test_programs 87 | source = extra_args.get('source', test_name + '.c') 88 | install = enable_installed_tests and extra_args.get('install', true) 89 | 90 | if install 91 | test_conf = configuration_data() 92 | test_conf.set('installed_tests_dir', installed_tests_execdir) 93 | test_conf.set('program', test_name) 94 | test_conf.set('env', '') 95 | configure_file( 96 | input: installed_tests_template, 97 | output: test_name + '.test', 98 | install_dir: installed_tests_metadir, 99 | configuration: test_conf, 100 | ) 101 | endif 102 | 103 | exe = executable(test_name, source, 104 | c_args : c_args + extra_args.get('c_args', []), 105 | link_args : extra_args.get('link_args', []), 106 | dependencies : deps + extra_args.get('dependencies', []), 107 | install_dir: installed_tests_execdir, 108 | install: install, 109 | ) 110 | 111 | test( 112 | test_name, 113 | exe, 114 | env: envs, 115 | suite: ['eos-updater'] + extra_args.get('suite', []), 116 | timeout: extra_args.get('slow', false) ? 600 : 60, 117 | is_parallel: extra_args.get('parallel', true), 118 | protocol: 'tap', 119 | ) 120 | endforeach 121 | 122 | python_tests = { 123 | 'eos-updater-avahi.py': { 124 | 'installed_only': true, 125 | }, 126 | 'eos-update-server.py': { 127 | 'installed_only': true, 128 | }, 129 | } 130 | 131 | foreach test_name, extra_args : python_tests 132 | install = enable_installed_tests and extra_args.get('install', true) 133 | 134 | if install 135 | test_conf = configuration_data() 136 | test_conf.set('installed_tests_dir', installed_tests_execdir) 137 | test_conf.set('program', test_name) 138 | test_conf.set('env', '') 139 | configure_file( 140 | input: installed_tests_template, 141 | output: test_name + '.test', 142 | install_dir: installed_tests_metadir, 143 | configuration: test_conf, 144 | ) 145 | endif 146 | 147 | main = files(test_name) 148 | if install 149 | install_data( 150 | main, 151 | files('taptestrunner.py'), 152 | install_dir: installed_tests_execdir, 153 | install_mode: 'rwxr-xr-x', 154 | ) 155 | endif 156 | 157 | if not extra_args.get('installed_only', false) 158 | test( 159 | test_name, 160 | py3, 161 | args: main, 162 | env: envs, 163 | suite: ['eos-updater'] + extra_args.get('suite', []), 164 | protocol: 'tap', 165 | ) 166 | endif 167 | endforeach 168 | 169 | reuse = find_program('reuse', required: false, disabler: true) 170 | test( 171 | 'reuse', 172 | reuse, 173 | args: ['lint'], 174 | protocol: 'exitcode', 175 | suite: 'eos-updater', 176 | workdir: meson.project_source_root(), 177 | ) 178 | 179 | subdir('services') 180 | -------------------------------------------------------------------------------- /tests/services/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Endless OS Foundation, LLC 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | # Service file used for some tests 5 | config = configuration_data() 6 | config.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir'))) 7 | 8 | configure_file( 9 | input: 'org.freedesktop.Flatpak.SystemHelper.service.in', 10 | output: 'org.freedesktop.Flatpak.SystemHelper.service', 11 | install: false, 12 | configuration: config, 13 | ) 14 | -------------------------------------------------------------------------------- /tests/services/org.freedesktop.Flatpak.SystemHelper.service.in: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Endless Mobile, Inc. 2 | # SPDX-License-Identifier: LGPL-2.1-or-later 3 | 4 | [D-BUS Service] 5 | Name=org.freedesktop.Flatpak.SystemHelper 6 | # The --session is there so this can be started on the mock session bus 7 | Exec=@libexecdir@/flatpak-system-helper --session --no-idle-exit 8 | SystemdService=flatpak-system-helper.service 9 | User=root 10 | -------------------------------------------------------------------------------- /tests/test-update-broken-delta.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2017 Kinvolk GmbH 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Krzesimir Nowak 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | /* Finds the big file in the deployment to figure out its checksum, so 36 | * it can then remove it from client's repository. 37 | */ 38 | static void 39 | delete_big_file_object_from_client_repo (EtcData *data) 40 | { 41 | const gchar *bigfile_path = eos_test_client_get_big_file_path (); 42 | const gchar *paths[] = 43 | { 44 | bigfile_path, 45 | NULL 46 | }; 47 | g_autoptr(GFile) client_repo = NULL; 48 | OstreeLsFlags flags = OSTREE_LS_CHECKSUM; 49 | g_auto(CmdResult) listed = CMD_RESULT_CLEARED; 50 | g_autoptr(GError) error = NULL; 51 | g_autofree gchar *escaped_bigfile_path = NULL; 52 | g_autofree gchar *regex = NULL; 53 | g_autoptr(GRegex) gregex = NULL; 54 | gboolean matched; 55 | g_autoptr(GMatchInfo) match_info = NULL; 56 | g_autofree gchar *checksum = NULL; 57 | g_autofree gchar *object = NULL; 58 | 59 | g_assert_nonnull (data); 60 | g_assert_nonnull (data->client); 61 | 62 | client_repo = eos_test_client_get_repo (data->client); 63 | ostree_ls (client_repo, 64 | flags, 65 | default_ref, 66 | paths, 67 | &listed, 68 | &error); 69 | g_assert_no_error (error); 70 | g_assert_true (cmd_result_ensure_ok_verbose (&listed)); 71 | 72 | escaped_bigfile_path = g_regex_escape_string (bigfile_path, -1); 73 | regex = g_strdup_printf ("\\s+([0-9a-zA-Z]{64})\\s+%s", escaped_bigfile_path); 74 | gregex = g_regex_new (regex, 75 | /* compile flags: */ 0, 76 | /* match flags: */ 0, 77 | &error); 78 | g_assert_no_error (error); 79 | matched = g_regex_match (gregex, 80 | listed.standard_output, 81 | /* match flags: */ 0, 82 | &match_info); 83 | g_assert_true (matched); 84 | checksum = g_match_info_fetch (match_info, 85 | /* match group: */ 1); 86 | object = g_strdup_printf ("%s.file", checksum); 87 | etc_delete_object (client_repo, object); 88 | } 89 | 90 | /* Corrupt a repository on the client side, so that using static delta 91 | * files is impossible and make sure that eos-updater can cope with 92 | * it. 93 | */ 94 | static void 95 | test_update_broken_delta (EosUpdaterFixture *fixture, 96 | gconstpointer user_data) 97 | { 98 | g_auto(EtcData) real_data = { NULL, }; 99 | EtcData *data = &real_data; 100 | 101 | g_test_bug ("T17183"); 102 | 103 | etc_data_init (data, fixture); 104 | /* Create and set up the server with the commit 0. 105 | */ 106 | etc_set_up_server (data); 107 | /* Create and set up the client, that pulls the update from the 108 | * server, so it should have also a commit 0 and a deployment based 109 | * on this commit. 110 | */ 111 | etc_set_up_client_synced_to_server (data); 112 | /* Update the server, so it has a new commit (1), and the delta 113 | * files between commits 0 and 1. 114 | */ 115 | etc_update_server (data, 1); 116 | /* Delete an object in repository objects directory which serves as 117 | * a base for generating a new version of the object with the static 118 | * delta files. 119 | */ 120 | delete_big_file_object_from_client_repo (data); 121 | /* Try to update the client - during the "fetch" step, it should 122 | * fallback to fetching objects instead of using delta files. 123 | */ 124 | etc_update_client (data); 125 | } 126 | 127 | int 128 | main (int argc, 129 | char **argv) 130 | { 131 | setlocale (LC_ALL, ""); 132 | 133 | g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL); 134 | g_test_bug_base ("https://phabricator.endlessm.com/"); 135 | 136 | eos_test_add ("/updater/update-cleanup-broken-delta", NULL, test_update_broken_delta); 137 | 138 | return g_test_run (); 139 | } 140 | -------------------------------------------------------------------------------- /tests/test-update-missing-deployed-commit.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- 2 | * 3 | * Copyright © 2018 Endless Mobile, Inc. 4 | * 5 | * SPDX-License-Identifier: LGPL-2.1-or-later 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | * 21 | * Authors: 22 | * - Philip Withnall 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | /* Delete the commit object representing the currently deployed commit, and try 32 | * to do an update. The update should succeed (but should warn about the missing 33 | * commit object). */ 34 | static void 35 | test_update_missing_deployed_commit (EosUpdaterFixture *fixture, 36 | gconstpointer user_data) 37 | { 38 | g_auto(EtcData) real_data = { NULL, }; 39 | EtcData *data = &real_data; 40 | 41 | g_test_bug ("T22805"); 42 | 43 | etc_data_init (data, fixture); 44 | /* Create and set up the server with the commit 0. 45 | */ 46 | etc_set_up_server (data); 47 | /* Create and set up the client, that pulls the update from the 48 | * server, so it should have also a commit 0 and a deployment based 49 | * on this commit. 50 | */ 51 | etc_set_up_client_synced_to_server (data); 52 | /* Update the server, so it has a new commit (1), and the delta 53 | * files between commits 0 and 1. 54 | */ 55 | etc_update_server (data, 1); 56 | /* Delete the currently deployed commit object (and all other commit objects) 57 | * from the client. 58 | */ 59 | etc_delete_all_client_commits (data); 60 | /* Try to update the client. It should succeed, but should warn about the 61 | * currently deployed commit being missing. 62 | */ 63 | etc_update_client_with_warnings (data, 64 | "Error loading current commit ‘*’ to check " 65 | "if ‘*’ is an update (assuming it is): No " 66 | "such metadata object *.commit"); 67 | } 68 | 69 | int 70 | main (int argc, 71 | char **argv) 72 | { 73 | setlocale (LC_ALL, ""); 74 | 75 | g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL); 76 | g_test_bug_base ("https://phabricator.endlessm.com/"); 77 | 78 | eos_test_add ("/updater/update-missing-deployed-commit", NULL, 79 | test_update_missing_deployed_commit); 80 | 81 | return g_test_run (); 82 | } 83 | --------------------------------------------------------------------------------