Skip to content

Commit

Permalink
Update Dockerfile to work with xbstrap, update docs and README
Browse files Browse the repository at this point in the history
  • Loading branch information
fido2020 committed Jan 29, 2022
1 parent de9d553 commit d211303
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 72 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
path: |
**/Build/tool-builds
**/Toolchain
**/mlibc
key: ${{ runner.os }}-lemon-toolchain-${{ hashFiles('llvm-hash.txt') }}
restore-keys: |
${{ runner.os }}-lemon-toolchain-${{ hashFiles('llvm-hash.txt') }}
Expand Down Expand Up @@ -105,6 +106,7 @@ jobs:
path: |
**/Build/tool-builds
**/Toolchain
**/mlibc
key: ${{ runner.os }}-lemon-toolchain-${{ hashFiles('llvm-hash.txt') }}
restore-keys: |
${{ runner.os }}-lemon-toolchain-${{ hashFiles('llvm-hash.txt') }}
Expand Down
38 changes: 0 additions & 38 deletions Documentation/Build/Building-Lemon-OS-with-Docker.md

This file was deleted.

36 changes: 27 additions & 9 deletions Documentation/Build/Building-Lemon-OS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
### *Building the toolchain can take an extremely long time, a Docker image has been built. Consider [Building Lemon OS with Docker](Building-Lemon-OS-with-Docker.md)*

### *Building the toolchain can take an extremely long time. Consider building with Docker*

