Rewrite README. Add docker.

master
WangRunji 7 years ago
parent 7f6576c9dc
commit 4ce1ba8f6d

1
.gitignore vendored

@ -1,2 +1,3 @@
build
target
Cargo.lock

@ -34,9 +34,34 @@ $(kernel): kernel $(rust_os) $(assembly_object_files) $(linker_script)
$(assembly_object_files) $(rust_os)
kernel:
@xargo build --target $(target)
@RUST_TARGET_PATH=$(shell pwd) xargo build --target $(target)
# compile assembly files
build/arch/$(arch)/%.o: src/arch/$(arch)/%.asm
@mkdir -p $(shell dirname $@)
@nasm -felf64 $< -o $@
# used by docker_* targets
docker_image ?= blog_os
tag ?= 0.1
docker_cargo_volume ?= blogos-$(shell id -u)-$(shell id -g)-cargo
docker_rustup_volume ?= blogos-$(shell id -u)-$(shell id -g)-rustup
docker_args ?= -e LOCAL_UID=$(shell id -u) -e LOCAL_GID=$(shell id -g) -v $(docker_cargo_volume):/usr/local/cargo -v $(docker_rustup_volume):/usr/local/rustup -v $(shell pwd):$(shell pwd) -w $(shell pwd)
docker_clean_args ?= $(docker_cargo_volume) $(docker_rustup_volume)
# docker_* targets
docker_build:
@docker build docker/ -t $(docker_image):$(tag)
docker_iso:
@docker run --rm $(docker_args) $(docker_image):$(tag) make iso
docker_run: docker_iso
@qemu-system-x86_64 -cdrom $(iso) -s
docker_interactive:
@docker run -it --rm $(docker_args) $(docker_image):$(tag)
docker_clean:
@docker volume rm $(docker_clean_args)

@ -1,16 +1,19 @@
# Blog OS (Double Faults)
[![Build Status](https://travis-ci.org/phil-opp/blog_os.svg?branch=post_10)](https://travis-ci.org/phil-opp/blog_os/branches)
# RustOS for x86_64 SMP
This repository contains the source code for the [Double Faults](http://os.phil-opp.com/double-faults.html) post of the [Writing an OS in Rust](http://os.phil-opp.com) series.
A project of THU OS2018 spring.
**Check out the [master branch](https://github.com/phil-opp/blog_os) for more information.**
[Project Wiki](http://os.cs.tsinghua.edu.cn/oscourse/OS2018spring/projects/g11)
The goal is to write a mini OS in Rust with multicore supporting.
It will start from the post of the [Writing an OS in Rust](http://os.phil-opp.com) series. Then reimplement [xv6-x86_64](https://github.com/jserv/xv6-x86_64) in Rust style.
## Building
You need to have `nasm`, `grub-mkrescue`, `xorriso`, `qemu`, a nightly Rust compiler, and [xargo] installed. Then you can run it using `make run`.
[xargo]: https://github.com/japaric/xargo
You need to have `nasm`, `grub-mkrescue`, `xorriso`, `qemu`, a nightly Rust compiler, and `xargo` installed. Then you can run it using `make run`.
Please file an issue if you have any problems.
A docker image is available and recommanded. Read [this](docker/README.md) for details.
## License
The source code is dual-licensed under MIT or the Apache License (Version 2.0).

@ -0,0 +1 @@
PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[1;35m\]<$IMAGE_NAME>\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "

@ -0,0 +1,40 @@
FROM rustlang/rust:nightly
ENV IMAGE_NAME=blog_os-docker
RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
nasm \
binutils \
grub-common \
xorriso \
grub-pc-bin && \
apt-get autoremove -q -y && \
apt-get clean -q -y && \
rm -rf /var/lib/apt/lists/* && \
cargo install xargo && \
rustup component add rust-src
ENV GOSU_VERSION 1.10
RUN set -ex; \
\
fetchDeps=' \
ca-certificates \
wget \
'; \
apt-get update; \
apt-get install -y --no-install-recommends $fetchDeps; \
rm -rf /var/lib/apt/lists/*; \
\
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
chmod +x /usr/local/bin/gosu; \
# verify that the binary works
gosu nobody true;
COPY entrypoint.sh /usr/local/bin/
COPY .bash_aliases /etc/skel/
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["/bin/bash"]

@ -0,0 +1,18 @@
# Building Blog OS using Docker
Inspired by [redox].
You just need `git`, `make`, and `docker`.
It is beter to use a non-privileged user to run the `docker` command, which is usually achieved by adding the user to the `docker` group.
## Run the container to build Blog OS
You can build the docker image using `make docker_build` and run it using `make docker_run`.
## Run the container interactively
You can use the `make` target `docker_interactive` to get a shell in the container.
## Clear the toolchain caches (Cargo & Rustup)
To clean the docker volumes used by the toolchain, you just need to run `make docker_clean`.
[redox]: https://github.com/redox-os/redox
## License
The source code is dual-licensed under MIT or the Apache License (Version 2.0). This excludes the `blog` directory.

@ -0,0 +1,19 @@
#!/bin/sh
USER_NAME=blogos
USER_UID=${LOCAL_UID:-9001}
USER_GID=${LOCAL_GID:-9001}
groupadd --non-unique --gid $USER_GID $USER_NAME
useradd --non-unique --create-home --uid $USER_UID --gid $USER_GID $USER_NAME
export HOME=/home/$USER_NAME
TESTFILE=$RUSTUP_HOME/settings.toml
CACHED_UID=$(stat -c "%u" $TESTFILE)
CACHED_GID=$(stat -c "%g" $TESTFILE)
if [ $CACHED_UID != $USER_UID ] || [ $USER_GID != $CACHED_GID ]; then
chown $USER_UID:$USER_GID -R $CARGO_HOME $RUSTUP_HOME
fi
exec gosu $USER_NAME "$@"

@ -1,3 +1,4 @@
#![feature(ptr_internals)]
#![feature(lang_items)]
#![feature(const_fn)]
#![feature(alloc)]

Loading…
Cancel
Save