Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/registry package index #2623

Merged
merged 8 commits into from
May 31, 2024
Merged
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
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ install: $(ALL_TARGETS)
$(call mkdir,$(DESTDIR)/usr/lib/startos/system-images)
$(call cp,system-images/compat/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/startos/system-images/compat.tar)
$(call cp,system-images/utils/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/startos/system-images/utils.tar)
$(call cp,system-images/binfmt/docker-images/$(ARCH).tar,$(DESTDIR)/usr/lib/startos/system-images/binfmt.tar)

$(call cp,firmware/$(PLATFORM),$(DESTDIR)/usr/lib/startos/firmware)

Expand Down Expand Up @@ -184,7 +183,7 @@ container-runtime/node_modules: container-runtime/package.json container-runtime
npm --prefix container-runtime ci
touch container-runtime/node_modules

sdk/lib/osBindings: $(shell core/startos/bindings)
sdk/lib/osBindings: core/startos/bindings
mkdir -p sdk/lib/osBindings
ls core/startos/bindings/*.ts | sed 's/core\/startos\/bindings\/\([^.]*\)\.ts/export { \1 } from ".\/\1";/g' > core/startos/bindings/index.ts
npm --prefix sdk exec -- prettier --config ./sdk/package.json -w ./core/startos/bindings/*.ts
Expand Down
13 changes: 13 additions & 0 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions core/helpers/src/script_dir.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use std::path::{Path, PathBuf};

use models::{PackageId, Version};
use models::{PackageId, VersionString};

pub const PKG_SCRIPT_DIR: &str = "package-data/scripts";

pub fn script_dir<P: AsRef<Path>>(datadir: P, pkg_id: &PackageId, version: &Version) -> PathBuf {
pub fn script_dir<P: AsRef<Path>>(
datadir: P,
pkg_id: &PackageId,
version: &VersionString,
) -> PathBuf {
datadir
.as_ref()
.join(&*PKG_SCRIPT_DIR)
Expand Down
2 changes: 2 additions & 0 deletions core/models/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub enum ErrorKind {
Timeout = 71,
Lxc = 72,
Cancelled = 73,
Git = 74,
}
impl ErrorKind {
pub fn as_str(&self) -> &'static str {
Expand Down Expand Up @@ -167,6 +168,7 @@ impl ErrorKind {
Timeout => "Timeout Error",
Lxc => "LXC Error",
Cancelled => "Cancelled",
Git => "Git Error",
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/models/src/id/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::str::FromStr;
use serde::{Deserialize, Deserializer, Serialize};
use ts_rs::TS;

use crate::{Id, InvalidId, PackageId, Version};
use crate::{Id, InvalidId, PackageId, VersionString};

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, TS)]
#[ts(type = "string")]
Expand All @@ -21,7 +21,7 @@ impl std::fmt::Display for ImageId {
}
}
impl ImageId {
pub fn for_package(&self, pkg_id: &PackageId, pkg_version: Option<&Version>) -> String {
pub fn for_package(&self, pkg_id: &PackageId, pkg_version: Option<&VersionString>) -> String {
format!(
"start9/{}/{}:{}",
pkg_id,
Expand Down
44 changes: 22 additions & 22 deletions core/models/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,89 +6,89 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use ts_rs::TS;

#[derive(Debug, Clone, TS)]
#[ts(type = "string")]
pub struct Version {
#[ts(type = "string", rename = "Version")]
pub struct VersionString {
version: emver::Version,
string: String,
}
impl Version {
impl VersionString {
pub fn as_str(&self) -> &str {
self.string.as_str()
}
pub fn into_version(self) -> emver::Version {
self.version
}
}
impl std::fmt::Display for Version {
impl std::fmt::Display for VersionString {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.string)
}
}
impl std::str::FromStr for Version {
impl std::str::FromStr for VersionString {
type Err = <emver::Version as FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Version {
Ok(VersionString {
string: s.to_owned(),
version: s.parse()?,
})
}
}
impl From<emver::Version> for Version {
impl From<emver::Version> for VersionString {
fn from(v: emver::Version) -> Self {
Version {
VersionString {
string: v.to_string(),
version: v,
}
}
}
impl From<Version> for emver::Version {
fn from(v: Version) -> Self {
impl From<VersionString> for emver::Version {
fn from(v: VersionString) -> Self {
v.version
}
}
impl Default for Version {
impl Default for VersionString {
fn default() -> Self {
Self::from(emver::Version::default())
}
}
impl Deref for Version {
impl Deref for VersionString {
type Target = emver::Version;
fn deref(&self) -> &Self::Target {
&self.version
}
}
impl AsRef<emver::Version> for Version {
impl AsRef<emver::Version> for VersionString {
fn as_ref(&self) -> &emver::Version {
&self.version
}
}
impl AsRef<str> for Version {
impl AsRef<str> for VersionString {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl PartialEq for Version {
fn eq(&self, other: &Version) -> bool {
impl PartialEq for VersionString {
fn eq(&self, other: &VersionString) -> bool {
self.version.eq(&other.version)
}
}
impl Eq for Version {}
impl PartialOrd for Version {
impl Eq for VersionString {}
impl PartialOrd for VersionString {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.version.partial_cmp(&other.version)
}
}
impl Ord for Version {
impl Ord for VersionString {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.version.cmp(&other.version)
}
}
impl Hash for Version {
impl Hash for VersionString {
fn hash<H: Hasher>(&self, state: &mut H) {
self.version.hash(state)
}
}
impl<'de> Deserialize<'de> for Version {
impl<'de> Deserialize<'de> for VersionString {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
Expand All @@ -98,7 +98,7 @@ impl<'de> Deserialize<'de> for Version {
Ok(Self { string, version })
}
}
impl Serialize for Version {
impl Serialize for VersionString {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
1 change: 1 addition & 0 deletions core/startos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ console-subscriber = { version = "0.2", optional = true }
cookie = "0.18.0"
cookie_store = "0.20.0"
current_platform = "0.2.0"
der = { version = "0.7.9", features = ["derive", "pem"] }
digest = "0.10.7"
divrem = "1.0.0"
ed25519 = { version = "2.2.3", features = ["pkcs8", "pem", "alloc"] }
Expand Down
8 changes: 4 additions & 4 deletions core/startos/src/backup/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::util::clap::FromStrParser;
use crate::util::serde::{
deserialize_from_str, display_serializable, serialize_display, HandlerExtSerde, WithIoFormat,
};
use crate::util::Version;
use crate::util::VersionString;

pub mod cifs;

Expand Down Expand Up @@ -194,7 +194,7 @@ pub async fn list(ctx: RpcContext) -> Result<BTreeMap<BackupTargetId, BackupTarg
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BackupInfo {
pub version: Version,
pub version: VersionString,
pub timestamp: Option<DateTime<Utc>>,
pub package_backups: BTreeMap<PackageId, PackageBackupInfo>,
}
Expand All @@ -203,8 +203,8 @@ pub struct BackupInfo {
#[serde(rename_all = "camelCase")]
pub struct PackageBackupInfo {
pub title: String,
pub version: Version,
pub os_version: Version,
pub version: VersionString,
pub os_version: VersionString,
pub timestamp: DateTime<Utc>,
}

Expand Down
6 changes: 3 additions & 3 deletions core/startos/src/context/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::context::config::{local_config_path, ClientConfig};
use crate::context::{DiagnosticContext, InstallContext, RpcContext, SetupContext};
use crate::middleware::auth::LOCAL_AUTH_COOKIE_PATH;
use crate::prelude::*;
use crate::rpc_continuations::RequestGuid;
use crate::rpc_continuations::Guid;

#[derive(Debug)]
pub struct CliContextSeed {
Expand Down Expand Up @@ -164,7 +164,7 @@ impl CliContext {

pub async fn ws_continuation(
&self,
guid: RequestGuid,
guid: Guid,
) -> Result<WebSocketStream<MaybeTlsStream<TcpStream>>, Error> {
let mut url = self.base_url.clone();
let ws_scheme = match url.scheme() {
Expand Down Expand Up @@ -194,7 +194,7 @@ impl CliContext {

pub async fn rest_continuation(
&self,
guid: RequestGuid,
guid: Guid,
body: reqwest::Body,
headers: reqwest::header::HeaderMap,
) -> Result<reqwest::Response, Error> {
Expand Down
7 changes: 3 additions & 4 deletions core/startos/src/db/model/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::net::utils::{get_iface_ipv4_addr, get_iface_ipv6_addr};
use crate::prelude::*;
use crate::progress::FullProgress;
use crate::util::cpupower::Governor;
use crate::util::Version;
use crate::util::VersionString;
use crate::version::{Current, VersionT};
use crate::{ARCH, PLATFORM};

Expand Down Expand Up @@ -109,8 +109,7 @@ pub struct ServerInfo {
pub platform: InternedString,
pub id: String,
pub hostname: String,
#[ts(type = "string")]
pub version: Version,
pub version: VersionString,
#[ts(type = "string | null")]
pub last_backup: Option<DateTime<Utc>>,
#[ts(type = "string")]
Expand All @@ -136,7 +135,7 @@ pub struct ServerInfo {
#[serde(default)]
pub zram: bool,
pub governor: Option<Governor>,
pub smtp: Option<String>
pub smtp: Option<String>,
}

#[derive(Debug, Deserialize, Serialize, HasModel, TS)]
Expand Down
4 changes: 2 additions & 2 deletions core/startos/src/disk/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::mount::guard::TmpMountGuard;
use crate::disk::mount::guard::GenericMountGuard;
use crate::disk::OsPartitionInfo;
use crate::util::serde::IoFormat;
use crate::util::{Invoke, Version};
use crate::util::{Invoke, VersionString};
use crate::{Error, ResultExt as _};

#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -56,7 +56,7 @@ pub struct PartitionInfo {
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EmbassyOsRecoveryInfo {
pub version: Version,
pub version: VersionString,
pub full: bool,
pub password_hash: Option<String>,
pub wrapped_key: Option<String>,
Expand Down
Loading
Loading