forked from RedDog99/bielefeld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·149 lines (125 loc) · 3.77 KB
/
install
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
#small script to install ff-firmware to a plain openwrt repository as an "environment"
#this script should only be called once. After that normal git operations on the ff-firmware
#dir "env" and the openwrt package should be used.
FFBASE=$1
OWBASE="./"
FFFEEDNAME=FreiFunk
#Should the git repos be reset to their FETCH_HEAD?
#"yes" is the default because custom patches should be kept in FFBASE anyway
#and "yes" makes this script reappliable
RESETFETCHHEAD=yes
patchDirToGit(){
local PATCHDIR=$1
local GITCO=$2
if [[ -z $PATCHDIR || -z $GITCO ]] ; then
echo PATCHDIR and GITCO needed!
return 1
fi
local MYGIT="git -C $GITCO"
if [[ $RESETFETCHHEAD == "yes" ]]; then
echo Resetting $GITCO to last fetched version
$MYGIT reset --hard FETCH_HEAD
echo
fi
for PATCH in $(ls $PATCHDIR/*.patch) ; do
echo Test applying $PATCH to $GITCO
if $MYGIT apply --check --whitespace=nowarn $PATCH ; then
echo Actually applying patch
if $MYGIT am --whitespace=nowarn $PATCH ; then
echo Success!
else
echo this should never happen...
exit 1
fi
else
echo Applying $PATCH failed!
FAILEDPATCHES="${FAILEDPATCHES}Failed applying\n$PATCH\nto\n$GITCO\n"
FAILEDPATCHES="${FAILEDPATCHES}\nTry calling \"git -C $GITCO am $PATCH\" manually. git will tell you more!\n\n"
echo Has it already been applied?
fi
echo
done
echo Patching $GITCO done
echo
}
OWBASE=$(realpath $OWBASE)
echo Using OpenWRT base: $OWBASE
echo
#this is a very weak check for openwrt base...
if [[ ! -d $OWBASE && ! -f $OWBASE/feeds.config.default ]] ; then
echo This script has to be called from a openWRT buildroot
exit 1
fi
FFBASE=$(realpath $FFBASE)
echo Using FreiFunk base: $FFBASE
echo
if [[ -z $FFBASE || ! -d $FFBASE ]] ; then
echo We need a working copy of the firmware repository as a single argument
exit 1
fi
FEEDSCRIPT=$OWBASE/scripts/feeds
if [[ -e $OWBASE/.config || -e $OWBASE/files ]] ; then
if [[ -L $OWBASE/.config && -L $OWBASE/files ]] ; then
#we won't delet things, so we can go on
echo this will alter the symlinks $OWBASE/.config and $OWBASE/files
else
echo $OWBASE is not clean! .config and files would be overridden!
exit 1
fi
fi
#from here we assume a clean openWRT build root
if [[ -f feeds.conf ]] ; then
if ! grep $FFFEEDNAME $OWBASE/feeds.conf ; then
echo Adding FreiFunk packages to package feeds.conf
echo src-link $FFFEEDNAME $FFBASE/packages >> $OWBASE/feeds.conf
else
echo FreiFunk packages already installed
echo
fi
else
echo Using default feeds.config
cp $OWBASE/feeds.conf.default $OWBASE/feeds.conf
echo src-link $FFFEEDNAME $FFBASE/packages >> $OWBASE/feeds.conf
fi
echo Patching openwrt
echo
patchDirToGit $FFBASE/patches/openwrt/ $OWBASE $OWBASE
echo Updating all packages
echo
$FEEDSCRIPT update -a
echo Patching upstream packages with FF-Packages
echo
echo Patching openwrt routing feed
echo
patchDirToGit $FFBASE/patches/routing/ $OWBASE/feeds/routing/
echo Patching openwrt packages feed
echo
patchDirToGit $FFBASE/patches/packages/ $OWBASE/feeds/packages/
if [[ -n $FAILEDPATCHES ]] ; then
echo Unfortunatly applying these patches failed:
echo -e $FAILEDPATCHES
echo Please examine them and fix them.
echo Thanks
fi
$FEEDSCRIPT install -a
#we have to link this after upgrading and installing because $FEEDSCRIPT will
#interfere with .config and dnsmasq will be installed :-(
echo Linking FF config
rm $OWBASE/.config
ln -s $FFBASE/.config $OWBASE/
echo Linking FF base files
echo
rm -rf $OWBASE/files
ln -s $FFBASE/files $OWBASE/files
echo
echo From here you should configure openwrt for the target device:
echo
echo make defconfig
echo make menuconfig
echo
echo Build it:
echo
echo make -j$(getconf _NPROCESSORS_ONLN)
echo
echo Have fun!