Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build images offline / against mirrors #150

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions build_falter
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
# shellcheck disable=SC2155
# shellcheck disable=SC1091

set -e
set -x

# use of 'set -o errexit' could abort a whole build if, i.e. the
# memory of a single 4MB-Device exceeds. This should be used with
# care.
set -o errexit
# set -o errexit
set -o pipefail
# we use unset variables in if-conditions, i.e. line 390. Thus not activating
# set -o nounset

REALPATH_SCRIPT=$(realpath "$0")
export BUILTER_DIR=$(dirname "$REALPATH_SCRIPT")

RELEASE_LINK_BASE="https://downloads.openwrt.org/releases/"
#export OPENWRT_MIRROR="https://downloads.openwrt.org"
export OPENWRT_MIRROR="http://192.168.1.1/downloads.openwrt.org"

RELEASE_LINK_BASE="$OPENWRT_MIRROR/releases/"

# General variables
FALTER_REPO_BASE="src/gz openwrt_falter https://firmware.berlin.freifunk.net/feed"
FREIFUNK_RELEASE=""
export OPENWRT_TOH="https://firmware.berlin.freifunk.net/openwrt-table-of-hardware.csv"
#export OPENWRT_TOH="https://firmware.berlin.freifunk.net/openwrt-table-of-hardware.csv"
export OPENWRT_TOH="http://192.168.1.1/firmware.berlin.freifunk.net/openwrt-table-of-hardware.csv"

