Skip to content

Commit

Permalink
feat(cli): set default ram-image to always be /usr/share/cartesi-mach…
Browse files Browse the repository at this point in the history
…ine/images/linux.bin
  • Loading branch information
tuler committed Nov 11, 2024
1 parent fd9e215 commit 21375e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-news-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/cli": major
---

set default ram-image to always be '/usr/share/cartesi-machine/images/linux.bin'
19 changes: 3 additions & 16 deletions apps/cli/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import bytes from "bytes";
import os from "os";
import { extname } from "path";
import { TomlPrimitive, parse as parseToml } from "smol-toml";

Expand Down Expand Up @@ -74,10 +73,7 @@ export class InvalidStringArrayError extends Error {
*/
const DEFAULT_FORMAT = "ext2";
const DEFAULT_RAM = "128Mi";
const DEFAULT_RAM_IMAGE_DOCKER = "/usr/share/cartesi-machine/images/linux.bin";
const DEFAULT_RAM_IMAGE_LINUX = "/usr/share/cartesi-machine/images/linux.bin";
const DEFAULT_RAM_IMAGE_MAC =
"/opt/homebrew/share/cartesi-machine/images/linux.bin";
const DEFAULT_RAM_IMAGE = "/usr/share/cartesi-machine/images/linux.bin";
export const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.1";

type Builder = "directory" | "docker" | "empty" | "none" | "tar";
Expand Down Expand Up @@ -172,15 +168,6 @@ export const defaultRootDriveConfig = (): DriveConfig => ({
tags: [],
});

export const defaultRamImage = (): string => {
switch (os.platform()) {
case "darwin":
return DEFAULT_RAM_IMAGE_MAC;
default:
return DEFAULT_RAM_IMAGE_LINUX;
}
};

export const defaultMachineConfig = (): MachineConfig => ({
assertRollingTemplate: undefined,
bootargs: [],
Expand All @@ -190,7 +177,7 @@ export const defaultMachineConfig = (): MachineConfig => ({
maxMCycle: undefined,
noRollup: undefined,
ramLength: DEFAULT_RAM,
ramImage: defaultRamImage(),
ramImage: DEFAULT_RAM_IMAGE,
store: "image",
user: undefined,
});
Expand Down Expand Up @@ -368,7 +355,7 @@ const parseMachine = (value: TomlPrimitive): MachineConfig => {
maxMCycle: parseOptionalNumber(toml["max-mcycle"]),
noRollup: parseBoolean(toml["no-rollup"], false),
ramLength: parseString(toml["ram-length"], DEFAULT_RAM),
ramImage: parseString(toml["ram-image"], defaultRamImage()),
ramImage: parseString(toml["ram-image"], DEFAULT_RAM_IMAGE),
store: "image",
user: parseOptionalString(toml.user),
};
Expand Down

0 comments on commit 21375e8

Please sign in to comment.