2012-09-29 18:36:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
builddir=./build
|
|
|
|
|
|
|
|
prepare() {
|
|
|
|
test -d $builddir || mkdir $builddir
|
2013-01-25 22:27:08 +01:00
|
|
|
|
2012-09-29 18:36:38 +02:00
|
|
|
#Get the OpenWrt Core Source for Firmware
|
2013-01-25 22:27:08 +01:00
|
|
|
svn checkout -r 35298 svn://svn.openwrt.org/openwrt/branches/attitude_adjustment/ $target
|
2012-09-29 18:36:38 +02:00
|
|
|
#apply own feeds.conf
|
|
|
|
cp ./build_patches/feeds.conf $target/feeds.conf
|
|
|
|
|
|
|
|
test -d $target/feeds && /bin/rm -rf $target/feeds
|
|
|
|
|
|
|
|
$target/scripts/feeds update
|
|
|
|
|
|
|
|
$target/scripts/feeds install -a
|
|
|
|
|
2013-03-17 15:50:47 +01:00
|
|
|
#fix for building toolchain on texinfo>=5
|
|
|
|
cp -a build_patches/toolchain $target
|
|
|
|
|
2013-07-29 13:58:40 +02:00
|
|
|
# This changes the default behavior of sysupgrade to not save the config
|
|
|
|
cat build_patches/sysupgrade_no_config_save.patch | patch -p0 -d $target
|
2012-11-17 22:55:02 +01:00
|
|
|
|
2013-07-29 13:58:40 +02:00
|
|
|
# This adds the sysctl load just before the network comes up
|
|
|
|
cat build_patches/invoke_sysctl_before_network.patch | patch -p0 -d $target
|
2013-02-03 20:40:17 +01:00
|
|
|
|
2013-10-04 14:48:04 +02:00
|
|
|
#backport mac80211
|
2013-10-10 09:54:04 +02:00
|
|
|
svn up -r 38351 $target/package/mac80211
|
2013-07-29 13:58:40 +02:00
|
|
|
svn up -r 37378 $target/target/linux/generic/files/include/linux/ath9k_platform.h
|
2013-05-20 01:11:04 +02:00
|
|
|
|
|
|
|
#backport kernelpatches from openwrt r36664
|
2013-07-14 13:59:22 +02:00
|
|
|
cp build_patches/linux/ar71xx/patches-3.3/* $target/target/linux/ar71xx/patches-3.3
|
2013-02-27 19:28:07 +01:00
|
|
|
|
2013-02-16 18:16:24 +01:00
|
|
|
#batman-adv: distributed arp table fixes
|
|
|
|
cat build_patches/changeset_35324.diff | patch -p1 -d $target/feeds
|
|
|
|
#batman-adv: fix dat NULL pointer dereference
|
|
|
|
cat build_patches/changeset_35609.diff | patch -p1 -d $target/feeds
|
|
|
|
|
2013-07-29 13:58:40 +02:00
|
|
|
#saves ~200MB for each build
|
|
|
|
test -d ./dl || mkdir ./dl
|
|
|
|
ln -s ../../dl $target/dl
|
2013-03-30 11:41:10 +01:00
|
|
|
|
2012-09-29 18:36:38 +02:00
|
|
|
board_prepare
|
|
|
|
}
|
|
|
|
|
|
|
|
prebuild() {
|
|
|
|
#create filesdir for our config
|
|
|
|
/bin/rm -rf $target/files
|
|
|
|
mkdir $target/files
|
|
|
|
|
|
|
|
cp -r ./bsp/default/root_file_system/* $target/files/
|
|
|
|
|
|
|
|
board_prebuild
|
|
|
|
|
2013-09-14 00:09:35 +02:00
|
|
|
for template in $(find $target/files -name *.tpl)
|
|
|
|
do
|
|
|
|
echo "Translating $template .."
|
2013-10-04 18:38:39 +02:00
|
|
|
$tpl_translate $template > $(dirname $template)/$(basename $template .tpl)
|
2013-09-14 00:09:35 +02:00
|
|
|
/bin/rm $template
|
|
|
|
done
|
|
|
|
|
2012-09-29 18:36:38 +02:00
|
|
|
#insert actual firware version informations into release file
|
2013-07-29 13:58:40 +02:00
|
|
|
version=$(git describe --tags --dirty)
|
2012-11-18 22:34:04 +01:00
|
|
|
|
|
|
|
echo "FIRMWARE_VERSION=\"$version\"" > $target/files/etc/firmware_release
|
|
|
|
echo "RELEASE_DATE=\"build date: "`date`"\"" >> $target/files/etc/firmware_release
|
2012-09-29 18:36:38 +02:00
|
|
|
echo "FIRMWARE_REVISION=\"build date: "`date`"\"" >> $target/files/etc/firmware_release
|
|
|
|
echo "OPENWRT_CORE_REVISION=\""`svn info $target |grep Revision: |cut -c11-`"\"" >> $target/files/etc/firmware_release
|
|
|
|
echo "OPENWRT_FEEDS_PACKAGES_REVISION=\""`svn info $target/feeds/packages |grep Revision: |cut -c11-`"\"" >> $target/files/etc/firmware_release
|
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
prebuild
|
|
|
|
|
2012-09-29 20:42:34 +02:00
|
|
|
opath=$(pwd)
|
2012-09-29 18:36:38 +02:00
|
|
|
cd $target
|
2013-07-29 13:58:40 +02:00
|
|
|
cpus=$(grep processor /proc/cpuinfo | wc -l)
|
2012-09-29 18:36:38 +02:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"debug")
|
|
|
|
make V=99
|
|
|
|
;;
|
|
|
|
"fast")
|
2013-05-09 15:14:08 +02:00
|
|
|
ionice -c 2 -- nice -n 1 -- make -j$[$cpus*2]
|
2012-09-29 18:36:38 +02:00
|
|
|
;;
|
|
|
|
*)
|
2013-05-09 15:14:08 +02:00
|
|
|
ionice -c 3 -- nice -n 10 -- make -j$[$cpus+1]
|
2012-09-29 18:36:38 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
# actually this does northing!
|
|
|
|
# rm -rf ./build_dir/files/
|
2012-09-29 20:42:34 +02:00
|
|
|
cd $opath
|
2012-09-29 18:36:38 +02:00
|
|
|
|
|
|
|
if [ ! -d bin ]; then
|
|
|
|
mkdir bin
|
|
|
|
fi
|
|
|
|
|
|
|
|
postbuild
|
|
|
|
}
|
|
|
|
|
|
|
|
postbuild() {
|
|
|
|
board_postbuild
|
|
|
|
}
|
|
|
|
|
|
|
|
flash() {
|
|
|
|
# some flash tools need an arguement..
|
|
|
|
board_flash $1
|
|
|
|
}
|
|
|
|
|
|
|
|
clean() {
|
|
|
|
board_clean
|
|
|
|
/bin/rm -rf bin $builddir
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:40:28 +02:00
|
|
|
buildall() {
|
|
|
|
for bsp in $(/bin/ls bsp/*.bsp)
|
|
|
|
do
|
|
|
|
./buildscript selectcommunity $1
|
|
|
|
./buildscript selectbsp $bsp
|
|
|
|
./buildscript prepare
|
|
|
|
./buildscript build
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-09-29 18:36:38 +02:00
|
|
|
routers() {
|
|
|
|
echo "router-types: "
|
|
|
|
echo " dir300"
|
|
|
|
echo " dir300b_adhoc"
|
|
|
|
echo " dir300b_ap"
|
|
|
|
echo " fonera"
|
|
|
|
echo " wrt54g_ap"
|
|
|
|
echo " wrt54g_adhoc"
|
|
|
|
echo " wr741nd"
|
|
|
|
echo " wr1043nd"
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:40:28 +02:00
|
|
|
if [ "$1" != "selectbsp" -a "$1" != "selectcommunity" -a "$1" != "buildall" ]; then
|
2012-09-30 02:52:22 +02:00
|
|
|
if [ ! -h selected_bsp ]; then
|
|
|
|
echo "Please select a Board-Support-Package using:"
|
2013-09-14 00:09:35 +02:00
|
|
|
echo "$0 selectbsp"
|
2012-09-30 02:52:22 +02:00
|
|
|
exit
|
2013-09-14 00:09:35 +02:00
|
|
|
fi
|
|
|
|
if [ ! -h selected_community ]; then
|
|
|
|
echo "Please select a community file using:"
|
|
|
|
echo "$0 selectcommunity"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
echo "Working with $(/bin/ls -l selected_bsp | awk '{ print $11 }') and" \
|
|
|
|
"$(/bin/ls -l selected_community | awk '{ print $11 }')"
|
|
|
|
. selected_bsp
|
|
|
|
tpl_translate=$(awk -F= 'BEGIN{printf("sed")} /^.+$/{printf(" -es/\\${%s}/%s/g",$1,$2)}' selected_community)
|
|
|
|
echo
|
2012-09-29 18:36:38 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
2013-09-14 00:09:35 +02:00
|
|
|
"selectbsp")
|
2012-09-29 18:36:38 +02:00
|
|
|
if [ "$2" = "help" ] || [ "$2" = "" ]; then
|
|
|
|
echo "Select a Board-Support-Package:"
|
|
|
|
echo
|
|
|
|
echo "Usage: $0 $1 bsp"
|
|
|
|
echo "bsp: "
|
2013-09-14 00:09:35 +02:00
|
|
|
/bin/ls bsp/*.bsp
|
|
|
|
else
|
|
|
|
if [ ! -f $2 ]; then
|
|
|
|
echo "Could not find $2"
|
|
|
|
else
|
|
|
|
/bin/rm -rf selected_bsp
|
|
|
|
/bin/ln -s $2 selected_bsp
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"selectcommunity")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "" ]; then
|
|
|
|
echo "Select a Community-File:"
|
|
|
|
echo
|
|
|
|
echo "Usage: $0 $1 community.cfg"
|
|
|
|
echo "community.cfg: "
|
|
|
|
/bin/ls community/*.cfg
|
2012-09-29 18:36:38 +02:00
|
|
|
else
|
2013-09-14 00:09:35 +02:00
|
|
|
if [ ! -f $2 ]; then
|
|
|
|
echo "Could not find $2"
|
|
|
|
else
|
|
|
|
/bin/rm -rf selected_community
|
|
|
|
/bin/ln -s $2 selected_community
|
|
|
|
fi
|
2012-09-29 18:36:38 +02:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"prepare")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "x" ]; then
|
|
|
|
echo "This option fetches the sources for the images and configurates the build so that it can be compiled"
|
|
|
|
echo "Usage: $0 $1"
|
|
|
|
else
|
|
|
|
prepare
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"build")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "x" ]; then
|
|
|
|
echo "This option compiles the firmware"
|
|
|
|
echo "Normaly the build uses lower IO and System priorities, "
|
|
|
|
echo "you can append \"fast\" option, to use normal user priorities"
|
|
|
|
echo "Usage: $0 $1 [fast|debug]"
|
|
|
|
else
|
|
|
|
build "$2"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"download")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "" ]; then
|
|
|
|
echo "This option downloads the ready configured images from an external location if needet."
|
|
|
|
echo "Usage: $0 $1 http://downloadfolder router-type"
|
|
|
|
echo "Common downloadfolder for firmware version 0.3 is http://dev.freifunk-ol.de/firmware/0.3/"
|
|
|
|
routers
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "This function is broken!"
|
|
|
|
else
|
|
|
|
exit
|
|
|
|
mkdir ./bin
|
|
|
|
cd ./bin
|
|
|
|
wget "$2/$3/openwrt-$3-root.squashfs"
|
|
|
|
wget "$2/$3/openwrt-$3-vmlinux.lzma"
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"flash")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "x" ]; then
|
|
|
|
echo "This option flashes the router."
|
|
|
|
echo "$0 $1 net-dev"
|
|
|
|
routers
|
|
|
|
echo "net-dev:"
|
|
|
|
echo " ethX"
|
|
|
|
else
|
|
|
|
flash "$2"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"clean")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "x" ]; then
|
|
|
|
echo "This option cleans all build files."
|
|
|
|
echo "$0 $1 all"
|
|
|
|
else
|
|
|
|
clean
|
|
|
|
fi
|
|
|
|
;;
|
2013-09-19 20:40:28 +02:00
|
|
|
"buildall")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "" ]; then
|
|
|
|
echo "This option builds the firmware for all routers of a given community."
|
|
|
|
echo "Usage: $0 $1 community.cfg"
|
|
|
|
echo "community.cfg: "
|
|
|
|
/bin/ls community/*.cfg
|
|
|
|
else
|
|
|
|
buildall $2
|
|
|
|
fi
|
|
|
|
;;
|
2012-09-29 18:36:38 +02:00
|
|
|
*)
|
|
|
|
echo "This is the Build Environment Script of the Freifunk Community Oldenburg."
|
|
|
|
echo "Usage: $0 command"
|
|
|
|
echo "command:"
|
2013-10-04 18:31:22 +02:00
|
|
|
echo " selectcommunity [communityfile]"
|
|
|
|
echo " selectbsp [bsp file]"
|
2012-09-29 18:36:38 +02:00
|
|
|
echo " prepare"
|
|
|
|
echo " build"
|
|
|
|
echo " flash"
|
|
|
|
echo " download"
|
|
|
|
echo ""
|
|
|
|
echo "If you need help to one of these options just type $0 command help"
|
|
|
|
;;
|
|
|
|
esac
|
2013-10-20 16:56:43 +02:00
|
|
|
# vim: noexpandtab
|