Allow user to download and extract alpinelinux rootfs in Makefile

master
Jiajie Chen 6 years ago
parent bf70c66685
commit 315299114e

@ -12,6 +12,10 @@ rust_bins := $(patsubst $(rust_src_dir)/%.rs, $(rust_bin_path)/%, $(wildcard $(r
ucore_bin_path := ucore/build/$(arch) ucore_bin_path := ucore/build/$(arch)
biscuit_bin_path := biscuit/build/$(arch) biscuit_bin_path := biscuit/build/$(arch)
busybox := $(out_dir)/busybox 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 rust_build_args := --target targets/$(arch)-rcore.json
cmake_build_args := -DARCH=$(arch) cmake_build_args := -DARCH=$(arch)
@ -22,7 +26,7 @@ cmake_build_args += -DCMAKE_BUILD_TYPE=Release
endif 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 all: build
@ -92,6 +96,15 @@ ifneq ($(shell uname), Darwin)
endif endif
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 build: rust ucore biscuit $(busybox) nginx redis
sfsimg: $(out_qcow2) sfsimg: $(out_qcow2)

@ -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) * `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`. * `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. * `rust`: Simple no_std Rust programs.
* `nginx`, `redis`: Real world applications. * `nginx`, `redis`, `busybox`, `alpine`: Real world applications.
## Build ## Build
To build biscuit programs, install musl toolchain first: To build biscuit programs, install musl toolchain first:
```bash ```bash
# for ARCH linux # 1. to download prebuilt binaries in Linux, visit [musl.cc](https://musl.cc)
$ sudo pacman -Syu musl # archlinux # 2. to build musl toolchains from source:
# for macOS # 2.1 for macOS musl toolchain for x86_64(,aarch64)
$ brew install FileSottile/musl-cross/musl-cross $ brew install FileSottile/musl-cross/musl-cross {--with-aarch64}
# for ubuntu 16.04, we should build gcc-musl for newest musl-1.1.21 # 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
# please see build-gcc-musl.md # 2.3 for riscv musl toolchain, please install [musl-riscv-toolchain](https://github.com/jiegec/musl-riscv-toolchain)
# for riscv musl toolchain, please install [musl-riscv-toolchain](https://github.com/jiegec/musl-riscv-toolchain)
``` ```
Then, build userspace programs for rCore:
```bash ```bash
$ make {ucore,biscuit,rust,nginx,redis,all} arch={x86_64,aarch64,riscv32,riscv64} $ 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} $ 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 ## Support matrix
@ -43,18 +45,21 @@ Output to `build/$(arch)`
| nginx (linux only) | ✅ | ✅ | ❌ | ✅ | | nginx (linux only) | ✅ | ✅ | ❌ | ✅ |
| redis (linux only) | ✅ | ✅ | ✅ | ❌ | | redis (linux only) | ✅ | ✅ | ✅ | ❌ |
| busybox | ✅ | ✅ | ❌ | ✅ | | busybox | ✅ | ✅ | ❌ | ✅ |
| alpine rootfs | ✅ | ✅ | ❌ | ❌ |
## How to use Redis ## 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 ```bash
/> redis-server redis.conf /> 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 ```bash
$ redis-cli -h 10.0.0.2 set abc def $ redis-cli -h 10.0.0.2 set abc def

1
alpine/.gitignore vendored

@ -0,0 +1 @@
*.tar.gz
Loading…
Cancel
Save