2012-09-29 18:36:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-11-10 20:37:21 +01:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
|
2012-09-29 18:36:38 +02:00
|
|
|
builddir=./build
|
|
|
|
|
2020-12-07 15:04:58 +01:00
|
|
|
OPENWRTREV="v19.07.5"
|
2018-01-03 19:46:55 +01:00
|
|
|
OPENWRTURL="https://git.openwrt.org/openwrt/openwrt.git"
|
2020-12-07 15:04:58 +01:00
|
|
|
PACKAGEREV="2974079d3db786fe5da00c10f1d80e79b0112093" # openwrt-19.07.5
|
2018-01-03 19:46:55 +01:00
|
|
|
PACKAGEURL="https://git.openwrt.org/feed/packages.git"
|
2013-12-01 14:15:14 +01:00
|
|
|
|
2015-10-11 20:37:08 +02:00
|
|
|
## Feed definition [0]: name aka directory, [1]: url, [2]: revision, [3..n]: patches
|
2014-11-28 19:10:55 +01:00
|
|
|
|
|
|
|
#official openwrt packages
|
|
|
|
OPENWRT=(openwrt
|
2015-06-28 14:35:15 +02:00
|
|
|
$PACKAGEURL
|
2019-04-08 15:32:10 +02:00
|
|
|
$PACKAGEREV)
|
2020-08-02 19:58:43 +02:00
|
|
|
OPENWRT_PKGS="gpioctl-sysfs libugpio fastd haserl micrond mtr bmon"
|
2014-11-28 19:10:55 +01:00
|
|
|
|
2017-10-05 15:37:41 +02:00
|
|
|
## Be careful: FFF uses COMPAT_VERSION 15 as default at the moment.
|
2015-10-13 21:57:34 +02:00
|
|
|
## See http://www.open-mesh.org/projects/batman-adv/wiki/Compatversion
|
2016-05-03 23:20:50 +02:00
|
|
|
GLUON=(gluon
|
2015-10-25 16:26:23 +01:00
|
|
|
https://github.com/freifunk-gluon/packages.git
|
2020-04-15 18:14:26 +02:00
|
|
|
12e41d0ff07ec54bbd67a31ab50d12ca04f2238c) # 2020-02-04
|
2020-04-15 18:14:25 +02:00
|
|
|
GLUON_PKGS="simple-tc uradvd"
|
2015-10-13 21:57:34 +02:00
|
|
|
|
|
|
|
#official openwrt routing packages
|
2014-11-28 19:10:55 +01:00
|
|
|
ROUTING=(routing
|
2018-01-03 19:46:55 +01:00
|
|
|
https://git.openwrt.org/feed/routing.git
|
2020-12-07 15:04:58 +01:00
|
|
|
02b4dbfcb7b8f8b566940847d22d5a6f229d2e66) # openwrt-19.07.5
|
2019-01-28 11:07:24 +01:00
|
|
|
ROUTING_PKGS="kmod-batman-adv batctl alfred babeld"
|
2014-11-28 19:10:55 +01:00
|
|
|
|
2015-12-06 13:42:19 +01:00
|
|
|
FFF=(fff)
|
|
|
|
FFF_PKGS="-a"
|
|
|
|
|
2016-10-31 19:21:20 +01:00
|
|
|
FEEDS=(OPENWRT ROUTING GLUON FFF)
|
2013-12-01 14:15:14 +01:00
|
|
|
|
2017-01-16 21:50:55 +01:00
|
|
|
# Disable dnsmasq and other useless stuff
|
|
|
|
export DEVICE_TYPE=
|
|
|
|
|
2014-11-23 23:39:27 +01:00
|
|
|
checkout_git(){
|
2015-07-17 18:47:16 +02:00
|
|
|
local DIRECTORY=$1
|
|
|
|
local REPO_URL=$2
|
|
|
|
local COMMITID=$3
|
|
|
|
|
|
|
|
local MYGIT="git -C $DIRECTORY"
|
|
|
|
echo "checking out $REPO_URL to $DIRECTORY in version $COMMITID"
|
|
|
|
if [ -d "$DIRECTORY" ]; then
|
|
|
|
if $MYGIT remote -v | grep -q "$REPO_URL" ; then
|
|
|
|
echo "Right remote detected"
|
|
|
|
if ! $MYGIT checkout "$COMMITID" ; then
|
|
|
|
echo "commitid not found trying to fetch new commits"
|
|
|
|
$MYGIT pull && $MYGIT checkout "$COMMITID"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "wrong remote or not an git repo at all -> deleting whole directory"
|
|
|
|
/bin/rm -rf "$DIRECTORY"
|
|
|
|
#needs to be without -C!!!
|
|
|
|
git clone "$REPO_URL" "$DIRECTORY"
|
|
|
|
$MYGIT checkout "$COMMITID"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "We need to do a fresh checkout"
|
|
|
|
#needs to be without -C!!!
|
|
|
|
git clone "$REPO_URL" "$DIRECTORY"
|
|
|
|
$MYGIT checkout "$COMMITID"
|
|
|
|
fi
|
2014-11-23 23:39:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get_source() {
|
2015-07-17 18:47:16 +02:00
|
|
|
test -d src || mkdir src
|
|
|
|
cd src
|
|
|
|
|
|
|
|
#Get the OpenWrt Core Source for Firmware
|
|
|
|
checkout_git openwrt $OPENWRTURL $OPENWRTREV
|
|
|
|
|
|
|
|
test -d packages || mkdir packages
|
|
|
|
cd packages
|
|
|
|
|
|
|
|
#checkout needed package feeds
|
|
|
|
for FEEDVAR in "${FEEDS[@]}" ; do
|
|
|
|
FEED="${FEEDVAR}[@]"
|
|
|
|
FEED=("${!FEED}")
|
|
|
|
|
|
|
|
local NAME=${FEED[0]}
|
|
|
|
local URL=${FEED[1]}
|
|
|
|
local REV=${FEED[2]}
|
|
|
|
|
2015-12-06 13:42:17 +01:00
|
|
|
if [ -n "$URL" ] && [ -n "$REV" ]; then
|
|
|
|
checkout_git "$NAME" "$URL" "$REV"
|
|
|
|
|
2019-04-08 15:32:10 +02:00
|
|
|
# Patches for feeds are stored in known directories like feed_patches/$NAME/
|
|
|
|
for PATCH in $(ls ../../feed_patches/${NAME}/*.patch 2>/dev/null); do
|
|
|
|
if [ -s "$PATCH" ] ; then
|
|
|
|
echo "Applying $PATCH"
|
|
|
|
git -C "$NAME" am --whitespace=nowarn "../$PATCH"
|
2015-12-06 13:42:17 +01:00
|
|
|
else
|
2019-04-08 15:32:10 +02:00
|
|
|
echo "Empty patch $PATCH ignored."
|
2015-12-06 13:42:17 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2015-07-17 18:47:16 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
cd .. # packages
|
|
|
|
cd .. # src
|
2013-12-01 14:15:14 +01:00
|
|
|
}
|
|
|
|
|
2016-03-19 11:56:40 +01:00
|
|
|
patch_target() {
|
2019-04-08 15:32:11 +02:00
|
|
|
for patch in $(ls "$PWD"/build_patches/openwrt/*.patch 2>/dev/null); do
|
|
|
|
echo "Applying $patch:"
|
2019-10-07 14:28:06 +02:00
|
|
|
patch --no-backup-if-mismatch -p1 -d "$builddir" -i "$patch"
|
2019-04-08 15:32:11 +02:00
|
|
|
done
|
2016-03-19 11:56:40 +01:00
|
|
|
}
|
|
|
|
|
2012-09-29 18:36:38 +02:00
|
|
|
prepare() {
|
2015-07-17 18:47:16 +02:00
|
|
|
get_source
|
|
|
|
|
|
|
|
test -d $builddir || mkdir $builddir
|
|
|
|
|
2019-10-07 14:28:06 +02:00
|
|
|
/bin/rm -rf "$builddir"
|
|
|
|
cp -a src/openwrt "$builddir"
|
2015-07-17 18:47:16 +02:00
|
|
|
|
2017-07-08 13:00:07 +02:00
|
|
|
patch_target
|
|
|
|
|
2019-11-10 16:33:56 +01:00
|
|
|
# apply variant to ensure the included file "variant.mk"
|
|
|
|
# exists in builddir.
|
|
|
|
apply_variant
|
2019-02-03 14:06:08 +01:00
|
|
|
|
2019-10-07 14:28:07 +02:00
|
|
|
#saves ~200MB for each build
|
|
|
|
test -d ./src/dl || mkdir ./src/dl
|
|
|
|
ln -s ../src/dl "$builddir"/dl
|
|
|
|
|
|
|
|
update_feeds
|
|
|
|
}
|
|
|
|
|
2019-11-10 16:33:56 +01:00
|
|
|
apply_variant() {
|
|
|
|
# set the variant for this build
|
|
|
|
cp "./src/packages/fff/fff/variant-$(cat selected_variant).mk" "$builddir"/variant.mk
|
|
|
|
# force the reevaluation of this Makefile to make note of the new variant
|
|
|
|
touch ./src/packages/fff/fff/Makefile
|
|
|
|
}
|
|
|
|
|
2019-10-07 14:28:07 +02:00
|
|
|
update_feeds() {
|
2015-07-17 18:47:16 +02:00
|
|
|
## generate own feeds.conf
|
|
|
|
#this local variable should be globally configure variable used in get_source and here
|
|
|
|
local PACKAGEBASE=${PWD}/src/packages
|
2019-10-07 14:28:06 +02:00
|
|
|
rm -f "$builddir"/feeds.conf
|
2015-07-17 18:47:16 +02:00
|
|
|
for FEEDVAR in "${FEEDS[@]}" ; do
|
|
|
|
FEED="${FEEDVAR}[@]"
|
|
|
|
FEED=("${!FEED}")
|
|
|
|
local NAME=${FEED[0]}
|
|
|
|
echo "adding $NAME to package feeds"
|
2019-10-07 14:28:06 +02:00
|
|
|
echo src-link "$NAME" "$PACKAGEBASE"/"$NAME" >> "$builddir"/feeds.conf
|
2015-07-17 18:47:16 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "cleaning feeds"
|
2020-04-17 15:39:58 +02:00
|
|
|
"$builddir"/scripts/feeds clean
|
2015-07-17 18:47:16 +02:00
|
|
|
|
2019-10-07 14:28:06 +02:00
|
|
|
"$builddir"/scripts/feeds update
|
2015-07-17 18:47:16 +02:00
|
|
|
|
|
|
|
for FEEDVAR in "${FEEDS[@]}" ; do
|
|
|
|
FEED="${FEEDVAR}[@]"
|
|
|
|
FEED=("${!FEED}")
|
|
|
|
local NAME=${FEED[0]}
|
|
|
|
local PACKAGESVAR="${FEEDVAR}_PKGS"
|
|
|
|
PACKAGESVAR="${PACKAGESVAR}[@]"
|
|
|
|
PACKAGESVAR=(${!PACKAGESVAR})
|
|
|
|
|
|
|
|
if [[ -n "${PACKAGESVAR[@]}" ]] ; then
|
|
|
|
echo "adding ${PACKAGESVAR[*]} from feed $NAME to available packages"
|
2019-10-07 14:28:06 +02:00
|
|
|
"$builddir"/scripts/feeds install -p "$NAME" "${PACKAGESVAR[@]}"
|
2015-07-17 18:47:16 +02:00
|
|
|
fi
|
|
|
|
done
|
2012-09-29 18:36:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
prebuild() {
|
2019-11-10 16:33:56 +01:00
|
|
|
apply_variant
|
|
|
|
|
2015-07-17 18:47:16 +02:00
|
|
|
#create filesdir for our config
|
2019-10-07 14:28:06 +02:00
|
|
|
/bin/rm -rf "$builddir"/files
|
|
|
|
mkdir "$builddir"/files
|
2015-07-17 18:47:16 +02:00
|
|
|
|
2019-10-07 14:28:06 +02:00
|
|
|
cp -r ./bsp/default/root_file_system/* "$builddir"/files/
|
|
|
|
cp ./bsp/"$machine"/.config "$builddir"/.config
|
2015-07-17 18:47:16 +02:00
|
|
|
|
2016-01-04 16:36:59 +01:00
|
|
|
while IFS= read -r -d '' template
|
2015-07-17 18:47:16 +02:00
|
|
|
do
|
|
|
|
echo "Translating $template .."
|
|
|
|
$tpl_translate "$template" > "$(dirname "$template")"/"$(basename "$template" .tpl)"
|
|
|
|
/bin/rm "$template"
|
2019-10-07 14:28:06 +02:00
|
|
|
done < <(find "${builddir}/files" -name '*.tpl' -print0)
|
2015-07-17 18:47:16 +02:00
|
|
|
|
|
|
|
#insert actual firware version informations into release file
|
2019-11-19 21:19:37 +01:00
|
|
|
variant=$(cat selected_variant)
|
2015-07-17 18:47:16 +02:00
|
|
|
version=$(git describe --tags --dirty)
|
2016-09-24 15:28:27 +02:00
|
|
|
if [ 0 -ne $? ]; then
|
|
|
|
version=$(git log -1 --pretty=format:%h)
|
|
|
|
fi
|
2019-11-19 21:19:37 +01:00
|
|
|
if [ -n "$variant" ]; then
|
|
|
|
version="$variant-$version"
|
2019-02-03 17:58:00 +01:00
|
|
|
fi
|
2015-07-17 18:47:16 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
echo "FIRMWARE_VERSION=\"$version\""
|
2019-11-19 21:19:37 +01:00
|
|
|
echo "VARIANT=\"$variant\""
|
2015-07-17 18:47:16 +02:00
|
|
|
echo "BUILD_DATE=\"build date: $(date)\""
|
|
|
|
echo "OPENWRT_CORE_REVISION=\"${OPENWRTREV}\""
|
|
|
|
echo "OPENWRT_FEEDS_PACKAGES_REVISION=\"${PACKAGEREV}\""
|
2019-10-07 14:28:06 +02:00
|
|
|
} > "$builddir"/files/etc/firmware_release
|
2015-12-06 13:42:20 +01:00
|
|
|
|
|
|
|
opath=$(pwd)
|
2019-10-07 14:28:06 +02:00
|
|
|
cd "$builddir"
|
2015-12-06 13:42:20 +01:00
|
|
|
make defconfig
|
|
|
|
cd "$opath"
|
2012-09-29 18:36:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
2015-07-17 18:47:16 +02:00
|
|
|
prebuild
|
|
|
|
|
2019-10-02 17:42:35 +02:00
|
|
|
rm_firmware
|
|
|
|
|
2015-07-17 18:47:16 +02:00
|
|
|
opath=$(pwd)
|
2019-10-07 14:28:06 +02:00
|
|
|
cd "$builddir"
|
2015-07-17 18:47:16 +02:00
|
|
|
cpus=$(grep -c processor /proc/cpuinfo)
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"debug")
|
|
|
|
make V=99
|
|
|
|
;;
|
|
|
|
"fast")
|
|
|
|
ionice -c 2 -- nice -n 1 -- make -j $((cpus*2))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ionice -c 3 -- nice -n 10 -- make -j $((cpus+1))
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
cd "$opath"
|
|
|
|
|
2016-04-05 22:00:32 +02:00
|
|
|
cp_firmware
|
2012-09-29 18:36:38 +02:00
|
|
|
}
|
|
|
|
|
2013-12-01 14:15:16 +01:00
|
|
|
config() {
|
2015-07-17 18:47:16 +02:00
|
|
|
prebuild
|
|
|
|
|
|
|
|
opath=$(pwd)
|
2019-10-07 14:28:06 +02:00
|
|
|
cd "$builddir"
|
2015-07-17 18:47:16 +02:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"openwrt")
|
|
|
|
make menuconfig
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
save=""
|
|
|
|
until [ "$save" = "y" -o "$save" = "n" ]; do
|
|
|
|
echo "Do you want to save the generated config? (y/n)"
|
|
|
|
read save
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$save" = "y" ]; then
|
|
|
|
case "$1" in
|
|
|
|
"openwrt")
|
2015-12-06 14:08:51 +01:00
|
|
|
echo "# Generated using \"./buildscript config openwrt\"." > "$opath"/bsp/"$machine"/.config
|
|
|
|
echo "# Do no edit manually" >> "$opath"/bsp/"$machine"/.config
|
|
|
|
echo "#" >> "$opath"/bsp/"$machine"/.config
|
|
|
|
./scripts/diffconfig.sh >> "$opath"/bsp/"$machine"/.config
|
2015-07-17 18:47:16 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2015-12-06 14:08:51 +01:00
|
|
|
|
|
|
|
cd "$opath"
|
2013-12-01 14:15:16 +01:00
|
|
|
}
|
|
|
|
|
2019-10-02 17:42:35 +02:00
|
|
|
rm_firmware() {
|
|
|
|
[ -n "$subtarget" ] || subtarget="generic"
|
|
|
|
|
2019-10-07 14:28:06 +02:00
|
|
|
rm -rf $builddir/bin/targets/${chipset}/${subtarget}
|
2019-10-02 17:42:35 +02:00
|
|
|
}
|
|
|
|
|
2016-04-05 22:00:32 +02:00
|
|
|
cp_firmware() {
|
2017-10-23 23:44:10 +02:00
|
|
|
[ -n "$subtarget" ] || subtarget="generic"
|
|
|
|
|
2019-12-14 21:16:54 +01:00
|
|
|
mkdir -p "bin/$variant"
|
|
|
|
|
2020-04-02 16:23:15 +02:00
|
|
|
imagesrcpath="$builddir/bin/targets/${chipset}/${subtarget}"
|
|
|
|
imagedestpath="./bin/$variant"
|
|
|
|
|
2016-04-05 22:00:32 +02:00
|
|
|
for image in ${images[@]}; do
|
2020-04-02 16:23:15 +02:00
|
|
|
# This assumes the set of images names is given with a wildcard
|
|
|
|
fullsrcpattern=$imagesrcpath/$image
|
|
|
|
if ! ls $fullsrcpattern >/dev/null 2>/dev/null; then
|
|
|
|
echo "Warning: $image not found."
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
for f in $fullsrcpattern; do
|
|
|
|
filename_build=${f##*/}
|
|
|
|
filename_build=${filename_build//openwrt/fff-${version}}
|
|
|
|
filename_build=${filename_build//squashfs-/}
|
|
|
|
filename_build=${filename_build//${chipset}-${subtarget}-/}
|
|
|
|
cp "$f" "$imagedestpath/$filename_build"
|
2017-01-06 14:15:56 +01:00
|
|
|
done
|
2016-04-05 22:00:32 +02:00
|
|
|
done
|
2012-09-29 18:36:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-05 22:00:34 +02:00
|
|
|
buildrelease() {
|
|
|
|
if [ "$1" = "all" ];then
|
2016-05-14 16:36:28 +02:00
|
|
|
all=true
|
2016-04-05 22:00:34 +02:00
|
|
|
elif [ "$1" = "fast" ];then
|
2016-05-14 16:36:28 +02:00
|
|
|
fast=fast
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$2" = "all" ];then
|
|
|
|
all=true
|
|
|
|
elif [ "$2" = "fast" ];then
|
|
|
|
fast=fast
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $all ]; then
|
|
|
|
buildall $fast
|
2016-04-05 22:00:34 +02:00
|
|
|
else
|
2016-05-14 16:36:28 +02:00
|
|
|
build $fast
|
2016-04-05 22:00:34 +02:00
|
|
|
fi
|
2016-05-14 16:36:28 +02:00
|
|
|
|
2019-12-14 21:16:54 +01:00
|
|
|
cd bin/$variant
|
2016-04-05 22:00:34 +02:00
|
|
|
for binary in *.bin; do
|
|
|
|
md5sum "$binary" > ./"$binary".md5
|
|
|
|
sha256sum "$binary" > ./"$binary".sha256
|
|
|
|
done
|
2019-12-14 21:16:54 +01:00
|
|
|
echo -e "VERSION:$version" > release.nfo
|
|
|
|
cd ../..
|
2016-04-05 22:00:34 +02:00
|
|
|
}
|
|
|
|
|
2012-09-29 18:36:38 +02:00
|
|
|
clean() {
|
2015-12-06 13:42:16 +01:00
|
|
|
/bin/rm -rf bin $builddir src/openwrt
|
|
|
|
|
|
|
|
# remove downloaded package feeds
|
|
|
|
for FEEDVAR in "${FEEDS[@]}" ; do
|
|
|
|
FEED="${FEEDVAR}[@]"
|
|
|
|
FEED=("${!FEED}")
|
|
|
|
|
|
|
|
local NAME=${FEED[0]}
|
2015-12-06 13:42:17 +01:00
|
|
|
local URL=${FEED[1]}
|
|
|
|
local REV=${FEED[2]}
|
2015-12-06 13:42:16 +01:00
|
|
|
|
2015-12-06 13:42:17 +01:00
|
|
|
if [ -n "$URL" ] && [ -n "$REV" ]; then
|
|
|
|
/bin/rm -rf src/packages/"$NAME"
|
|
|
|
fi
|
2015-12-06 13:42:16 +01:00
|
|
|
done
|
2012-09-29 18:36:38 +02:00
|
|
|
}
|
|
|
|
|
2016-05-14 16:36:26 +02:00
|
|
|
loadBSP()
|
|
|
|
{
|
2020-04-17 14:21:13 +02:00
|
|
|
localbsppath=$(/bin/ls -l selected_bsp | awk '{ print $11 }')
|
|
|
|
|
|
|
|
if ! [ -s selected_bsp ]; then
|
|
|
|
echo "Error: $localbsppath does not exist. Aborting ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Working with $localbsppath"
|
2016-05-14 16:36:26 +02:00
|
|
|
. selected_bsp
|
2020-04-15 15:47:03 +02:00
|
|
|
machine=$(basename $(realpath selected_bsp) .bsp)
|
2016-05-14 16:36:26 +02:00
|
|
|
}
|
|
|
|
|
2019-02-03 14:06:08 +01:00
|
|
|
loadVariant()
|
|
|
|
{
|
|
|
|
echo "Working with build variant \"$(cat selected_variant)\""
|
|
|
|
}
|
|
|
|
|
|
|
|
setVariant()
|
|
|
|
{
|
|
|
|
echo "$1" > selected_variant
|
|
|
|
}
|
|
|
|
|
2016-05-14 16:36:26 +02:00
|
|
|
setBSP()
|
|
|
|
{
|
|
|
|
/bin/rm -rf selected_bsp
|
|
|
|
/bin/ln -s "$1" selected_bsp
|
|
|
|
loadBSP
|
|
|
|
}
|
|
|
|
|
2013-09-19 20:40:28 +02:00
|
|
|
buildall() {
|
2015-07-17 18:47:16 +02:00
|
|
|
for bsp in $(/bin/ls bsp/*.bsp); do
|
2016-05-14 16:36:27 +02:00
|
|
|
setBSP "$bsp"
|
|
|
|
build "$1"
|
2015-07-17 18:47:16 +02:00
|
|
|
done
|
2013-09-19 20:40:28 +02:00
|
|
|
}
|
|
|
|
|
2017-08-19 16:07:26 +02:00
|
|
|
if [ "$(/usr/bin/id -u)" -eq 0 ]; then
|
2019-02-03 17:59:19 +01:00
|
|
|
echo "don't run buildscript as root"
|
|
|
|
exit 1
|
2017-08-19 16:07:26 +02:00
|
|
|
fi
|
|
|
|
|
2019-02-03 14:06:08 +01:00
|
|
|
if [ "$1" != "selectbsp" -a "$1" != "selectvariant" ]; then
|
2015-07-17 18:47:16 +02:00
|
|
|
if [ ! -h selected_bsp ]; then
|
|
|
|
echo "Please select a Board-Support-Package using:"
|
|
|
|
echo "$0 selectbsp"
|
|
|
|
exit
|
|
|
|
fi
|
2019-02-03 14:06:08 +01:00
|
|
|
if [ ! -f selected_variant ]; then
|
|
|
|
echo "Please select a build variant using:"
|
|
|
|
echo "$0 selectvariant"
|
|
|
|
exit
|
|
|
|
fi
|
2016-05-14 16:36:26 +02:00
|
|
|
loadBSP
|
2019-02-03 14:06:08 +01:00
|
|
|
loadVariant
|
2015-07-17 18:47:16 +02:00
|
|
|
echo
|
2012-09-29 18:36:38 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
2015-07-17 18:47:16 +02:00
|
|
|
"selectbsp")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "" ]; then
|
|
|
|
echo "Select a Board-Support-Package:"
|
|
|
|
echo
|
2016-01-28 00:30:56 +01:00
|
|
|
echo "Usage: $0 $1 <bsp-file>"
|
2015-07-17 18:47:16 +02:00
|
|
|
echo "available packages:"
|
|
|
|
/bin/ls bsp/*.bsp
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
else
|
|
|
|
if [ ! -f "$2" ]; then
|
|
|
|
echo "Could not find $2"
|
|
|
|
else
|
2016-05-14 16:36:26 +02:00
|
|
|
setBSP "$2"
|
2015-07-17 18:47:16 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
2019-02-03 14:06:08 +01:00
|
|
|
"selectvariant")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "" ]; then
|
|
|
|
echo "Select a build varaint:"
|
|
|
|
echo
|
|
|
|
echo "Usage: $0 $1 <name of variant>"
|
|
|
|
echo "available variants: "
|
|
|
|
/bin/ls src/packages/fff/fff/variant-*.mk | sed 's#.*/variant-\(.*\)\.mk#\1#g'
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
if [ ! -f "src/packages/fff/fff/variant-$2.mk" ]; then
|
|
|
|
echo "Could not find variant $2"
|
|
|
|
else
|
|
|
|
setVariant $2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
2015-07-17 18:47:16 +02:00
|
|
|
"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"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
echo "Usage: $0 $1"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
else
|
|
|
|
prepare
|
|
|
|
fi
|
|
|
|
;;
|
2019-10-07 14:28:07 +02:00
|
|
|
"updatefeeds")
|
|
|
|
update_feeds
|
|
|
|
;;
|
2015-07-17 18:47:16 +02:00
|
|
|
"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"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
echo "Usage: $0 $1 [fast|debug]"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
else
|
|
|
|
build "$2"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"config")
|
|
|
|
case "$2" in
|
|
|
|
openwrt)
|
|
|
|
config openwrt
|
|
|
|
;;
|
|
|
|
*)
|
2016-08-11 22:02:03 +02:00
|
|
|
echo "This open the OpenWrt menuconfig dialog"
|
2015-07-17 18:47:16 +02:00
|
|
|
echo
|
2015-12-06 13:42:22 +01:00
|
|
|
echo "Usage: $0 $1 openwrt"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
"clean")
|
|
|
|
if [ "$2" = "help" ] || [ "$2" = "x" ]; then
|
|
|
|
echo "This option cleans all build files."
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
|
|
|
echo "Usage: $0 $1"
|
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
else
|
|
|
|
clean
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"buildall")
|
2016-05-14 16:36:25 +02:00
|
|
|
if [ "$2" = "help" ]; then
|
2018-03-03 18:29:43 +01:00
|
|
|
echo "This option builds the firmware for all routers."
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2016-05-14 16:36:25 +02:00
|
|
|
echo "Usage: $0 $1 [fast]"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
else
|
2016-05-14 16:36:25 +02:00
|
|
|
buildall "$2"
|
2015-07-17 18:47:16 +02:00
|
|
|
fi
|
|
|
|
;;
|
2016-04-05 22:00:34 +02:00
|
|
|
"release")
|
|
|
|
if [ "$2" = help ]; then
|
|
|
|
echo "This option builds the firmware for a given board. It also creates hash sums and a the file release.nfo"
|
|
|
|
echo
|
|
|
|
echo "Usage: $0 $1 [all] [fast]"
|
|
|
|
echo
|
|
|
|
else
|
2016-05-14 16:36:28 +02:00
|
|
|
buildrelease "$2" "$3"
|
2016-04-05 22:00:34 +02:00
|
|
|
fi
|
|
|
|
;;
|
2015-07-17 18:47:16 +02:00
|
|
|
*)
|
|
|
|
echo "This is the Build Environment Script of the Freifunk Community Franken."
|
2016-01-28 00:30:56 +01:00
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
echo "Usage: $0 command"
|
|
|
|
echo "command:"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo " selectbsp <bsp-file>"
|
2019-02-03 14:06:08 +01:00
|
|
|
echo " selectvariant <name of variant>"
|
2015-07-17 18:47:16 +02:00
|
|
|
echo " prepare"
|
2019-10-07 14:28:07 +02:00
|
|
|
echo " updatefeeds"
|
2016-01-28 00:30:56 +01:00
|
|
|
echo " config openwrt"
|
|
|
|
echo " build [fast|debug]"
|
2016-05-14 16:36:25 +02:00
|
|
|
echo " buildall [fast]"
|
2016-04-05 22:00:34 +02:00
|
|
|
echo " release [all] [fast]"
|
2015-07-17 18:47:16 +02:00
|
|
|
echo " clean"
|
|
|
|
echo ""
|
2016-01-28 00:30:56 +01:00
|
|
|
echo "If you need help to one of these options just type: $0 <command> help"
|
|
|
|
echo
|
2015-07-17 18:47:16 +02:00
|
|
|
;;
|
2012-09-29 18:36:38 +02:00
|
|
|
esac
|