Skip to content

Commit

Permalink
Add more archs to s2sx (#333)
Browse files Browse the repository at this point in the history
* Add more archs to s2sx
* Compress the internal images.
* Move packages to bottom.
  • Loading branch information
klauspost authored Mar 5, 2021
1 parent 26a590d commit 4b35233
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ _testmain.go
*.exe
*.test
*.prof
/s2/cmd/_sfx/sfx-exe
/s2/cmd/_s2sx/sfx-exe
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ changelog:

nfpms:
-
file_name_template: "s2-Install_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
file_name_template: "s2_package_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
vendor: Klaus Post
homepage: https://github.com/klauspost/compress
maintainer: Klaus Post <klauspost@gmail.com>
Expand Down
10 changes: 8 additions & 2 deletions s2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,19 @@ Options:
Do not overwrite output files
-untar
Untar on destination
```

Available platforms are:

* darwin-amd64
* darwin-arm64
* linux-amd64
* windows-amd64
```
* linux-arm
* linux-arm64
* linux-mips64
* linux-ppc64le
* windows-386
* windows-amd64

### Self-extracting TAR files

Expand Down
25 changes: 25 additions & 0 deletions s2/cmd/_s2sx/gensfx.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
go build ../s2c

DEL /Q sfx-exe\*

SET GOOS=linux
SET GOARCH=amd64
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go
SET GOARCH=arm64
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go
SET GOARCH=arm
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go
SET GOARCH=ppc64le
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go
SET GOARCH=mips64
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go


SET GOOS=darwin
SET GOARCH=amd64
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go
SET GOARCH=arm64
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go

SET GOOS=windows
SET GOARCH=amd64
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go
SET GOARCH=386
go build -ldflags="-s -w" -o ./sfx-exe/%GOOS%-%GOARCH% ./_unpack/main.go

s2c.exe -rm -slower sfx-exe\*
DEL /Q s2c.exe

16 changes: 16 additions & 0 deletions s2/cmd/_s2sx/gensfx.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/bin/sh

go build -o=s2c ../s2c

rm -rf sfx-exe/ || true

GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go
GOOS=linux GOARCH=arm go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go
GOOS=linux GOARCH=ppc64le go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go
GOOS=linux GOARCH=mpis64 go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go

GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go

GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go
GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o ./sfx-exe/$GOOS-$GOARCH ./_unpack/main.go

./s2c -rm -slower sfx-exe/*

rm s2c
2 changes: 1 addition & 1 deletion s2/cmd/_s2sx/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/klauspost/compress/s2/cmd/_s2sx
module github.com/klauspost/compress/s2/cmd/s2sx

go 1.16

Expand Down
11 changes: 8 additions & 3 deletions s2/cmd/_s2sx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package main

import (
"bufio"
"bytes"
"embed"
"errors"
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -66,7 +68,7 @@ Options:`)
exitErr(err)
_, _ = fmt.Fprintf(os.Stderr, "\nAvailable platforms are:\n\n")
for _, d := range dir {
_, _ = fmt.Fprintf(os.Stderr, " * %s\n", d.Name())
_, _ = fmt.Fprintf(os.Stderr, " * %s\n", strings.TrimSuffix(d.Name(), ".s2"))
}

os.Exit(0)
Expand All @@ -84,17 +86,20 @@ Options:`)
files = append(files, found...)
}
wantPlat := *goos + "-" + *goarch
exec, err := embeddedFiles.ReadFile(path.Join("sfx-exe", wantPlat))
exec, err := embeddedFiles.ReadFile(path.Join("sfx-exe", wantPlat+".s2"))
if os.IsNotExist(err) {
dir, err := embeddedFiles.ReadDir("sfx-exe")
exitErr(err)
_, _ = fmt.Fprintf(os.Stderr, "os-arch %v not available. Available sfx platforms are:\n\n", wantPlat)
for _, d := range dir {
_, _ = fmt.Fprintf(os.Stderr, "* %s\n", d.Name())
_, _ = fmt.Fprintf(os.Stderr, "* %s\n", strings.TrimSuffix(d.Name(), ".s2"))
}
_, _ = fmt.Fprintf(os.Stderr, "\nUse -os and -arch to specify the destination platform.")
os.Exit(1)
}
exec, err = ioutil.ReadAll(s2.NewReader(bytes.NewBuffer(exec)))
exitErr(err)

mode := byte(opUnpack)
if *untar {
mode = opUnTar
Expand Down

0 comments on commit 4b35233

Please sign in to comment.