Skip to content

Commit e76afb8

Browse files
committed
build: cache sdk downloads and feeds
Signed-off-by: Packet Please <[email protected]>
1 parent 6208791 commit e76afb8

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

build/build.sh

+32-13
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ gitmirror="https://git.openwrt.org"
6464
# gitmirror="file:///mnt/mirror/git.openwrt.org"
6565
# gitmirror="http://192.168.1.1/git.openwrt.org"
6666

67+
function cache_feed() {
68+
local name="$1"
69+
local url="$2"
70+
if [[ ! -d "tmp/feeds/$name" ]] ; then
71+
git clone --mirror "$url" "tmp/feeds/$name"
72+
else
73+
(cd "tmp/feeds/$name" ; git fetch --all)
74+
fi
75+
}
76+
mkdir -p tmp/feeds
77+
cache_feed base "$gitmirror/openwrt/openwrt.git"
78+
cache_feed packages "$gitmirror/feed/packages.git"
79+
cache_feed luci "$gitmirror/project/luci.git"
80+
cache_feed routing "$gitmirror/feed/routing.git"
81+
cache_feed telephony "$gitmirror/feed/telephony.git"
82+
6783
mkdir -p "$dest/falter"
6884
destdir=$(realpath "$dest")
6985

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

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

92-
# configure our feed, with an indirection via /tmp/feed so sdk doesn't recurse our feed
93-
mkdir -p ./tmp/feed
94-
ln -sfT "$(pwd)/packages" ./tmp/feed/packages
95-
ln -sfT "$(pwd)/luci" ./tmp/feed/luci
96-
cp "$sdkdir/feeds.conf.default" "$sdkdir/feeds.conf"
97-
if [ "$gitmirror" != "https://git.openwrt.org" ]; then
98-
sed -i "s|https://git.openwrt.org/openwrt|$gitmirror|g" "$sdkdir/feeds.conf"
99-
sed -i "s|https://git.openwrt.org/feed|$gitmirror|g" "$sdkdir/feeds.conf"
100-
sed -i "s|https://git.openwrt.org/project|$gitmirror|g" "$sdkdir/feeds.conf"
101-
sed -i 's|src-git |src-git-full |g' "$sdkdir/feeds.conf"
102-
fi
103-
echo "src-link falter $(pwd)/tmp/feed" >> "$sdkdir/feeds.conf"
108+
# use the local cached feed repos
109+
{
110+
echo "src-git base file:///$(pwd)/tmp/feeds/base"
111+
echo "src-git packages file:///$(pwd)/tmp/feeds/packages"
112+
echo "src-git luci file:///$(pwd)/tmp/feeds/luci"
113+
echo "src-git routing file:///$(pwd)/tmp/feeds/routing"
114+
echo "src-git telephony file:///$(pwd)/tmp/feeds/telephony"
115+
} >> "$sdkdir/feeds.conf"
116+
117+
# configure our own feed
118+
# with an indirection via a symlink so the sdk doesn't recurse our feed
119+
mkdir -p ./tmp/feeds/falter
120+
ln -sfT "$(pwd)/packages" ./tmp/feeds/falter/packages
121+
ln -sfT "$(pwd)/luci" ./tmp/feeds/falter/luci
122+
echo "src-link falter $(pwd)/tmp/feeds/falter" >> "$sdkdir/feeds.conf"
104123

105124
cd "$sdkdir"
106125

0 commit comments

Comments
 (0)