pressing supports dry runs
This commit is contained in:
parent
b979bb7a0a
commit
ffb952fae6
@ -7,6 +7,7 @@
|
||||
#include "json.hpp"
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "cellar.hpp"
|
||||
#include "internal/bottles.hpp"
|
||||
#include "launch.hpp"
|
||||
#include "internal/launch.hpp"
|
||||
@ -24,32 +25,44 @@ void cellar::bottles::press(string exec, vector<string> args, bool noexec) {
|
||||
string homedir = getenv("HOME");
|
||||
string datadir = homedir + "/.local/share/cellar";
|
||||
string presseddir = datadir + "/pressed";
|
||||
|
||||
output::statement("making sure " + presseddir + " exists", true);
|
||||
if (!dryrun) {
|
||||
if (!boost::filesystem::exists(datadir)) { boost::filesystem::create_directory(datadir); }
|
||||
if (!boost::filesystem::exists(presseddir)) { boost::filesystem::create_directory(presseddir); }
|
||||
}
|
||||
|
||||
string filename = boost::filesystem::path(exec).filename().native();
|
||||
auto pressedpath = boost::filesystem::path(presseddir);
|
||||
string pressedfile = (pressedpath / filename).native();
|
||||
if (boost::filesystem::exists(pressedfile)) {
|
||||
output::warning("clobbering existing version of " + filename);
|
||||
boost::filesystem::remove(pressedfile);
|
||||
if (!dryrun) { boost::filesystem::remove(pressedfile); }
|
||||
}
|
||||
boost::filesystem::copy(exec, pressedfile);
|
||||
output::statement("copying " + exec + " to " + pressedfile);
|
||||
if (!dryrun) { boost::filesystem::copy(exec, pressedfile); }
|
||||
|
||||
vector<string> argv;
|
||||
argv.push_back("wine");
|
||||
argv.push_back(pressedfile);
|
||||
|
||||
if (!noexec) { launch::popen(argv); }
|
||||
if (!noexec) {
|
||||
output::statement("launching " + pressedfile, true);
|
||||
if (!dryrun) { launch::popen(argv); }
|
||||
}
|
||||
|
||||
if (active_bottle.config.find("pressed") == active_bottle.config.end()) {
|
||||
json pressed;
|
||||
active_bottle.config["pressed"] = pressed;
|
||||
output::statement("no pressed object in json, creating", true);
|
||||
if (!dryrun) { active_bottle.config["pressed"] = pressed; }
|
||||
}
|
||||
|
||||
output::statement("recording pressed installer", true);
|
||||
if (!dryrun) {
|
||||
active_bottle.config["pressed"].emplace(filename, args);
|
||||
active_bottle.save_config();
|
||||
}
|
||||
}
|
||||
|
||||
void cellar::bottles::press_command(int argc, vector<string> argv) {
|
||||
bool noexec = false;
|
||||
|
Loading…
Reference in New Issue
Block a user