Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -15,10 +15,8 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y libaccountsservice-dev libdbus-1-dev libgranite-dev libgeoclue-2-dev meson valac
apt install -y libaccountsservice-dev libdbus-1-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>
61 changes: 61 additions & 0 deletions data/io.elementary.settings-daemon.system-upgrade.helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
import argparse
import os
import re
import shutil


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

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

if "ppa.launchpad.net/elementary-os" in line:
should_delete = True
elif "packages.elementary.io" in line:
should_delete = True

if should_delete:
os.remove(repository_file)

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


def install_files(next):
update_files = os.path.join(
"/", "usr", "share", "io.elementary.settings-daemon", "system-upgrades", next)
shutil.copytree(update_files, "/", dirs_exist_ok=True)


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-files", 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_files and args.next:
return install_files(args.next)


if __name__ == "__main__":
main()
29 changes: 29 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,32 @@ i18n.merge_file(
install: true,
install_dir: join_paths(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_subdir(
'system-upgrades',
install_dir: pkgdatadir
)

install_data(
meson.project_name() + '.system-upgrade.helper',
install_mode: 'r-xr--r--',
install_dir: pkgdatadir
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://ppa.launchpad.net/elementary-os/stable/ubuntu jammy main
deb-src http://ppa.launchpad.net/elementary-os/stable/ubuntu jammy main
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deb http://ppa.launchpad.net/elementary-os/os-patches/ubuntu jammy main
deb-src http://ppa.launchpad.net/elementary-os/os-patches/ubuntu jammy main
14 changes: 14 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ project('io.elementary.settings-daemon',
license: 'GPL3',
)

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())

gio_dep = dependency ('gio-2.0')
glib_dep = dependency('glib-2.0')
granite_dep = dependency('granite', version: '>= 5.3.0')
Expand All @@ -12,6 +21,11 @@ i18n = import('i18n')
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])

conf_data = configuration_data()
conf_data.set('PROJECT_NAME', meson.project_name())
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
data/io.elementary.settings-daemon.policy.in
data/settings-daemon.appdata.xml.in
18 changes: 18 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,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) {
var application = new Application ();
return application.run (args);
Expand Down
Loading