-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
134 lines (110 loc) · 4.81 KB
/
Makefile
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
OUT_TGZ=rootfs.tar.gz
DLR=curl
DLR_FLAGS=-L
BASE_URL=http://mirrors.edge.kernel.org/archlinux/iso/2024.04.01/archlinux-bootstrap-x86_64.tar.gz
FRTCP_URL=https://github.com/yuk7/arch-prebuilt/releases/download/24042500/fakeroot-tcp-1.34-1-x86_64.pkg.tar.zst
GLIBC_URL=https://github.com/yuk7/arch-prebuilt/releases/download/24042500/glibc-2.39-2-x86_64.pkg.tar.zst
GLIBC_LINUX4_URL=https://github.com/yuk7/arch-prebuilt/releases/download/24042500/glibc-linux4-2.39-2-x86_64.pkg.tar.zst
PAC_PKGS=archlinux-keyring base less nano sudo vim curl
all: $(OUT_TGZ)
tgz: $(OUT_TGZ)
$(OUT_TGZ): rootfinal.tmp
@echo -e '\e[1;31mBuilding $(OUT_TGZ)\e[m'
cd root.x86_64; sudo bsdtar -zcpf ../$(OUT_TGZ) *
sudo chown `id -un` $(OUT_TGZ)
rootfinal.tmp: glibc.tmp fakeroot.tmp locale.tmp glibc-linux4.pkg.tar.zst
@echo -e '\e[1;31mCleaning files from rootfs...\e[m'
yes | sudo chroot root.x86_64 /usr/bin/pacman -Scc
sudo umount root.x86_64/sys
sudo umount root.x86_64/proc
-sudo umount root.x86_64/sys
-sudo umount root.x86_64/proc
sudo mv -f root.x86_64/etc/mtab.bak root.x86_64/etc/mtab
sudo cp -f pacman.conf root.x86_64/etc/pacman.conf
echo "# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line." | sudo tee root.x86_64/etc/resolv.conf
sudo rm -rf root.x86_64/etc/machine-id
sudo rm -rf root.x86_64/usr/lib/systemd/system/sysinit.target.wants/systemd-firstboot.service
sudo rm -rf `sudo find root.x86_64/root/ -type f`
sudo rm -rf `sudo find root.x86_64/tmp/ -type f`
@echo -e '\e[1;31mCopy Extra files to rootfs...\e[m'
sudo cp bash_profile root.x86_64/root/.bash_profile
sudo cp glibc-linux4.pkg.tar.zst root.x86_64/root/glibc-linux4.pkg.tar.zst
sudo cp wsl.conf root.x86_64/etc/wsl.conf
echo > rootfinal.tmp
fakeroot.tmp: proc-tmp.tmp glibc.tmp fakeroot-tcp.pkg.tar.zst
@echo -e '\e[1;31mInstalling fakeroot-tcp...\e[m'
sudo cp -f fakeroot-tcp.pkg.tar.zst root.x86_64/root/fakeroot-tcp.pkg.tar.zst
yes | sudo chroot root.x86_64 /usr/bin/pacman -U /root/fakeroot-tcp.pkg.tar.zst
sudo rm -rf root.x86_64/root/fakeroot-tcp.pkg.tar.zst
touch fakeroot.tmp
glibc.tmp: proc-tmp.tmp pacpkgs.tmp glibc.pkg.tar.zst
@echo -e '\e[1;31mInstalling glibc...\e[m'
sudo cp -f glibc.pkg.tar.zst root.x86_64/root/glibc.tar.zst
yes | sudo chroot root.x86_64 /usr/bin/pacman -U /root/glibc.tar.zst
sudo rm -rf root.x86_64/root/glibc.pkg.tar.zst
touch glibc.tmp
pacpkgs.tmp: proc-tmp.tmp resolv-tmp.tmp mirrorlist-tmp.tmp paccnf-tmp.tmp
@echo -e '\e[1;31mInstalling basic packages...\e[m'
sudo chroot root.x86_64 /usr/bin/pacman -Syu --noconfirm $(PAC_PKGS)
sudo mkdir -p root.x86_64/etc/pacman.d/hooks
sudo cp -f setcap-iputils.hook root.x86_64/etc/pacman.d/hooks/50-setcap-iputils.hook
sudo setcap cap_net_raw+p root.x86_64/usr/bin/ping
touch pacpkgs.tmp
locale.tmp: proc-tmp.tmp pacpkgs.tmp
sudo sed -i -e "s/#en_US.UTF-8/en_US.UTF-8/" root.x86_64/etc/locale.gen
echo "LANG=en_US.UTF-8" | sudo tee root.x86_64/etc/locale.conf
sudo ln -sf /etc/locale.conf root.x86_64/etc/default/locale
sudo chroot root.x86_64 /usr/bin/locale-gen
touch locale.tmp
resolv-tmp.tmp: proc-tmp.tmp
sudo cp -f /etc/resolv.conf root.x86_64/etc/resolv.conf
touch resolv-tmp.tmp
mirrorlist-tmp.tmp: root.x86_64.tmp
sudo cp -bf mirrorlist root.x86_64/etc/pacman.d/mirrorlist
touch mirrorlist-tmp.tmp
paccnf-tmp.tmp: root.x86_64.tmp
sudo cp -bf pacman.conf.nosig root.x86_64/etc/pacman.conf
touch paccnf.tmp
proc-tmp.tmp: root.x86_64.tmp
@echo -e '\e[1;31mMounting proc to rootfs...\e[m'
sudo mv root.x86_64/etc/mtab root.x86_64/etc/mtab.bak
echo "rootfs / rootfs rw 0 0" | sudo tee root.x86_64/etc/mtab
sudo mount -t proc proc root.x86_64/proc/
sudo mount --bind /sys root.x86_64/sys
touch proc-tmp.tmp
root.x86_64.tmp: base.tar.gz
@echo -e '\e[1;31mExtracting rootfs...\e[m'
sudo bsdtar -zxpf base.tar.gz
sudo chmod +x root.x86_64
touch root.x86_64.tmp
glibc.pkg.tar.zst:
@echo -e '\e[1;31mDownloading glibc.pkg.tar.zst...\e[m'
$(DLR) $(DLR_FLAGS) $(GLIBC_URL) -o glibc.pkg.tar.zst
glibc-linux4.pkg.tar.zst:
@echo -e '\e[1;31mDownloading glibc-linux4.pkg.tar.zst...\e[m'
$(DLR) $(DLR_FLAGS) $(GLIBC_LINUX4_URL) -o glibc-linux4.pkg.tar.zst
fakeroot-tcp.pkg.tar.zst:
@echo -e '\e[1;31mDownloading fakeroot-tcp.pkg.tar.zst...\e[m'
$(DLR) $(DLR_FLAGS) $(FRTCP_URL) -o fakeroot-tcp.pkg.tar.zst
base.tar.gz:
@echo -e '\e[1;31mDownloading base.tar.gz...\e[m'
$(DLR) $(DLR_FLAGS) $(BASE_URL) -o base.tar.gz
clean: cleanall
cleanall: cleanroot cleanproc cleantmp cleanpkg cleanbase
cleanroot: cleanproc
-sudo rm -rf root.x86_64
-rm root.x86_64.tmp
cleanproc:
-sudo umount root.x86_64/sys
-sudo umount root.x86_64/proc
-sudo umount root.x86_64/sys
-sudo umount root.x86_64/proc
-rm proc-tmp.tmp
cleantmp:
-rm *.tmp
cleanpkg:
-rm glibc.pkg.tar.zst
-rm glibc-linux4.pkg.tar.zst
-rm fakeroot-tcp.pkg.tar.zst
cleanbase:
-rm base.tar.gz