Skip to content

Commit 8b71904

Browse files
authored
feat: Install Location & adapt Reset button for this possibility & feat: CPU threads & cores are consistent now, updated to strictly physical cores everywhere (#219)
* feat: Install Location & adapt Reset button for this possibility fix/chore: CPU threads & cores are consistent now, updated to strictly physical cores everywhere * chore: Bump version to 0.8.6-alpha for new alpha
1 parent 45f3582 commit 8b71904

10 files changed

Lines changed: 191 additions & 48 deletions

File tree

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "winboat",
3-
"version": "0.8.5",
3+
"version": "0.8.6-alpha",
44
"description": "Windows for Penguins",
55
"type": "module",
66
"main": "main/main.js",
@@ -41,6 +41,7 @@
4141
"@vueuse/core": "^13.1.0",
4242
"@vueuse/motion": "^2.2.6",
4343
"apexcharts": "^4.5.0",
44+
"check-disk-space": "^3.4.0",
4445
"consola": "^3.4.2",
4546
"electron-store": "^11.0.0",
4647
"form-data": "^4.0.4",

src/renderer/lib/install.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,23 @@ export class InstallManager {
111111
createComposeFile() {
112112
this.changeState(InstallStates.CREATING_COMPOSE_FILE);
113113

114-
// Ensure the directory exists
114+
// Ensure the .winboat directory exists
115115
if (!fs.existsSync(WINBOAT_DIR)) {
116116
fs.mkdirSync(WINBOAT_DIR);
117117
logger.info(`Created WinBoat directory: ${WINBOAT_DIR}`);
118118
}
119119

120+
// Ensure the installation directory exists
121+
if (!fs.existsSync(this.conf.installFolder)) {
122+
fs.mkdirSync(this.conf.installFolder, { recursive: true });
123+
logger.info(`Created installation directory: ${this.conf.installFolder}`);
124+
}
125+
120126
// Configure the compose file
121127
const composeContent = { ...DefaultCompose }
122128

123129
composeContent.services.windows.environment.RAM_SIZE = `${this.conf.ramGB}G`;
124-
composeContent.services.windows.environment.CPU_CORES = `${this.conf.cpuThreads}`;
130+
composeContent.services.windows.environment.CPU_CORES = `${this.conf.cpuCores}`;
125131
composeContent.services.windows.environment.DISK_SIZE = `${this.conf.diskSpaceGB}G`;
126132
composeContent.services.windows.environment.VERSION = this.conf.windowsVersion;
127133
composeContent.services.windows.environment.LANGUAGE = this.conf.windowsLanguage;
@@ -131,6 +137,15 @@ export class InstallManager {
131137
if (this.conf.customIsoPath) {
132138
composeContent.services.windows.volumes.push(`${this.conf.customIsoPath}:/boot.iso`);
133139
}
140+
141+
const storageFolderIdx = composeContent.services.windows.volumes.findIndex(vol => vol.includes('/storage'));
142+
if (storageFolderIdx !== -1) {
143+
composeContent.services.windows.volumes[storageFolderIdx] = `${this.conf.installFolder}:/storage`;
144+
} else {
145+
logger.warn("No /storage volume found in compose template, adding one...");
146+
composeContent.services.windows.volumes.push(`${this.conf.installFolder}:/storage`);
147+
}
148+
134149

135150
// Write the compose file
136151
const composeYAML = YAML.stringify(composeContent).replaceAll("null", "");

src/renderer/lib/specs.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ export function satisfiesPrequisites(specs: Specs) {
1515
specs.iptableNatLoaded &&
1616
specs.kvmEnabled &&
1717
specs.ramGB >= 4 &&
18-
specs.cpuThreads >= 2 &&
19-
specs.diskSpaceGB >= 32
18+
specs.cpuCores >= 2
2019
}
2120

2221
export const defaultSpecs: Specs = {
23-
cpuThreads: 0,
22+
cpuCores: 0,
2423
ramGB: 0,
25-
diskSpaceGB: 0,
2624
kvmEnabled: false,
2725
dockerInstalled: false,
2826
dockerComposeInstalled: false,
@@ -36,7 +34,13 @@ export const defaultSpecs: Specs = {
3634
export async function getSpecs() {
3735
const specs: Specs = { ...defaultSpecs };
3836

39-
specs.cpuThreads = os.cpus().length;
37+
// Physical CPU cores check
38+
try {
39+
const res = (await execAsync('lscpu -p | egrep -v "^#" | sort -u -t, -k 2,4 | wc -l')).stdout;
40+
specs.cpuCores = parseInt(res.trim(), 10);
41+
} catch(e) {
42+
console.error('Error getting CPU cores:', e);
43+
}
4044

4145
// TODO: These commands might silently fail
4246
// But if they do, it means something wasn't right to begin with
@@ -47,18 +51,6 @@ export async function getSpecs() {
4751
console.error('Error reading /proc/meminfo:', e);
4852
}
4953

50-
// Docker check
51-
try {
52-
// We use /var here because /var/lib/docker is _the_ location for Docker data.
53-
// Also it covers cases of immutable distros using Podman (hello Bazzite!), since
54-
// /home is a symlink to /var/home there.
55-
// TODO:hdkv where does Podman stores the images and the data on non-immutables (aka regular Fedora)?
56-
const diskStats = fs.statfsSync('/var');
57-
specs.diskSpaceGB = Math.round(diskStats.bavail * diskStats.bsize / 1024 / 1024 / 1024 * 100) / 100;
58-
} catch (e) {
59-
console.error('Error getting disk space for /var:', e);
60-
}
61-
6254
// KVM check
6355
try {
6456
const cpuInfo = fs.readFileSync('/proc/cpuinfo', 'utf8');

src/renderer/lib/winboat.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,22 @@ export class Winboat {
557557
await execAsync("docker rm WinBoat")
558558
console.info("Removed container")
559559

560-
// 3. Remove the container volume
561-
await execAsync("docker volume rm winboat_data");
562-
console.info("Removed volume");
560+
// 3. Remove the container volume or folder
561+
const compose = this.parseCompose();
562+
const storage = compose.services.windows.volumes.find(vol => vol.includes('/storage'));
563+
if (storage?.startsWith("data:")) {
564+
// In this case we have a volume (legacy)
565+
await execAsync("docker volume rm winboat_data");
566+
console.info("Removed volume");
567+
} else {
568+
const storageFolder = storage?.split(":").at(0) ?? null;
569+
if (storageFolder && fs.existsSync(storageFolder)) {
570+
fs.rmSync(storageFolder, { recursive: true, force: true });
571+
console.info(`Removed storage folder at ${storageFolder}`);
572+
} else {
573+
console.warn("Storage folder does not exist, skipping removal");
574+
}
575+
}
563576

564577
// 4. Remove WinBoat directory
565578
fs.rmSync(WINBOAT_DIR, { recursive: true, force: true });
Lines changed: 1 addition & 0 deletions
Loading

src/renderer/views/About.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="flex flex-col items-center justify-center h-[calc(100vh-9rem)]">
3-
<img class="w-48" src="/img/winboat_logo.png">
3+
<img class="w-48" src="/img/winboat_logo.svg">
44
<h2 class="mb-0">WinBoat</h2>
55
<p class="text-sm text-gray-500">Windows for 🐧 penguins</p>
66
<p class="text-gray-400 !mt-4">WinBoat Beta v{{ appVer }} {{ isDev ? 'Dev' : 'Prod' }}</p>

src/renderer/views/Config.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ async function assignValues() {
479479
480480
const specs = await getSpecs();
481481
maxRamGB.value = specs.ramGB;
482-
maxNumCores.value = specs.cpuThreads;
482+
maxNumCores.value = specs.cpuCores;
483483
484484
refreshAvailableDevices();
485485
}

0 commit comments

Comments
 (0)