Skip to content

Commit

Permalink
Add 'upx'
Browse files Browse the repository at this point in the history
  • Loading branch information
myhro committed Nov 27, 2021
1 parent 53928eb commit bea1b8e
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
staticd
=======

Download statically linked Go/Rust binaries from GitHub.
Download statically linked binaries from GitHub.
9 changes: 9 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ func main() {
},
}

upxCmd := &cobra.Command{
Use: tools.UPX,
Short: "The Ultimate Packer for eXecutables",
Run: func(cmd *cobra.Command, args []string) {
run(tools.UPX)
},
}

xhCmd := &cobra.Command{
Use: tools.Xh,
Short: "Friendly and fast tool for sending HTTP requests",
Expand All @@ -138,6 +146,7 @@ func main() {
rootCmd.AddCommand(cloudflaredCmd)
rootCmd.AddCommand(dockerComposeCmd)
rootCmd.AddCommand(k9sCmd)
rootCmd.AddCommand(upxCmd)
rootCmd.AddCommand(xhCmd)
rootCmd.AddCommand(versionCmd)

Expand Down
6 changes: 6 additions & 0 deletions tables/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ var Arch = map[string]map[string]map[string]string{
"arm": "arm",
},
},
UPX: {
"linux": {
"amd64": "amd64",
"arm": "arm",
},
},
Xh: {
"darwin": {
"amd64": "x86_64",
Expand Down
6 changes: 6 additions & 0 deletions tables/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ var OS = map[string]map[string]map[string]string{
"arm": "Linux",
},
},
UPX: {
"linux": {
"amd64": "linux",
"arm": "linux",
},
},
Xh: {
"darwin": {
"amd64": "apple-darwin",
Expand Down
4 changes: 4 additions & 0 deletions tables/tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (s *TablesTestSuite) TestToolsNames() {
local: tables.K9s,
remote: tools.K9s,
},
{
local: tables.UPX,
remote: tools.UPX,
},
{
local: tables.Xh,
remote: tools.Xh,
Expand Down
1 change: 1 addition & 0 deletions tables/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ const (
Cloudflared = "cloudflared"
DockerCompose = "docker-compose"
K9s = "k9s"
UPX = "upx"
Xh = "xh"
)
1 change: 1 addition & 0 deletions tables/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ var URL = map[string]string{
Cloudflared: "https://github.com/cloudflare/cloudflared/releases",
DockerCompose: "https://github.com/docker/compose/releases",
K9s: "https://github.com/derailed/k9s/releases",
UPX: "https://github.com/upx/upx/releases",
Xh: "https://github.com/ducaale/xh/releases",
}
33 changes: 33 additions & 0 deletions tools/asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ func (s *AssetTestSuite) TestDestination() {
},
dest: "/usr/local/bin/k9s",
},
{
tool: &Tool{
Name: UPX,
},
dest: "/usr/local/bin/upx",
},
{
tool: &Tool{
Name: Xh,
Expand Down Expand Up @@ -124,6 +130,15 @@ func (s *AssetTestSuite) TestIsBinary() {
os: "linux",
binary: false,
},
{
tool: &Tool{
Name: UPX,
Version: "v3.96",
},
arch: "amd64",
os: "linux",
binary: false,
},
{
tool: &Tool{
Name: Xh,
Expand Down Expand Up @@ -194,6 +209,15 @@ func (s *AssetTestSuite) TestName() {
os: "linux",
name: "k9s_Linux_x86_64.tar.gz",
},
{
tool: &Tool{
Name: UPX,
Version: "v3.96",
},
arch: "amd64",
os: "linux",
name: "upx-3.96-amd64_linux.tar.xz",
},
{
tool: &Tool{
Name: Xh,
Expand Down Expand Up @@ -264,6 +288,15 @@ func (s *AssetTestSuite) TestWithinArchive() {
os: "linux",
withinArchive: "k9s",
},
{
tool: &Tool{
Name: UPX,
Version: "v3.96",
},
arch: "amd64",
os: "linux",
withinArchive: "upx-3.96-amd64_linux/upx",
},
{
tool: &Tool{
Name: Xh,
Expand Down
6 changes: 6 additions & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
Cloudflared = "cloudflared"
DockerCompose = "docker-compose"
K9s = "k9s"
UPX = "upx"
Xh = "xh"
)

Expand Down Expand Up @@ -150,6 +151,11 @@ func (t *Tool) SetAsset() error {
t.Asset.IsBinary = true
case K9s:
t.Asset.Name = fmt.Sprintf("k9s_%v_%v.tar.gz", t.OS, t.Arch)
case UPX:
version := strings.TrimPrefix(t.Version, "v")
baseName := fmt.Sprintf("upx-%v-%v_%v", version, t.Arch, t.OS)
t.Asset.Name = baseName + ".tar.xz"
t.Asset.WithinArchive = path.Join(baseName, t.Name)
case Xh:
baseName := fmt.Sprintf("xh-%v-%v-%v", t.Version, t.Arch, t.OS)
t.Asset.Name = baseName + ".tar.gz"
Expand Down

0 comments on commit bea1b8e

Please sign in to comment.