mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-09-18 01:25:54 +00:00
add upx
as part of building step to shrink the size of binary files (#797)
This commit is contained in:
parent
8cff99f726
commit
84f17b4c4b
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt-get --no-install-recommends --yes install \
|
sudo apt-get --no-install-recommends --yes install \
|
||||||
libc6-dev-amd64-cross \
|
upx libc6-dev-amd64-cross \
|
||||||
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
|
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
|
||||||
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
|
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
|
||||||
-
|
-
|
||||||
|
@ -25,9 +25,6 @@ builds:
|
|||||||
- linux
|
- linux
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
hooks:
|
|
||||||
post:
|
|
||||||
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
|
|
||||||
- id: casaos-arm64
|
- id: casaos-arm64
|
||||||
binary: build/sysroot/usr/bin/casaos
|
binary: build/sysroot/usr/bin/casaos
|
||||||
env:
|
env:
|
||||||
@ -44,9 +41,6 @@ builds:
|
|||||||
- linux
|
- linux
|
||||||
goarch:
|
goarch:
|
||||||
- arm64
|
- arm64
|
||||||
hooks:
|
|
||||||
post:
|
|
||||||
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
|
|
||||||
- id: casaos-arm-7
|
- id: casaos-arm-7
|
||||||
binary: build/sysroot/usr/bin/casaos
|
binary: build/sysroot/usr/bin/casaos
|
||||||
env:
|
env:
|
||||||
@ -65,9 +59,6 @@ builds:
|
|||||||
- arm
|
- arm
|
||||||
goarm:
|
goarm:
|
||||||
- "7"
|
- "7"
|
||||||
hooks:
|
|
||||||
post:
|
|
||||||
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
|
|
||||||
- id: casaos-migration-tool-amd64
|
- id: casaos-migration-tool-amd64
|
||||||
binary: build/sysroot/usr/bin/casaos-migration-tool
|
binary: build/sysroot/usr/bin/casaos-migration-tool
|
||||||
main: ./cmd/migration-tool
|
main: ./cmd/migration-tool
|
||||||
|
@ -11,9 +11,14 @@ before:
|
|||||||
builds:
|
builds:
|
||||||
- id: casaos-amd64
|
- id: casaos-amd64
|
||||||
binary: build/sysroot/usr/bin/casaos
|
binary: build/sysroot/usr/bin/casaos
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- upx --best --lzma -v --no-progress "{{ .Path }}"
|
||||||
env:
|
env:
|
||||||
- CC=x86_64-linux-gnu-gcc
|
- CC=x86_64-linux-gnu-gcc
|
||||||
ldflags:
|
ldflags:
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
- -s
|
- -s
|
||||||
- -w
|
- -w
|
||||||
- -extldflags "-static"
|
- -extldflags "-static"
|
||||||
@ -25,14 +30,16 @@ builds:
|
|||||||
- linux
|
- linux
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
hooks:
|
|
||||||
post:
|
|
||||||
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
|
|
||||||
- id: casaos-arm64
|
- id: casaos-arm64
|
||||||
binary: build/sysroot/usr/bin/casaos
|
binary: build/sysroot/usr/bin/casaos
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- upx --best --lzma -v --no-progress "{{ .Path }}"
|
||||||
env:
|
env:
|
||||||
- CC=aarch64-linux-gnu-gcc
|
- CC=aarch64-linux-gnu-gcc
|
||||||
ldflags:
|
ldflags:
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
- -s
|
- -s
|
||||||
- -w
|
- -w
|
||||||
- -extldflags "-static"
|
- -extldflags "-static"
|
||||||
@ -44,14 +51,16 @@ builds:
|
|||||||
- linux
|
- linux
|
||||||
goarch:
|
goarch:
|
||||||
- arm64
|
- arm64
|
||||||
hooks:
|
|
||||||
post:
|
|
||||||
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
|
|
||||||
- id: casaos-arm-7
|
- id: casaos-arm-7
|
||||||
binary: build/sysroot/usr/bin/casaos
|
binary: build/sysroot/usr/bin/casaos
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- upx --best --lzma -v --no-progress "{{ .Path }}"
|
||||||
env:
|
env:
|
||||||
- CC=arm-linux-gnueabihf-gcc
|
- CC=arm-linux-gnueabihf-gcc
|
||||||
ldflags:
|
ldflags:
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
- -s
|
- -s
|
||||||
- -w
|
- -w
|
||||||
- -extldflags "-static"
|
- -extldflags "-static"
|
||||||
@ -65,15 +74,17 @@ builds:
|
|||||||
- arm
|
- arm
|
||||||
goarm:
|
goarm:
|
||||||
- "7"
|
- "7"
|
||||||
hooks:
|
|
||||||
post:
|
|
||||||
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
|
|
||||||
- id: casaos-migration-tool-amd64
|
- id: casaos-migration-tool-amd64
|
||||||
binary: build/sysroot/usr/bin/casaos-migration-tool
|
binary: build/sysroot/usr/bin/casaos-migration-tool
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- upx --best --lzma -v --no-progress "{{ .Path }}"
|
||||||
main: ./cmd/migration-tool
|
main: ./cmd/migration-tool
|
||||||
env:
|
env:
|
||||||
- CC=x86_64-linux-gnu-gcc
|
- CC=x86_64-linux-gnu-gcc
|
||||||
ldflags:
|
ldflags:
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
- -s
|
- -s
|
||||||
- -w
|
- -w
|
||||||
- -extldflags "-static"
|
- -extldflags "-static"
|
||||||
@ -87,10 +98,15 @@ builds:
|
|||||||
- amd64
|
- amd64
|
||||||
- id: casaos-migration-tool-arm64
|
- id: casaos-migration-tool-arm64
|
||||||
binary: build/sysroot/usr/bin/casaos-migration-tool
|
binary: build/sysroot/usr/bin/casaos-migration-tool
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- upx --best --lzma -v --no-progress "{{ .Path }}"
|
||||||
main: ./cmd/migration-tool
|
main: ./cmd/migration-tool
|
||||||
env:
|
env:
|
||||||
- CC=aarch64-linux-gnu-gcc
|
- CC=aarch64-linux-gnu-gcc
|
||||||
ldflags:
|
ldflags:
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
- -s
|
- -s
|
||||||
- -w
|
- -w
|
||||||
- -extldflags "-static"
|
- -extldflags "-static"
|
||||||
@ -104,10 +120,15 @@ builds:
|
|||||||
- arm64
|
- arm64
|
||||||
- id: casaos-migration-tool-arm-7
|
- id: casaos-migration-tool-arm-7
|
||||||
binary: build/sysroot/usr/bin/casaos-migration-tool
|
binary: build/sysroot/usr/bin/casaos-migration-tool
|
||||||
|
hooks:
|
||||||
|
post:
|
||||||
|
- upx --best --lzma -v --no-progress "{{ .Path }}"
|
||||||
main: ./cmd/migration-tool
|
main: ./cmd/migration-tool
|
||||||
env:
|
env:
|
||||||
- CC=arm-linux-gnueabihf-gcc
|
- CC=arm-linux-gnueabihf-gcc
|
||||||
ldflags:
|
ldflags:
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
- -s
|
- -s
|
||||||
- -w
|
- -w
|
||||||
- -extldflags "-static"
|
- -extldflags "-static"
|
||||||
|
@ -17,10 +17,10 @@ import (
|
|||||||
|
|
||||||
interfaces "github.com/IceWhaleTech/CasaOS-Common"
|
interfaces "github.com/IceWhaleTech/CasaOS-Common"
|
||||||
"github.com/IceWhaleTech/CasaOS-Common/utils/systemctl"
|
"github.com/IceWhaleTech/CasaOS-Common/utils/systemctl"
|
||||||
"github.com/IceWhaleTech/CasaOS-Gateway/common"
|
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/sqlite"
|
"github.com/IceWhaleTech/CasaOS/pkg/sqlite"
|
||||||
"github.com/IceWhaleTech/CasaOS/service"
|
"github.com/IceWhaleTech/CasaOS/service"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/types"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,40 +29,35 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
commit = "private build"
|
||||||
|
date = "private build"
|
||||||
|
|
||||||
_logger *Logger
|
_logger *Logger
|
||||||
sqliteDB *gorm.DB
|
sqliteDB *gorm.DB
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
configFlag = ""
|
configFlag = ""
|
||||||
dbFlag = ""
|
dbFlag = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
config.InitSetup(configFlag)
|
|
||||||
|
|
||||||
if len(dbFlag) == 0 {
|
|
||||||
dbFlag = config.AppInfo.DBPath + "/db"
|
|
||||||
}
|
|
||||||
|
|
||||||
sqliteDB = sqlite.GetDb(dbFlag)
|
|
||||||
// gredis.GetRedisConn(config.RedisInfo),
|
|
||||||
|
|
||||||
service.MyService = service.NewService(sqliteDB, "", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
versionFlag := flag.Bool("v", false, "version")
|
versionFlag := flag.Bool("v", false, "version")
|
||||||
debugFlag := flag.Bool("d", true, "debug")
|
debugFlag := flag.Bool("d", true, "debug")
|
||||||
forceFlag := flag.Bool("f", true, "force")
|
forceFlag := flag.Bool("f", true, "force")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
_logger = NewLogger()
|
|
||||||
if *versionFlag {
|
if *versionFlag {
|
||||||
fmt.Println(common.Version)
|
fmt.Println("v" + types.CURRENTVERSION)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println("git commit:", commit)
|
||||||
|
println("build date:", date)
|
||||||
|
|
||||||
|
_logger = NewLogger()
|
||||||
|
|
||||||
if os.Getuid() != 0 {
|
if os.Getuid() != 0 {
|
||||||
|
_logger.Info("Root privileges are required to run this program.")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +77,19 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.InitSetup(configFlag)
|
||||||
|
|
||||||
|
if len(dbFlag) == 0 {
|
||||||
|
dbFlag = config.AppInfo.DBPath + "/db"
|
||||||
|
}
|
||||||
|
|
||||||
|
sqliteDB = sqlite.GetDb(dbFlag)
|
||||||
|
// gredis.GetRedisConn(config.RedisInfo),
|
||||||
|
|
||||||
|
service.MyService = service.NewService(sqliteDB, "", nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
migrationTools := []interfaces.MigrationTool{
|
migrationTools := []interfaces.MigrationTool{
|
||||||
// nothing to migrate from last version
|
// nothing to migrate from last version
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,6 @@ func (u *migrationTool) PostMigrate() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMigrationToolFor_036() interfaces.MigrationTool {
|
func NewMigrationDummy() interfaces.MigrationTool {
|
||||||
return &migrationTool{}
|
return &migrationTool{}
|
||||||
}
|
}
|
33
go.mod
33
go.mod
@ -5,33 +5,32 @@ go 1.16
|
|||||||
require (
|
require (
|
||||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
||||||
github.com/IceWhaleTech/CasaOS-Common v0.4.1-alpha2
|
github.com/IceWhaleTech/CasaOS-Common v0.4.1-alpha2
|
||||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6
|
github.com/benbjohnson/clock v1.3.0 // indirect
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
github.com/dsoprea/go-exif/v3 v3.0.0-20210625224831-a6301f85c82b
|
github.com/dsoprea/go-exif/v3 v3.0.0-20221012082141-d21ac8e2de85
|
||||||
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
|
|
||||||
github.com/gin-contrib/gzip v0.0.6
|
github.com/gin-contrib/gzip v0.0.6
|
||||||
github.com/gin-gonic/gin v1.8.1
|
github.com/gin-gonic/gin v1.8.2
|
||||||
github.com/glebarez/sqlite v1.5.0
|
github.com/glebarez/sqlite v1.6.0
|
||||||
github.com/go-ini/ini v1.62.0
|
github.com/go-ini/ini v1.67.0
|
||||||
github.com/golang/mock v1.6.0
|
github.com/golang/mock v1.6.0
|
||||||
github.com/gomodule/redigo v1.8.5
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
|
github.com/gomodule/redigo v1.8.9
|
||||||
github.com/google/go-github/v36 v36.0.0
|
github.com/google/go-github/v36 v36.0.0
|
||||||
github.com/googollee/go-socket.io v1.6.2
|
github.com/googollee/go-socket.io v1.6.2
|
||||||
github.com/gorilla/websocket v1.5.0
|
github.com/gorilla/websocket v1.5.0
|
||||||
github.com/hirochachacha/go-smb2 v1.1.0
|
github.com/hirochachacha/go-smb2 v1.1.0
|
||||||
|
github.com/klauspost/compress v1.15.13 // indirect
|
||||||
github.com/mholt/archiver/v3 v3.5.1
|
github.com/mholt/archiver/v3 v3.5.1
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/robfig/cron v1.2.0
|
github.com/robfig/cron v1.2.0
|
||||||
github.com/satori/go.uuid v1.2.0
|
github.com/satori/go.uuid v1.2.0
|
||||||
github.com/shirou/gopsutil/v3 v3.22.7
|
github.com/shirou/gopsutil/v3 v3.22.11
|
||||||
github.com/smartystreets/assertions v1.2.0 // indirect
|
github.com/stretchr/testify v1.8.1
|
||||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
github.com/tidwall/gjson v1.14.4
|
||||||
github.com/stretchr/testify v1.8.0
|
go.uber.org/zap v1.24.0
|
||||||
github.com/tidwall/gjson v1.10.2
|
golang.org/x/crypto v0.4.0
|
||||||
go.uber.org/zap v1.21.0
|
golang.org/x/oauth2 v0.3.0
|
||||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
|
gorm.io/gorm v1.24.2
|
||||||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
|
|
||||||
gorm.io/gorm v1.24.0
|
|
||||||
gotest.tools v2.2.0+incompatible
|
gotest.tools v2.2.0+incompatible
|
||||||
)
|
)
|
||||||
|
7
main.go
7
main.go
@ -32,6 +32,9 @@ const LOCALHOST = "127.0.0.1"
|
|||||||
var sqliteDB *gorm.DB
|
var sqliteDB *gorm.DB
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
commit = "private build"
|
||||||
|
date = "private build"
|
||||||
|
|
||||||
configFlag = flag.String("c", "", "config address")
|
configFlag = flag.String("c", "", "config address")
|
||||||
dbFlag = flag.String("db", "", "db path")
|
dbFlag = flag.String("db", "", "db path")
|
||||||
versionFlag = flag.Bool("v", false, "version")
|
versionFlag = flag.Bool("v", false, "version")
|
||||||
@ -43,6 +46,10 @@ func init() {
|
|||||||
fmt.Println("v" + types.CURRENTVERSION)
|
fmt.Println("v" + types.CURRENTVERSION)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println("git commit:", commit)
|
||||||
|
println("build date:", date)
|
||||||
|
|
||||||
config.InitSetup(*configFlag)
|
config.InitSetup(*configFlag)
|
||||||
|
|
||||||
logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt)
|
logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user