Skip to content

Commit 68b2536

Browse files
authored
fix: Format filesizes (#280)
1 parent 157ca3e commit 68b2536

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM scratch
2-
COPY --from=qemux/qemu-arm:3.05 / /
2+
COPY --from=qemux/qemu-arm:3.06 / /
33

44
ARG VERSION_ARG="0.00"
55
ARG DEBCONF_NOWARNINGS="yes"

readme.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/mas
9595
9696
Select from the values below:
9797
98-
| **Value** | **Version** | **Platform** | **Size** |
99-
|---|---|---|---|
100-
| `11` | Windows 11 Pro | ARM64 | 4.8 GB |
101-
| `11l` | Windows 11 LTSC | ARM64 | 4.7 GB |
102-
| `11e` | Windows 11 Enterprise | ARM64 | 4.8 GB |
103-
|||||
104-
| `10` | Windows 10 Pro | ARM64 | 3.5 GB |
105-
| `10l` | Windows 10 LTSC | ARM64 | 4.1 GB |
106-
| `10e` | Windows 10 Enterprise | ARM64 | 3.4 GB |
98+
| **Value** | **Version** | **Size** |
99+
|---|---|---|
100+
| `11` | Windows 11 Pro | 4.8 GB |
101+
| `11l` | Windows 11 LTSC | 4.7 GB |
102+
| `11e` | Windows 11 Enterprise | 4.8 GB |
103+
||||
104+
| `10` | Windows 10 Pro | 3.5 GB |
105+
| `10l` | Windows 10 LTSC | 4.1 GB |
106+
| `10e` | Windows 10 Enterprise | 3.4 GB |
107107

108108
> [!TIP]
109109
> To install x64 versions of Windows, use [dockur/windows](https://github.com/dockur/windows/).
@@ -379,6 +379,10 @@ The example folder `./example` will be available as ` \\host.lan\Data`.
379379

380380
- it could help to add `privileged: true` to your compose file (or `sudo` to your `docker run` command), to rule out any permission issue.
381381

382+
### How do I run a Linux desktop in a container?
383+
384+
You can use [qemus/qemu-arm](https://github.com/qemus/qemu-arm) in that case.
385+
382386
### Is this project legal?
383387

384388
Yes, this project contains only open-source code and does not distribute any copyrighted material. Any product keys found in the code are just generic placeholders provided by Microsoft for trial purposes. So under all applicable laws, this project will be considered legal.

src/install.sh

+9-9
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ extractESD() {
250250
mkdir -p "$dir"
251251

252252
size=16106127360
253-
size_gb=$(( (size + 1073741823)/1073741824 ))
253+
size_gb=$(formatBytes "$size")
254254
space=$(df --output=avail -B 1 "$dir" | tail -n 1)
255-
space_gb=$(( (space + 1073741823)/1073741824 ))
255+
space_gb=$(formatBytes "$space")
256256

257257
if (( size > space )); then
258-
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
258+
error "Not enough free space in $STORAGE, have $space_gb available but need at least $size_gb." && return 1
259259
fi
260260

261261
local esdImageCount
@@ -341,16 +341,16 @@ extractImage() {
341341
mkdir -p "$dir"
342342

343343
size=$(stat -c%s "$iso")
344-
size_gb=$(( (size + 1073741823)/1073741824 ))
344+
size_gb=$(formatBytes "$size")
345345
space=$(df --output=avail -B 1 "$dir" | tail -n 1)
346-
space_gb=$(( (space + 1073741823)/1073741824 ))
346+
space_gb=$(formatBytes "$space")
347347

348348
if ((size<100000000)); then
349349
error "Invalid ISO file: Size is smaller than 100 MB" && return 1
350350
fi
351351

352352
if (( size > space )); then
353-
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
353+
error "Not enough free space in $STORAGE, have $space_gb available but need at least $size_gb." && return 1
354354
fi
355355

356356
rm -rf "$dir"
@@ -953,12 +953,12 @@ buildImage() {
953953
fi
954954

955955
size=$(du -h -b --max-depth=0 "$dir" | cut -f1)
956-
size_gb=$(( (size + 1073741823)/1073741824 ))
956+
size_gb=$(formatBytes "$size")
957957
space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
958-
space_gb=$(( (space + 1073741823)/1073741824 ))
958+
space_gb=$(formatBytes "$space")
959959

960960
if (( size > space )); then
961-
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1
961+
error "Not enough free space in $STORAGE, have $space_gb available but need at least $size_gb." && return 1
962962
fi
963963

964964
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then

src/mido.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,15 @@ downloadFile() {
516516
local size="$4"
517517
local lang="$5"
518518
local desc="$6"
519-
local rc total progress domain dots space folder
519+
local rc total total_gb progress domain dots space folder
520520

521521
rm -f "$iso"
522522

523523
if [ -n "$size" ] && [[ "$size" != "0" ]]; then
524524
folder=$(dirname -- "$iso")
525525
space=$(df --output=avail -B 1 "$folder" | tail -n 1)
526-
(( size > space )) && error "Not enough free space left to download file!" && return 1
526+
total_gb=$(formatBytes "$space")
527+
(( size > space )) && error "Not enough free space to download file, only $total_gb left!" && return 1
527528
fi
528529

529530
# Check if running with interactive TTY or redirected to docker log
@@ -553,8 +554,9 @@ downloadFile() {
553554

554555
if (( rc == 0 )) && [ -f "$iso" ]; then
555556
total=$(stat -c%s "$iso")
557+
total_gb=$(formatBytes "$total")
556558
if [ "$total" -lt 100000000 ]; then
557-
error "Invalid download link: $url (is only $total bytes?). Please report this at $SUPPORT/issues." && return 1
559+
error "Invalid download link: $url (is only $total_gb ?). Please report this at $SUPPORT/issues." && return 1
558560
fi
559561
verifyFile "$iso" "$size" "$total" "$sum" || return 1
560562
html "Download finished successfully..." && return 0

0 commit comments

Comments
 (0)