Building package from source

HI,

I try to build dnsproxy package, the last version for my wrt3200 device.
I downloaded the last version here;
I took arm7 : https://github.com/AdguardTeam/dnsproxy/releases/tag/v0.65.0
dnsproxy-linux-arm7-v0.65.0.tar.gz

and it seems I need go to install it or build, I extracted the tar file, but I don't know how to proceed for the next steps, some tips or advices?
thanks

Is there a reason you want to build from source? dnsproxy is available in the OpenWrt repo (although to be fair it is slightly older).

too old.
so this is why I would like to

Ok. Well, start by getting the build system up and running for OpenWrt... you'll need the toolchain:

https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem

Then, you'll probably want to follow the process for building a single package:
https://openwrt.org/docs/guide-developer/toolchain/single.package

The complete documentation for the developer guide is here:
https://openwrt.org/docs/guide-developer/start

2 Likes

Ive already my buildroot, I make my custom build for my wrt device

I just dont know when I need to use that file ;
dnsproxy-linux-arm7-v0.65.0.tar.gz

Typically you'd decompress the file, and put it into the packages directory, and build from there. It should all be in the developer guides. It's been a long time since I've done this specific thing, though, so if you need more specific help, hopefully other developers can chime in.

1 Like
james@msi:/media/james/D/WRT_build/test_OWRT/feeds/packages$ make package/dnsproxy/download
make: *** No rule to make target 'package/dnsproxy/download'.  Stop.

I thiink I need to be elsewhere in my directories to run that?

You should use the existing OpenWrt Makefile for that package, and just edit the Makefile to use the newer upstream version. Once you have built and tested it, you could author a pull request to get the updated package definition into the OpenWrt packages feed repo.

2 Likes

yep but I need the new PKG_HASH.

The error message will tell you the expected hash (the one currently in the Makefile) and the computed hash (the one you should put into the Makefile).

2 Likes

what I did, I chnage the version in the makefile, the only change I made is that, and I got that; I can see the hash

 make -j1 package/dnsproxy/compile V=sc
12720de6f1540aee7d3c08b6b32e602d05126a8c55f251bbb94d379306608241, requested: 3e7a032b7f69cbbb64825cc373da5f0c2bec1417b8211db6a5cb6aff5ab2ca57) - deleting download.
+ curl -f --connect-timeout 20 --retry 5 --location https://sources.cdn.openwrt.org/dnsproxy-0.65.0.tar.gz

but after I changed the hash in makefile I got that;

