2017-12-22 10:08:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
umask 0022
|
|
|
|
unset GREP_OPTIONS SED
|
|
|
|
|
|
|
|
_get_repo() {
|
|
|
|
git clone "$2" "$1" 2>/dev/null || true
|
|
|
|
git -C "$1" remote set-url origin "$2"
|
|
|
|
git -C "$1" fetch origin
|
|
|
|
git -C "$1" fetch origin --tags
|
|
|
|
git -C "$1" checkout "origin/$3" -B "build" || git -C "$1" checkout "$3" -B "build"
|
|
|
|
}
|
|
|
|
|
2018-02-02 10:23:20 +00:00
|
|
|
OMR_DIST=${OMR_DIST:-openmptcprouter}
|
2018-01-23 14:56:13 +00:00
|
|
|
OMR_HOST=${OMR_HOST:-$(curl -sS ifconfig.co)}
|
2017-12-22 10:08:56 +00:00
|
|
|
OMR_PORT=${OMR_PORT:-8000}
|
|
|
|
OMR_REPO=${OMR_REPO:-http://$OMR_HOST:$OMR_PORT/$OMR_PATH}
|
2018-01-26 21:53:41 +00:00
|
|
|
OMR_KEEPBIN=${OMR_KEEPBIN:-no}
|
2018-01-29 09:02:35 +00:00
|
|
|
OMR_UEFI=${OMR_UEFI:-yes}
|
2017-12-22 10:08:56 +00:00
|
|
|
OMR_TARGET=${OMR_TARGET:-x86_64}
|
|
|
|
OMR_TARGET_CONFIG="config-$OMR_TARGET"
|
|
|
|
|
|
|
|
OMR_FEED_URL="${OMR_FEED_URL:-https://github.com/ysurac/openmptcprouter-feeds}"
|
|
|
|
OMR_FEED_SRC="${OMR_FEED_SRC:-master}"
|
|
|
|
|
|
|
|
if [ ! -f "$OMR_TARGET_CONFIG" ]; then
|
|
|
|
echo "Target $OMR_TARGET not found !"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-01-23 14:56:13 +00:00
|
|
|
#_get_repo source https://github.com/ysurac/openmptcprouter-source "master"
|
2018-01-23 17:42:18 +00:00
|
|
|
_get_repo source https://github.com/lede-project/source.git "lede-17.01"
|
2017-12-22 10:08:56 +00:00
|
|
|
_get_repo feeds/packages https://github.com/openwrt/packages "master"
|
2018-01-23 14:56:13 +00:00
|
|
|
_get_repo feeds/luci https://github.com/openwrt/luci "lede-17.01"
|
2017-12-22 10:08:56 +00:00
|
|
|
|
|
|
|
if [ -z "$OMR_FEED" ]; then
|
2017-12-22 10:16:59 +00:00
|
|
|
OMR_FEED=feeds/openmptcprouter
|
2017-12-22 10:08:56 +00:00
|
|
|
_get_repo "$OMR_FEED" "$OMR_FEED_URL" "$OMR_FEED_SRC"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$1" ] && [ -f "$OMR_FEED/$1/Makefile" ]; then
|
|
|
|
OMR_DIST=$1
|
|
|
|
shift 1
|
|
|
|
fi
|
|
|
|
|
2018-01-26 21:58:20 +00:00
|
|
|
if [ "$OMR_KEEPBIN" = "no" ]; then
|
|
|
|
rm -rf source/bin
|
|
|
|
fi
|
2018-01-26 21:53:41 +00:00
|
|
|
rm -rf source/files source/tmp
|
2018-01-23 15:57:04 +00:00
|
|
|
cp -rf root/* source
|
2017-12-22 10:08:56 +00:00
|
|
|
|
2018-01-23 15:57:04 +00:00
|
|
|
cat >> source/package/base-files/files/etc/banner <<EOF
|
2017-12-22 10:08:56 +00:00
|
|
|
-----------------------------------------------------
|
|
|
|
PACKAGE: $OMR_DIST
|
|
|
|
VERSION: $(git describe --tag --always)
|
|
|
|
|
|
|
|
BUILD REPO: $(git config --get remote.origin.url)
|
|
|
|
BUILD DATE: $(date -u)
|
|
|
|
-----------------------------------------------------
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > source/feeds.conf <<EOF
|
|
|
|
src-link packages $(readlink -f feeds/packages)
|
|
|
|
src-link luci $(readlink -f feeds/luci)
|
|
|
|
src-link openmptcprouter $(readlink -f "$OMR_FEED")
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat "$OMR_TARGET_CONFIG" config -> source/.config <<EOF
|
|
|
|
CONFIG_IMAGEOPT=y
|
|
|
|
CONFIG_VERSIONOPT=y
|
|
|
|
CONFIG_VERSION_DIST="$OMR_DIST"
|
|
|
|
CONFIG_VERSION_REPO="$OMR_REPO"
|
|
|
|
CONFIG_VERSION_NUMBER="$(git describe --tag --always)"
|
|
|
|
CONFIG_VERSION_CODE="$(git -C "$OMR_FEED" describe --tag --always)"
|
2018-01-29 09:02:35 +00:00
|
|
|
CONFIG_PACKAGE_${OMR_DIST}-full=y
|
2017-12-22 10:08:56 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
echo "Building $OMR_DIST for the target $OMR_TARGET"
|
|
|
|
|
|
|
|
cd source
|
|
|
|
|
2018-01-29 09:02:35 +00:00
|
|
|
if [ "$OMR_UEFI" = "yes" ] && [ "$OMR_TARGET" = "x86_64" ]; then
|
2018-01-29 14:40:40 +00:00
|
|
|
if ! patch -Rf -N -p1 -s --dry-run < ../patches/uefi.patch; then
|
|
|
|
patch -N -p1 -s < ../patches/uefi.patch
|
|
|
|
fi
|
2018-01-29 09:02:35 +00:00
|
|
|
else
|
2018-01-29 14:40:40 +00:00
|
|
|
if ! patch -Nf -p1 -s --dry-run < ../patches/uefi.patch; then
|
|
|
|
patch -N -R -p1 -s < ../patches/uefi.patch
|
|
|
|
fi
|
2018-01-29 09:02:35 +00:00
|
|
|
fi
|
2018-01-29 14:40:40 +00:00
|
|
|
echo "Done"
|
2017-12-22 10:08:56 +00:00
|
|
|
cp .config .config.keep
|
|
|
|
scripts/feeds clean
|
|
|
|
scripts/feeds update -a
|
|
|
|
scripts/feeds install -a -d y -f -p openmptcprouter
|
|
|
|
cp .config.keep .config
|
|
|
|
|
|
|
|
make defconfig
|
|
|
|
make "$@"
|