blob: f8153310f0dc7de3184b063b5472c6a16d99c885 (
plain)
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
|
#!/bin/bash
##############################################################################
# parabola-riscv64-bootstrap #
# #
# Copyright (C) 2018 Andreas Grapentin #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
##############################################################################
check_stage2_chroot() {
echo -n "checking for functional $CARCH skeleton chroot ... "
local pacman_works=yes
pacman --config "$CHROOTDIR"/etc/pacman.conf -r "$CHROOTDIR" -Syyu &>/dev/null || pacman_works=no
echo $pacman_works
[ "x$pacman_works" == "xyes" ] || return "$ERROR_MISSING"
}
build_stage2_chroot() {
# create directories
rm -rf "$CHROOTDIR"
mkdir -pv "$CHROOTDIR"/etc/pacman.d/{gnupg,hooks} \
"$CHROOTDIR"/var/{lib/pacman,cache/pacman/pkg,log} \
| sed "s#$CHROOTDIR#\$CHROOTDIR#"
# create sane pacman config
cat > "$CHROOTDIR"/etc/pacman.conf << EOF
[options]
RootDir = $CHROOTDIR
DBPath = $CHROOTDIR/var/cache/pacman/
CacheDir = $CHROOTDIR/var/cache/pacman/pkg/
LogFile = $CHROOTDIR/var/log/pacman.log
GPGDir = $CHROOTDIR/etc/pacman.d/gnupg
HookDir = $CHROOTDIR/etc/pacman.d/hooks
Architecture = $CARCH
[cross]
SigLevel = Never
Server = file://${PKGDEST%/$CARCH}/\$arch
EOF
# copy toolchain sysroot to chroot
cp -ar "$SYSROOT"/usr "$CHROOTDIR"/
# final sanity check
check_stage2_chroot || return
}
umount_stage2_chrootdir() {
umount "$SYSROOT"/usr
trap - INT TERM EXIT
}
mount_stage2_chrootdir() {
if mount | grep -q "$SYSROOT/usr"; then umount_stage2_chrootdir; fi
mount -o bind "$CHROOTDIR"/usr "$SYSROOT"/usr
trap 'umount_stage2_chrootdir' INT TERM EXIT
}
prepare_stage2_chroot() {
check_stage2_chroot || build_stage2_chroot || return
mount_stage2_chrootdir
}
|