touch /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.prepared_e10336a4d89b5a2801bf14ce22f9f286_6664517399ebbbc92a37c5bb081b5c53
rm -f /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.configured_*
rm -f /media/james/D/WRT_build/divest_OWRT/staging_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/stamp/.dnsproxy_installed
CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE="" GO_BUILD_CACHE_DIR="/media/james/D/WRT_build/divest_OWRT/tmp/go-build" GO_MOD_CACHE_DIR="/media/james/D/WRT_build/divest_OWRT/dl/go-mod-cache" GO_MOD_ARGS="-modcacherw" GO_PKG="github.com/AdguardTeam/dnsproxy" GO_INSTALL_EXTRA="" GO_INSTALL_ALL="" GO_SOURCE_ONLY="" GO_BUILD_PKG="github.com/AdguardTeam/dnsproxy/..." GO_EXCLUDES="" GO_GO_GENERATE="" GO_INSTALL_BIN_PATH="/usr/bin" BUILD_DIR="/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0" GO_BUILD_DIR="/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.go_work/build" GO_BUILD_BIN_DIR="/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.go_work/build/bin/linux_arm" GO_BUILD_DEPENDS_PATH="/usr/share/gocode" GO_BUILD_DEPENDS_SRC="/media/james/D/WRT_build/divest_OWRT/staging_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/usr/share/gocode/src" /usr/bin/env bash ../../lang/golang//golang-build.sh configure
Copying files from /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0 into /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.go_work/build/src/github.com/AdguardTeam/dnsproxy
fastip/cache.go
fastip/cache_test.go
fastip/fastest.go
fastip/fastest_test.go
fastip/ping.go
fastip/ping_test.go
go.mod
go.sum
internal/bootstrap/bootstrap.go
internal/bootstrap/bootstrap_test.go
internal/bootstrap/error.go
internal/bootstrap/resolver.go
internal/bootstrap/resolver_test.go
internal/netutil/listenconfig.go
internal/netutil/listenconfig_unix.go
internal/netutil/listenconfig_windows.go
internal/netutil/netutil.go
internal/netutil/netutil_example_test.go
internal/netutil/netutil_test.go
internal/netutil/testdata/TestHosts/bad_file/hosts
internal/netutil/testdata/TestHosts/good_file/hosts
internal/netutil/udp.go
internal/netutil/udp_unix.go
internal/netutil/udp_windows.go
internal/netutil/udpoob_darwin.go
internal/netutil/udpoob_others.go
internal/tools/doc.go
internal/tools/go.mod
internal/tools/go.sum
internal/tools/tools.go
internal/version/version.go
main.go
proxy/bogusnxdomain.go
proxy/bogusnxdomain_test.go
proxy/cache.go
proxy/cache_test.go
proxy/clock.go
proxy/config.go
proxy/dns64.go
proxy/dns64_test.go
proxy/dnscontext.go
proxy/errors.go
proxy/errors_plan9.go
proxy/errors_test.go
proxy/exchange.go
proxy/exchange_internal_test.go
proxy/handler_test.go
proxy/helpers.go
proxy/lookup.go
proxy/lookup_test.go
proxy/optimisticresolver.go
proxy/optimisticresolver_test.go
proxy/proxy.go
proxy/proxy_test.go
proxy/proxycache.go
proxy/ratelimit.go
proxy/ratelimit_test.go
proxy/server.go
proxy/server_dnscrypt.go
proxy/server_dnscrypt_test.go
proxy/server_https.go
proxy/server_https_test.go
proxy/server_quic.go
proxy/server_quic_test.go
proxy/server_tcp.go
proxy/server_tcp_test.go
proxy/server_udp.go
proxy/server_udp_test.go
proxy/upstreams.go
proxy/upstreams_test.go
proxyutil/dns.go
upstream/dnscrypt.go
upstream/dnscrypt_test.go
upstream/doh.go
upstream/doh_test.go
upstream/doq.go
upstream/doq_test.go
upstream/dot.go
upstream/dot_test.go
upstream/dot_unix.go
upstream/dot_windows.go
upstream/hostsresolver.go
upstream/hostsresolver_test.go
upstream/parallel.go
upstream/parallel_test.go
upstream/plain.go
upstream/plain_test.go
upstream/resolver.go
upstream/resolver_test.go
upstream/upstream.go
upstream/upstream_test.go

/media/james/D/WRT_build/divest_OWRT/staging_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/usr/share/gocode/src does not exist, skipping symlinks

