2023-02-24 22:19:13 +00:00
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
2023-02-24 21:22:21 +00:00
// The dist command builds Tailscale release packages for distribution.
package main
import (
"context"
"errors"
"flag"
"log"
"os"
"tailscale.com/release/dist"
2023-02-24 22:15:35 +00:00
"tailscale.com/release/dist/cli"
2024-04-22 20:42:01 +00:00
"tailscale.com/release/dist/qnap"
2023-05-26 19:42:05 +00:00
"tailscale.com/release/dist/synology"
2023-02-24 21:22:21 +00:00
"tailscale.com/release/dist/unixpkgs"
)
2024-04-22 20:42:01 +00:00
var (
synologyPackageCenter bool
qnapPrivateKeyPath string
qnapCertificatePath string
)
2023-05-26 19:42:05 +00:00
2023-08-24 21:36:47 +00:00
func getTargets ( ) ( [ ] dist . Target , error ) {
2023-05-26 19:42:05 +00:00
var ret [ ] dist . Target
2023-08-24 21:36:47 +00:00
ret = append ( ret , unixpkgs . Targets ( unixpkgs . Signers { } ) ... )
2023-05-26 19:42:05 +00:00
// Synology packages can be built either for sideloading, or for
// distribution by Synology in their package center. When
// distributed through the package center, apps can request
// additional permissions to use a tuntap interface and control
// the NAS's network stack, rather than be forced to run in
// userspace mode.
//
// Since only we can provide packages to Synology for
// distribution, we default to building the "sideload" variant of
// packages that we distribute on pkgs.tailscale.com.
2024-02-08 19:01:23 +00:00
//
// To build for package center, run
// ./tool/go run ./cmd/dist build --synology-package-center synology
2023-08-24 21:36:47 +00:00
ret = append ( ret , synology . Targets ( synologyPackageCenter , nil ) ... )
2024-04-22 20:42:01 +00:00
if ( qnapPrivateKeyPath == "" ) != ( qnapCertificatePath == "" ) {
return nil , errors . New ( "both --qnap-private-key-path and --qnap-certificate-path must be set" )
}
ret = append ( ret , qnap . Targets ( qnapPrivateKeyPath , qnapCertificatePath ) ... )
2023-05-26 19:42:05 +00:00
return ret , nil
2023-02-24 21:22:21 +00:00
}
2023-02-24 22:15:35 +00:00
func main ( ) {
cmd := cli . CLI ( getTargets )
2023-05-26 19:42:05 +00:00
for _ , subcmd := range cmd . Subcommands {
if subcmd . Name == "build" {
subcmd . FlagSet . BoolVar ( & synologyPackageCenter , "synology-package-center" , false , "build synology packages with extra metadata for the official package center" )
2024-04-22 20:42:01 +00:00
subcmd . FlagSet . StringVar ( & qnapPrivateKeyPath , "qnap-private-key-path" , "" , "sign qnap packages with given key (must also provide --qnap-certificate-path)" )
subcmd . FlagSet . StringVar ( & qnapCertificatePath , "qnap-certificate-path" , "" , "sign qnap packages with given certificate (must also provide --qnap-private-key-path)" )
2023-05-26 19:42:05 +00:00
}
}
2023-02-24 22:15:35 +00:00
if err := cmd . ParseAndRun ( context . Background ( ) , os . Args [ 1 : ] ) ; err != nil && ! errors . Is ( err , flag . ErrHelp ) {
log . Fatal ( err )
2023-02-24 21:22:21 +00:00
}
}