-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
73 lines (70 loc) · 2.58 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
version: '3'
vars:
DLR: curl
DLR_FLAGS: "-L"
ALPINE_REL: "3.21"
ALPINE_VER: "3.21.3"
ALPINE_ARCH: "x86_64"
ALPINE_CDN: dl-cdn.alpinelinux.org
ALPINE_MIRROR: mirrors.cloud.tencent.com
BASE_URL: "https://{{.ALPINE_MIRROR}}/alpine/v{{.ALPINE_REL}}/releases/x86_64/alpine-minirootfs-{{.ALPINE_VER}}-{{.ALPINE_ARCH}}.tar.gz"
tasks:
default:
cmds:
- task: clean
- task: build
build:
desc: "构建一个为WSL环境定制的Alpine Linux根文件系统包"
deps: [base]
cmds:
- task: profile
- "echo -e '\\e[1;31mBuilding rootfs...\\e[m'"
- sudo mkdir rootfs
- sudo tar -zxpf base.tar.gz -C rootfs
- sudo cp -f profile rootfs/etc/profile
- "sudo echo 'nameserver 114.114.115.115' >> rootfs/etc/resolv.conf"
- "sudo echo 'nameserver 9.9.9.9' >> rootfs/etc/resolv.conf"
- sudo chroot rootfs /bin/sed -i 's|{{.ALPINE_CDN}}|{{.ALPINE_MIRROR}}|g' /etc/apk/repositories
- sudo chroot rootfs /sbin/apk update
- sudo chroot rootfs /sbin/apk upgrade
- sudo chroot rootfs /sbin/apk add bash vim curl wget htop tree xz zip unzip shadow
- sudo chroot rootfs /usr/bin/chsh -s /bin/bash root
- "echo '# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.' | sudo tee rootfs/etc/resolv.conf"
- "sudo rm -rf `find rootfs/var/cache/apk/ -type f`"
- "sudo chmod +x rootfs"
- "echo -e '\\e[1;31mBuilding rootfs.tar.gz...\\e[m'"
- "sudo tar -zcpf ./dist/rootfs.tar.gz -C ./rootfs ."
- "sudo chown `id -un` ./dist/rootfs.tar.gz"
container:
desc: "把制作的根文件系统导入到podman镜像库中"
cmds:
- podman manifest create alpine-base
- podman build --platform linux/amd64 --manifest alpine-base --tag alpine:latest .
- podman manifest inspect alpine-base
- podman image prune -f
clean:
desc: "删除中间产生的临时文件"
cmds:
- sudo rm -f base.tar.gz
- sudo rm -f profile
- sudo rm -rf rootfs
base:
desc: "下载一个Alpine Linux指定版本的mini rootfs压缩包作为基础的rootfs树"
cmds:
- "echo -e '\\e[1;31mDownloading base.tar.gz...\\e[m'"
- "{{.DLR}} {{.DLR_FLAGS}} {{.BASE_URL}} -o base.tar.gz"
profile:
cmds:
- |
cat > profile <<'EOF'
export CHARSET=UTF-8
export LANG=C.UTF-8
export PAGER=less
export PS1='\\h:\\w \\\$ '
umask 022
for script in /etc/profile.d/*.sh ; do
if [ -r \\$script ] ; then
. \\$script
fi
done
EOF