This commit is contained in:
parent
a37e42884f
commit
a524d12e0c
@ -325,12 +325,12 @@ int publish_tool(int argc, char* argv[]) {
|
|||||||
int update_tool(int argc, char* argv[]) {
|
int update_tool(int argc, char* argv[]) {
|
||||||
std::cout << "Updating getpkg itself..." << std::endl;
|
std::cout << "Updating getpkg itself..." << std::endl;
|
||||||
|
|
||||||
// First update getpkg itself
|
// First try to update getpkg itself
|
||||||
char* fakeArgv[] = {argv[0], (char*)"install", (char*)"getpkg"};
|
char* fakeArgv[] = {argv[0], (char*)"install", (char*)"getpkg"};
|
||||||
int result = install_tool(3, fakeArgv);
|
int result = install_tool(3, fakeArgv);
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
std::cerr << "Failed to update getpkg" << std::endl;
|
std::cerr << "Warning: Failed to update getpkg (may not be published)" << std::endl;
|
||||||
return result;
|
// Continue with updating other tools instead of failing
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then update all installed tools
|
// Then update all installed tools
|
||||||
@ -338,12 +338,18 @@ int update_tool(int argc, char* argv[]) {
|
|||||||
std::filesystem::path configDir = std::filesystem::path(home) / ".config/getpkg";
|
std::filesystem::path configDir = std::filesystem::path(home) / ".config/getpkg";
|
||||||
std::cout << "Updating all installed tools..." << std::endl;
|
std::cout << "Updating all installed tools..." << std::endl;
|
||||||
|
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(configDir)) {
|
bool anyUpdates = false;
|
||||||
if (entry.path().extension() == ".json") {
|
if (std::filesystem::exists(configDir)) {
|
||||||
std::string tname = entry.path().stem();
|
for (const auto& entry : std::filesystem::directory_iterator(configDir)) {
|
||||||
if (tname != "getpkg") { // Skip getpkg since we already updated it
|
if (entry.path().extension() == ".json") {
|
||||||
char* toolArgv[] = {argv[0], (char*)"install", (char*)tname.c_str()};
|
std::string tname = entry.path().stem();
|
||||||
install_tool(3, toolArgv);
|
if (tname != "getpkg") { // Skip getpkg since we already tried it
|
||||||
|
std::cout << "Checking " << tname << "..." << std::endl;
|
||||||
|
char* toolArgv[] = {argv[0], (char*)"install", (char*)tname.c_str()};
|
||||||
|
if (install_tool(3, toolArgv) == 0) {
|
||||||
|
anyUpdates = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ fi
|
|||||||
# Test 14: Update command (if we have tools installed)
|
# Test 14: Update command (if we have tools installed)
|
||||||
if [ -d ~/.config/getpkg ] && [ "$(find ~/.config/getpkg -name "*.json" -type f 2>/dev/null | wc -l)" -gt 0 ]; then
|
if [ -d ~/.config/getpkg ] && [ "$(find ~/.config/getpkg -name "*.json" -type f 2>/dev/null | wc -l)" -gt 0 ]; then
|
||||||
echo -e "\nTest 14: Update command"
|
echo -e "\nTest 14: Update command"
|
||||||
UPDATE_ALL_OUTPUT=$(timeout 3 "$GETPKG" update 2>&1) || UPDATE_ALL_OUTPUT=""
|
UPDATE_ALL_OUTPUT=$(timeout 30 "$GETPKG" update 2>&1) || UPDATE_ALL_OUTPUT=""
|
||||||
if [[ "$UPDATE_ALL_OUTPUT" =~ Update\ complete ]]; then
|
if [[ "$UPDATE_ALL_OUTPUT" =~ Update\ complete ]]; then
|
||||||
print_test_result "Update all tools command" 0
|
print_test_result "Update all tools command" 0
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user