## Contents
- [Standard Setup (requires building toolchain)](#Standard-Setup)
- [Docker Setup (faster)](#Docker-Setup)
- [Build and run](#Build-and-run)

## Prerequisites
_NOTE: Building on WSL2 is doable, however I strongly recommend an actual UNIX system._
* A UNIX-like build system
* An existing GCC toolchain
* Root access
* [Meson](https://mesonbuild.com/Getting-meson.html)
* Root access (to build the disk image)
* The following packages OR Docker

## Linux
# Standard Setup
*NOTE: It is recommended that you install meson from pip, some distributions (e.g. Ubuntu) offer outdated meson packages*

### Arch Linux
Expand Down Expand Up @@ -47,14 +49,30 @@ This will build binutils, LLVM, automake, libtool and limine for Lemon OS. This

You may run out of RAM whilst building LLVM (especially during the linking stage), so I recommend no more than **12 compile jobs (default determined by ninja, based on CPU thread count) on 16GB of RAM** I have changed the default amount parallel of linker jobs to 2. **If you run out of RAM, close some memory hungry applications and re-run the command.** See `host-llvm` in [bootstrap.yml](../../bootstrap.yml)

## Build and run
Run `xbstrap install --all`, or `xbstrap install lemon-base` to only install the core applications and libraries.
# Docker Setup
Run `Scripts/docker-init.sh`
```sh
Scripts/docker-init.sh
```

This will do the following:
- Pull docker image
- Initialize xbstrap
- Extract prebuilt toolchain
- Install toolchain

# Build and run
In `Build/`, run `xbstrap install --all`, or `xbstrap install lemon-base` to only install the core applications and libraries.
```sh
xbstrap install lemon-base # Build and install base applications and libraries

OR

xbstrap install --all # Build and install everything

OR

xbstrap install lemon-base # Build and install base applications and libraries
xbstrap install lemon-base lemondoom # Build and install the packages you want
```

To build the disk image (requires root privileges) run
Expand Down
1 change: 0 additions & 1 deletion Documentation/Build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

### Building Lemon OS
[Building Lemon OS](Building-Lemon-OS.md) \
[Building Lemon OS with Docker (Outdated)](Building-Lemon-OS-with-Docker.md)

### Lemon Toolchain
[LIC (Lemon Interface Compiler)](lic.md)
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ Lemon OS includes its own [modular kernel](Kernel) with SMP and networking, [win

If you have any questions or concerns feel free to open a GitHub issue, join our [Discord server](https://discord.gg/NAYp6AUYWM) or email me at [email protected].

[Website](https://lemonos.org) \
[Discord Server](https://discord.gg/NAYp6AUYWM)

## Building
- [Building Lemon OS (Requires building toolchain)](Documentation/Build/Building-Lemon-OS.md)
- [Building Lemon OS with Docker](Documentation/Build/Building-Lemon-OS-with-Docker.md)
## [Website](https://lemonos.org)
## [Discord Server](https://discord.gg/NAYp6AUYWM)
## [Building Lemon OS](Documentation/Build/Building-Lemon-OS.md)

## Prebuilt Image
[Nightly Images](https://github.com/LemonOSProject/LemonOS/actions/workflows/ci.yml?query=is%3Asuccess+branch%3Amaster) - Go to latest job, `Lemon.img` located under Artifacts\
Expand Down
30 changes: 19 additions & 11 deletions Scripts/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
FROM alpine:3.12

RUN apk add --no-cache nasm python3 ninja make cmake automake autoconf libtool make gcc g++ musl-dev git curl patch e2fsprogs dosfstools
RUN apk add --no-cache nasm python3 python3-dev ninja make cmake automake autoconf libtool make gcc g++ musl-dev git curl patch zstd coreutils \
# automake needs GNU gzip
gzip \
# libtool
help2man xz \
# wayland-scanner
expat-dev \
# used by binutils
texinfo bison flex \
# limine, disk image
mtools dosfstools e2fsprogs

RUN cd /root && curl https://raw.githubusercontent.com/fido2020/Lemon-OS/master/Toolchain/buildtoolchain.sh -o buildtoolchain.sh && curl https://raw.githubusercontent.com/fido2020/Lemon-OS/master/Toolchain/lemon-binutils-2.32.patch -o lemon-binutils-2.32.patch && chmod 755 /root/buildtoolchain.sh
RUN python3 -m ensurepip; python3 -m pip install meson xbstrap

RUN /root/buildtoolchain.sh prepare
RUN /root/buildtoolchain.sh binutils
RUN /root/buildtoolchain.sh llvm CC=gcc CXX=g++
RUN /root/buildtoolchain.sh limine
RUN if [ ! -f "/root/.local/share/lemon/bin/clang" ]; then ninja -C /root/llvm-project/build install; fi && ln -sf /root/.local/share/lemon/bin/clang /root/.local/share/lemon/bin/lemon-clang && ln -sf /root/.local/share/lemon/bin/clang++ /root/.local/share/lemon/bin/lemon-clang++ && ln -sf ../../include/c++ /root/.local/share/lemon/sysroot/system/include/c++ \
&& cd /root/.local/share/lemon/bin && rm clang-repl clang-scan-deps clang-check clang-refactor clang-rename clang-extdef-mapping diagtool \
&& /root/buildtoolchain.sh clean && python3 -m ensurepip --default-pip && python3 -m pip install meson && chmod -R a+rx /root

ENV PATH=$PATH:/root/.local/share/lemon/bin:/root/.local/share/lemon/x86_64-lemon/bin/
WORKDIR /var
RUN set -e; git clone https://github.com/LemonOSProject/LemonOS --depth 1; find LemonOS/ -maxdepth 1 -mindepth 1 -type d \
-not -name patches -not -name Ports -not -name Scripts -exec rm -rf {} +
RUN cd LemonOS; mkdir Build; cd Build; xbstrap init ..
RUN cd LemonOS/Build; xbstrap compile-tool --all;
RUN mkdir -p /var/lemon-tools/Build; mv /var/LemonOS/Toolchain /var/lemon-tools; mv /var/LemonOS/Build/tool-builds /var/lemon-tools/Build/tool-builds; \
tar -cvf - lemon-tools | zstd - -o lemon-tools.tar.zst; rm -rf LemonOS lemon-tools; chmod 644 /var/lemon-tools.tar.zst
5 changes: 5 additions & 0 deletions Scripts/docker-bootstrap-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
container:
runtime: docker
image: lemontoolchain
src_mount: /var/LemonOS
build_mount: /var/LemonOS/Build
17 changes: 17 additions & 0 deletions Scripts/docker-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

docker pull computerfido/lemontoolchain:latest

SPATH=$(dirname $(readlink -f "$0"))

cd $SPATH/..

mkdir -p Build

cp Scripts/docker-bootstrap-site.yml Build/bootstrap-site.yml
echo " create_extra_args: ['--user', '$(id -u):$(id -g)']" >> Build/bootstrap-site.yml

cd Build/
xbstrap init ..
docker run -v "$SPATH/..:/var/LemonOS" -w $(pwd) --user $(id -u):$(id -g) -it computerfido/lemontoolchain:latest sh -c "zstd -d /var/lemon-tools.tar.zst --stdout | tar -oxvf - -C /var/LemonOS --strip-components=1; chown -hR $(id -u) /var/LemonOS"
xbstrap install-tool --all
6 changes: 0 additions & 6 deletions Scripts/docker-run.sh

This file was deleted.

1 change: 1 addition & 0 deletions bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ tasks:
- '@SOURCE_ROOT@/Scripts/buildinitrd.sh'

- name: build-disk
containerless: true
tasks_required:
- build-initrd
tools_required:
Expand Down
2 changes: 1 addition & 1 deletion mlibc

0 comments on commit d211303

Please sign in to comment.