touch /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.configured_68b329da9893e34099c7d8ad5cb9c940
rm -f /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.built
touch /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.built_check
CONFIG_GOLANG_MOD_CACHE_WORLD_READABLE="" GO_BUILD_CACHE_DIR="/media/james/D/WRT_build/divest_OWRT/tmp/go-build" GO_MOD_CACHE_DIR="/media/james/D/WRT_build/divest_OWRT/dl/go-mod-cache" GO_MOD_ARGS="-modcacherw" GO_PKG="github.com/AdguardTeam/dnsproxy" GO_INSTALL_EXTRA="" GO_INSTALL_ALL="" GO_SOURCE_ONLY="" GO_BUILD_PKG="github.com/AdguardTeam/dnsproxy/..." GO_EXCLUDES="" GO_GO_GENERATE="" GO_INSTALL_BIN_PATH="/usr/bin" BUILD_DIR="/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0" GO_BUILD_DIR="/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.go_work/build" GO_BUILD_BIN_DIR="/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.go_work/build/bin/linux_arm" GO_BUILD_DEPENDS_PATH="/usr/share/gocode" GO_BUILD_DEPENDS_SRC="/media/james/D/WRT_build/divest_OWRT/staging_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/usr/share/gocode/src" GOOS="linux" GOARCH="arm" GO386="" GOAMD64="" GOARM="7" GOMIPS="" GOMIPS64="" GOPPC64="" CGO_ENABLED=1 CC="arm-openwrt-linux-muslgnueabi-gcc" CXX="arm-openwrt-linux-muslgnueabi-g++" CGO_CFLAGS="-O2 -pipe -mthumb -fno-caller-saves -fno-plt -fhonour-copts -mfloat-abi=hard -ffile-prefix-map=/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0=dnsproxy-0.65.0 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -fstack-clash-protection -fwrapv" CGO_CPPFLAGS="-I/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/usr/include -I/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/include -I/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/include/fortify" CGO_CXXFLAGS="-O2 -pipe -mthumb -fno-caller-saves -fno-plt -fhonour-copts -mfloat-abi=hard -ffile-prefix-map=/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0=dnsproxy-0.65.0 -Wformat -Werror=format-security -DPIC -fpic -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -fstack-clash-protection -fwrapv" CGO_LDFLAGS="-L/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/usr/lib -L/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/lib -fuse-ld=bfd -DPIC -fpic -specs=/media/james/D/WRT_build/divest_OWRT/include/hardened-ld-pie.specs -znow -zrelro" GOPATH="/media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.go_work/build" GOCACHE="/media/james/D/WRT_build/divest_OWRT/tmp/go-build" GOMODCACHE="/media/james/D/WRT_build/divest_OWRT/dl/go-mod-cache" GOENV=off GOTOOLCHAIN=local /usr/bin/env bash ../../lang/golang//golang-build.sh build -v -buildvcs=false -trimpath -ldflags "all=-buildid '1708815027' -linkmode external -extldflags '-L/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/usr/lib -L/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/lib -fuse-ld=bfd -DPIC -fpic -specs=/media/james/D/WRT_build/divest_OWRT/include/hardened-ld-pie.specs -Wl,-z,now -Wl,-z,relro'"   -buildmode pie -installsuffix "v7"    -ldflags " -X github.com/AdguardTeam/dnsproxy/internal/version.version=v0.65.0 -buildid '1708815027' -linkmode external -extldflags '-L/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/usr/lib -L/media/james/D/WRT_build/divest_OWRT/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-12.3.0_musl_eabi/lib -fuse-ld=bfd -DPIC -fpic -specs=/media/james/D/WRT_build/divest_OWRT/include/hardened-ld-pie.specs -Wl,-z,now -Wl,-z,relro'"  
Finding targets
go: ../../go.mod requires go >= 1.21.7 (running go 1.21.5; GOTOOLCHAIN=local)

Building targets
go: ../../go.mod requires go >= 1.21.7 (running go 1.21.5; GOTOOLCHAIN=local)

make[2]: *** [Makefile:64: /media/james/D/WRT_build/divest_OWRT/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/dnsproxy-0.65.0/.built] Error 1
make[2]: Leaving directory '/media/james/D/WRT_build/divest_OWRT/feeds/packages/net/dnsproxy'
time: package/feeds/packages/dnsproxy/compile#0.39#0.19#0.79
    ERROR: package/feeds/packages/dnsproxy failed to build.
make[1]: *** [package/Makefile:128: package/feeds/packages/dnsproxy/compile] Error 1
make[1]: Leaving directory '/media/james/D/WRT_build/divest_OWRT'
make: *** [/media/james/D/WRT_build/divest_OWRT/include/toplevel.mk:233: package/dnsproxy/compile] Error 2

Well, the new version apparently needs also a newer go...
(Might be the reason why it has not been updated, yet...)

You might try upgrading that, too?

Welcome to the wonderful world of package maintenance.

3 Likes

yep, I just did;

go version
go version go1.21.7 linux/amd64

but, still the error about go version and about symlink

media/james/D/WRT_build/divest_OWRT/staging_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/usr/share/gocode/src does not exist, skipping symlinks


Finding targets
go: ../../go.mod requires go >= 1.21.7 (running go 1.21.5; GOTOOLCHAIN=local)

Building targets
go: ../../go.mod requires go >= 1.21.7 (running go 1.21.5; GOTOOLCHAIN=local)

