Skip to content

Commit

Permalink
add 2 dep of ssrp+
Browse files Browse the repository at this point in the history
  • Loading branch information
iyuangang committed Sep 23, 2020
1 parent ecefa96 commit a54d35a
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 0 deletions.
85 changes: 85 additions & 0 deletions package/lean/naiveproxy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#
# Copyright (C) 2020 Project OpenWrt
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=naiveproxy
PKG_VERSION:=85.0.4183.83-3
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/klzgrad/naiveproxy/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=66a8f275a9aa0fa04649062fb141a10add9bd76855f32ee65e6ee60a7fc4649c
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

PKG_LICENSE:=BSD 3-Clause
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=CN_SZTL <[email protected]>

PKG_BUILD_DEPENDS:=ninja/host python3/host
PKG_USE_MIPS16:=0
PKG_BUILD_PARALLEL:=1

ifneq ($(CONFIG_CPU_TYPE)," ")
CPU_TYPE:=$(word 1, $(subst +," ,$(CONFIG_CPU_TYPE)))
CPU_SUBTYPE:=$(word 2, $(subst +, ",$(CONFIG_CPU_TYPE)))
ifeq ($(CPU_SUBTYPE),)
CPU_SUBTYPE:=""
endif
else
CPU_TYPE:=""
CPU_SUBTYPE:=""
endif

include $(INCLUDE_DIR)/package.mk

define Package/naiveproxy
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
URL:=https://github.com/klzgrad/naiveproxy
TITLE:=Make a fortune quietly
DEPENDS:=@!(arc||armeb||powerpc) +libatomic +libnss
endef

define Package/naiveproxy/description
NaïveProxy uses Chrome's network stack to camouflage traffic with strong
censorship resistance and low detectability. Reusing Chrome's stack also
ensures best practices in performance and security.
endef

ifneq ($(CONFIG_CCACHE),)
export CCACHE_SLOPPINESS=time_macros
export CCACHE_BASEDIR=$(PKG_BUILD_DIR)/src
export CCACHE_CPP2=yes
export naive_ccache_flags=cc_wrapper="ccache"
endif

define Build/Compile
( \
cd $(PKG_BUILD_DIR) ; \
./tools/import-upstream.sh ; \
. ./init_env.sh "$(ARCH)" "$(BOARD)" $(CPU_TYPE) $(CPU_SUBTYPE) "$(TOOLCHAIN_DIR)" "$(DL_DIR)"; \
export naive_flags="$$$${naive_flags} $$$${naive_ccache_flags}" ; \
export OP_STAGING_DIR="$(STAGING_DIR)" ; \
mkdir -p out ; \
./gn/out/gn gen "out/Release" --args="$$$${naive_flags}" --script-executable="$(STAGING_DIR_HOSTPKG)/bin/python3" ; \
$(STAGING_DIR_HOSTPKG)/bin/ninja -C "out/Release" naive ; \
)
endef

define Package/naiveproxy/conffiles
/etc/chromium/policies/managed/proxy.json
endef

define Package/naiveproxy/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/out/Release/naive $(1)/usr/bin/naive
$(INSTALL_DIR) $(1)/etc/chromium/policies/managed
$(INSTALL_CONF) $(CURDIR)/files/proxy.json $(1)/etc/chromium/policies/managed/proxy.json
endef

$(eval $(call BuildPackage,naiveproxy))
1 change: 1 addition & 0 deletions package/lean/naiveproxy/files/proxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "MaxConnectionsPerProxy": 99 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 5b476d92f8dbee8b83061faa8cd18a46e5ab4aae Mon Sep 17 00:00:00 2001
From: CN_SZTL <[email protected]>
Date: Tue, 18 Aug 2020 20:36:39 +0000
Subject: [PATCH 1/3] build: add OpenWrt staging libraries

---
src/build/config/posix/BUILD.gn | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/src/build/config/posix/BUILD.gn b/src/build/config/posix/BUILD.gn
index 9ccb89f27..de9e5501d 100644
--- a/src/build/config/posix/BUILD.gn
+++ b/src/build/config/posix/BUILD.gn
@@ -28,6 +28,9 @@ config("runtime_library") {
if (!is_mac && !is_ios && sysroot != "") {
# Pass the sysroot to all C compiler variants, the assembler, and linker.
sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include" ]
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include/nss" ]
+ sysroot_flags += [ "-I" + getenv("OP_STAGING_DIR") + "/usr/include/nspr" ]
if (is_linux) {
# This is here so that all files get recompiled after a sysroot roll and
# when turning the sysroot on or off. (defines are passed via the command
@@ -57,6 +60,7 @@ config("runtime_library") {
cflags_objcc += sysroot_flags

# Need to get some linker flags out of the sysroot.
+ ldflags += [ "-L" + getenv("OP_STAGING_DIR") + "/usr/lib" ]
ld_paths = exec_script("sysroot_ld_path.py",
[
rebase_path("//build/linux/sysroot_ld_path.sh",
--
2.17.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
From fd4f8c65ecbbdd15d71a04d213314de056107a31 Mon Sep 17 00:00:00 2001
From: CN_SZTL <[email protected]>
Date: Tue, 18 Aug 2020 20:47:40 +0000
Subject: [PATCH 2/3] build: add mips & x86 OpenWrt toolchain definitions

---
src/build/toolchain/linux/BUILD.gn | 42 ++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)

diff --git a/src/build/toolchain/linux/BUILD.gn b/src/build/toolchain/linux/BUILD.gn
index 2e7913a4f..cc8084eac 100644
--- a/src/build/toolchain/linux/BUILD.gn
+++ b/src/build/toolchain/linux/BUILD.gn
@@ -95,6 +95,18 @@ clang_toolchain("clang_x86") {
}
}

+clang_toolchain("clang_x86_openwrt") {
+ # Output linker map files for binary size analysis.
+ enable_linker_map = true
+ extra_cppflags = "--target=i386-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
+ extra_ldflags = "--target=i386-openwrt-linux-musl"
+
+ toolchain_args = {
+ current_cpu = "x86"
+ current_os = "linux"
+ }
+}
+
clang_toolchain("clang_x86_v8_arm") {
toolchain_args = {
current_cpu = "x86"
@@ -203,6 +215,26 @@ gcc_toolchain("x64") {
}
}

+clang_toolchain("clang_mips_openwrt") {
+ extra_cppflags = "--target=mips-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
+ extra_ldflags = "--target=mips-openwrt-linux-musl"
+
+ toolchain_args = {
+ current_cpu = "mips"
+ current_os = "linux"
+ }
+}
+
+clang_toolchain("clang_mips64_openwrt") {
+ extra_cppflags = "--target=mips64-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
+ extra_ldflags = "--target=mips64-openwrt-linux-musl"
+
+ toolchain_args = {
+ current_cpu = "mips64"
+ current_os = "linux"
+ }
+}
+
clang_toolchain("clang_mipsel") {
toolchain_args = {
current_cpu = "mipsel"
@@ -227,6 +259,16 @@ clang_toolchain("clang_mips64el") {
}
}

+clang_toolchain("clang_mips64el_openwrt") {
+ extra_cppflags = "--target=mips64el-openwrt-linux-musl -D_LIBCPP_HAS_MUSL_LIBC -D__UCLIBC__"
+ extra_ldflags = "--target=mips64el-openwrt-linux-musl"
+
+ toolchain_args = {
+ current_cpu = "mips64el"
+ current_os = "linux"
+ }
+}
+
gcc_toolchain("mipsel") {
toolprefix = "mipsel-linux-gnu-"

--
2.17.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From dd07b78f561914ccc6cbe076ae66c380304bf92c Mon Sep 17 00:00:00 2001
From: CN_SZTL <[email protected]>
Date: Wed, 19 Aug 2020 12:42:45 +0000
Subject: [PATCH 3/3] build: drop useless deps simd_asm

libjpeg_turbo itself has alreadly set the dependency "simd_asm",
and this will cause cross-compile failed:
```
ERROR Unresolved dependencies.
//:gn_all(//build/toolchain/linux:clang_arm64_openwrt)
needs //third_party/libjpeg_turbo:simd_asm(//build/toolchain/linux:clang_arm64_openwrt)
```
So, let's drop it in global build file.
---
src/BUILD.gn | 1 -
1 file changed, 1 deletion(-)

diff --git a/src/BUILD.gn b/src/BUILD.gn
index 97494c0a0..daddf5213 100644
--- a/src/BUILD.gn
+++ b/src/BUILD.gn
@@ -746,7 +746,6 @@ group("gn_all") {
if (enable_nacl) {
deps += [ "//native_client/src/trusted/platform_qualify:vcpuid" ]
}
- deps += [ "//third_party/libjpeg_turbo:simd_asm" ]
}
if (is_linux && current_toolchain == host_toolchain) {
deps += [ "//v8:v8_shell" ]
--
2.17.1

113 changes: 113 additions & 0 deletions package/lean/naiveproxy/src/init_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/bash
# [CTCGFW] Project-OpenWrt
# Use it under GPLv3.
# --------------------------------------------------------
# Init build dependencies for naiveproxy

# Read args from shell
target_arch="$1"
target_board="$2"
cpu_type="$3"
cpu_subtype="$4"
toolchain_dir="$5"
dl_dir="$6"

# Set arch info
naive_arch="${target_arch}"
[ "${target_arch}" == "i386" ] && naive_arch="x86"
[ "${target_arch}" == "x86_64" ] && naive_arch="x64"
[ "${target_arch}" == "aarch64" ] && naive_arch="arm64"
ldso_path="/lib/$(find "${toolchain_dir}/" | grep -Eo "ld-musl-[a-z0-9_-]+\\.so\\.1")"

# OS detection
[ "$(uname)" != "Linux" -o "$(uname -m)" != "x86_64" ] && { echo -e "Support Linux AMD64 only."; exit 1; }

cd "$PWD/src"

# AFDO profile
[ ! -f "chrome/android/profiles/afdo.prof" ] && {
AFDO_NAME="$(cat "chrome/android/profiles/newest.txt")"
[ ! -f "${dl_dir}/${AFDO_NAME}" ] && curl -f --connect-timeout 20 --retry 5 --location --insecure "https://storage.googleapis.com/chromeos-prebuilt/afdo-job/llvm/${AFDO_NAME}" -o "${dl_dir}/${AFDO_NAME}"
bzip2 -cd > "chrome/android/profiles/afdo.prof" < "${dl_dir}/${AFDO_NAME}"
}

# Download Clang
[ ! -d "third_party/llvm-build/Release+Asserts/bin" ] && {
mkdir -p "third_party/llvm-build/Release+Asserts"
CLANG_REVISION="$(python3 "tools/clang/scripts/update.py" --print-revision)"
[ ! -f "${dl_dir}/clang-${CLANG_REVISION}.tgz" ] && curl -f --connect-timeout 20 --retry 5 --location --insecure "https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-${CLANG_REVISION}.tgz" -o "${dl_dir}/clang-${CLANG_REVISION}.tgz"
tar -xzf "${dl_dir}/clang-${CLANG_REVISION}.tgz" -C "third_party/llvm-build/Release+Asserts"
}

# Download GN tool
[ ! -f "gn/out/gn" ] && {
mkdir -p "gn/out"
GN_VERSION="$(grep "'gn_version':" "buildtools/DEPS" | cut -d"'" -f4)"
[ ! -f "${dl_dir}/gn-${GN_VERSION}.zip" ] && curl -f --connect-timeout 20 --retry 5 --location --insecure "https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/${GN_VERSION}" -o "${dl_dir}/gn-${GN_VERSION}.zip"
unzip -o "${dl_dir}/gn-${GN_VERSION}.zip" -d "gn/out"
}

# Set ENV
export DEPOT_TOOLS_WIN_TOOLCHAIN=0
export naive_flags="
is_official_build=true
exclude_unwind_tables=true
enable_resource_whitelist_generation=false
symbol_level=0
is_clang=true
use_sysroot=false
use_allocator=\"none\"
use_allocator_shim=false
fatal_linker_warnings=false
treat_warnings_as_errors=false
fieldtrial_testing_like_official_build=true
enable_base_tracing=false
enable_nacl=false
enable_print_preview=false
enable_remoting=false
use_alsa=false
use_cups=false
use_dbus=false
use_gio=false
use_platform_icu_alternatives=true
use_gtk=false
use_system_libdrm=false
use_gnome_keyring=false
use_libpci=false
use_pangocairo=false
use_glib=false
use_pulseaudio=false
use_udev=false
disable_file_support=true
enable_websockets=false
disable_ftp_support=true
use_kerberos=false
enable_mdns=false
enable_reporting=false
include_transport_security_state_preload_list=false
rtc_use_pipewire=false
use_xkbcommon=false
use_ozone=true
ozone_auto_platforms=false
ozone_platform=\"headless\"
ozone_platform_headless=true
current_os=\"linux\"
current_cpu=\"${naive_arch}\"
sysroot=\"${toolchain_dir}\"
custom_toolchain=\"//build/toolchain/linux:clang_${naive_arch}_openwrt\"
ldso_path=\"${ldso_path}\""
[ "${target_arch}" == "arm" ] && {
naive_flags="${naive_flags} arm_version=0 arm_cpu=\"${cpu_type}\""
[ -n "${cpu_subtype}" ] && { echo "${cpu_subtype}" | grep -q "neon" && neon_flag="arm_use_neon=true" || neon_flag="arm_use_neon=false"; naive_flags="${naive_flags} arm_fpu=\"${cpu_subtype}\" arm_float_abi=\"hard\" ${neon_flag}"; } || naive_flags="${naive_flags} arm_float_abi=\"soft\" arm_use_neon=false"
}
[[ "mips mips64 mipsel mips64el" =~ (^|[[:space:]])"${target_arch}"($|[[:space:]]) ]] && {
naive_flags="${naive_flags} use_gold=false is_cfi=false use_cfi_icall=false use_thin_lto=false mips_arch_variant=\"r2\""
[[ "${target_arch}" =~ ^"mips"$|^"mipsel"$ ]] && naive_flags="${naive_flags} mips_float_abi=\"soft\" mips_tune=\"${cpu_type}\""
}
41 changes: 41 additions & 0 deletions package/lean/tcping/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Copyright (C) 2014 OpenWrt-dist
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=tcping
PKG_VERSION:=0.3
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/Lienol/tcping
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=db9101834732dac9aaa59dbb7fb9c74612dbf723
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk

define Package/tcping
SECTION:=net
CATEGORY:=Network
TITLE:=tcping measures the latency of a tcp-connection
URL:=https://github.com/Lienol/tcping
endef

define Package/tcping/description
endef

define Package/tcping/conffiles
endef

define Package/tcping/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tcping $(1)/usr/sbin
endef

$(eval $(call BuildPackage,tcping))

0 comments on commit a54d35a

Please sign in to comment.