-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild_pineapple.sh
executable file
·99 lines (86 loc) · 2.41 KB
/
build_pineapple.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
top=$(pwd)
extract_firmware() {
cd "$top/firmware-mod-kit"
./extract-firmware.sh "$top"/upgrade-"$upstream_version".bin
cd "$top"
echo "$upstream_version" > configs/.upstream_version
mkdir openwrt-cc/files
cp -r firmware-mod-kit/fmk/rootfs/* openwrt-cc/files/
rm -rf openwrt-cc/files/lib/modules/*
rm -rf openwrt-cc/files/sbin/modprobe
}
apt_get() {
# Clean this up
sudo apt-get update
sudo apt-get install -y \
git build-essential zlib1g-dev liblzma-dev python-magic subversion \
build-essential git-core libncurses5-dev zlib1g-dev gawk flex quilt \
libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip
}
install_binwalk() {
cd "$top/binwalk"
./deps.sh
sudo python setup.py install
cd "$top"
}
first_run() {
cd "$top"
apt_get
#git submodule update --recursive --remote
wget https://www.wifipineapple.com/downloads/nano/latest -O upgrade-"$upstream_version".bin
install_binwalk
echo "BINWALK=binwalk" >> firmware-mod-kit/shared-ng.inc
touch configs/.upstream_version
cp configs/gl-ar150-defconfig openwrt-cc/.config
mkdir firmware_images
extract_firmware
}
install_scripts() {
cd "$top/openwrt-cc"
./scripts/feeds update -a
./scripts/feeds install -a
}
build_firmware() {
cd "$top/openwrt-cc"
make -j$(cat /proc/cpuinfo | grep "^processor" | wc -l)
for line in $(find "$top/openwrt-cc/bin" -name "*-sysupgrade.bin"); do
cp "$line" "$top/firmware_images/"
echo " - [*] File ready at - $line"
done
cd "$top"
}
full_build() {
upstream_version=`curl -s https://www.wifipineapple.com/downloads/nano/ | \
python -c "import sys, json; print(json.load(sys.stdin)['version'])"`
current_version=`cat configs/.upstream_version`
if [ -f "configs/.upstream_version" ]; then
echo "config file found"
git submodule update
else
echo "config file not found"
first_run
fi
if [ "$upstream_version" < "$current_version" ]; then
extract_firmware
fi
install_scripts
make defconfig
build_firmware
}
if [ "$1" = "-f" ]; then
rm configs/.upstream_version
full_build
elif
[ "$1" = "-c" ]; then
rm -rf firmware_images
rm -rf firmware-mod-kit/fmk
cd openwrt-cc
make dirclean
# do I need sudo doe?
rm -rf files
cd ..
elif
[ -z "$1" ]; then
full_build
fi