chore(cmd): clean up commands (#9705)

Move infrastructure related commands to under `cmd/infra` and
development stuff to `cmd/dev`. The default build command builds the
regular user facing binaries: syncthing, stdiscosrv, and strelaysrv.
This commit is contained in:
Jakob Borg 2024-09-21 09:04:22 +02:00 committed by GitHub
parent cbe1220680
commit d4770ddc77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
49 changed files with 21 additions and 25 deletions

View File

@ -516,7 +516,7 @@ jobs:
- name: Install signing tool - name: Install signing tool
run: | run: |
go install ./cmd/stsigtool go install ./cmd/dev/stsigtool
- name: Sign archives - name: Sign archives
run: | run: |

View File

@ -193,37 +193,37 @@ var targets = map[string]target{
debname: "syncthing-relaypoolsrv", debname: "syncthing-relaypoolsrv",
debdeps: []string{"libc6"}, debdeps: []string{"libc6"},
description: "Syncthing Relay Pool Server", description: "Syncthing Relay Pool Server",
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/strelaypoolsrv"}, buildPkgs: []string{"github.com/syncthing/syncthing/cmd/infra/strelaypoolsrv"},
binaryName: "strelaypoolsrv", // .exe will be added automatically for Windows builds binaryName: "strelaypoolsrv", // .exe will be added automatically for Windows builds
archiveFiles: []archiveFile{ archiveFiles: []archiveFile{
{src: "{{binary}}", dst: "{{binary}}", perm: 0755}, {src: "{{binary}}", dst: "{{binary}}", perm: 0755},
{src: "cmd/strelaypoolsrv/README.md", dst: "README.txt", perm: 0644}, {src: "cmd/infra/strelaypoolsrv/README.md", dst: "README.txt", perm: 0644},
{src: "cmd/strelaypoolsrv/LICENSE", dst: "LICENSE.txt", perm: 0644}, {src: "cmd/infra/strelaypoolsrv/LICENSE", dst: "LICENSE.txt", perm: 0644},
{src: "AUTHORS", dst: "AUTHORS.txt", perm: 0644}, {src: "AUTHORS", dst: "AUTHORS.txt", perm: 0644},
}, },
installationFiles: []archiveFile{ installationFiles: []archiveFile{
{src: "{{binary}}", dst: "deb/usr/bin/{{binary}}", perm: 0755}, {src: "{{binary}}", dst: "deb/usr/bin/{{binary}}", perm: 0755},
{src: "cmd/strelaypoolsrv/README.md", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/README.txt", perm: 0644}, {src: "cmd/infra/strelaypoolsrv/README.md", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/README.txt", perm: 0644},
{src: "cmd/strelaypoolsrv/LICENSE", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/LICENSE.txt", perm: 0644}, {src: "cmd/infra/strelaypoolsrv/LICENSE", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/LICENSE.txt", perm: 0644},
{src: "AUTHORS", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/AUTHORS.txt", perm: 0644}, {src: "AUTHORS", dst: "deb/usr/share/doc/syncthing-relaypoolsrv/AUTHORS.txt", perm: 0644},
}, },
}, },
"stupgrades": { "stupgrades": {
name: "stupgrades", name: "stupgrades",
description: "Syncthing Upgrade Check Server", description: "Syncthing Upgrade Check Server",
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/stupgrades"}, buildPkgs: []string{"github.com/syncthing/syncthing/cmd/infra/stupgrades"},
binaryName: "stupgrades", binaryName: "stupgrades",
}, },
"stcrashreceiver": { "stcrashreceiver": {
name: "stcrashreceiver", name: "stcrashreceiver",
description: "Syncthing Crash Server", description: "Syncthing Crash Server",
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/stcrashreceiver"}, buildPkgs: []string{"github.com/syncthing/syncthing/cmd/infra/stcrashreceiver"},
binaryName: "stcrashreceiver", binaryName: "stcrashreceiver",
}, },
"ursrv": { "ursrv": {
name: "ursrv", name: "ursrv",
description: "Syncthing Usage Reporting Server", description: "Syncthing Usage Reporting Server",
buildPkgs: []string{"github.com/syncthing/syncthing/cmd/ursrv"}, buildPkgs: []string{"github.com/syncthing/syncthing/cmd/infra/ursrv"},
binaryName: "ursrv", binaryName: "ursrv",
}, },
} }
@ -232,15 +232,11 @@ func initTargets() {
all := targets["all"] all := targets["all"]
pkgs, _ := filepath.Glob("cmd/*") pkgs, _ := filepath.Glob("cmd/*")
for _, pkg := range pkgs { for _, pkg := range pkgs {
pkg = filepath.Base(pkg) if files, err := filepath.Glob(pkg + "/*.go"); err != nil || len(files) == 0 {
if strings.HasPrefix(pkg, ".") { // No go files in the directory
// ignore dotfiles
continue continue
} }
if noupgrade && pkg == "stupgrades" { all.buildPkgs = append(all.buildPkgs, fmt.Sprintf("github.com/syncthing/syncthing/%s", pkg))
continue
}
all.buildPkgs = append(all.buildPkgs, fmt.Sprintf("github.com/syncthing/syncthing/cmd/%s", pkg))
} }
targets["all"] = all targets["all"] = all
@ -838,12 +834,12 @@ func listFiles(dir string) []string {
func rebuildAssets() { func rebuildAssets() {
os.Setenv("SOURCE_DATE_EPOCH", fmt.Sprint(buildStamp())) os.Setenv("SOURCE_DATE_EPOCH", fmt.Sprint(buildStamp()))
runPrint(goCmd, "generate", "github.com/syncthing/syncthing/lib/api/auto", "github.com/syncthing/syncthing/cmd/strelaypoolsrv/auto") runPrint(goCmd, "generate", "github.com/syncthing/syncthing/lib/api/auto", "github.com/syncthing/syncthing/cmd/infra/strelaypoolsrv/auto")
} }
func lazyRebuildAssets() { func lazyRebuildAssets() {
shouldRebuild := shouldRebuildAssets("lib/api/auto/gui.files.go", "gui") || shouldRebuild := shouldRebuildAssets("lib/api/auto/gui.files.go", "gui") ||
shouldRebuildAssets("cmd/strelaypoolsrv/auto/gui.files.go", "cmd/strelaypoolsrv/gui") shouldRebuildAssets("cmd/infra/strelaypoolsrv/auto/gui.files.go", "cmd/infra/strelaypoolsrv/gui")
if withNextGenGUI { if withNextGenGUI {
shouldRebuild = buildNextGenGUI() || shouldRebuild shouldRebuild = buildNextGenGUI() || shouldRebuild

View File

@ -4,7 +4,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file, // License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/. // You can obtain one at https://mozilla.org/MPL/2.0/.
//go:generate go run ../../../script/genassets.go -o gui.files.go ../gui //go:generate go run ../../../../script/genassets.go -o gui.files.go ../gui
// Package auto contains auto generated files for web assets. // Package auto contains auto generated files for web assets.
package auto package auto

View File

@ -23,7 +23,7 @@ import (
lru "github.com/hashicorp/golang-lru/v2" lru "github.com/hashicorp/golang-lru/v2"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/syncthing/syncthing/cmd/strelaypoolsrv/auto" "github.com/syncthing/syncthing/cmd/infra/strelaypoolsrv/auto"
"github.com/syncthing/syncthing/lib/assets" "github.com/syncthing/syncthing/lib/assets"
_ "github.com/syncthing/syncthing/lib/automaxprocs" _ "github.com/syncthing/syncthing/lib/automaxprocs"
"github.com/syncthing/syncthing/lib/geoip" "github.com/syncthing/syncthing/lib/geoip"

View File

@ -11,8 +11,8 @@ import (
"os" "os"
"github.com/alecthomas/kong" "github.com/alecthomas/kong"
"github.com/syncthing/syncthing/cmd/ursrv/aggregate" "github.com/syncthing/syncthing/cmd/infra/ursrv/aggregate"
"github.com/syncthing/syncthing/cmd/ursrv/serve" "github.com/syncthing/syncthing/cmd/infra/ursrv/serve"
_ "github.com/syncthing/syncthing/lib/automaxprocs" _ "github.com/syncthing/syncthing/lib/automaxprocs"
) )

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -611,7 +611,7 @@ found in the LICENSE file.
</div> </div>
<hr> <hr>
<p> <p>
<a href="https://github.com/syncthing/syncthing/tree/main/cmd/ursrv">Source code</a>. <a href="https://github.com/syncthing/syncthing/">Source code</a>.
This product includes GeoLite2 data created by MaxMind, available from This product includes GeoLite2 data created by MaxMind, available from
<a href="http://www.maxmind.com">http://www.maxmind.com</a>. <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
</p> </p>

View File

@ -25,7 +25,7 @@ type Release struct {
Assets []Asset `json:"assets"` Assets []Asset `json:"assets"`
// The HTML URL is needed for human readable links in the output created // The HTML URL is needed for human readable links in the output created
// by cmd/stupgrades. // by cmd/infra/stupgrades.
HTMLURL string `json:"html_url"` HTMLURL string `json:"html_url"`
} }
@ -34,7 +34,7 @@ type Asset struct {
Name string `json:"name"` Name string `json:"name"`
// The browser URL is needed for human readable links in the output created // The browser URL is needed for human readable links in the output created
// by cmd/stupgrades. // by cmd/infra/stupgrades.
BrowserURL string `json:"browser_download_url,omitempty"` BrowserURL string `json:"browser_download_url,omitempty"`
} }