From: Arvin Schnell Date: Wed, 23 Jul 2025 12:59:36 +0000 (+0200) Subject: - removed deprecated functions X-Git-Tag: v0.13.0~33^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1036%2Fhead;p=thirdparty%2Fsnapper.git - removed deprecated functions --- diff --git a/package/snapper.changes b/package/snapper.changes index 2e0f0dd3..a9653565 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -2,6 +2,7 @@ Wed Jul 23 10:35:22 CEST 2025 - aschnell@suse.com - allow to send log to system logger (gh#openSUSE/snapper#1030) +- removed deprecated functions ------------------------------------------------------------------- Fri Jul 04 12:52:34 CEST 2025 - aschnell@suse.com diff --git a/snapper/Btrfs.cc b/snapper/Btrfs.cc index 055f46a3..75f2295c 100644 --- a/snapper/Btrfs.cc +++ b/snapper/Btrfs.cc @@ -1465,14 +1465,6 @@ namespace snapper } - void - Btrfs::setDefault(unsigned int num) const - { - Plugins::Report report; - setDefault(num, report); - } - - void Btrfs::setDefault(unsigned int num, Plugins::Report& report) const { @@ -1552,13 +1544,6 @@ namespace snapper } - void - Btrfs::setDefault(unsigned int num) const - { - Filesystem::setDefault(num); - } - - void Btrfs::setDefault(unsigned int num, Plugins::Report& report) const { diff --git a/snapper/Btrfs.h b/snapper/Btrfs.h index 94491432..d67d7015 100644 --- a/snapper/Btrfs.h +++ b/snapper/Btrfs.h @@ -87,7 +87,6 @@ namespace snapper virtual std::pair getDefault() const override; - virtual void setDefault(unsigned int num) const override; virtual void setDefault(unsigned int num, Plugins::Report& report) const override; virtual bool isActive(unsigned int num) const override; diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 5d807924..7cb1bc04 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -191,14 +191,6 @@ namespace snapper } - void - Filesystem::setDefault(unsigned int num) const - { - SN_THROW(UnsupportedException()); - __builtin_unreachable(); - } - - void Filesystem::setDefault(unsigned int num, Plugins::Report& report) const { diff --git a/snapper/Filesystem.h b/snapper/Filesystem.h index 83e200b0..c587a35d 100644 --- a/snapper/Filesystem.h +++ b/snapper/Filesystem.h @@ -34,11 +34,6 @@ #include "snapper/Plugins.h" -#ifndef SN_DEPRECATED -#define SN_DEPRECATED __attribute__((deprecated)) -#endif - - namespace snapper { using std::string; @@ -100,7 +95,6 @@ namespace snapper */ virtual std::pair getDefault() const; - virtual void setDefault(unsigned int num) const SN_DEPRECATED; virtual void setDefault(unsigned int num, Plugins::Report& report) const; virtual std::pair getActive() const; diff --git a/snapper/Hooks.cc b/snapper/Hooks.cc deleted file mode 100644 index 1a64d0e8..00000000 --- a/snapper/Hooks.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) [2011-2015] Novell, Inc. - * Copyright (c) [2022-2023] SUSE LLC - * - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, you may - * find current contact information at www.novell.com. - */ - - -// TODO obsolete, remove with next ABI break - - -#include "config.h" - -#include "snapper/FileUtils.h" -#include "snapper/Hooks.h" -#include "snapper/SystemCmd.h" -#include "snapper/SnapperDefines.h" - - -namespace snapper -{ - using namespace std; - - - static bool - plugins_filter_entries(unsigned char type, const char* name) - { - // must start with digit - return *name >= '0' && *name <= '9'; - } - - - void - Hooks::run_scripts(const vector& args) - { - try - { - SDir dir(PLUGINS_DIR); - - vector scripts = dir.entries(plugins_filter_entries); - std::sort(scripts.begin(), scripts.end()); - for (const string& script : scripts) - { - SystemCmd::Args cmd_args = { dir.fullname(script) }; - cmd_args << args; - SystemCmd cmd(cmd_args); - } - } - catch (const Exception& e) - { - SN_CAUGHT(e); - } - } - - - // Actions without -pre/-post are legacy and deprecated (2022-12-22). - - - void - Hooks::create_config(Stage stage, const string& subvolume, const Filesystem* filesystem) - { - switch (stage) - { - case Stage::PRE_ACTION: - run_scripts({ "create-config-pre", subvolume, filesystem->fstype() }); - break; - - case Stage::POST_ACTION: - grub(subvolume, filesystem, "--enable"); - run_scripts({ "create-config", subvolume, filesystem->fstype() }); - run_scripts({ "create-config-post", subvolume, filesystem->fstype() }); - break; - } - } - - - void - Hooks::delete_config(Stage stage, const string& subvolume, const Filesystem* filesystem) - { - switch (stage) - { - case Stage::PRE_ACTION: - grub(subvolume, filesystem, "--disable"); - run_scripts({ "delete-config-pre", subvolume, filesystem->fstype() }); - run_scripts({ "delete-config", subvolume, filesystem->fstype() }); - break; - - case Stage::POST_ACTION: - run_scripts({ "delete-config-post", subvolume, filesystem->fstype() }); - break; - } - } - - - void - Hooks::create_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, const Snapshot& snapshot) - { - switch (stage) - { - case Stage::PRE_ACTION: - run_scripts({ "create-snapshot-pre", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - break; - - case Stage::POST_ACTION: - grub(subvolume, filesystem, "--refresh"); - run_scripts({ "create-snapshot", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - run_scripts({ "create-snapshot-post", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - break; - } - } - - - void - Hooks::modify_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, const Snapshot& snapshot) - { - switch (stage) - { - case Stage::PRE_ACTION: - run_scripts({ "modify-snapshot-pre", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - break; - - case Stage::POST_ACTION: - grub(subvolume, filesystem, "--refresh"); - run_scripts({ "modify-snapshot", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - run_scripts({ "modify-snapshot-post", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - break; - } - } - - - void - Hooks::delete_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, const Snapshot& snapshot) - { - switch (stage) - { - case Stage::PRE_ACTION: - run_scripts({ "delete-snapshot-pre", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - break; - - case Stage::POST_ACTION: - grub(subvolume, filesystem, "--refresh"); - run_scripts({ "delete-snapshot", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - run_scripts({ "delete-snapshot-post", subvolume, filesystem->fstype(), std::to_string(snapshot.getNum()) }); - break; - } - } - - - void - Hooks::set_default_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, unsigned int num) - { - switch (stage) - { - case Stage::PRE_ACTION: - run_scripts({ "set-default-snapshot-pre", subvolume, filesystem->fstype(), std::to_string(num) }); - break; - - case Stage::POST_ACTION: - run_scripts({ "set-default-snapshot", subvolume, filesystem->fstype(), std::to_string(num) }); - run_scripts({ "set-default-snapshot-post", subvolume, filesystem->fstype(), std::to_string(num) }); - break; - } - } - - - void - Hooks::grub(const string& subvolume, const Filesystem* filesystem, const char* option) - { -#ifdef ENABLE_ROLLBACK - -#define GRUB_SCRIPT "/usr/lib/snapper/plugins/grub" - - if (subvolume == "/" && filesystem->fstype() == "btrfs" && access(GRUB_SCRIPT, X_OK) == 0) - { - SystemCmd cmd({ GRUB_SCRIPT, option }); - } -#endif - } - - - void - Hooks::rollback(const string& old_root, const string& new_root) - { -#ifdef ENABLE_ROLLBACK - -#define ROLLBACK_SCRIPT "/usr/lib/snapper/plugins/rollback" - - // Fate#319108 - if (access(ROLLBACK_SCRIPT, X_OK) == 0) - { - SystemCmd cmd({ ROLLBACK_SCRIPT, old_root, new_root }); - } -#endif - } - - - void - Hooks::rollback(Stage stage, const string& subvolume, const Filesystem* filesystem, unsigned int old_num, - unsigned int new_num) - { - switch (stage) - { - case Stage::PRE_ACTION: - run_scripts({ "rollback-pre", subvolume, filesystem->fstype(), std::to_string(old_num), - std::to_string(new_num) }); - break; - - case Stage::POST_ACTION: - run_scripts({ "rollback", subvolume, filesystem->fstype(), std::to_string(old_num), - std::to_string(new_num) }); - run_scripts({ "rollback-post", subvolume, filesystem->fstype(), std::to_string(old_num), - std::to_string(new_num) }); - break; - } - } - -} diff --git a/snapper/Hooks.h b/snapper/Hooks.h deleted file mode 100644 index 269cbecd..00000000 --- a/snapper/Hooks.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) [2011-2015] Novell, Inc. - * Copyright (c) 2022 SUSE LLC - * - * All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, contact Novell, Inc. - * - * To contact Novell about this file by physical or electronic mail, you may - * find current contact information at www.novell.com. - */ - - -// TODO obsolete, remove with next ABI break - - -#ifndef SNAPPER_HOOKS_H -#define SNAPPER_HOOKS_H - - -#include "snapper/Snapper.h" -#include "snapper/Filesystem.h" - - -namespace snapper -{ - using namespace std; - - - class Hooks - { - public: - - enum class Stage { PRE_ACTION, POST_ACTION }; - - static void create_config(Stage stage, const string& subvolume, const Filesystem* filesystem) SN_DEPRECATED; - static void delete_config(Stage stage, const string& subvolume, const Filesystem* filesystem) SN_DEPRECATED; - - static void create_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, - const Snapshot& snapshot) SN_DEPRECATED; - static void modify_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, - const Snapshot& snapshot) SN_DEPRECATED; - static void delete_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, - const Snapshot& snapshot) SN_DEPRECATED; - - static void set_default_snapshot(Stage stage, const string& subvolume, const Filesystem* filesystem, - unsigned int num) SN_DEPRECATED; - - static void rollback(const string& old_root, const string& new_root) SN_DEPRECATED; - - static void rollback(Stage stage, const string& subvolume, const Filesystem* filesystem, unsigned int old_num, - unsigned int new_num) SN_DEPRECATED; - - private: - - static void grub(const string& subvolume, const Filesystem* filesystem, - const char* option); - - static void run_scripts(const vector& args); - - }; - -} - - -#endif diff --git a/snapper/Makefile.am b/snapper/Makefile.am index 5c86052e..6941061f 100644 --- a/snapper/Makefile.am +++ b/snapper/Makefile.am @@ -27,7 +27,6 @@ libsnapper_la_SOURCES = \ Acls.cc Acls.h \ Plugins.cc Plugins.h \ PluginsImpl.cc PluginsImpl.h \ - Hooks.cc Hooks.h \ Systemctl.cc Systemctl.h \ Exception.cc Exception.h \ SnapperTmpl.h \ diff --git a/snapper/Snapper.cc b/snapper/Snapper.cc index 7c54cc33..2a9e35e2 100644 --- a/snapper/Snapper.cc +++ b/snapper/Snapper.cc @@ -233,62 +233,6 @@ namespace snapper } - Snapshots::iterator - Snapper::createSingleSnapshot(const SCD& scd) - { - Plugins::Report report; - return createSingleSnapshot(scd, report); - } - - - Snapshots::iterator - Snapper::createSingleSnapshot(Snapshots::const_iterator parent, const SCD& scd) - { - Plugins::Report report; - return createSingleSnapshot(parent, scd, report); - } - - - Snapshots::iterator - Snapper::createSingleSnapshotOfDefault(const SCD& scd) - { - Plugins::Report report; - return createSingleSnapshotOfDefault(scd, report); - } - - - Snapshots::iterator - Snapper::createPreSnapshot(const SCD& scd) - { - Plugins::Report report; - return createPreSnapshot(scd, report); - } - - - Snapshots::iterator - Snapper::createPostSnapshot(Snapshots::const_iterator pre, const SCD& scd) - { - Plugins::Report report; - return createPostSnapshot(pre, scd, report); - } - - - void - Snapper::modifySnapshot(Snapshots::iterator snapshot, const SMD& smd) - { - Plugins::Report report; - modifySnapshot(snapshot, smd, report); - } - - - void - Snapper::deleteSnapshot(Snapshots::iterator snapshot) - { - Plugins::Report report; - deleteSnapshot(snapshot, report); - } - - Snapshots::iterator Snapper::createSingleSnapshot(const SCD& scd, Plugins::Report& report) { @@ -387,16 +331,6 @@ namespace snapper } - void - Snapper::createConfig(const string& config_name, const string& root_prefix, - const string& subvolume, const string& fstype, - const string& template_name) - { - Plugins::Report report; - createConfig(config_name, root_prefix, subvolume, fstype, template_name, report); - } - - void Snapper::createConfig(const string& config_name, const string& root_prefix, const string& subvolume, const string& fstype, @@ -532,14 +466,6 @@ namespace snapper } - void - Snapper::deleteConfig(const string& config_name, const string& root_prefix) - { - Plugins::Report report; - deleteConfig(config_name, root_prefix, report); - } - - void Snapper::deleteConfig(const string& config_name, const string& root_prefix, Plugins::Report& report) { diff --git a/snapper/Snapper.h b/snapper/Snapper.h index 0f09673c..a43f8aaa 100644 --- a/snapper/Snapper.h +++ b/snapper/Snapper.h @@ -141,16 +141,6 @@ namespace snapper Snapshots::const_iterator getSnapshotCurrent() const; - Snapshots::iterator createSingleSnapshot(const SCD& scd) SN_DEPRECATED; - Snapshots::iterator createSingleSnapshot(Snapshots::const_iterator parent, const SCD& scd) SN_DEPRECATED; - Snapshots::iterator createSingleSnapshotOfDefault(const SCD& scd) SN_DEPRECATED; - Snapshots::iterator createPreSnapshot(const SCD& scd) SN_DEPRECATED; - Snapshots::iterator createPostSnapshot(Snapshots::const_iterator pre, const SCD& scd) SN_DEPRECATED; - - void modifySnapshot(Snapshots::iterator snapshot, const SMD& smd) SN_DEPRECATED; - - void deleteSnapshot(Snapshots::iterator snapshot) SN_DEPRECATED; - Snapshots::iterator createSingleSnapshot(const SCD& scd, Plugins::Report& report); Snapshots::iterator createSingleSnapshot(Snapshots::const_iterator parent, const SCD& scd, Plugins::Report& report); @@ -168,11 +158,6 @@ namespace snapper static ConfigInfo getConfig(const string& config_name, const string& root_prefix); static list getConfigs(const string& root_prefix); - static void createConfig(const string& config_name, const string& root_prefix, - const string& subvolume, const string& fstype, - const string& template_name) SN_DEPRECATED; - static void deleteConfig(const string& config_name, const string& root_prefix) SN_DEPRECATED; - static void createConfig(const string& config_name, const string& root_prefix, const string& subvolume, const string& fstype, const string& template_name, Plugins::Report& report); diff --git a/snapper/Snapshot.cc b/snapper/Snapshot.cc index efee43a0..6acbe1c9 100644 --- a/snapper/Snapshot.cc +++ b/snapper/Snapshot.cc @@ -158,14 +158,6 @@ namespace snapper } - void - Snapshot::setDefault() const - { - Plugins::Report report; - setDefault(report); - } - - void Snapshot::setDefault(Plugins::Report& report) const { diff --git a/snapper/Snapshot.h b/snapper/Snapshot.h index 287a29f8..2a1d1388 100644 --- a/snapper/Snapshot.h +++ b/snapper/Snapshot.h @@ -36,11 +36,6 @@ #include "snapper/Plugins.h" -#ifndef SN_DEPRECATED -#define SN_DEPRECATED __attribute__((deprecated)) -#endif - - namespace snapper { using std::string; @@ -126,11 +121,6 @@ namespace snapper */ bool isDefault() const; - /** - * Change default snapshot (will be activated on next boot time). - */ - void setDefault() const SN_DEPRECATED; - /** * Change default snapshot (will be activated on next boot time). */