Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cmake/macros/rv_stage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,19 @@ FUNCTION(rv_stage)
MESSAGE(DEBUG "Found version for '${arg_TARGET}.rvpkg' package version ${_pkg_version} ...")
ENDIF()

# Normalize version for filename: strip .0 patch if present, keep non-zero patches
# Only strip if it's a 3-part version ending in .0 (e.g. 2.5.0 -> 2.5, but keep 2.0 as-is)
SET(_pkg_version_normalized "${_pkg_version}")
STRING(REGEX REPLACE "^([0-9]+\\.[0-9]+)\\.0$" "\\1" _pkg_version_normalized "${_pkg_version}")
IF(NOT "${_pkg_version}" STREQUAL "${_pkg_version_normalized}")
MESSAGE(DEBUG "Normalized package version from '${_pkg_version}' to '${_pkg_version_normalized}' for filename")
ENDIF()

SET(_package_filename
"${RV_PACKAGES_DIR}/${arg_TARGET}-${_pkg_version}.rvpkg"
"${RV_PACKAGES_DIR}/${arg_TARGET}-${_pkg_version_normalized}.rvpkg"
)

LIST(APPEND RV_PACKAGE_LIST "${RV_PACKAGES_DIR}/${arg_TARGET}-${_pkg_version}.rvpkg")
LIST(APPEND RV_PACKAGE_LIST "${RV_PACKAGES_DIR}/${arg_TARGET}-${_pkg_version_normalized}.rvpkg")
LIST(REMOVE_DUPLICATES RV_PACKAGE_LIST)
SET(RV_PACKAGE_LIST
${RV_PACKAGE_LIST}
Expand Down Expand Up @@ -472,11 +480,11 @@ FUNCTION(rv_stage)
)

ADD_CUSTOM_TARGET(
${arg_TARGET}-${_pkg_version}.rvpkg ALL
${arg_TARGET}-${_pkg_version_normalized}.rvpkg ALL
DEPENDS ${_package_filename}
)

ADD_DEPENDENCIES(packages ${arg_TARGET}-${_pkg_version}.rvpkg)
ADD_DEPENDENCIES(packages ${arg_TARGET}-${_pkg_version_normalized}.rvpkg)
ENDIF()

ELSEIF(${arg_TYPE} STREQUAL "IMAGE_FORMAT")
Expand Down
46 changes: 36 additions & 10 deletions src/lib/app/RvPackage/PackageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ namespace Rv
{
using namespace std;

// Normalize version string to major.minor.patch format
// If only major.minor is provided, append .0 for patch
QString normalizeVersion(const QString& version)
{
QString v = version.trimmed();

// Count the number of dots
int dotCount = v.count('.');

// If we have 0 or 1 dots, we need to add patch version
if (dotCount == 0)
{
// major only -> major.0.0
return v + ".0.0";
}
else if (dotCount == 1)
{
// major.minor -> major.minor.0
return v + ".0";
}

// Already has 2+ dots, return as-is
return v;
}

QString extractFile(unzFile uf, const string& outputPath)
{
char filename[256];
Expand All @@ -45,7 +70,9 @@ namespace Rv
FILE* outFile = std::fopen(fullPath.c_str(), "wb");
if (outFile == nullptr)
{
cerr << "ERROR: Unable to open output file" << endl;
cerr << "ERROR: Unable to open output file: " << fullPath << endl;
cerr << " Directory: " << parentDir.absolutePath().toStdString() << endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: The CI is failing because parentDir isn't defined:
/Users/runner/work/OpenRV/OpenRV/src/lib/app/RvPackage/PackageManager.cpp:74:45: error: use of undeclared identifier 'parentDir' 74 | cerr << " Directory: " << parentDir.absolutePath().toStdString() << endl;

cerr << " Check permissions and disk space." << endl;
unzCloseCurrentFile(uf);
return "";
}
Expand Down Expand Up @@ -87,11 +114,8 @@ namespace Rv
do
{
QString extractedFilePath = extractFile(uf, outputPath);
if (extractedFilePath == "")
{
cerr << "ERROR: Unable to extract zip file" << endl;
}
else
// Only add .rvpkg files to the list, ignore directories and other files
if (!extractedFilePath.isEmpty() && extractedFilePath.endsWith(".rvpkg"))
{
includedPackages.push_back(extractedFilePath);
}
Expand Down Expand Up @@ -1291,7 +1315,7 @@ namespace Rv
else if (pname == "contact")
package.contact = v;
else if (pname == "version")
package.version = v;
package.version = normalizeVersion(v);
else if (pname == "requires")
package.
requires
Expand Down Expand Up @@ -1346,7 +1370,8 @@ namespace Rv
});
}

QRegularExpression rvpkgRE(R"((.*)-[0-9]+\.[0-9]+\.rvpkg)");
// Add support for optional packages with patch version
QRegularExpression rvpkgRE(R"((.*)-[0-9]+\.[0-9]+(\.[0-9]+)?\.rvpkg)");
QRegularExpression zipRE(R"((.*)\.zip)");

QRegularExpressionMatch match = rvpkgRE.match(finfo.fileName());
Expand Down Expand Up @@ -1722,8 +1747,9 @@ namespace Rv
// First check that package files exist and have legal names
//

QRegularExpression rvpkgRE(R"((.*)-[0-9]+\.[0-9]+\.rvpkg)");
QRegularExpression rvpkgsRE(R"(.*)-[0-9]+\.[0-9]+\.rvpkgs)"); // bundle
// Add support for optional packages with patch version
QRegularExpression rvpkgRE(R"((.*)-[0-9]+\.[0-9]+(\.[0-9]+)?\.rvpkg)");
QRegularExpression rvpkgsRE(R"(.*)-[0-9]+\.[0-9]+(\.[0-9]+)?\.rvpkgs)"); // bundle
QRegularExpression zipRE(R"((.*)\.zip)");

for (size_t i = 0; i < files.size(); i++)
Expand Down
21 changes: 17 additions & 4 deletions src/lib/app/mu_rvui/mode_manager.mu
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class: ModeManagerMode : MinorMode
string base;
int major;
int minor;
int patch;
Package existing;
}

Expand Down Expand Up @@ -531,28 +532,40 @@ class: ModeManagerMode : MinorMode

int major = 1;
int minor = 0;
int patch = 0;

if (ext == "rvpkg")
{
let error = false;
try
{
let vparts = name.split("-")[1].split(".");
major = int(vparts[0]);
minor = int(vparts[1]);
// Support both major.minor and major.minor.patch formats
if (vparts.size() >= 2)
{
major = int(vparts[0]);
minor = int(vparts[1]);

if (vparts.size() > 2)
patch = int(vparts[2]);
}
else
{
error = true;
}
}
catch (...)
{
error = true;
}

if (error) {
print("ERROR: bad rvpkg package name \"%s\" expecting name-X.X.rvpkg\n" % name);
print("ERROR: bad rvpkg package name \"%s\" expecting name-X.X.rvpkg or name-X.X.X.rvpkg\n" % name);
return nil;
}
}

_packages.push_back(Package(name, without_extension(name), base, major, minor, existing));
_packages.push_back(Package(name, without_extension(name), base, major, minor, patch, existing));
return _packages.back();
}

Expand Down
Loading