From: Imobach González Sosa Date: Thu, 14 May 2015 14:26:10 +0000 (+0100) Subject: Add snapshots creation to installation helpers X-Git-Tag: v0.2.8~11^2~5 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=c6f694e58cee8da3478fdde2d3a9ddfb28a08d1b;p=thirdparty%2Fsnapper.git Add snapshots creation to installation helpers --- diff --git a/client/installation-helper.cc b/client/installation-helper.cc index 1bb0b462..84f186ed 100644 --- a/client/installation-helper.cc +++ b/client/installation-helper.cc @@ -195,6 +195,38 @@ step4() cout << "done" << endl; } +void +step5(const string& description) +{ + // step runs in chroot + + // preconditions (maybe incomplete): + // snapper rpms installed in chroot + + unsigned int num; + + SCD scd; + scd.read_only = false; + scd.description = description; + + Snapper snapper("root", "/"); + + try + { + Snapshots::iterator snapshot = snapper.createSingleSnapshot(scd); + num = snapshot->getNum(); + snapper.getFilesystem()->setDefault(num); + } + catch (const runtime_error& e) + { + y2err("create snapshot failed, " << e.what()); + exit(EXIT_FAILURE); + } + + cout << num << endl; + exit(EXIT_SUCCESS); +} + void log_do(LogLevel level, const string& component, const char* file, const int line, const char* func, @@ -270,4 +302,6 @@ main(int argc, char** argv) step3(root_prefix, default_subvolume_name); else if (step == "4") step4(); + else if (step == "5") + step5(description); }