Skip to content

Get rid of artifacts #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 23, 2025
Merged
Prev Previous commit
Next Next commit
sync-zephyr-artifacts: use otiai10/copy instead of os.CopyFS to overw…
…rite
  • Loading branch information
pillo79 committed Apr 17, 2025
commit b946d76f50ae6512be8ea12576218009fea5179b
3 changes: 3 additions & 0 deletions extra/sync-zephyr-artifacts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.24.1
require (
github.com/codeclysm/extract/v4 v4.0.0
github.com/go-git/go-git/v5 v5.14.0
github.com/otiai10/copy v1.14.1
)

require (
Expand All @@ -23,13 +24,15 @@ require (
github.com/juju/loggo v1.0.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.13 // indirect
github.com/otiai10/mint v1.6.3 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.35.0 // indirect
golang.org/x/net v0.36.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.30.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
6 changes: 6 additions & 0 deletions extra/sync-zephyr-artifacts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ github.com/mattn/go-colorable v0.0.6/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/otiai10/copy v1.14.1 h1:5/7E6qsUMBaH5AnQ0sSLzzTg1oTECmcCmT6lvF45Na8=
github.com/otiai10/copy v1.14.1/go.mod h1:oQwrEDDOci3IM8dJF0d8+jnbfPDllW6vUjNc3DoZm9I=
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4=
github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -97,6 +101,8 @@ golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA=
golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
35 changes: 25 additions & 10 deletions extra/sync-zephyr-artifacts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/codeclysm/extract/v4"
"github.com/go-git/go-git/v5"
cp "github.com/otiai10/copy"
)

func downloadFile(filepath string, url string) (err error) {
Expand Down Expand Up @@ -121,25 +122,39 @@ func main() {
// Use packer/tar and compress/bzip2 to extract the file
file, err := os.Open(filepath.Join(tmpDir, filename))
if err != nil {
fmt.Println("Error opening zip file:", err)
fmt.Println("Error opening archive:", err)
return
}
defer file.Close()
extract.Bz2(context.Background(), file, filepath.Join(tmpDir, "extract"), nil)
// Copy the content of firmware folder to gitCorePath/firmware
err = os.CopyFS(filepath.Join(gitCorePath, "firmwares"), os.DirFS(filepath.Join(tmpDir, "extract", "ArduinoCore-zephyr", "firmwares")))

err = extract.Bz2(context.Background(), file, filepath.Join(tmpDir, "extract"), nil)
if err != nil {
fmt.Println("Error copying firmware folder:", err)
fmt.Println("Error extracting archive:", err)
return
}
// Copy the content of variants folder to gitCorePath/variants
// Since CopyFS does not overwrite, before doing so remove gitCorePath/variants
err = os.RemoveAll(filepath.Join(gitCorePath, "variants"))

// Remove old firmwares and variants/*/llext-edk files
os.RemoveAll(filepath.Join(gitCorePath, "firmwares"))
filepath.WalkDir(filepath.Join(gitCorePath, "variants"), func(path string, d os.DirEntry, err error) error {
if err != nil {
fmt.Println("Error:", err)
return nil
}

if d.IsDir() && d.Name() == "llext-edk" {
os.RemoveAll(path)
}
return nil
})

// Copy the content of firmware folder to gitCorePath/firmware
err = cp.Copy(filepath.Join(tmpDir, "extract", "ArduinoCore-zephyr", "firmwares"), filepath.Join(gitCorePath, "firmwares"))
if err != nil {
fmt.Println("Error renaming variants folder:", err)
fmt.Println("Error copying firmware folder:", err)
return
}
err = os.CopyFS(filepath.Join(gitCorePath, "variants"), os.DirFS(filepath.Join(tmpDir, "extract", "ArduinoCore-zephyr", "variants")))
// Copy the content of variants folder to gitCorePath/variants
err = cp.Copy(filepath.Join(tmpDir, "extract", "ArduinoCore-zephyr", "variants"), filepath.Join(gitCorePath, "variants"))
if err != nil {
fmt.Println("Error copying variants folder:", err)
return
Expand Down