2017-12-22 10:08:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
umask 0022
|
|
|
|
unset GREP_OPTIONS SED
|
|
|
|
|
2018-07-18 20:36:20 +00:00
|
|
|
_get_repo() (
|
|
|
|
mkdir -p "$1"
|
|
|
|
cd "$1"
|
|
|
|
[ -d .git ] || git init
|
|
|
|
if git remote get-url origin >/dev/null 2>/dev/null; then
|
|
|
|
git remote set-url origin "$2"
|
|
|
|
else
|
|
|
|
git remote add origin "$2"
|
|
|
|
fi
|
|
|
|
git fetch origin
|
|
|
|
git fetch origin --tags
|
2018-07-30 09:19:28 +00:00
|
|
|
git checkout -f "origin/$3" -B "build" 2>/dev/null || git checkout "$3" -B "build"
|
2018-07-18 20:36:20 +00:00
|
|
|
)
|
2017-12-22 10:08:56 +00:00
|
|
|
|
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}
|
2018-02-15 14:36:12 +00:00
|
|
|
OMR_REPO=${OMR_REPO:-http://$OMR_HOST:$OMR_PORT/release}
|
2018-01-26 21:53:41 +00:00
|
|
|
OMR_KEEPBIN=${OMR_KEEPBIN:-no}
|
2018-02-23 08:46:51 +00:00
|
|
|
OMR_IMG=${OMR_IMG:-yes}
|
2018-01-29 09:02:35 +00:00
|
|
|
OMR_UEFI=${OMR_UEFI:-yes}
|
2018-04-05 15:16:42 +00:00
|
|
|
OMR_ALL_PACKAGES=${OMR_ALL_PACKAGES:-no}
|
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 !"
|
2018-05-11 13:14:40 +00:00
|
|
|
#exit 1
|
2017-12-22 10:08:56 +00:00
|
|
|
fi
|
|
|
|
|
2018-04-17 07:35:12 +00:00
|
|
|
if [ "$OMR_TARGET" = "rpi3" ]; then
|
2018-04-17 07:49:09 +00:00
|
|
|
OMR_REAL_TARGET="aarch64_cortex-a53"
|
2018-05-18 13:38:15 +00:00
|
|
|
elif [ "$OMR_TARGET" = "rpi2" ]; then
|
|
|
|
OMR_REAL_TARGET="arm_cortex-a7_neon-vfpv4"
|
2018-04-17 06:32:01 +00:00
|
|
|
else
|
2018-04-17 07:49:09 +00:00
|
|
|
OMR_REAL_TARGET=${OMR_TARGET}
|
2018-04-17 06:32:01 +00:00
|
|
|
fi
|
|
|
|
|
2018-01-23 14:56:13 +00:00
|
|
|
#_get_repo source https://github.com/ysurac/openmptcprouter-source "master"
|
2018-03-24 06:01:35 +00:00
|
|
|
#_get_repo "$OMR_TARGET/source" https://github.com/lede-project/source.git "3db9d6e57def2912314c7ce0bc0c282f313ed654"
|
2018-08-08 14:33:00 +00:00
|
|
|
_get_repo "$OMR_TARGET/source" https://github.com/openwrt/openwrt "openwrt-18.06"
|
2018-07-23 15:12:15 +00:00
|
|
|
_get_repo feeds/packages https://github.com/openwrt/packages "openwrt-18.06"
|
2018-02-27 20:54:33 +00:00
|
|
|
#_get_repo feeds/luci https://github.com/openwrt/luci "lede-17.01"
|
2018-07-23 15:12:15 +00:00
|
|
|
_get_repo feeds/luci https://github.com/openwrt/luci "openwrt-18.06"
|
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
|
2018-02-21 14:09:20 +00:00
|
|
|
rm -rf "$OMR_TARGET/source/bin"
|
2018-01-26 21:58:20 +00:00
|
|
|
fi
|
2018-02-21 14:09:20 +00:00
|
|
|
rm -rf "$OMR_TARGET/source/files" "$OMR_TARGET/source/tmp"
|
|
|
|
cp -rf root/* "$OMR_TARGET/source"
|
2017-12-22 10:08:56 +00:00
|
|
|
|
2018-02-21 16:06:07 +00:00
|
|
|
cat >> "$OMR_TARGET/source/package/base-files/files/etc/banner" <<EOF
|
2017-12-22 10:08:56 +00:00
|
|
|
-----------------------------------------------------
|
|
|
|
PACKAGE: $OMR_DIST
|
2018-03-06 16:13:43 +00:00
|
|
|
VERSION: $(git -C "$OMR_FEED" describe --tag --always)
|
2017-12-22 10:08:56 +00:00
|
|
|
|
|
|
|
BUILD REPO: $(git config --get remote.origin.url)
|
|
|
|
BUILD DATE: $(date -u)
|
|
|
|
-----------------------------------------------------
|
|
|
|
EOF
|
|
|
|
|
2018-02-21 16:06:07 +00:00
|
|
|
cat > "$OMR_TARGET/source/feeds.conf" <<EOF
|
2017-12-22 10:08:56 +00:00
|
|
|
src-link packages $(readlink -f feeds/packages)
|
|
|
|
src-link luci $(readlink -f feeds/luci)
|
|
|
|
src-link openmptcprouter $(readlink -f "$OMR_FEED")
|
|
|
|
EOF
|
|
|
|
|
2018-07-31 16:07:01 +00:00
|
|
|
#cat > "$OMR_TARGET/source/package/system/opkg/files/customfeeds.conf" <<EOF
|
|
|
|
#src/gz openwrt_luci http://downloads.openwrt.org/snapshots/packages/${OMR_REAL_TARGET}/luci
|
|
|
|
#src/gz openwrt_packages http://downloads.openwrt.org/snapshots/packages/${OMR_REAL_TARGET}/packages
|
|
|
|
#src/gz openwrt_base http://downloads.openwrt.org/snapshots/packages/${OMR_REAL_TARGET}/base
|
|
|
|
#src/gz openwrt_routing http://downloads.openwrt.org/snapshots/packages/${OMR_REAL_TARGET}/routing
|
|
|
|
#src/gz openwrt_telephony http://downloads.openwrt.org/snapshots/packages/${OMR_REAL_TARGET}/telephony
|
|
|
|
#EOF
|
2018-05-10 21:10:49 +00:00
|
|
|
cat > "$OMR_TARGET/source/package/system/opkg/files/customfeeds.conf" <<EOF
|
2018-07-31 16:07:01 +00:00
|
|
|
src/gz openwrt_luci http://downloads.openwrt.org/releases/18.06.0/packages/${OMR_REAL_TARGET}/luci
|
|
|
|
src/gz openwrt_packages http://downloads.openwrt.org/releases/18.06.0/packages/${OMR_REAL_TARGET}/packages
|
|
|
|
src/gz openwrt_base http://downloads.openwrt.org/releases/18.06.0/packages/${OMR_REAL_TARGET}/base
|
|
|
|
src/gz openwrt_routing http://downloads.openwrt.org/releases/18.06.0/packages/${OMR_REAL_TARGET}/routing
|
|
|
|
src/gz openwrt_telephony http://downloads.openwrt.org/releases/18.06.0/packages/${OMR_REAL_TARGET}/telephony
|
2018-04-17 06:32:01 +00:00
|
|
|
EOF
|
|
|
|
|
2018-05-18 08:26:49 +00:00
|
|
|
if [ -f "$OMR_TARGET_CONFIG" ]; then
|
|
|
|
cat "$OMR_TARGET_CONFIG" config -> "$OMR_TARGET/source/.config" <<-EOF
|
|
|
|
CONFIG_IMAGEOPT=y
|
|
|
|
CONFIG_VERSIONOPT=y
|
|
|
|
CONFIG_VERSION_DIST="$OMR_DIST"
|
|
|
|
CONFIG_VERSION_REPO="$OMR_REPO"
|
|
|
|
CONFIG_VERSION_NUMBER="$(git -C "$OMR_FEED" describe --tag --always)"
|
|
|
|
CONFIG_PACKAGE_${OMR_DIST}-full=y
|
|
|
|
EOF
|
|
|
|
else
|
|
|
|
cat config -> "$OMR_TARGET/source/.config" <<-EOF
|
|
|
|
CONFIG_IMAGEOPT=y
|
|
|
|
CONFIG_VERSIONOPT=y
|
|
|
|
CONFIG_VERSION_DIST="$OMR_DIST"
|
|
|
|
CONFIG_VERSION_REPO="$OMR_REPO"
|
|
|
|
CONFIG_VERSION_NUMBER="$(git -C "$OMR_FEED" describe --tag --always)"
|
|
|
|
CONFIG_PACKAGE_${OMR_DIST}-full=y
|
|
|
|
EOF
|
|
|
|
fi
|
2018-04-05 15:16:42 +00:00
|
|
|
if [ "$OMR_ALL_PACKAGES" = "yes" ]; then
|
|
|
|
echo 'CONFIG_ALL=y' >> "$OMR_TARGET/source/.config"
|
|
|
|
fi
|
2018-02-14 09:28:01 +00:00
|
|
|
if [ "$OMR_IMG" = "yes" ] && [ "$OMR_TARGET" = "x86_64" ]; then
|
2018-02-21 14:09:20 +00:00
|
|
|
echo 'CONFIG_VDI_IMAGES=y' >> "$OMR_TARGET/source/.config"
|
|
|
|
echo 'CONFIG_VMDK_IMAGES=y' >> "$OMR_TARGET/source/.config"
|
2018-02-14 09:28:01 +00:00
|
|
|
fi
|
|
|
|
|
2017-12-22 10:08:56 +00:00
|
|
|
|
2018-02-21 14:09:20 +00:00
|
|
|
cd "$OMR_TARGET/source"
|
2017-12-22 10:08:56 +00:00
|
|
|
|
2018-02-27 20:54:33 +00:00
|
|
|
echo "Checking if UEFI patch is set or not"
|
2018-01-29 09:02:35 +00:00
|
|
|
if [ "$OMR_UEFI" = "yes" ] && [ "$OMR_TARGET" = "x86_64" ]; then
|
2018-02-21 14:09:20 +00:00
|
|
|
if ! patch -Rf -N -p1 -s --dry-run < ../../patches/uefi.patch; then
|
2018-08-08 14:33:00 +00:00
|
|
|
patch --force --posix -N -p1 -s < ../../patches/uefi.patch
|
2018-01-29 14:40:40 +00:00
|
|
|
fi
|
2018-01-29 09:02:35 +00:00
|
|
|
else
|
2018-02-21 14:09:20 +00:00
|
|
|
if ! patch -Nf -p1 -s --dry-run < ../../patches/uefi.patch; then
|
2018-08-08 14:33:00 +00:00
|
|
|
patch --force --posix -N -R -p1 -s < ../../patches/uefi.patch
|
2018-01-29 14:40:40 +00:00
|
|
|
fi
|
2018-01-29 09:02:35 +00:00
|
|
|
fi
|
2018-01-29 14:40:40 +00:00
|
|
|
echo "Done"
|
2018-02-27 20:54:33 +00:00
|
|
|
|
2018-06-29 13:46:10 +00:00
|
|
|
echo "Remove gtime dependency"
|
|
|
|
if ! patch -Rf -N -p1 -s --dry-run < ../../patches/gtime.patch; then
|
|
|
|
patch -N -p1 -s < ../../patches/gtime.patch
|
|
|
|
fi
|
|
|
|
echo "Done"
|
2018-05-10 21:10:49 +00:00
|
|
|
|
|
|
|
|
2018-03-23 20:58:08 +00:00
|
|
|
#echo "Set to kernel 4.9 for all arch"
|
|
|
|
#find target/linux/ -type f -name Makefile -exec sed -i 's%KERNEL_PATCHVER:=4.14%KERNEL_PATCHVER:=4.9%g' {} \;
|
2018-03-22 18:55:12 +00:00
|
|
|
#echo "Done"
|
2018-05-18 13:38:15 +00:00
|
|
|
echo "Set to kernel 4.14 for rpi arch"
|
2018-03-23 20:58:08 +00:00
|
|
|
find target/linux/brcm2708 -type f -name Makefile -exec sed -i 's%KERNEL_PATCHVER:=4.9%KERNEL_PATCHVER:=4.14%g' {} \;
|
|
|
|
echo "Done"
|
2018-02-27 20:54:33 +00:00
|
|
|
|
|
|
|
echo "Update feeds index"
|
2017-12-22 10:08:56 +00:00
|
|
|
cp .config .config.keep
|
|
|
|
scripts/feeds clean
|
|
|
|
scripts/feeds update -a
|
2018-04-05 15:16:42 +00:00
|
|
|
if [ "$OMR_ALL_PACKAGES" = "yes" ]; then
|
|
|
|
scripts/feeds install -a -p packages
|
|
|
|
scripts/feeds install -a -p luci
|
|
|
|
fi
|
2017-12-22 10:08:56 +00:00
|
|
|
scripts/feeds install -a -d y -f -p openmptcprouter
|
|
|
|
cp .config.keep .config
|
2018-02-27 20:54:33 +00:00
|
|
|
echo "Done"
|
2017-12-22 10:08:56 +00:00
|
|
|
|
2018-05-11 13:14:40 +00:00
|
|
|
if [ ! -f "../../$OMR_TARGET_CONFIG" ]; then
|
|
|
|
echo "Target $OMR_TARGET not found ! You have to configure and compile your kernel manually."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-02-27 20:54:33 +00:00
|
|
|
echo "Building $OMR_DIST for the target $OMR_TARGET"
|
2017-12-22 10:08:56 +00:00
|
|
|
make defconfig
|
2018-04-17 06:32:01 +00:00
|
|
|
make IGNORE_ERRORS=m "$@"
|
2018-02-27 20:54:33 +00:00
|
|
|
echo "Done"
|