-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathtermux-fedora.sh
64 lines (44 loc) · 1.66 KB
/
termux-fedora.sh
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
#!/data/data/com.termux/files/usr/bin/bash
# input validator and help
case "$1" in
f37_arm64)
DOCKERIMAGE=https://download.fedoraproject.org/pub/fedora/linux/releases/37/Container/aarch64/images/Fedora-Container-Base-37-1.7.aarch64.tar.xz
;;
f36_arm64)
DOCKERIMAGE=https://download.fedoraproject.org/pub/fedora/linux/releases/36/Container/aarch64/images/Fedora-Container-Base-36-1.5.aarch64.tar.xz
;;
uninstall)
chmod -R 777 ~/fedora
rm -rf ~/fedora
rm -f /data/data/com.termux/files/usr/bin/startfedora
exit 0
;;
*)
echo $"Usage: $0 {f36_arm64|f37_arm64|uninstall}"
exit 2
;;
esac
# install necessary packages
pkg install proot tar wget -y
# get the docker image
mkdir ~/fedora
cd ~/fedora
/data/data/com.termux/files/usr/bin/wget $DOCKERIMAGE -O fedora.tar.xz
# extract the Docker image
/data/data/com.termux/files/usr/bin/tar xvf fedora.tar.xz --strip-components=1 --exclude json --exclude VERSION
# extract the rootfs
/data/data/com.termux/files/usr/bin/tar xpf layer.tar
# cleanup
chmod +w .
rm layer.tar
rm fedora.tar.xz
# fix DNS
echo "nameserver 8.8.8.8" > ~/fedora/etc/resolv.conf
# make a shortcut
cat > /data/data/com.termux/files/usr/bin/startfedora <<- EOM
#!/data/data/com.termux/files/usr/bin/bash
unset LD_PRELOAD && proot --link2symlink -0 -r ~/fedora -b /dev/ -b /sys/ -b /proc/ -b /storage/ -b $HOME -w $HOME /bin/env -i HOME=/root TERM="$TERM" PS1='[termux@fedora \W]\$ ' LANG=$LANG PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login
EOM
chmod +x /data/data/com.termux/files/usr/bin/startfedora
# all done
echo "All done! Start Fedora with 'startfedora'. Get updates with regular 'dnf update'. "