move cellar bottles to .local/share
This commit is contained in:
parent
89998bada1
commit
429b19abee
2
cogrc
2
cogrc
@ -1,5 +1,5 @@
|
|||||||
[version]
|
[version]
|
||||||
release_version=0.4
|
release_version=0.5
|
||||||
|
|
||||||
[defaults]
|
[defaults]
|
||||||
wine-path=wine
|
wine-path=wine
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "commands.hpp"
|
#include "commands.hpp"
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "bottles.hpp"
|
#include "bottles.hpp"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define __CONFIG_HPP
|
#define __CONFIG_HPP
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ void cellar::bottles::switch_active_bottle(int argc, vector<string> argv) {
|
|||||||
|
|
||||||
string homepath = getenv("HOME"); // /home/nick
|
string homepath = getenv("HOME"); // /home/nick
|
||||||
string bottlepath = homepath + "/.wine"; // /home/nick/.wine
|
string bottlepath = homepath + "/.wine"; // /home/nick/.wine
|
||||||
string targetpath = bottlepath + "." + argv[1]; // /home/nick/.wine.example
|
string targetpath = homepath + "/.local/share/cellar/bottles/" + argv[1]; // /home/nick/.wine.example
|
||||||
|
|
||||||
file_status targetstatus = symlink_status(targetpath);
|
file_status targetstatus = symlink_status(targetpath);
|
||||||
if (!exists(targetstatus)) {
|
if (!exists(targetstatus)) {
|
||||||
|
@ -12,20 +12,17 @@ using namespace cellar::bottles;
|
|||||||
|
|
||||||
void cellar::bottles::print_active_bottle(int argc, vector<string> argv) {
|
void cellar::bottles::print_active_bottle(int argc, vector<string> argv) {
|
||||||
map<string, Bottle> bottlemap = get_bottles();
|
map<string, Bottle> bottlemap = get_bottles();
|
||||||
if (bottlemap.find(".wine") == bottlemap.end()) { // not found
|
|
||||||
output::error("no active wine bottle");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bottle active_bottle = bottlemap[".wine"];
|
Bottle active_bottle = Bottle(getenv("HOME") + string("/.wine"));
|
||||||
string bottlepath = active_bottle.canonical_path;
|
string bottlepath = active_bottle.canonical_path;
|
||||||
stringstream outstr;
|
stringstream outstr;
|
||||||
bool cellar_managed = true;
|
bool cellar_managed = true;
|
||||||
if (active_bottle.type == bottle_symlink) {
|
if (active_bottle.type == bottle_symlink) {
|
||||||
outstr << "symlink to ";
|
outstr << "symlink to ";
|
||||||
string homedir = getenv("HOME");
|
string homedir = getenv("HOME");
|
||||||
if (active_bottle.canonical_path.substr(0, homedir.length()) == homedir) {
|
string bottlerack = homedir + "/.local/share/cellar/bottles";
|
||||||
bottlepath.replace(0, homedir.length() + 1, ""); // should convert "/home/someone/.wine.example" to ".wine.example"
|
if (active_bottle.canonical_path.substr(0, bottlerack.length()) == bottlerack) {
|
||||||
|
bottlepath.replace(0, bottlerack.length() + 1, ""); // should convert "/home/someone/.wine.example" to ".wine.example"
|
||||||
active_bottle = bottlemap[bottlepath];
|
active_bottle = bottlemap[bottlepath];
|
||||||
} else {
|
} else {
|
||||||
outstr << active_bottle.canonical_path;
|
outstr << active_bottle.canonical_path;
|
||||||
@ -40,7 +37,7 @@ void cellar::bottles::print_active_bottle(int argc, vector<string> argv) {
|
|||||||
outstr << "anonymous wine bottle at " << active_bottle.canonical_path;
|
outstr << "anonymous wine bottle at " << active_bottle.canonical_path;
|
||||||
break;
|
break;
|
||||||
case bottle_labelled:
|
case bottle_labelled:
|
||||||
outstr << active_bottle.config["name"] << " (~/" << bottlepath << ")";
|
outstr << active_bottle.config["name"] << " (" << bottlepath << ")";
|
||||||
if (active_bottle.config.find("desc") != active_bottle.config.end()) {
|
if (active_bottle.config.find("desc") != active_bottle.config.end()) {
|
||||||
outstr << " - " << active_bottle.config["desc"];
|
outstr << " - " << active_bottle.config["desc"];
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "bottles.hpp"
|
#include "bottles.hpp"
|
||||||
#include "internal/bottles.hpp"
|
#include "internal/bottles.hpp"
|
||||||
@ -59,15 +59,13 @@ map<string, Bottle> cellar::bottles::get_bottles() {
|
|||||||
map<string, Bottle> result;
|
map<string, Bottle> result;
|
||||||
|
|
||||||
string homepath = getenv("HOME");
|
string homepath = getenv("HOME");
|
||||||
vector<string> homedir = fs::listdir(homepath);
|
vector<string> homedir = fs::listdir(homepath + "/.local/share/cellar/bottles");
|
||||||
for (string item : homedir) {
|
for (string item : homedir) {
|
||||||
if (item.substr(0,5) == ".wine") {
|
string fullitem = homepath + "/.local/share/cellar/bottles/" + item;
|
||||||
string fullitem = homepath + "/" + item;
|
|
||||||
Bottle output(fullitem);
|
Bottle output(fullitem);
|
||||||
|
|
||||||
result[item] = output;
|
result[item] = output;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -85,13 +83,8 @@ string cellar::bottles::resolve_bottle(string bottlechoice) {
|
|||||||
output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
|
output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
|
||||||
result = bottlechoice;
|
result = bottlechoice;
|
||||||
} else {
|
} else {
|
||||||
if (bottlechoice.substr(0,6) == ".wine.") {
|
|
||||||
output::statement("tip: cellar can add the \".wine.\" prefix automatically");
|
|
||||||
bottlechoice.replace(0,6,"");
|
|
||||||
}
|
|
||||||
|
|
||||||
string homepath = getenv("HOME");
|
string homepath = getenv("HOME");
|
||||||
string fullbottlepath = homepath + "/.wine." + bottlechoice;
|
string fullbottlepath = homepath + "/.local/share/cellar/bottles" + bottlechoice;
|
||||||
result = fullbottlepath;
|
result = fullbottlepath;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -103,8 +96,8 @@ void cellar::bottles::print_bottles(int argc, vector<string> argv) {
|
|||||||
stringstream outstr;
|
stringstream outstr;
|
||||||
|
|
||||||
for (auto item : bottles) {
|
for (auto item : bottles) {
|
||||||
if (item.first == ".wine" || item.first == ".wine.template") {
|
if (item.first == ".wine" || item.first == ".local/share/cellar/bottles/template") {
|
||||||
// .wine is considered to be "active", and .wine.template is used as a template
|
// .wine is considered to be "active", and .local/share/cellar/bottles/template is used as a template
|
||||||
// and therefore treated specially
|
// and therefore treated specially
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "bottles.hpp"
|
#include "bottles.hpp"
|
||||||
#include "internal/bottles.hpp"
|
#include "internal/bottles.hpp"
|
||||||
|
@ -45,12 +45,7 @@ void cellar::bottles::create_bottle(int argc, vector<string> argv) {
|
|||||||
output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
|
output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
|
||||||
fullbottlepath = bottlechoice;
|
fullbottlepath = bottlechoice;
|
||||||
} else {
|
} else {
|
||||||
if (bottlechoice.substr(0,6) == ".wine.") {
|
fullbottlepath = homepath + "/.local/share/cellar/bottles/" + bottlechoice;
|
||||||
output::statement("tip: cellar can add the \".wine.\" prefix automatically");
|
|
||||||
bottlechoice.replace(0,6,"");
|
|
||||||
}
|
|
||||||
|
|
||||||
fullbottlepath = homepath + "/.wine." + bottlechoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boost::filesystem::exists(fullbottlepath)) {
|
if (boost::filesystem::exists(fullbottlepath)) {
|
||||||
@ -58,13 +53,13 @@ void cellar::bottles::create_bottle(int argc, vector<string> argv) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullbottlepath != homepath + "/.wine.template") {
|
if (fullbottlepath != homepath + "/.local/share/cellar/bottles/template") {
|
||||||
output::statement("copying template bottle to " + fullbottlepath, true);
|
output::statement("copying template bottle to " + fullbottlepath, true);
|
||||||
|
|
||||||
// all this gets skipped if we're creating the template bottle
|
// all this gets skipped if we're creating the template bottle
|
||||||
if (boost::filesystem::exists(homepath + "/.wine.template")) {
|
if (boost::filesystem::exists(homepath + "/.local/share/cellar/bottles/template")) {
|
||||||
if (!dryrun) {
|
if (!dryrun) {
|
||||||
fs::recursive_copy(homepath + "/.wine.template", fullbottlepath);
|
fs::recursive_copy(homepath + "/.local/share/cellar/bottles/template", fullbottlepath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "bottles.hpp"
|
#include "bottles.hpp"
|
||||||
#include "cellar.hpp"
|
#include "cellar.hpp"
|
||||||
|
@ -22,12 +22,7 @@ void cellar::bottles::remove_bottle(int argc, vector<string> argv) {
|
|||||||
output::error("paths not accepted");
|
output::error("paths not accepted");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (bottlechoice.substr(0,6) == ".wine.") {
|
fullbottlepath = homepath + "/.local/share/cellar/bottles/" + bottlechoice;
|
||||||
output::statement("tip: cellar can add the \".wine.\" prefix automatically");
|
|
||||||
bottlechoice.replace(0,6,"");
|
|
||||||
}
|
|
||||||
|
|
||||||
fullbottlepath = homepath + "/.wine." + bottlechoice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!boost::filesystem::exists(fullbottlepath)) {
|
if (!boost::filesystem::exists(fullbottlepath)) {
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.hpp"
|
||||||
#include "tclap/CmdLine.h"
|
#include "tclap/CmdLine.h"
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "bottles.hpp"
|
#include "bottles.hpp"
|
||||||
#include "cellar.hpp"
|
#include "cellar.hpp"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// vim: ft=cpp :
|
// vim: ft=cpp :
|
||||||
|
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include "json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "cellar.hpp"
|
#include "cellar.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user