-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmoduleutils.sh
executable file
·60 lines (51 loc) · 1.87 KB
/
moduleutils.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
#!/bin/bash
# utilities that are supposed to be imported into a mudule before running it
export IROOT="${IROOT:-/root/instantARCH/config}"
export INSTANTARCH="${INSTANTARCH:-/root/instantARCH}"
source /root/instantARCH/utils.sh
# install pacman packages and try a few things to fix pacman without user input
# if installation fails
pacloop() {
while ! pacman -S --noconfirm --needed $@; do
echo 'Package installation failed
Please ensure you are connected to the internet' | imenu -M
if {
! [ -e /root/instantARCH/refreshedkeyring ] || [ -z "$REFRESHEDKEYRING" ]
} && ! [ "$1" = "archlinux-keyring" ]; then
pacman -Sy archlinux-keyring --noconfirm
export REFRESHEDKEYRING="true"
mkdir /root/instantARCH
touch /root/instantARCH/refreshedkeyring
continue
fi
if command -v reflector; then
reflector --latest 40 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist
else
pacman-mirrors --geoip
fi
updaterepos
echo "retrying package installation in 4 seconds"
sleep 4
done
}
# pacstrap wrapper to accomodate different arch based systems and install isos
pacstraploop() {
PACSTRAP_ARGLIST=()
# use host package cache if installation disk is an instantOS iso
# TODO function to better check if we are on an instantOS iso
if [ -e /usr/share/liveutils ]; then
PACSTRAP_ARGLIST+=("-c")
fi
while ! {
if command -v pacstrap &>/dev/null; then
pacstrap "${PACSTRAP_ARGLIST[@]}" /mnt $@
else
basestrap "${PACSTRAP_ARGLIST[@]}" /mnt $@
fi
}; do
imenu -m "package installation failed. ensure you are connected to the internet"
sleep 2
done
# clean up cache so ramfs doesn't fill up
yes | pacman -Scc
}