-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathprepare-rootfs
executable file
·39 lines (31 loc) · 1.46 KB
/
prepare-rootfs
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
#!/usr/bin/env bash
set -e
. scripts/env.sh
run_in_qemu()
{
sudo chroot $SYSROOT /usr/bin/qemu-arm-static /usr/bin/env -i PATH="/sbin:/usr/sbin:/bin:/usr/bin" TERM="$TERM" $*
}
status "Installing qemu-arm-static binary into target FS..."
QEMUDEB=$(mktemp)
curl http://ftp.debian.org/debian/pool/main/q/qemu/qemu-user-static_2.1+dfsg-4_i386.deb >$QEMUDEB
ar p $QEMUDEB data.tar.xz|sudo tar xJf - -C $SYSROOT ./usr/bin/qemu-arm-static
rm -f $QEMUDEB
status "Fixing target's resolv.conf..."
sudo mv $SYSROOT/etc/resolv.conf $SYSROOT/etc/resolv.conf.backup
sudo cp /etc/resolv.conf $SYSROOT/etc/resolv.conf
status "Using qemu to install required packages on target FS..."
run_in_qemu /usr/bin/apt-get update
run_in_qemu /usr/bin/apt-get -y install $(cat $TOP/scripts/ubuntu-packages)
# Installing libudev-dev might upgrade udev, which will fail because upstart is not running.
# Install it independently and forcibly to about this.
run_in_qemu /usr/bin/apt-get download libudev-dev
run_in_qemu /usr/bin/dpkg --force-depends -i $(basename $SYSROOT/libudev-dev*.deb)
rm -f $SYSROOT/libudev-dev*.deb
# Fix the absolute symlinks in the target filesystem that will prevent us
# from linking to them
status "Fixing libraries symlinks..."
run_in_qemu /usr/bin/symlinks -cr /lib /usr/lib
status "Restoring target's resolv.conf..."
sudo rm -f $SYSROOT/etc/resolv.conf
sudo mv $SYSROOT/etc/resolv.conf.backup $SYSROOT/etc/resolv.conf
status "Target FS ready to compile the open graphics stack!"