Skip to content

Commit

Permalink
Merge pull request #6018 from mysteriumnetwork/improvements/port-jgab…
Browse files Browse the repository at this point in the history
…riel98-armv6l

Port jgabriel98 armv6l
  • Loading branch information
mdomasevicius authored Mar 19, 2024
2 parents 1297ff7 + 6f6c018 commit 453bb8b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ jobs:
- PackageLinuxArm
- PackageLinuxDebianAmd64
- PackageLinuxDebianArm64
- PackageLinuxDebianArmv6l
- PackageLinuxDebianArm
- PackageMacOSAmd64
- PackageMacOSArm64
Expand Down
5 changes: 5 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ package:linux-debian-arm:
tags: [go]
script: go run mage.go -v PackageLinuxDebianArm

package:linux-debian-armv6l:
stage: build
tags: [go]
script: go run mage.go -v PackageLinuxDebianArmv6l

package:linux-debian-arm64:
stage: build
tags: [go]
Expand Down
8 changes: 6 additions & 2 deletions ci/packages/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func buildBinary(source, target string) error {
if !ok {
targetArch = runtime.GOARCH
}
return buildBinaryFor(source, target, targetOS, targetArch, false)
return buildBinaryFor(source, target, targetOS, targetArch, nil, false)
}

func buildBinaryFor(source, target, targetOS, targetArch string, buildStatic bool) error {
func buildBinaryFor(source, target, targetOS, targetArch string, extraEnvs map[string]string, buildStatic bool) error {
log.Info().Msgf("Building %s -> %s %s/%s", source, target, targetOS, targetArch)

buildDir, err := filepath.Abs(path.Join("build", target))
Expand Down Expand Up @@ -110,6 +110,10 @@ func buildBinaryFor(source, target, targetOS, targetArch string, buildStatic boo
"GOOS": targetOS,
"GOARCH": targetArch,
}
for envKey, envValue := range extraEnvs {
envi[envKey] = envValue
}

if buildStatic {
envi["CGO_ENABLED"] = "0"
}
Expand Down
50 changes: 41 additions & 9 deletions ci/packages/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
// PackageLinuxAmd64 builds and stores linux amd64 package
func PackageLinuxAmd64() error {
logconfig.Bootstrap()
if err := packageStandalone("build/myst/myst_linux_amd64", "linux", "amd64"); err != nil {
if err := packageStandalone("build/myst/myst_linux_amd64", "linux", "amd64", nil); err != nil {
return err
}
return env.IfRelease(storage.UploadArtifacts)
Expand All @@ -48,7 +48,19 @@ func PackageLinuxAmd64() error {
// PackageLinuxArm builds and stores linux arm package
func PackageLinuxArm() error {
logconfig.Bootstrap()
if err := packageStandalone("build/myst/myst_linux_arm", "linux", "arm"); err != nil {
if err := packageStandalone("build/myst/myst_linux_arm", "linux", "arm", nil); err != nil {
return err
}
return env.IfRelease(storage.UploadArtifacts)
}

// PackageLinuxArmv6l builds and stores linux armv6 package
func PackageLinuxArmv6l() error {
logconfig.Bootstrap()
extraEnv := map[string]string{
"GOARM": "6",
}
if err := packageStandalone("build/myst/myst_linux_armv6l", "linux", "arm", extraEnv); err != nil {
return err
}
return env.IfRelease(storage.UploadArtifacts)
Expand All @@ -73,7 +85,7 @@ func PackageLinuxDebianAmd64() error {
return env.IfRelease(storage.UploadArtifacts)
}

// PackageLinuxDebianArm builds and stores debian arm package
// PackageLinuxDebianArm builds and stores debian armv7l+ package
func PackageLinuxDebianArm() error {
logconfig.Bootstrap()
if err := goGet("github.com/debber/debber-v0.3/cmd/debber"); err != nil {
Expand All @@ -92,6 +104,26 @@ func PackageLinuxDebianArm() error {
return env.IfRelease(storage.UploadArtifacts)
}

// PackageLinuxDebianArmv6l builds and stores debian armv6l package
func PackageLinuxDebianArmv6l() error {
logconfig.Bootstrap()
if err := goGet("github.com/debber/debber-v0.3/cmd/debber"); err != nil {
return err
}
envi := map[string]string{
"GOOS": "linux",
"GOARCH": "arm",
"GOARM": "6",
}
if err := sh.RunWith(envi, "bin/build"); err != nil {
return err
}
if err := packageDebian("build/myst/myst", "armv6l"); err != nil {
return err
}
return env.IfRelease(storage.UploadArtifacts)
}

// PackageLinuxDebianArm64 builds and stores debian arm64 package
func PackageLinuxDebianArm64() error {
logconfig.Bootstrap()
Expand All @@ -114,7 +146,7 @@ func PackageLinuxDebianArm64() error {
// PackageMacOSAmd64 builds and stores macOS amd64 package
func PackageMacOSAmd64() error {
logconfig.Bootstrap()
if err := packageStandalone("build/myst/myst_darwin_amd64", "darwin", "amd64"); err != nil {
if err := packageStandalone("build/myst/myst_darwin_amd64", "darwin", "amd64", nil); err != nil {
return err
}
return env.IfRelease(storage.UploadArtifacts)
Expand All @@ -123,7 +155,7 @@ func PackageMacOSAmd64() error {
// PackageMacOSArm64 builds and stores macOS arm64 package
func PackageMacOSArm64() error {
logconfig.Bootstrap()
if err := packageStandalone("build/myst/myst_darwin_arm64", "darwin", "arm64"); err != nil {
if err := packageStandalone("build/myst/myst_darwin_arm64", "darwin", "arm64", nil); err != nil {
return err
}
return env.IfRelease(storage.UploadArtifacts)
Expand All @@ -132,7 +164,7 @@ func PackageMacOSArm64() error {
// PackageWindowsAmd64 builds and stores Windows amd64 package
func PackageWindowsAmd64() error {
logconfig.Bootstrap()
if err := packageStandalone("build/myst/myst_windows_amd64.exe", "windows", "amd64"); err != nil {
if err := packageStandalone("build/myst/myst_windows_amd64.exe", "windows", "amd64", nil); err != nil {
return err
}
return env.IfRelease(storage.UploadArtifacts)
Expand Down Expand Up @@ -341,21 +373,21 @@ func goGet(pkg string) error {
return sh.RunWith(map[string]string{"GO111MODULE": "off"}, "go", "get", "-u", pkg)
}

func packageStandalone(binaryPath, os, arch string) error {
func packageStandalone(binaryPath, os, arch string, extraEnvs map[string]string) error {
log.Info().Msgf("Packaging %s %s %s", binaryPath, os, arch)
var err error
if os == "linux" {
filename := path.Base(binaryPath)
binaryPath = path.Join("build", filename, filename)
err = buildBinaryFor(path.Join("cmd", "mysterium_node", "mysterium_node.go"), filename, os, arch, true)
err = buildBinaryFor(path.Join("cmd", "mysterium_node", "mysterium_node.go"), filename, os, arch, extraEnvs, true)
} else {
err = buildCrossBinary(os, arch)
}
if err != nil {
return err
}

err = buildBinaryFor(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", os, arch, true)
err = buildBinaryFor(path.Join("cmd", "supervisor", "supervisor.go"), "myst_supervisor", os, arch, extraEnvs, true)
if err != nil {
return err
}
Expand Down

0 comments on commit 453bb8b

Please sign in to comment.