Skip to content

Commit

Permalink
build: cache sdk downloads and feeds
Browse files Browse the repository at this point in the history
Signed-off-by: Packet Please <pktpls@systemli.org>
  • Loading branch information
pktpls committed Feb 11, 2024
1 parent 59187a5 commit 4468660
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ gitmirror="https://git.openwrt.org"
# gitmirror="file:///mnt/mirror/git.openwrt.org"
# gitmirror="http://192.168.1.1/git.openwrt.org"

function cache_feed() {
local name="$1"
local url="$2"
if [[ ! -d "tmp/feeds/$name" ]] ; then
git clone --mirror "$url" "tmp/feeds/$name"
else
(cd "tmp/feeds/$name" ; git fetch --all)
fi
}
mkdir -p tmp/feeds
cache_feed base "$gitmirror/openwrt/openwrt.git"
cache_feed packages "$gitmirror/feed/packages.git"
cache_feed luci "$gitmirror/project/luci.git"
cache_feed routing "$gitmirror/feed/routing.git"
cache_feed telephony "$gitmirror/feed/telephony.git"

mkdir -p "$dest/falter"
destdir=$(realpath "$dest")

Expand All @@ -84,23 +100,26 @@ unbuf="stdbuf --output=0 --error=0"

# download and extract sdk tarball
mkdir -p "./tmp/dl/$branch"
wget --progress=dot:giga -O "./tmp/dl/$branch/$sdkfile" "$dlurl/$target/$sdkfile"
( cd "./tmp/dl/$branch/" ; wget -N --progress=dot:giga "$dlurl/$target/$sdkfile")
rm -rf "$sdkdir"
mkdir -p "$sdkdir"
tar -x -C "$sdkdir" --strip-components=1 -f "./tmp/dl/$branch/$sdkfile"

# configure our feed, with an indirection via /tmp/feed so sdk doesn't recurse our feed
mkdir -p ./tmp/feed
ln -sfT "$(pwd)/packages" ./tmp/feed/packages
ln -sfT "$(pwd)/luci" ./tmp/feed/luci
cp "$sdkdir/feeds.conf.default" "$sdkdir/feeds.conf"
if [ "$gitmirror" != "https://git.openwrt.org" ]; then
sed -i "s|https://git.openwrt.org/openwrt|$gitmirror|g" "$sdkdir/feeds.conf"
sed -i "s|https://git.openwrt.org/feed|$gitmirror|g" "$sdkdir/feeds.conf"
sed -i "s|https://git.openwrt.org/project|$gitmirror|g" "$sdkdir/feeds.conf"
sed -i 's|src-git |src-git-full |g' "$sdkdir/feeds.conf"
fi
echo "src-link falter $(pwd)/tmp/feed" >> "$sdkdir/feeds.conf"
# use the local cached feed repos
{
echo "src-git base file:///$(pwd)/tmp/feeds/base"
echo "src-git packages file:///$(pwd)/tmp/feeds/packages"
echo "src-git luci file:///$(pwd)/tmp/feeds/luci"
echo "src-git routing file:///$(pwd)/tmp/feeds/routing"
echo "src-git telephony file:///$(pwd)/tmp/feeds/telephony"
} >> "$sdkdir/feeds.conf"

# configure our own feed
# with an indirection via a symlink so the sdk doesn't recurse our feed
mkdir -p ./tmp/feeds/falter
ln -sfT "$(pwd)/packages" ./tmp/feeds/falter/packages
ln -sfT "$(pwd)/luci" ./tmp/feeds/falter/luci
echo "src-link falter $(pwd)/tmp/feeds/falter" >> "$sdkdir/feeds.conf"

cd "$sdkdir"

Expand Down

0 comments on commit 4468660

Please sign in to comment.