-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathtar-strap
executable file
·49 lines (37 loc) · 1007 Bytes
/
tar-strap
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
#!/bin/bash
usage() {
bin=$(basename $0)
echo >&2 "Usage: $bin tar-url [path]"
echo >&2
echo >&2 "Creates arch chroot using tarball url"
echo >&2 " in specified path (default: arch-root, must not exist)."
echo >&2 "Get the tarball url from: https://mirrors.kernel.org/archlinux/iso/latest/"
exit ${1:-0}
}
[[ -z "$1" || "$1" = -h || "$1" = --help ]] && usage
[[ "$#" -gt 2 ]] && usage 1
set -e -o pipefail
export LC_ALL=C
url=$1 p=${2:-arch-root}
[[ -f "$url" ]] && url=$(readlink -f "$url")
[[ -e "$p" ]] || mkdir -m0700 "$p"
pushd "$p" >/dev/null
if [[ -f "$url" ]]
then
ln -s "$url".sig src.tar.xx.sig
ln -s "$url" src.tar.xx
else
echo $url
curl "$url".sig >src.tar.xx.sig
curl "$url" >src.tar.xx
fi
pacman-key -v src.tar.xx.sig
rm -f src.tar.xx.sig
bsdtar -xf src.tar.xx
rm -f src.tar.xx
mv root.*/* .
rmdir root.*
cp -aL /etc/{locale.gen,localtime,hostname,resolv.conf} etc/
cp -aL /etc/pacman.d/{mirrorlist,gnupg} etc/pacman.d/
popd >/dev/null
exec arch-chroot "$p" /bin/bash