Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System upgrade #153

Draft
wants to merge 27 commits into
base: horus
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
63ebac5
Add helper script and policy file
meisenzahl Jan 29, 2022
fc19871
Implement offline upgrade
meisenzahl Jan 29, 2022
60c7047
Fix PolicyKit action
meisenzahl Jan 29, 2022
9ed5376
Fix helper script
meisenzahl Jan 29, 2022
2030370
Fix typo
meisenzahl Jan 29, 2022
9084bdc
Add repositories for focal
meisenzahl Jan 30, 2022
0ceb038
Revert "Add repositories for focal"
meisenzahl Jan 30, 2022
44207a5
GitHub CI: Install dependencies
meisenzahl Jan 30, 2022
e0659cf
SystemUpgrade: inhibit during update
meisenzahl Feb 1, 2022
9f3165e
Application: Satisfy linter
meisenzahl Feb 1, 2022
93180c0
GitHub CI: Remove meson destdir
meisenzahl Feb 1, 2022
89c32a6
SystemUpgrade: Handle errors
meisenzahl Feb 6, 2022
ab93333
SystemUpgrade: Implement cancel method
meisenzahl Feb 6, 2022
1c8dd84
Add option to cancel upgrade
meisenzahl Feb 24, 2022
e33b62f
Merge branch 'master' into offline-system-upgrades
meisenzahl Oct 30, 2022
8818e44
Merge branch 'master' into offline-system-upgrades
meisenzahl Dec 24, 2022
83b5ac7
Update sources to stable
meisenzahl Dec 25, 2022
41194dd
Disable user interaction during offline upgrade
meisenzahl Jan 30, 2023
038677b
Revert "Disable user interaction during offline upgrade"
meisenzahl Jan 30, 2023
3f83fa9
Update helper
lenemter Jul 11, 2024
4462d80
Bruh
lenemter Jul 11, 2024
4222ffc
Remove unneded files
lenemter Jul 11, 2024
3215c51
More helper removals
lenemter Jul 11, 2024
c453e2b
Rewrite for OS 8
lenemter Jul 12, 2024
f09efc3
Merge branch 'horus' into lenemter/system-upgrade
lenemter Jul 12, 2024
cfa6dba
Fix lint
lenemter Jul 12, 2024
38b417e
Merge branch 'lenemter/system-upgrade' of https://github.com/elementa…
lenemter Jul 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y libaccountsservice-dev libdbus-1-dev libgranite-dev libgeoclue-2-dev libfwupd-dev meson valac
apt install -y libaccountsservice-dev libdbus-1-dev libfwupd-dev libgranite-dev libgeoclue-2-dev libpackagekit-glib2-dev libpolkit-gobject-1-dev meson valac
- name: Build
env:
DESTDIR: out
run: |
meson build
ninja -C build
Expand Down
20 changes: 20 additions & 0 deletions data/io.elementary.settings-daemon.policy.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>elementary</vendor>
<vendor_url>https://elementary.io/</vendor_url>

<action id="io.elementary.settings-daemon.system-upgrade">
<message gettext-domain="@GETTEXT_PACKAGE@">Authentication is required to upgrade elementary OS</message>
<icon_name>system-os-installer</icon_name>
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">@PKGDATADIR@/io.elementary.settings-daemon.system-upgrade.helper</annotate>
</action>

</policyconfig>
53 changes: 53 additions & 0 deletions data/io.elementary.settings-daemon.system-upgrade.helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
import argparse
import os
import re


def update_third_party_repository(current, next, repository_file):
r = re.compile("[deb|deb-src].* ({}).*$".format(current))

if os.path.isfile(repository_file):
should_update = False
with open(repository_file) as f:
content = []
for line in f.read().split("\n"):
if r.match(line):
should_update = True
line = line.replace(current, next)

if "ppa.launchpad.net/elementary-os" in line:
# FIXME: Remove this when OS 8 stable repo is ready
line = line.replace("/stable/", "/daily/")

content.append(line)

if should_update:
with open(repository_file, "w") as f:
f.write("\n".join(content))


