@@ -47,6 +47,42 @@ are given, pacstrap defaults to the "base" group.
47
47
EOF
48
48
}
49
49
50
+ pacstrap () {
51
+ (( EUID == 0 )) || die ' This script must be run with root privileges'
52
+
53
+ # create obligatory directories
54
+ msg ' Creating install root at %s' " $newroot "
55
+ mkdir -m 0755 -p " $newroot " /var/{cache/pacman/pkg,lib/pacman,log} " $newroot " /{dev,run,etc/pacman.d}
56
+ mkdir -m 1777 -p " $newroot " /tmp
57
+ mkdir -m 0555 -p " $newroot " /{sys,proc}
58
+
59
+ # mount API filesystems
60
+ $setup " $newroot " || die " failed to setup chroot %s" " $newroot "
61
+
62
+ if [[ ! -d $newroot /etc/pacman.d/gnupg ]]; then
63
+ if (( initkeyring )) ; then
64
+ pacman-key --gpgdir " $newroot " /etc/pacman.d/gnupg --init
65
+ elif (( copykeyring )) && [[ -d /etc/pacman.d/gnupg ]]; then
66
+ # if there's a keyring on the host, copy it into the new root
67
+ cp -a --no-preserve=ownership /etc/pacman.d/gnupg " $newroot /etc/pacman.d/"
68
+ fi
69
+ fi
70
+
71
+ msg ' Installing packages to %s' " $newroot "
72
+ if ! $pid_unshare pacman -r " $newroot " " ${pacman_args[@]} " ; then
73
+ die ' Failed to install packages to new root'
74
+ fi
75
+
76
+ if (( copymirrorlist )) ; then
77
+ # install the host's mirrorlist onto the new root
78
+ cp -a /etc/pacman.d/mirrorlist " $newroot /etc/pacman.d/"
79
+ fi
80
+
81
+ if (( copyconf )) ; then
82
+ cp -a " $pacman_config " " $newroot /etc/pacman.conf"
83
+ fi
84
+ }
85
+
50
86
if [[ -z $1 || $1 = @ (-h| --help) ]]; then
51
87
usage
52
88
exit $(( $# ? 0 : 1 ))
109
145
110
146
[[ -d $newroot ]] || die " %s is not a directory" " $newroot "
111
147
112
- pacstrap () {
113
- (( EUID == 0 )) || die ' This script must be run with root privileges'
114
-
115
- # create obligatory directories
116
- msg ' Creating install root at %s' " $newroot "
117
- mkdir -m 0755 -p " $newroot " /var/{cache/pacman/pkg,lib/pacman,log} " $newroot " /{dev,run,etc/pacman.d}
118
- mkdir -m 1777 -p " $newroot " /tmp
119
- mkdir -m 0555 -p " $newroot " /{sys,proc}
120
-
121
- # mount API filesystems
122
- $setup " $newroot " || die " failed to setup chroot %s" " $newroot "
123
-
124
- if [[ ! -d $newroot /etc/pacman.d/gnupg ]]; then
125
- if (( initkeyring )) ; then
126
- pacman-key --gpgdir " $newroot " /etc/pacman.d/gnupg --init
127
- elif (( copykeyring )) && [[ -d /etc/pacman.d/gnupg ]]; then
128
- # if there's a keyring on the host, copy it into the new root
129
- cp -a --no-preserve=ownership /etc/pacman.d/gnupg " $newroot /etc/pacman.d/"
130
- fi
131
- fi
132
-
133
- msg ' Installing packages to %s' " $newroot "
134
- if ! $pid_unshare pacman -r " $newroot " " ${pacman_args[@]} " ; then
135
- die ' Failed to install packages to new root'
136
- fi
137
-
138
- if (( copymirrorlist )) ; then
139
- # install the host's mirrorlist onto the new root
140
- cp -a /etc/pacman.d/mirrorlist " $newroot /etc/pacman.d/"
141
- fi
142
-
143
- if (( copyconf )) ; then
144
- cp -a " $pacman_config " " $newroot /etc/pacman.conf"
145
- fi
146
- }
147
-
148
148
if (( unshare )) ; then
149
149
$mount_unshare bash -c " $( declare_all) ; pacstrap"
150
150
else
0 commit comments