This repository has been archived by the owner on Jul 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·69 lines (48 loc) · 1.94 KB
/
install.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
61
62
63
64
65
66
67
68
69
#!/bin/bash
#
# Script for setup a build environment for Raspberry Pi.
#
# Author:
# Sergio Conde <[email protected]>
# https://github.com/skgsergio/rpi-buildenv
#
. aux.inc.sh
RASPBIAN_MIRROR="http://archive.raspbian.org"
#RASPBIAN_MIRROR="http://raspbian.sconde.net"
RASPBIAN_VERSION="wheezy" # jessie
chk_dep() {
if [[ $($cmd_sudo which $1) == "" ]]; then
echo "[ERR] $1 not found."
if [[ $2 != "-" ]]; then
echo -e "\nIf you are using Debian, Ubuntu, Mint or any other apt/deb based distribution you can install it using: apt-get install $2"
fi
exit 1
else
echo "[ OK] $1 found."
fi
}
print_msg "Checking for dependencies...\n"
chk_dep debootstrap debootstrap
chk_dep qemu-debootstrap qemu-user-static
chk_dep chroot coreutils
print_msg "Downloading Raspbian rootfs...\n"
$cmd_sudo qemu-debootstrap --no-check-gpg --include=ca-certificates,git-core,binutils,curl --arch armhf $RASPBIAN_VERSION $rootfs_dir $RASPBIAN_MIRROR/raspbian/
print_msg "Configuring rootfs...\n"
cat <<EOF | $cmd_sudo tee $rootfs_dir/usr/sbin/policy-rc.d > /dev/null
#!/bin/sh
echo "rc.d operations disabled for chroot"
exit 101
EOF
$cmd_sudo chmod 0755 $rootfs_dir/usr/sbin/policy-rc.d
print_msg "Importing Raspbian's GPG key...\n"
echo "deb $RASPBIAN_MIRROR/raspbian/ $RASPBIAN_VERSION main contrib non-free" | $cmd_sudo tee $rootfs_dir/etc/apt/sources.list > /dev/null
$cmd_sudo wget $RASPBIAN_MIRROR/raspbian.public.key -O $rootfs_dir/root/raspbian.key
run_chroot apt-key add /root/raspbian.key
run_chroot apt-get update
$cmd_sudo rm $rootfs_dir/root/raspbian.key
print_msg "Installing rpi-update into the rootfs and running it to fetch firmware and libraries...\n"
$cmd_sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O $rootfs_dir/usr/bin/rpi-update
$cmd_sudo chmod +x $rootfs_dir/usr/bin/rpi-update
$cmd_sudo mkdir $rootfs_dir/lib/modules
run_chroot rpi-update
print_msg "Finished!"