but I think the problem is about (https://mirror2.openwrt.org/sources/dnsproxy-0.65.0-1.tar.gz) there is no 0.65.0-1 yet, only the 0.64 ??

mkdir -p /media/james/D/WRT_build/divest_OWRT/dl
SHELL= flock /media/james/D/WRT_build/divest_OWRT/tmp/.dnsproxy-0.65.0-1.tar.gz.flock -c '  	/media/james/D/WRT_build/divest_OWRT/scripts/download.pl "/media/james/D/WRT_build/divest_OWRT/dl" "dnsproxy-0.65.0-1.tar.gz" "12720de6f1540aee7d3c08b6b32e602d05126a8c55f251bbb94d379306608241" "" "https://codeload.github.com/AdguardTeam/dnsproxy/tar.gz/v0.65.0-1?"    '
+ curl -f --connect-timeout 20 --retry 5 --location https://codeload.github.com/AdguardTeam/dnsproxy/tar.gz/v0.65.0-1?/dnsproxy-0.65.0-1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    14    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
Download failed.
+ curl -f --connect-timeout 20 --retry 5 --location https://sources.cdn.openwrt.org/dnsproxy-0.65.0-1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   146    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
Download failed.
+ curl -f --connect-timeout 20 --retry 5 --location https://sources.openwrt.org/dnsproxy-0.65.0-1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   146    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
Download failed.
+ curl -f --connect-timeout 20 --retry 5 --location https://mirror2.openwrt.org/sources/dnsproxy-0.65.0-1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0   153    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
Download failed.
No more mirrors to try - giving up.

No, as you are the first one to find tech it from upstream, the more serious is the first error of not finding it upstream.
You have something wrong in Makefile.

1 Like

there is no dnsproxy anyway in https://mirror2.openwrt.org/sources/

# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021 ImmortalWrt.org
include $(TOPDIR)/rules.mk
PKG_NAME:=dnsproxy
PKG_VERSION:=0.65.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/AdguardTeam/dnsproxy/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=12720de6f1540aee7d3c08b6b32e602d05126a8c55f251bbb94d379306608241
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
PKG_LICENSE:=Apache-2.0
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16
GO_PKG:=github.com/AdguardTeam/dnsproxy
GO_PKG_LDFLAGS_X:=$(GO_PKG)/internal/version.version=v$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include ../../lang/golang/golang-package.mk
define Package/dnsproxy
SECTION:=net
CATEGORY:=Network
SUBMENU:=IP Addresses and Names
TITLE:=Simple DNS proxy with DoH, DoT, DoQ and DNSCrypt support
URL:=https://github.com/AdguardTeam/dnsproxy
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
USERID:=dnsproxy=411:dnsproxy=411
endef
define Package/dnsproxy/description
A simple DNS proxy server that supports all existing DNS protocols including
DNS-over-TLS, DNS-over-HTTPS, DNSCrypt, and DNS-over-QUIC.Moreover, it can
work as a DNS-over-HTTPS, DNS-over-TLS or DNS-over-QUIC server.
endef
define Package/dnsproxy/install
$(call GoPackage/Package/Install/Bin,$(1))
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) $(CURDIR)/files/dnsproxy.config $(1)/etc/config/dnsproxy
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) $(CURDIR)/files/dnsproxy.init $(1)/etc/init.d/dnsproxy
$(INSTALL_DIR) $(1)/etc/uci-defaults/
$(INSTALL_BIN) $(CURDIR)/files/dnsproxy.defaults $(1)/etc/uci-defaults/80-dnsproxy-migration
endef
define Package/dnsproxy/conffiles
/etc/config/dnsproxy
endef
$(eval $(call GoBinPackage,dnsproxy))
$(eval $(call BuildPackage,dnsproxy))

what I see, is like openwrt build go version 1.21.5, so it is the problem, all other problems are now ok, seems only that one the problem.

build_dir/hostpkg/go-1.21.5

Installed Go for linux/amd64 in /media/james/D/WRT_build/divest_OWRT/build_dir/hostpkg/go-1.21.5/.go_bootstrap
Installed commands in /media/james/D/WRT_build/divest_OWRT/build_dir/hostpkg/go-1.21.5/.go_bootstrap/bin
( cd "/media/james/D/WRT_build/divest_OWRT/build_dir/hostpkg/go-1.21.5/.go_bootstrap_1.17/src" ;   GOROOT_BOOTSTRAP="/media/james/D/WRT_build/divest_OWRT/build_dir/hostpkg/go-1.21.5/.go_bootstrap" GOHOSTARCH="amd64" GOCACHE="/media/james/D/WRT_build/divest_OWRT/tmp/go-build" GOENV=off CC="/media/james/D/WRT_build/divest_OWRT/staging_dir/host/bin/gcc" CXX="/media/james/D/WRT_build/divest_OWRT/staging_dir/host/bin/g++"  bash make.bash -v --no-banner ; )
Building Go cmd/dist using /media/james/D/WRT_build/divest_OWRT/build_dir/hostpkg/go-1.21.5/.go_bootstrap. (go1.4-bootstrap-20170531 linux/amd64)
cmd/dist

Building Go toolchain1 using /media/james/D/WRT_build/divest_OWRT/build_dir/hostpkg/go-1.21.5/.go_bootstrap.