Skip to content

Commit

Permalink
meta: Bump cutekit and allow the tool to be installed.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Jan 21, 2025
1 parent 15d6211 commit 454560a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
2 changes: 1 addition & 1 deletion meta/plugins/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git+https://github.com/cute-engineering/cutekit.git@0.7.10
git+https://github.com/cute-engineering/cutekit.git@0.7.12
Markdown~=3.7
12 changes: 11 additions & 1 deletion src/impls/impl-posix/pkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@
namespace Karm::Pkg::_Embed {

Res<Vec<String>> installedBundles() {
auto repoRoot = try$(Mime::parseUrlOrPath(try$(Posix::repoRoot())));
auto [repo, format] = try$(Posix::repoRoot());
Mime::Url repoRoot;
if (format == Posix::RepoType::CUTEKIT) {
repoRoot = Mime::Url::parse(repo);
} else if (format == Posix::RepoType::PREFIX) {
repoRoot = Mime::Url::parse(repo)
.join("share");
} else {
return Error::notFound("unknown repo type");
}

auto dirs = try$(Sys::_Embed::readDir(repoRoot));
Vec<String> ids;
for (auto& dir : dirs) {
Expand Down
20 changes: 15 additions & 5 deletions src/impls/impl-posix/sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,25 @@ Res<Mime::Path> resolve(Mime::Url const& url) {

resolved = Mime::Path::parse(runtimeDir).join(path);
} else if (url.scheme == "bundle") {
auto repo = try$(Posix::repoRoot());
auto [repo, format] = try$(Posix::repoRoot());

auto path = url.path;
path.rooted = false;

resolved = Mime::Path::parse(repo)
.join(url.host)
.join("__res__")
.join(path);
if (format == Posix::RepoType::CUTEKIT) {
resolved = Mime::Path::parse(repo)
.join(url.host)
.join("__res__")
.join(path);
} else if (format == Posix::RepoType::PREFIX) {
resolved = Mime::Path::parse(repo)
.join("share")
.join(url.host)
.join(path);
logDebug("resolved bundle path: {}", resolved);
} else {
return Error::notFound("unknown repo type");
}
} else if (url.scheme == "location") {
auto* maybeHome = getenv("HOME");
if (not maybeHome)
Expand Down
30 changes: 20 additions & 10 deletions src/impls/impl-posix/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,31 @@ struct timespec toTimespec(TimeSpan ts) {
return pts;
}

Res<Str> repoRoot() {
Res<Tuple<Str, RepoType>> repoRoot() {
auto* maybeRepo = getenv("CK_BUILDDIR");
if (maybeRepo) {
return Ok(Tuple<Str, RepoType>{
Str::fromNullterminated(maybeRepo),
RepoType::CUTEKIT,
});
}

if (not maybeRepo)
maybeRepo = getenv("SKIFT_BUNDLES");
maybeRepo = getenv("SKIFT_BUNDLES");
if (maybeRepo) {
return Ok(Tuple<Str, RepoType>{
Str::fromNullterminated(maybeRepo),
RepoType::CUTEKIT,
});
}

#ifdef __ck_prefix__
if (not maybeRepo)
maybeRepo = __ck_prefix__;
#ifdef __ck_prefix_value
return Ok(Tuple<Str, RepoType>{
stringify$(__ck_prefix_value) ""s,
RepoType::PREFIX,
});
#endif

if (not maybeRepo)
return Error::notFound("SKIFT_BUNDLES not set");

return Ok(Str::fromNullterminated(maybeRepo));
return Error::notFound("SKIFT_BUNDLES not set");
}

} // namespace Posix
7 changes: 6 additions & 1 deletion src/impls/impl-posix/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ struct timespec toTimespec(TimeStamp ts);

struct timespec toTimespec(TimeSpan ts);

Res<Str> repoRoot();
enum struct RepoType {
CUTEKIT,
PREFIX
};

Res<Tuple<Str, RepoType>> repoRoot();

} // namespace Posix

0 comments on commit 454560a

Please sign in to comment.