Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 50 lines (46 sloc) 2.05 KB
#!/usr/bin/env bash
set -eu
# TODO: provide a means to switch builder. right now, simply move builder to builder-ar71xx and symlink to builder
#IMAGEBUILDER_URL="http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-i486.tar.bz2"
# Caution: Snapshots are unstable
#IMAGEBUILDER_URL="http://downloads.openwrt.org/snapshots/trunk/ar71xx/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2"
IMAGEBUILDER_URL=${IMAGEBUILDER_URL:-https://downloads.openwrt.org/chaos_calmer/15.05/x86/64/OpenWrt-ImageBuilder-15.05-x86-64.Linux-x86_64.tar.bz2}
archive=$(basename $IMAGEBUILDER_URL)
# $IMAGEBUILDER_URL can be an environment variable set outside this script
if [ -z "$IMAGEBUILDER_URL" ] ; then
IMAGEBUILDER_URL="https://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/OpenWrt-ImageBuilder-15.05-ar71xx-generic.Linux-x86_64.tar.bz2"
# IMAGEBUILDER_URL="https://downloads.openwrt.org/snapshots/trunk/ramips/generic/OpenWrt-ImageBuilder-ramips-rt305x.Linux-x86_64.tar.bz2"
# Caution: Snapshots are unstable
fi
cd $(dirname $(readlink -f $0))
git submodule update --init
if [ -z "${1:-}" ];then
echo "usage: $0 PROFILE"
echo
HIDE_TRAITS="true" sh $(dirname $(readlink -f $0))/bin/available_profiles
exit 1
fi
PROFILE=$1
if [ ! -e builder/init ]; then
wget --trust-server-names -c "$IMAGEBUILDER_URL"
tar xf $(basename "$IMAGEBUILDER_URL")
mv OpenWrt-*-x86_64 builder
echo "Builder successfully downloaded"
else
echo "Builder already installed, skipping download"
fi
echo
echo "copying generic init:"
cp --remove-destination lib/init builder/init
echo " profile/init -> builder/init"
cp --remove-destination lib/init_overlay builder/init_overlay
echo " profile/init_overlay -> builder/init_overlay"
[ -e builder/overlay ] && echo "removing old overlay" && rm -rf builder/overlay
echo
echo "copying profile:"
./copy_profile "$PROFILE"
if [ -e builder/overlay ];then
echo
echo "This profile also contains overlay data,"
echo 'run `builder/init_overlay` to copy'
fi