Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 80 lines (69 sloc) 2.088 kb
#!/bin/bash
set -eu
usage() {
cat << EOF
Usage: $0 PROFILE
ENVIRONMENT:
PLATFORM -- Set openWRT platform (Default: TLWR703, examples: TLMR3020)
TRAIT_DIR -- Set Trait directory (Default traits/)
EOF
echo
HIDE_TRAITS="true" bin/available_profiles
}
[ x"${1:-}" = "x" ] && usage && exit 1
HERE="$(dirname $(readlink -f $0))"
PROFILE_DIR="${HERE}/profiles"
TRAIT_DIR="${TRAIT_DIR:-${HERE}/traits}"
BUILD_DIR="${HERE}/builder/"
PLATFORM="${PLATFORM:-TLWR703}"
PROFILE="$PROFILE_DIR/$1"
PKG_FILE="${BUILD_DIR}/root_packages"
OVERLAY_PKG_FILE="${BUILD_DIR}/overlay_packages"
APPEND_FILES="${HERE}/lib/append_files"
indent() {
while read line;do
yes ' ' | head -${1:-4} | tr -d '\n'
echo $line
done
}
handle_append(){
cat ${APPEND_FILES}| while read i;do
[ -e "$1/files/$i" ] && cat "$1/files/$i" >> "$BUILD_DIR/customfiles/$i"
done
}
handle_trait_dir(){
if [ "$(readlink -f $TRAIT_DIR )" = "$1" ];then
return 0
else
# higher level traits supersede more general definitions
cd "$1"
#echo "in $CUR" >&2
handle_trait_dir $(readlink -f ..) ||:
if [ -e "$1/files" ] ;then
rsync -rl --exclude-from="$APPEND_FILES" "$1/files/"* "$BUILD_DIR/customfiles"
handle_append "$1"
fi
if [ -e "$1/MANIFEST" ];then
. "$1/MANIFEST"
printf '%s' "${PACKAGES:-} " >> $PKG_FILE
printf '%s' "${OVERLAY_PACKAGES:-} " >> $OVERLAY_PKG_FILE
fi
fi
}
build_custom_make(){
#hack to avoid newlines in build file
PLATFORM="$1"
echo "make image PROFILE='$PLATFORM' PACKAGES='`cat $PKG_FILE`' FILES=customfiles/" > \
"$BUILD_DIR/custom_make"
}
main (){
rm -rf "$BUILD_DIR/customfiles"
rm -f $OVERLAY_PKG_FILE $PKG_FILE
mkdir -p "$BUILD_DIR/customfiles"
ALL_PACKAGES=`cat "$PROFILE" | while read trait;do
echo "Handling $TRAIT_DIR/$trait" >&2
handle_trait_dir "$(readlink -f $TRAIT_DIR/$trait)" ||:
done`
build_custom_make "$PLATFORM"
}
main $@
Jump to Line
Something went wrong with that request. Please try again.