cestup, linux, can be setup as user or sudo, added appli reference to menu

This commit is contained in:
Basile Burg 2015-06-04 21:03:07 +02:00
parent 6c3d5d55a3
commit 7e45031965
1 changed files with 45 additions and 21 deletions

View File

@ -84,14 +84,6 @@ void main(string[] args)
writeln("| press a key to continue... |"); writeln("| press a key to continue... |");
writeln("|---------------------------------------------|"); writeln("|---------------------------------------------|");
/*version(win32){} else if (environment.get("SUDO_USER") == "")
{
writeln("the extractor must be run with sudo !");
readln;
return;
}*/
readln; readln;
writeln("|---------------------------------------------|"); writeln("|---------------------------------------------|");
size_t failures; size_t failures;
@ -137,6 +129,7 @@ void main(string[] args)
else else
{ {
version(win32) win32PostInstall(); version(win32) win32PostInstall();
else nuxPostInstall();
writeln("| the files are correctly extracted |"); writeln("| the files are correctly extracted |");
} }
writeln("| press a key to exit... |"); writeln("| press a key to exit... |");
@ -145,15 +138,15 @@ void main(string[] args)
} }
else else
{ {
failures += !uinstallResource!coedit(exePath); failures += !uninstallResource!coedit(exePath);
failures += !uinstallResource!cesyms(exePath); failures += !uninstallResource!cesyms(exePath);
failures += !uinstallResource!cetodo(exePath); failures += !uninstallResource!cetodo(exePath);
failures += !uinstallResource!celic(appDataPath); failures += !uninstallResource!celic(appDataPath);
failures += !uinstallResource!icon(appDataPath); failures += !uninstallResource!icon(appDataPath);
failures += !uinstallResource!png(appDataPath); failures += !uninstallResource!png(appDataPath);
failures += !uinstallResource!dcd_client(exePath); failures += !uninstallResource!dcd_client(exePath);
failures += !uinstallResource!dcd_server(exePath); failures += !uninstallResource!dcd_server(exePath);
failures += !uinstallResource!dcdlic(appDataPath); failures += !uninstallResource!dcdlic(appDataPath);
version(win32) version(win32)
{ {
@ -168,6 +161,8 @@ void main(string[] args)
} }
else else
{ {
version(win32) win32PostUninstall();
else nuxPostUninstall();
writeln("| the files are correctly removed |"); writeln("| the files are correctly removed |");
} }
writeln("| press a key to exit... |"); writeln("| press a key to exit... |");
@ -197,7 +192,7 @@ bool installResource(alias resource)(string path)
if (resource.isExe) if (resource.isExe)
if (fname.exists) if (fname.exists)
{ {
string cmd = "chmod +x " ~ fname; string cmd = "chmod a+x " ~ fname;
executeShell(cmd); executeShell(cmd);
} }
} }
@ -207,7 +202,7 @@ bool installResource(alias resource)(string path)
return true; return true;
} }
bool uinstallResource(alias resource)(string path) bool uninstallResource(alias resource)(string path)
{ {
import std.file: exists, remove; import std.file: exists, remove;
string fname = path ~ dirSeparator ~ resource.destName; string fname = path ~ dirSeparator ~ resource.destName;
@ -220,6 +215,32 @@ bool uinstallResource(alias resource)(string path)
void nuxPostInstall() void nuxPostInstall()
{ {
import std.stream: File, FileMode;
File f;
if (asSu) f = new File("/usr/share/applications/coedit.desktop", FileMode.OutNew);
else f = new File("/home/" ~ environment.get("USER") ~
"/.local/share/applications/coedit.desktop", FileMode.OutNew);
f.writeLine("[Desktop Entry]");
f.writeLine("Name=coedit");
f.writeLine("Exec=coedit %f");
f.writeLine("Icon=" ~ appDataPath ~ "/coedit.png");
f.writeLine("Type=Application");
f.writeLine("Categories=Utility;Application;Development;");
f.writeLine("Terminal=false");
f.close;
}
void nuxPostUninstall()
{
import std.file: remove;
try
{
if (asSu)"/usr/share/applications/coedit.desktop".remove;
else remove("/home/" ~ environment.get("USER") ~
"/.local/share/applications/coedit.desktop");
}
catch (Exception e) {}
} }
void win32PostInstall() void win32PostInstall()
@ -241,5 +262,8 @@ void win32PostInstall()
f.writeLine("\"" ~ target ~ "\""); f.writeLine("\"" ~ target ~ "\"");
f.writeLine("IconIndex=0"); f.writeLine("IconIndex=0");
f.close; f.close;
}
void win32PostUninstall()
{
} }