Re: Packaging usql - help to limit the scope of the build?
Thanks!
Note I got this far by skipping the test suite. I will need to revisit
it though, but getting end-to-end working first makes optimizing
stages easier workflow-wise.
...
> So, dh-golang runs `go list -f` to generate a dependency list and propagate to substvar as per the
> manpage[1].
>
> I do not see the explicit -tags option in the upstream manpage[2]. However, if I pass in -tags to `go list`
> in a debian system, it does seem to give some output. I am not sure if that is even a standard option
> or no. However, dh-golang does not have provision to pass -tags in any case as can been seen in the code[3]
>
> However, it does have a provision to specify DH_GOLANG_BUILDPKG. So you can pass that variable via an override
> to dh_golang. Here's an example for you:
>
> https://salsa.debian.org/go-team/packages/docker/-/blob/master/debian/rules?ref_type=heads#L75
The package already has this defined and it behaves correctly in the
build, but not in this last phase:
export DH_GOLANG_BUILDPKG = \
github.com/xo/usql \
github.com/xo/usql/drivers \
github.com/xo/usql/drivers/metadata \
github.com/xo/usql/drivers/metadata/informationschema \
github.com/xo/usql/drivers/metadata/mysql \
github.com/xo/usql/drivers/metadata/postgres \
github.com/xo/usql/drivers/mymysql \
github.com/xo/usql/drivers/mysql \
github.com/xo/usql/drivers/sqlite3 \
github.com/xo/usql/drivers/sqlite3/sqshared \
github.com/xo/usql/env \
github.com/xo/usql/handler \
github.com/xo/usql/internal \
github.com/xo/usql/metacmd \
github.com/xo/usql/metacmd/charts \
github.com/xo/usql/rline \
github.com/xo/usql/stmt \
github.com/xo/usql/styles \
github.com/xo/usql/text
> The other option is an ugly hack that I did in mgmt package. Since that was just one file, I moved
> it to a different name and moved back after dh_golang so go list does not discover it.
>
> https://salsa.debian.org/go-team/packages/mgmt/-/blob/debian/unstable/debian/rules?ref_type=heads#L55
I tried this and it seems to pass the TAGS correctly to dh_golang, but
it didn't affect the for loop:
make[1]: Entering directory '/tmp/build/source'
dh_golang -O--buildsystem=golang
-O--builddirectory=debian/.build/upstream -- -tags "mymysql mysql
sqlite sqlite_app_armor sqlite_fts5 sqlite_introspect sqlite_json1
sqlite_math_functions sqlite_stat4 sqlite_vtable no_clickhouse no_csvq
no_oracle no_sqlserver no_moderncsqlite"
"go list -f '{{ range .Deps }}{{.}}\
{{ end }}'" github.com/xo/usql github.com/xo/usql/drivers
github.com/xo/usql/drivers/metadata
github.com/xo/usql/drivers/metadata/informationschema
github.com/xo/usql/drivers/metadata/mysql
github.com/xo/usql/drivers/metadata/postgres
github.com/xo/usql/drivers/mymysql github.com/xo/usql/drivers/mysql
github.com/xo/usql/drivers/sqlite3
github.com/xo/usql/drivers/sqlite3/sqshared github.com/xo/usql/env
github.com/xo/usql/handler github.com/xo/usql/internal
github.com/xo/usql/metacmd github.com/xo/usql/metacmd/charts
github.com/xo/usql/rline github.com/xo/usql/stmt
github.com/xo/usql/styles github.com/xo/usql/text
debian/.build/upstream/src/github.com/xo/usql/drivers/clickhouse/clickhouse.go:12:2:
cannot find package "github.com/ClickHouse/clickhouse-go/v2" in any
of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/ClickHouse/clickhouse-go/v2
(vendor tree)
/usr/lib/go-1.24/src/github.com/ClickHouse/clickhouse-go/v2 (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/ClickHouse/clickhouse-go/v2
(from $GOPATH)
debian/.build/upstream/src/github.com/xo/usql/drivers/csvq/csvq.go:12:2:
cannot find package "github.com/mithrandie/csvq-driver" in any of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/mithrandie/csvq-driver
(vendor tree)
/usr/lib/go-1.24/src/github.com/mithrandie/csvq-driver (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/mithrandie/csvq-driver
(from $GOPATH)
debian/.build/upstream/src/github.com/xo/usql/drivers/csvq/csvq.go:13:2:
cannot find package "github.com/mithrandie/csvq/lib/query" in any of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/mithrandie/csvq/lib/query
(vendor tree)
/usr/lib/go-1.24/src/github.com/mithrandie/csvq/lib/query (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/mithrandie/csvq/lib/query
(from $GOPATH)
debian/.build/upstream/src/github.com/xo/usql/drivers/oracle/oracle.go:12:2:
cannot find package "github.com/sijms/go-ora/v2" in any of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/sijms/go-ora/v2
(vendor tree)
/usr/lib/go-1.24/src/github.com/sijms/go-ora/v2 (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/sijms/go-ora/v2
(from $GOPATH)
debian/.build/upstream/src/github.com/xo/usql/drivers/sqlserver/sqlserver.go:15:2:
cannot find package "github.com/microsoft/go-mssqldb" in any of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/microsoft/go-mssqldb
(vendor tree)
/usr/lib/go-1.24/src/github.com/microsoft/go-mssqldb (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/microsoft/go-mssqldb
(from $GOPATH)
debian/.build/upstream/src/github.com/xo/usql/drivers/sqlserver/sqlserver.go:21:2:
cannot find package "github.com/microsoft/go-mssqldb/azuread" in any
of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/microsoft/go-mssqldb/azuread
(vendor tree)
/usr/lib/go-1.24/src/github.com/microsoft/go-mssqldb/azuread (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/microsoft/go-mssqldb/azuread
(from $GOPATH)
debian/.build/upstream/src/github.com/xo/usql/drivers/sqlserver/sqlserver.go:22:2:
cannot find package "github.com/microsoft/go-mssqldb/namedpipe" in any
of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/microsoft/go-mssqldb/namedpipe
(vendor tree)
/usr/lib/go-1.24/src/github.com/microsoft/go-mssqldb/namedpipe (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/microsoft/go-mssqldb/namedpipe
(from $GOPATH)
debian/.build/upstream/src/github.com/xo/usql/drivers/sqlserver/sqlserver.go:23:2:
cannot find package "github.com/microsoft/go-mssqldb/sharedmemory" in
any of:
/tmp/build/source/debian/.build/upstream/src/vendor/github.com/microsoft/go-mssqldb/sharedmemory
(vendor tree)
/usr/lib/go-1.24/src/github.com/microsoft/go-mssqldb/sharedmemory (from $GOROOT)
/tmp/build/source/debian/.build/upstream/src/github.com/microsoft/go-mssqldb/sharedmemory
(from $GOPATH)
dh_golang: error: go list -f '{{ range .Deps }}{{.}}
{{ end }}' returned exit code 1
make[1]: *** [debian/rules:71: override_dh_golang] Error 1
> Final option would be to ofcourse disable dh_golang but that may not be a good option.
I am reading dh_golang to figure out if there is a way to get around
this.. I guess I could also make a patch that disables those files
with a "go:build" header.
Reply to: