diff --git a/src/cowtool.cpp b/src/cowtool.cpp index db3e1de..366dff1 100644 --- a/src/cowtool.cpp +++ b/src/cowtool.cpp @@ -5,7 +5,8 @@ #include #include #include - +#include +#include /* * File structure: * /etc/cowtool/ @@ -71,14 +72,33 @@ int main(int argc, char* argv[]) { if (!std::filesystem::exists("/etc/cowtool/disabled/install_"+name+".sh")) { - system(("cp -v /etc/cowtool/install_template.sh /etc/cowtool/disabled/install_"+name+".sh").c_str()); - system(("cp -v /etc/cowtool/disabled/install_"+name+".sh /etc/cowtool/disabled/remove_"+name+".sh").c_str()); - system(("echo #### ADD UNINSTALLATION #### >> /etc/cowtool/disabled/remove_"+name+".sh").c_str()); + std::cout << "First time installation! Watching you! Type 'manure' to complete the script!" << std::endl; + chdir("/sources/cowtool/buildspace/"); + std::cout << "Entered buildspace - don't for get to clean up before exiting!" << std::endl; + + std::ofstream out; + out.open("/etc/cowtool/disabled/install_"+name+".sh", std::ios::app); + + out << "cd /sources/cowtool/buildspace/" << std::endl; + std::string input=""; + while (input!="manure" && input!="exit"){ + + out << input << std::endl; + system(input.c_str()); + if (input.substr(0,3)=="cd "){ + chdir((input.substr(3)).c_str()); + } + + std::cout<< "[cowtool] : "; + + std::getline(std::cin, input); + } + + out.close(); } system((editor+" /etc/cowtool/disabled/install_"+name+".sh").c_str()); - system((editor+" /etc/cowtool/disabled/remove_"+name+".sh").c_str()); - std::cout << "Remember to `milk` to install/update `"+ name << "`!" << std::endl; + std::cout << "Remember to `milk` to update `"+ name << "`!" << std::endl; } else if (firstArg == "milk") { @@ -98,10 +118,10 @@ int main(int argc, char* argv[]) { } else if (firstArg == "herd") { std::cout << "List of package scripts:" << std::endl << std::endl; - system("ls /etc/cowtool/disabled/install_*"); + system("ls -1 /etc/cowtool/disabled/"); std::cout << std::endl << "List of package scripts marked as autoupdate:" << std::endl << std::endl; - system("ls /etc/cowtool/enabled/install_*"); + system("ls -1 /etc/cowtool/enabled/"); } else if (firstArg == "graze") { @@ -123,7 +143,7 @@ int main(int argc, char* argv[]) { std::string name = argv[2]; system(("rm -f /etc/cowtool/enabled/install_"+name+".sh").c_str()); - system(("bash /etc/cowtool/disabled/remove_"+name+".sh").c_str()); + std::cout << "Program removed from autoupdate list -- remember to uninstall it!" << std::endl; } else {