This commit is contained in:
parent
f20c8ff330
commit
a4ce65fa5b
@ -157,11 +157,12 @@ int install_tool(int argc, char* argv[]) {
|
||||
tfile.close();
|
||||
|
||||
std::string localHash = toolInfo.value("hash", "");
|
||||
std::string localArch = toolInfo.value("arch", arch);
|
||||
|
||||
// Get remote hash to compare
|
||||
// Get remote hash to compare - use the same arch that was originally installed
|
||||
GetbinClient getbin;
|
||||
std::string remoteHash;
|
||||
if (getbin.getHash(toolName, arch, remoteHash) && !remoteHash.empty()) {
|
||||
if (getbin.getHash(toolName, localArch, remoteHash) && !remoteHash.empty()) {
|
||||
if (localHash != remoteHash) {
|
||||
needsUpdate = true;
|
||||
std::cout << "Updating " << toolName << "..." << std::endl;
|
||||
@ -183,12 +184,19 @@ int install_tool(int argc, char* argv[]) {
|
||||
scriptManager.removeToolEntry(toolName);
|
||||
if (std::filesystem::exists(binDir)) std::filesystem::remove_all(binDir);
|
||||
|
||||
// Download tool
|
||||
// Download tool - try arch-specific version first, then universal fallback
|
||||
GetbinClient getbin2;
|
||||
std::string downloadArch = arch;
|
||||
std::cout << "Downloading " << toolName << ":" << arch << "..." << std::endl;
|
||||
if (!getbin2.download(toolName, arch, archivePath.string())) {
|
||||
std::cerr << "Failed to download tool archive." << std::endl;
|
||||
return 1;
|
||||
// Try universal version as fallback
|
||||
std::cout << "Arch-specific version not found, trying universal version..." << std::endl;
|
||||
std::cout << "Downloading " << toolName << ":universal..." << std::endl;
|
||||
if (!getbin2.download(toolName, "universal", archivePath.string())) {
|
||||
std::cerr << "Failed to download tool archive (tried both " << arch << " and universal)." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
downloadArch = "universal";
|
||||
}
|
||||
|
||||
// Unpack tool
|
||||
@ -207,7 +215,7 @@ int install_tool(int argc, char* argv[]) {
|
||||
|
||||
// Get tool info
|
||||
std::string hash;
|
||||
getbin2.getHash(toolName, arch, hash);
|
||||
getbin2.getHash(toolName, downloadArch, hash);
|
||||
std::string version;
|
||||
std::string toolPath = binDir.string() + "/" + toolName;
|
||||
std::string versionCmd = shellEscape(toolPath) + " version";
|
||||
@ -231,7 +239,7 @@ int install_tool(int argc, char* argv[]) {
|
||||
{"name", toolName},
|
||||
{"version", version},
|
||||
{"hash", hash},
|
||||
{"arch", arch}
|
||||
{"arch", downloadArch}
|
||||
};
|
||||
std::ofstream toolInfoFile(toolInfoPath);
|
||||
toolInfoFile << toolInfo.dump(2);
|
||||
@ -256,6 +264,11 @@ int publish_tool(int argc, char* argv[]) {
|
||||
}
|
||||
std::string labeltag = argv[2];
|
||||
std::string folder = argv[3];
|
||||
|
||||
// If no ARCH is provided (no colon in labeltag), append ":universal" for cross-platform tools
|
||||
if (labeltag.find(':') == std::string::npos) {
|
||||
labeltag += ":universal";
|
||||
}
|
||||
std::string home = get_home();
|
||||
std::filesystem::path archivePath = std::filesystem::path(home) / ".tmp" / (labeltag + ".tgz");
|
||||
std::filesystem::create_directories(archivePath.parent_path());
|
||||
|
@ -285,6 +285,25 @@ EOF
|
||||
else
|
||||
print_test_result "Publish tool without ARCH" 1
|
||||
fi
|
||||
|
||||
# Test 12c: Install universal tool (arch fallback)
|
||||
echo -e "\nTest 12c: Install universal tool (arch fallback)"
|
||||
rm -rf ~/.config/getpkg/"${TEST_TOOL_NOARCH}.json" ~/.local/bin/getpkg/"${TEST_TOOL_NOARCH}" 2>/dev/null || true
|
||||
FALLBACK_INSTALL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || FALLBACK_INSTALL_OUTPUT=""
|
||||
if [[ "$FALLBACK_INSTALL_OUTPUT" =~ "Arch-specific version not found, trying universal version" ]] && [[ "$FALLBACK_INSTALL_OUTPUT" =~ "Installed ${TEST_TOOL_NOARCH} successfully" ]]; then
|
||||
print_test_result "Install universal tool with arch fallback" 0
|
||||
|
||||
# Test update check for universal tool
|
||||
UPDATE_UNIVERSAL_OUTPUT=$(timeout 3 "$GETPKG" install "${TEST_TOOL_NOARCH}" 2>&1) || UPDATE_UNIVERSAL_OUTPUT=""
|
||||
if [[ "$UPDATE_UNIVERSAL_OUTPUT" =~ "${TEST_TOOL_NOARCH} is already up to date" ]]; then
|
||||
print_test_result "Update check for universal tool" 0
|
||||
else
|
||||
print_test_result "Update check for universal tool" 1
|
||||
fi
|
||||
else
|
||||
print_test_result "Install universal tool with arch fallback" 1
|
||||
print_test_result "Update check for universal tool" 1
|
||||
fi
|
||||
else
|
||||
echo -e "\n${YELLOW}Skipping publish/install tests (SOS_WRITE_TOKEN not set)${NC}"
|
||||
echo "To run full tests, set SOS_WRITE_TOKEN environment variable"
|
||||
|
10
getpkg/test_debug/test-noarch-37801/test-noarch-37801
Normal file
10
getpkg/test_debug/test-noarch-37801/test-noarch-37801
Normal file
@ -0,0 +1,10 @@
|
||||
#\!/bin/bash
|
||||
case "$1" in
|
||||
version)
|
||||
echo "1.0.0"
|
||||
;;
|
||||
*)
|
||||
echo "Cross-platform test tool"
|
||||
;;
|
||||
esac
|
||||
EOF < /dev/null
|
9
getpkg/test_debug/test-noarch-37879/test-noarch-37879
Executable file
9
getpkg/test_debug/test-noarch-37879/test-noarch-37879
Executable file
@ -0,0 +1,9 @@
|
||||
#\!/bin/bash
|
||||
case "$1" in
|
||||
version)
|
||||
echo "1.0.0"
|
||||
;;
|
||||
*)
|
||||
echo "Cross-platform test tool"
|
||||
;;
|
||||
esac
|
9
getpkg/test_debug/test-universal-12345/test-universal-12345
Executable file
9
getpkg/test_debug/test-universal-12345/test-universal-12345
Executable file
@ -0,0 +1,9 @@
|
||||
#\!/bin/bash
|
||||
case "$1" in
|
||||
version)
|
||||
echo "1.0.0"
|
||||
;;
|
||||
*)
|
||||
echo "Universal test tool"
|
||||
;;
|
||||
esac
|
2
getpkg/test_debug/test-universal-40978/test-universal-40978
Executable file
2
getpkg/test_debug/test-universal-40978/test-universal-40978
Executable file
@ -0,0 +1,2 @@
|
||||
#\!/bin/bash
|
||||
echo "Universal test tool v1.0.0"
|
Loading…
x
Reference in New Issue
Block a user