Last active
April 24, 2021 16:33
-
-
Save amq/f3895b208850ab07c5e2e855fa5fcab9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prerequisites: http://wiki.openwrt.org/doc/howto/buildroot.exigence | |
# Additionally JDK is needed | |
generate_buildenv() { | |
# Prepare build enviroment | |
mkdir lede_build | |
cd lede_build | |
git clone https://github.com/lede-project/source.git | |
cd source | |
} | |
dl_and_install_feeds() { | |
# Download and install package feeds | |
./scripts/feeds update -a | |
./scripts/feeds install -a | |
rm -f .config .config.old | |
} | |
dl_and_update_config() { | |
# Download and update .config | |
wget -qO .config https://gist.githubusercontent.com/amq/6b5a78e38d0ab7142a070d9de7485482/raw | |
make defconfig | |
} | |
optimize_luci() { | |
dl_and_extract_apps() { | |
wget -qO yuicompressor.jar https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor-2.4.8.jar | |
wget -qO compiler.zip http://dl.google.com/closure-compiler/compiler-latest.zip | |
unzip -ojqq compiler.zip | |
rm -f compiler.zip | |
mv closure-compiler-*.jar compiler.jar | |
} | |
# The following code is based on: | |
# https://forum.openwrt.org/viewtopic.php?pid=183795#p183795 | |
# We might want to look at modifiying imgopt for our needs | |
minify_css() { | |
for file in $( find "feeds/luci" -iname '*.css' ) | |
do | |
echo "$file" | |
java -jar yuicompressor.jar -o "$file-min.css" "$file" | |
mv "$file-min.css" "$file" | |
done | |
} | |
optimize_js() { | |
for file in $( find "feeds/luci" -iname '*.js' ) | |
do | |
echo "$file" | |
java -jar compiler.jar --compilation_level=SIMPLE_OPTIMIZATIONS --js="$file" --js_output_file="$file-min.js" | |
mv "$file-min.js" "$file" | |
done | |
} | |
dl_and_extract_apps | |
minify_css | |
optimize_js | |
rm -f yuicompressor.jar compiler.jar | |
} | |
run_make() { | |
# Compile firmware | |
make -j "$(getconf _NPROCESSORS_ONLN 2> /dev/null)" V=s 2>&1 | tee build.log | grep -i error | |
} | |
generate_buildenv | |
dl_and_install_feeds | |
dl_and_update_config | |
optimize_luci | |
run_make |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment