From 8b6169bc60b73ed1bcac417522f9a9ecd68658d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20H=C3=BCbner?= Date: Sat, 26 Mar 2022 18:24:23 +0100 Subject: [PATCH] build_falter: implement reducing packagelists for 8MiB-Devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Devices with 8MiB Flash ran out of memory when storing changes on the configuration. This commit tackles that problem by automatically removing some not crucial packages, if we detect a device with 8MiB flash. This is achieved by loading the OpenWrt Table of Hardware into a sqlite-db and querying for the flash amount. In the future this can also be used for detecting 32MiB-RAM devices. The list of packages that should be removed is defined in a variable at the tob of the script. In addition there is a list of routers that should get less packages even if they have technically more than 8MiB flash. This is useful for example for UniFi-AC-Mesh, which has two 8MiB-Partitions on a 16MiB-Flash. Signed-off-by: Martin Hübner --- build_falter | 128 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 104 insertions(+), 24 deletions(-) diff --git a/build_falter b/build_falter index c7aff77..a91f510 100755 --- a/build_falter +++ b/build_falter @@ -4,16 +4,27 @@ # memory of a single 4MB-Device exceeds. # set -e +REALPATH_SCRIPT=$(realpath "$0") +BUILTER_DIR=$(dirname "$REALPATH_SCRIPT") + RELEASE_LINK_BASE="https://downloads.openwrt.org/releases/" -RELEASES=" - https://downloads.openwrt.org/releases/19.07.5/targets/ - https://downloads.openwrt.org/releases/19.07.6/targets/ - https://downloads.openwrt.org/releases/21.02-SNAPSHOT/targets/ - https://downloads.openwrt.org/snapshots/targets/" # General variables FALTER_REPO_BASE="src/gz openwrt_falter https://firmware.berlin.freifunk.net/feed/" FREIFUNK_RELEASE="" +OPENWRT_TOH="https://openwrt.org/_media/toh_dump_tab_separated.gz" + +# list of packages, that get omitted on 8 MiB devices +OMIT_LIST_8MiB=" + mtr + iperf3 + tmux + vnstat + " +# list of devices, that have technically 16 MiB flash, but have two partitions a 8 MiB +OVERRIDE_TO_8MiB=" + ubnt_unifiac-mesh +" ################## # CMD-PARSER # @@ -220,20 +231,51 @@ done # repository derives directly from the falter-version. Download freifunk_release # file and determine openwrt-version by its variables -BASE_URL=$(echo $FALTER_REPO_BASE | cut -d' ' -f 3) +BASE_URL=$(echo "$FALTER_REPO_BASE" | cut -d' ' -f 3) FEEDURL="$BASE_URL$PARSER_FALTER_VERSION/packages/mips_24kc/falter/" if ! curl --silent --fail "$FEEDURL" >/dev/null; then echo "Error: failed retrieving feed URL. Wrong version '$PARSER_FALTER_VERSION'?" exit 2 fi -COMMONFILEURL=$FEEDURL$(curl -s ${FEEDURL}/Packages | sed -n '/falter-common$/,/^$/p' | awk '{if(/Filename: /) print $2}') -TMP=$(curl -s $COMMONFILEURL | tar xzOf - ./data.tar.gz | tar xzOf - ./etc/freifunk_release) -eval $TMP + +COMMONFILEURL=$FEEDURL$(curl -s "${FEEDURL}"/Packages | sed -n '/falter-common$/,/^$/p' | awk '{if(/Filename: /) print $2}') +TMP=$(curl -s "$COMMONFILEURL" | tar xzOf - ./data.tar.gz | tar xzOf - ./etc/freifunk_release) +eval "$TMP" ################# # FUNCTIONS # ################# +function build_router_db { + # load the table-of-hardware from openwrt project, to get further information on router, + # like i.e. flash-size + wget "$OPENWRT_TOH" -O "$BUILTER_DIR/build/toh.gz" + gunzip "$BUILTER_DIR/build/toh.gz" + echo -e '.separator "\t"\n.import '"$BUILTER_DIR/build/toh"' toh' | sqlite3 "$BUILTER_DIR/build/toh.db" +} + +function request_router_from_db { + local board="$1" + local response + + response=$(sqlite3 -batch "$BUILTER_DIR/build/toh.db" <