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
}
- void
- Btrfs::setDefault(unsigned int num) const
- {
- Plugins::Report report;
- setDefault(num, report);
- }
-
-
void
Btrfs::setDefault(unsigned int num, Plugins::Report& report) const
{
}
- void
- Btrfs::setDefault(unsigned int num) const
- {
- Filesystem::setDefault(num);
- }
-
-
void
Btrfs::setDefault(unsigned int num, Plugins::Report& report) const
{
virtual std::pair<bool, unsigned int> 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;
}
- void
- Filesystem::setDefault(unsigned int num) const
- {
- SN_THROW(UnsupportedException());
- __builtin_unreachable();
- }
-
-
void
Filesystem::setDefault(unsigned int num, Plugins::Report& report) const
{
#include "snapper/Plugins.h"
-#ifndef SN_DEPRECATED
-#define SN_DEPRECATED __attribute__((deprecated))
-#endif
-
-
namespace snapper
{
using std::string;
*/
virtual std::pair<bool, unsigned int> getDefault() const;
- virtual void setDefault(unsigned int num) const SN_DEPRECATED;
virtual void setDefault(unsigned int num, Plugins::Report& report) const;
virtual std::pair<bool, unsigned int> getActive() const;
+++ /dev/null
-/*
- * 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<string>& args)
- {
- try
- {
- SDir dir(PLUGINS_DIR);
-
- vector<string> 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;
- }
- }
-
-}
+++ /dev/null
-/*
- * 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<string>& args);
-
- };
-
-}
-
-
-#endif
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 \
}
- 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)
{
}
- 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,
}
- 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)
{
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);
static ConfigInfo getConfig(const string& config_name, const string& root_prefix);
static list<ConfigInfo> 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);
}
- void
- Snapshot::setDefault() const
- {
- Plugins::Report report;
- setDefault(report);
- }
-
-
void
Snapshot::setDefault(Plugins::Report& report) const
{
#include "snapper/Plugins.h"
-#ifndef SN_DEPRECATED
-#define SN_DEPRECATED __attribute__((deprecated))
-#endif
-
-
namespace snapper
{
using std::string;
*/
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).
*/