# list of packages, that get omitted on 8 MiB devices
export OMIT_LIST_8MiB="
Expand Down Expand Up @@ -290,10 +297,14 @@ function start_build {

REPO="$FALTER_REPO_BASE/$FEED_VERSION/packages/$INSTR_SET/falter"
echo "injecting repo line: $REPO"
echo "$REPO" >>repositories.conf
# echo "$REPO" >>repositories.conf
echo "src falter file:///home/user/w/ff/falter-packages/out/master/$INSTR_SET/falter" >>repositories.conf
sed -i 's/option check_signature//g' repositories.conf
sed -i 's|https://downloads.openwrt.org/|http://192.168.1.1/downloads.openwrt.org/|g' repositories.conf

# the hexadecimal number represents the fringerprint of the key. Refer to third section of https://openwrt.org/docs/guide-user/security/keygen#generate_usign_key_pair
local URL="https://firmware.berlin.freifunk.net/feed/packagefeed_master.pub"
# local URL="https://firmware.berlin.freifunk.net/feed/packagefeed_master.pub"
local URL="http://192.168.1.1/firmware.berlin.freifunk.net/feed/packagefeed_master.pub"
local FINGERPRINT="61a078a38408e710"
echo "loading package-feed key from $URL..."
mkdir -p keys
Expand Down Expand Up @@ -382,25 +393,29 @@ build_router_db
# if openwrt_base is "master": change to "snapshots". That is the correct
# directory for downloading openwrt-master
if [ "$FREIFUNK_OPENWRT_BASE" == "master" ] || [ "$FREIFUNK_OPENWRT_BASE" == "snapshot" ] ; then
RELEASE_LINK_BASE="https://downloads.openwrt.org/"
RELEASE_LINK_BASE="$OPENWRT_MIRROR/"
FREIFUNK_OPENWRT_BASE="snapshots"
fi

if [ -z "$PARSER_TARGET" ] && [ -z "$IMAGE_BUILDER_PATH" ]; then
# build one release for all targets
RELEASE_LINK="$RELEASE_LINK_BASE""$FREIFUNK_OPENWRT_BASE""/targets/"
for target in $(fetch_subdirs "$RELEASE_LINK"); do
for subtarget in $(fetch_subdirs "$RELEASE_LINK$target"); do
imagebuilder=$(fetch_subdirs "$RELEASE_LINK$PARSER_PROFILE$target$subtarget" | grep imagebuilder)
start_build "$RELEASE_LINK$target$subtarget$imagebuilder"
done
done
else
# We require PARSER_TARGET (-t) nowadays, so it's never empty,
# and custom IMAGE_BUILDER_PATH is something we should consider removing.
#
# if [ -z "$PARSER_TARGET" ] && [ -z "$IMAGE_BUILDER_PATH" ]; then
# # build one release for all targets
# RELEASE_LINK="$RELEASE_LINK_BASE""$FREIFUNK_OPENWRT_BASE""/targets/"
# for target in $(fetch_subdirs "$RELEASE_LINK"); do
# for subtarget in $(fetch_subdirs "$RELEASE_LINK$target"); do
# imagebuilder=$(fetch_subdirs "$RELEASE_LINK$PARSER_PROFILE$target$subtarget" | grep imagebuilder)
# start_build "$RELEASE_LINK$target$subtarget$imagebuilder"
# done
# done
# else
# there was given a release and a target
RELEASE_LINK="$RELEASE_LINK_BASE""$FREIFUNK_OPENWRT_BASE""/targets/"
# build directly that target. if requested, for all image types.
TARGET_LIST="$RELEASE_LINK$PARSER_TARGET/"
IMAGEBUILDER=$(fetch_subdirs "$TARGET_LIST" | grep imagebuilder)
IMAGEBUILDER=$(wget -q -O - "$TARGET_LIST/sha256sums" | cut -d'*' -f2 | grep -i imagebuilder)
# IMAGEBUILDER=$(fetch_subdirs "$TARGET_LIST" | grep imagebuilder)
if [ "$PSET_PATHS" ]; then
for PKG_SET in $PSET_PATHS; do
echo "-> building three packagelists..."
Expand All @@ -412,4 +427,4 @@ else
# "targets" is on purpose there. Otherwise that positonal argument would be empty.
start_build "$TARGET_LIST$IMAGEBUILDER" targets "$PARSER_PROFILE"
fi
fi
# fi
1 change: 1 addition & 0 deletions lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function fetch_subdirs {
local URL=$1
local raw_html

# XXX wtf is the second grep for?
raw_html=$(curl -s "$URL" | grep href | grep -v 'snapshots\|releases')
if [ -z "$raw_html" ]; then
# write to stderr, to get the prompt printed outside the subshell too
Expand Down
11 changes: 5 additions & 6 deletions scripts/03-luci-footer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# shellcheck shell=bash

set -e
set -x

VERSION="$1"
TARGET="$2"
OPENWRT_BASE="$3"
Expand All @@ -8,20 +11,16 @@ REVISION="$4"
SCRIPTPATH=$(dirname "$(readlink -f "$0")")

if [ "$OPENWRT_BASE" = "openwrt-19.07" ] || [ "$OPENWRT_BASE" = "openwrt-21.02" ] || [ "$OPENWRT_BASE" = "openwrt-22.03" ]; then
SRCFOOTER="https://raw.githubusercontent.com/openwrt/luci/${OPENWRT_BASE}/themes/luci-theme-bootstrap/luasrc/view/themes/bootstrap/footer.htm"

FOOTERDIR="$SCRIPTPATH/../embedded-files/usr/lib/lua/luci/view/themes/bootstrap/"
mkdir -p "$FOOTERDIR" || exit 42

wget -q -P "$FOOTERDIR" "$SRCFOOTER" || exit 42
cp -v "$SCRIPTPATH/../store/footer.htm" "$FOOTERDIR/footer.htm"
sed -i "/Powered by.*/a \ \ \ \ <br><a href=\"https://berlin.freifunk.net\">Freifunk Berlin</a> (Falter v$VERSION - $REVISION) $TARGET" "$FOOTERDIR/footer.htm" || exit 42
else
SRCFOOTER="https://raw.githubusercontent.com/openwrt/luci/${OPENWRT_BASE}/themes/luci-theme-bootstrap/ucode/template/themes/bootstrap/footer.ut"

FOOTERDIR="$SCRIPTPATH/../embedded-files/usr/share/ucode/luci/template/themes/bootstrap/"
mkdir -p "$FOOTERDIR" || exit 42
wget -q -P "$FOOTERDIR" "$SRCFOOTER" || exit 42

cp -v "$SCRIPTPATH/../store/footer.ut" "$FOOTERDIR/footer.ut"
sed -i 's|{{ entityencode(version.disturl ?? .*, true) }}|https://berlin.freifunk.net|g' "$FOOTERDIR/footer.ut" || exit 42
sed -i "s|{{ version.distname }} {{ version.distversion }} ({{ version.distrevision }})|(Falter v$VERSION - $REVISION) $TARGET|g" "$FOOTERDIR/footer.ut" || exit 42
fi
21 changes: 21 additions & 0 deletions store/footer.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%#
Copyright 2008 Steven Barth <[email protected]>
Copyright 2008 Jo-Philipp Wich <[email protected]>
Copyright 2012 David Menting <[email protected]>
Licensed to the public under the Apache License 2.0.
-%>

<% if not blank_page then %>
<% local ver = require "luci.version" %>
</div>
<footer>
<span>
<a href="https://github.com/openwrt/luci">Powered by <%= ver.luciname %> (<%= ver.luciversion %>)</a> / <%= ver.distversion %>
</span>
<ul class="breadcrumb pull-right" id="modemenu" style="display:none"></ul>
</footer>
<script type="text/javascript">L.require('menu-bootstrap')</script>
<% end %>
</body>
</html>

20 changes: 20 additions & 0 deletions store/footer.ut
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% if (!blank_page): %}
</div>
<footer>
<span>
Powered by
<a href="https://github.com/openwrt/luci">
{{ version.luciname }} ({{ version.luciversion }})</a>
/
<a href="{{ entityencode(version.disturl ?? '#', true) }}">
{{ version.distname }} {{ version.distversion }} ({{ version.distrevision }})</a>
{% if (lua_active): %}
/ {{ _('Lua compatibility mode active') }}
{% endif %}
</span>
<ul class="breadcrumb pull-right" id="modemenu" style="display:none"></ul>
</footer>
<script type="text/javascript">L.require('menu-bootstrap')</script>
{% endif %}
</body>
</html>