def install_network_manager_config():
with open("/etc/NetworkManager/conf.d/10-globally-managed-devices.conf", "w+") as f:
pass

def main():
parser = argparse.ArgumentParser(description="Helper to upgrade elementary OS")

parser.add_argument("--update-third-party-repository", action="store_true")
parser.add_argument("--install-network-manager-config", action="store_true")

parser.add_argument("--current", nargs="?", default=None)
parser.add_argument("--next", nargs="?", default=None)
parser.add_argument("--repository-file", nargs="?", default=None)

args = parser.parse_args()

if args.update_third_party_repository and args.current and args.next and args.repository_file:
return update_third_party_repository(args.current, args.next, args.repository_file)
elif args.install_network_manager_config:
return install_network_manager_config()


if __name__ == "__main__":
main()
24 changes: 24 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ i18n.merge_file(
install_dir: get_option('datadir') / 'metainfo',
)

conf = configuration_data()
conf.set('PKGDATADIR', pkgdatadir)
conf.set('GETTEXT_PACKAGE', meson.project_name())

gettext_declaration = configure_file(
configuration: conf,
input: meson.project_name() + '.policy.in',
output: meson.project_name() + '.policy.in'
)

i18n.merge_file(
input: gettext_declaration,
output: meson.project_name() + '.policy',
po_dir: join_paths(meson.source_root(), 'po'),
install: true,
install_dir: polkit_actiondir
)

install_data(
meson.project_name() + '.system-upgrade.helper',
install_mode: 'r-xr--r--',
install_dir: pkgdatadir
)
busctl_path = get_option('busctlpath')
systemd_system_unit_dir = get_option('systemdsystemunitdir')

Expand Down Expand Up @@ -84,3 +107,4 @@ foreach i : icon_sizes
rename: meson.project_name() + '.svg'
)
endforeach

14 changes: 14 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ project('io.elementary.settings-daemon',
meson_version: '>=0.58.0'
)

add_project_arguments(
'-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE',
language:'c'
)

prefix = get_option('prefix')
datadir = join_paths(prefix, get_option('datadir'))
pkgdatadir = join_paths(datadir, meson.project_name())

fwupd_dep = dependency('fwupd')
gio_dep = dependency ('gio-2.0')
glib_dep = dependency('glib-2.0')
Expand All @@ -27,6 +36,11 @@ add_global_arguments(
cc = meson.get_compiler('c')
m_dep = cc.find_library('m', required : false)
libgeoclue_dep = dependency ('libgeoclue-2.0')
packagekit_dep = dependency('packagekit-glib2')
polkit_dep = dependency('polkit-gobject-1')
posix_dep = meson.get_compiler('vala').find_library('posix')

polkit_actiondir = polkit_dep.get_pkgconfig_variable('actiondir', define_variable: ['prefix', prefix])

prefix = get_option('prefix')
datadir = prefix / get_option('datadir')
Expand Down
3 changes: 2 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
data/io.elementary.settings-daemon.policy.in
data/settings-daemon.metainfo.xml.in
src/Application.vala
src/Application.vala
18 changes: 18 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,24 @@ public class SettingsDaemon.Application : GLib.Application {
}
}

public override bool dbus_register (DBusConnection connection, string object_path) throws Error {
// We must chain up to the parent class:
base.dbus_register (connection, object_path);

// Now we can do our own stuff here. For example, we could export some D-Bus objects
connection.register_object (object_path, new Backends.SystemUpgrade ());

return true;
}

public override void dbus_unregister (DBusConnection connection, string object_path) {
// Do our own stuff here, e.g. unexport any D-Bus objects we exported in the dbus_register
// hook above. Be sure to check that we actually did export them, since the hook
// above might have returned early due to the parent class' hook returning false!

base.dbus_unregister (connection, object_path);
}

public static int main (string[] args) {
GLib.Intl.setlocale (LocaleCategory.ALL, "");
GLib.Intl.bindtextdomain (Build.GETTEXT_PACKAGE, Build.LOCALEDIR);
Expand Down
Loading
Loading