fix: Format filesizes (#280)

This commit is contained in:
Kroese 2025-03-15 14:16:16 +01:00 committed by GitHub
parent 157ca3e80c
commit 68b2536858
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 22 deletions

View file

@ -1,5 +1,5 @@
FROM scratch FROM scratch
COPY --from=qemux/qemu-arm:3.05 / / COPY --from=qemux/qemu-arm:3.06 / /
ARG VERSION_ARG="0.00" ARG VERSION_ARG="0.00"
ARG DEBCONF_NOWARNINGS="yes" ARG DEBCONF_NOWARNINGS="yes"

View file

@ -95,15 +95,15 @@ kubectl apply -f https://raw.githubusercontent.com/dockur/windows/refs/heads/mas
Select from the values below: Select from the values below:
| **Value** | **Version** | **Platform** | **Size** | | **Value** | **Version** | **Size** |
|---|---|---|---| |---|---|---|
| `11` | Windows 11 Pro | ARM64 | 4.8 GB | | `11` | Windows 11 Pro | 4.8 GB |
| `11l` | Windows 11 LTSC | ARM64 | 4.7 GB | | `11l` | Windows 11 LTSC | 4.7 GB |
| `11e` | Windows 11 Enterprise | ARM64 | 4.8 GB | | `11e` | Windows 11 Enterprise | 4.8 GB |
||||| ||||
| `10` | Windows 10 Pro | ARM64 | 3.5 GB | | `10` | Windows 10 Pro | 3.5 GB |
| `10l` | Windows 10 LTSC | ARM64 | 4.1 GB | | `10l` | Windows 10 LTSC | 4.1 GB |
| `10e` | Windows 10 Enterprise | ARM64 | 3.4 GB | | `10e` | Windows 10 Enterprise | 3.4 GB |
> [!TIP] > [!TIP]
> To install x64 versions of Windows, use [dockur/windows](https://github.com/dockur/windows/). > 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`.
- it could help to add `privileged: true` to your compose file (or `sudo` to your `docker run` command), to rule out any permission issue. - it could help to add `privileged: true` to your compose file (or `sudo` to your `docker run` command), to rule out any permission issue.
### How do I run a Linux desktop in a container?
You can use [qemus/qemu-arm](https://github.com/qemus/qemu-arm) in that case.
### Is this project legal? ### Is this project legal?
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. 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.

View file

@ -250,12 +250,12 @@ extractESD() {
mkdir -p "$dir" mkdir -p "$dir"
size=16106127360 size=16106127360
size_gb=$(( (size + 1073741823)/1073741824 )) size_gb=$(formatBytes "$size")
space=$(df --output=avail -B 1 "$dir" | tail -n 1) space=$(df --output=avail -B 1 "$dir" | tail -n 1)
space_gb=$(( (space + 1073741823)/1073741824 )) space_gb=$(formatBytes "$space")
if (( size > space )); then if (( size > space )); then
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1 error "Not enough free space in $STORAGE, have $space_gb available but need at least $size_gb." && return 1
fi fi
local esdImageCount local esdImageCount
@ -341,16 +341,16 @@ extractImage() {
mkdir -p "$dir" mkdir -p "$dir"
size=$(stat -c%s "$iso") size=$(stat -c%s "$iso")
size_gb=$(( (size + 1073741823)/1073741824 )) size_gb=$(formatBytes "$size")
space=$(df --output=avail -B 1 "$dir" | tail -n 1) space=$(df --output=avail -B 1 "$dir" | tail -n 1)
space_gb=$(( (space + 1073741823)/1073741824 )) space_gb=$(formatBytes "$space")
if ((size<100000000)); then if ((size<100000000)); then
error "Invalid ISO file: Size is smaller than 100 MB" && return 1 error "Invalid ISO file: Size is smaller than 100 MB" && return 1
fi fi
if (( size > space )); then if (( size > space )); then
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1 error "Not enough free space in $STORAGE, have $space_gb available but need at least $size_gb." && return 1
fi fi
rm -rf "$dir" rm -rf "$dir"
@ -953,12 +953,12 @@ buildImage() {
fi fi
size=$(du -h -b --max-depth=0 "$dir" | cut -f1) size=$(du -h -b --max-depth=0 "$dir" | cut -f1)
size_gb=$(( (size + 1073741823)/1073741824 )) size_gb=$(formatBytes "$size")
space=$(df --output=avail -B 1 "$TMP" | tail -n 1) space=$(df --output=avail -B 1 "$TMP" | tail -n 1)
space_gb=$(( (space + 1073741823)/1073741824 )) space_gb=$(formatBytes "$space")
if (( size > space )); then if (( size > space )); then
error "Not enough free space in $STORAGE, have $space_gb GB available but need at least $size_gb GB." && return 1 error "Not enough free space in $STORAGE, have $space_gb available but need at least $size_gb." && return 1
fi fi
if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then if [[ "${BOOT_MODE,,}" != "windows_legacy" ]]; then

View file

@ -516,14 +516,15 @@ downloadFile() {
local size="$4" local size="$4"
local lang="$5" local lang="$5"
local desc="$6" local desc="$6"
local rc total progress domain dots space folder local rc total total_gb progress domain dots space folder
rm -f "$iso" rm -f "$iso"
if [ -n "$size" ] && [[ "$size" != "0" ]]; then if [ -n "$size" ] && [[ "$size" != "0" ]]; then
folder=$(dirname -- "$iso") folder=$(dirname -- "$iso")
space=$(df --output=avail -B 1 "$folder" | tail -n 1) space=$(df --output=avail -B 1 "$folder" | tail -n 1)
(( size > space )) && error "Not enough free space left to download file!" && return 1 total_gb=$(formatBytes "$space")
(( size > space )) && error "Not enough free space to download file, only $total_gb left!" && return 1
fi fi
# Check if running with interactive TTY or redirected to docker log # Check if running with interactive TTY or redirected to docker log
@ -553,8 +554,9 @@ downloadFile() {
if (( rc == 0 )) && [ -f "$iso" ]; then if (( rc == 0 )) && [ -f "$iso" ]; then
total=$(stat -c%s "$iso") total=$(stat -c%s "$iso")
total_gb=$(formatBytes "$total")
if [ "$total" -lt 100000000 ]; then if [ "$total" -lt 100000000 ]; then
error "Invalid download link: $url (is only $total bytes?). Please report this at $SUPPORT/issues." && return 1 error "Invalid download link: $url (is only $total_gb ?). Please report this at $SUPPORT/issues." && return 1
fi fi
verifyFile "$iso" "$size" "$total" "$sum" || return 1 verifyFile "$iso" "$size" "$total" "$sum" || return 1
html "Download finished successfully..." && return 0 html "Download finished successfully..." && return 0