Skip to content

Commit a7dfaa0

Browse files
committed
build, internal/build: drop own file/folder copier
1 parent e1dcea8 commit a7dfaa0

2 files changed

Lines changed: 10 additions & 51 deletions

File tree

‎build/ci.go‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import (
5959
"strings"
6060
"time"
6161

62+
"github.com/cespare/cp"
6263
"github.com/ethereum/go-ethereum/internal/build"
6364
"github.com/ethereum/go-ethereum/params"
6465
)
@@ -516,8 +517,9 @@ func doDebianSource(cmdline []string) {
516517
log.Fatalf("Failed to rename Go source folder: %v", err)
517518
}
518519
// Add all dependency modules in compressed form
519-
build.CopyFolder(filepath.Join(pkgdir, ".mod", "cache", "download"), filepath.Join(gobuild.Default.GOPATH, "pkg", "mod", "cache", "download"), 0755)
520-
520+
if err := cp.CopyAll(filepath.Join(pkgdir, ".mod", "cache", "download"), filepath.Join(gobuild.Default.GOPATH, "pkg", "mod", "cache", "download")); err != nil {
521+
log.Fatalf("Failed to copy Go module dependencies: %v", err)
522+
}
521523
// Run the packaging and upload to the PPA
522524
debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc", "-d", "-Zxz")
523525
debuild.Dir = pkgdir
@@ -783,9 +785,12 @@ func doWindowsInstaller(cmdline []string) {
783785
build.Render("build/nsis.uninstall.nsh", filepath.Join(*workdir, "uninstall.nsh"), 0644, allTools)
784786
build.Render("build/nsis.pathupdate.nsh", filepath.Join(*workdir, "PathUpdate.nsh"), 0644, nil)
785787
build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil)
786-
build.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll", 0755)
787-
build.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING", 0755)
788-
788+
if err := cp.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll"); err != nil {
789+
log.Fatal("Failed to copy SimpleFC.dll: %v", err)
790+
}
791+
if err := cp.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING"); err != nil {
792+
log.Fatal("Failed to copy copyright note: %v", err)
793+
}
789794
// Build the installer. This assumes that all the needed files have been previously
790795
// built (don't mix building and packaging to keep cross compilation complexity to a
791796
// minimum).
@@ -802,7 +807,6 @@ func doWindowsInstaller(cmdline []string) {
802807
"/DARCH="+*arch,
803808
filepath.Join(*workdir, "geth.nsi"),
804809
)
805-
806810
// Sign and publish installer.
807811
if err := archiveUpload(installer, *upload, *signer); err != nil {
808812
log.Fatal(err)

‎internal/build/util.go‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -118,51 +118,6 @@ func render(tpl *template.Template, outputFile string, outputPerm os.FileMode, x
118118
}
119119
}
120120

121-
// CopyFile copies a file.
122-
func CopyFile(dst, src string, mode os.FileMode) {
123-
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
124-
log.Fatal(err)
125-
}
126-
destFile, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode)
127-
if err != nil {
128-
log.Fatal(err)
129-
}
130-
defer destFile.Close()
131-
132-
srcFile, err := os.Open(src)
133-
if err != nil {
134-
log.Fatal(err)
135-
}
136-
defer srcFile.Close()
137-
138-
if _, err := io.Copy(destFile, srcFile); err != nil {
139-
log.Fatal(err)
140-
}
141-
}
142-
143-
// CopyFolder copies a folder.
144-
func CopyFolder(dst, src string, mode os.FileMode) {
145-
if err := os.MkdirAll(dst, mode); err != nil {
146-
log.Fatal(err)
147-
}
148-
dir, _ := os.Open(src)
149-
150-
objects, err := dir.Readdir(-1)
151-
if err != nil {
152-
log.Fatal(err)
153-
}
154-
for _, obj := range objects {
155-
srcPath := filepath.Join(src, obj.Name())
156-
dstPath := filepath.Join(dst, obj.Name())
157-
158-
if obj.IsDir() {
159-
CopyFolder(dstPath, srcPath, mode)
160-
} else {
161-
CopyFile(dstPath, srcPath, mode)
162-
}
163-
}
164-
}
165-
166121
// GoTool returns the command that runs a go tool. This uses go from GOROOT instead of PATH
167122
// so that go commands executed by build use the same version of Go as the 'host' that runs
168123
// build code. e.g.

0 commit comments

Comments
 (0)