diff --git a/Makefile b/Makefile index 05aceb3..382bed4 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ rust_bins := $(patsubst $(rust_src_dir)/%.rs, $(rust_bin_path)/%, $(wildcard $(r ucore_bin_path := ucore/build/$(arch) biscuit_bin_path := biscuit/build/$(arch) busybox := $(out_dir)/busybox +alpine_version_major := 3.9 +alpine_version_full := 3.9.2 +alpine_file := alpine-minirootfs-3.9.2-$(arch).tar.gz +alpine := alpine/$(alpine_file) rust_build_args := --target targets/$(arch)-rcore.json cmake_build_args := -DARCH=$(arch) @@ -22,7 +26,7 @@ cmake_build_args += -DCMAKE_BUILD_TYPE=Release endif -.PHONY: all clean build rust ucore biscuit bin busybox nginx redis +.PHONY: all clean build rust ucore biscuit bin busybox nginx redis alpine all: build @@ -92,6 +96,15 @@ ifneq ($(shell uname), Darwin) endif endif +$(alpine): + wget "http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/$(arch)/$(alpine_file)" -O $(alpine) + +alpine: $(alpine) +ifeq ($(arch), $(filter $(arch), x86_64 aarch64)) + @mkdir -p $(out_dir) + @cd $(out_dir) && tar xvf ../../$(alpine) +endif + build: rust ucore biscuit $(busybox) nginx redis sfsimg: $(out_qcow2) diff --git a/README.md b/README.md index 86957cc..ae4444d 100644 --- a/README.md +++ b/README.md @@ -10,28 +10,30 @@ Now it has 4 parts: * `ucore`: C-lang, from the original [ucore_os_lab](https://github.com/chyyuu/ucore_os_plus) * `biscuit`: C/C++, from [Biscuit](https://github.com/mit-pdos/biscuit), based on a `musl` instead of original `litc`. * `rust`: Simple no_std Rust programs. -* `nginx`, `redis`: Real world applications. +* `nginx`, `redis`, `busybox`, `alpine`: Real world applications. ## Build To build biscuit programs, install musl toolchain first: ```bash -# for ARCH linux -$ sudo pacman -Syu musl # archlinux -# for macOS -$ brew install FileSottile/musl-cross/musl-cross -# for ubuntu 16.04, we should build gcc-musl for newest musl-1.1.21 -# please see build-gcc-musl.md -# for riscv musl toolchain, please install [musl-riscv-toolchain](https://github.com/jiegec/musl-riscv-toolchain) +# 1. to download prebuilt binaries in Linux, visit [musl.cc](https://musl.cc) +# 2. to build musl toolchains from source: +# 2.1 for macOS musl toolchain for x86_64(,aarch64) +$ brew install FileSottile/musl-cross/musl-cross {--with-aarch64} +# 2.2 for ubuntu 16.04, we should build gcc-musl for newest musl-1.1.21, please see build-gcc-musl.md for instructions +# 2.3 for riscv musl toolchain, please install [musl-riscv-toolchain](https://github.com/jiegec/musl-riscv-toolchain) ``` +Then, build userspace programs for rCore: + ```bash $ make {ucore,biscuit,rust,nginx,redis,all} arch={x86_64,aarch64,riscv32,riscv64} +$ make alpine arch={x86_64,aarch64} # if you want to use alpine rootfs $ make sfsimg arch={x86_64,aarch64,riscv32,riscv64} ``` -Output to `build/$(arch)` +A rootfs is created at `build/$(arch)` and converted to `qcow2`. ## Support matrix @@ -43,18 +45,21 @@ Output to `build/$(arch)` | nginx (linux only) | ✅ | ✅ | ❌ | ✅ | | redis (linux only) | ✅ | ✅ | ✅ | ❌ | | busybox | ✅ | ✅ | ❌ | ✅ | +| alpine rootfs | ✅ | ✅ | ❌ | ❌ | ## How to use Redis -After running commands above, you should be able to run redis-server in rCore. Then, start `redis-server` in rCore: +If redis is dynamically linked to musl (default if you use commands above), you might need to copy `ld-musl-$(arch).so.1` to rootfs `/lib` . Alpine rootfs includes one as well. + +After building redis, you should be able to run redis-server in rCore. Then, start `redis-server` in rCore: ```bash /> redis-server redis.conf ``` -Then you should be able to connect to it using `redis-cli`: +Then you should be able to connect to it using `redis-cli` over the network: ```bash $ redis-cli -h 10.0.0.2 set abc def diff --git a/alpine/.gitignore b/alpine/.gitignore new file mode 100644 index 0000000..335ec95 --- /dev/null +++ b/alpine/.gitignore @@ -0,0 +1 @@ +*.tar.gz