mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-18 04:27:06 +02:00
This adds support for the Raspberry Pi 4 Model B. Signed-off-by: Andrew Rynhard <andrew@rynhard.io>
88 lines
1.4 KiB
Go
88 lines
1.4 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package copy
|
|
|
|
import (
|
|
"io"
|
|
"io/ioutil"
|
|
"os"
|
|
"path"
|
|
)
|
|
|
|
// File copies the `src` file to the `dst` file.
|
|
func File(src, dst string) error {
|
|
var (
|
|
err error
|
|
s *os.File
|
|
d *os.File
|
|
info os.FileInfo
|
|
)
|
|
|
|
if s, err = os.Open(src); err != nil {
|
|
return err
|
|
}
|
|
|
|
// nolint: errcheck
|
|
defer s.Close()
|
|
|
|
if d, err = os.Create(dst); err != nil {
|
|
return err
|
|
}
|
|
|
|
// nolint: errcheck
|
|
defer d.Close()
|
|
|
|
// nolint: errcheck
|
|
defer d.Sync()
|
|
|
|
if _, err = io.Copy(d, s); err != nil {
|
|
return err
|
|
}
|
|
|
|
if info, err = os.Stat(src); err != nil {
|
|
return err
|
|
}
|
|
|
|
return os.Chmod(dst, info.Mode())
|
|
}
|
|
|
|
// Dir copies the `src` directory to the `dst` directory.
|
|
func Dir(src, dst string) error {
|
|
var (
|
|
err error
|
|
files []os.FileInfo
|
|
info os.FileInfo
|
|
)
|
|
|
|
if info, err = os.Stat(src); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err = os.MkdirAll(dst, info.Mode()); err != nil {
|
|
return err
|
|
}
|
|
|
|
if files, err = ioutil.ReadDir(src); err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, file := range files {
|
|
s := path.Join(src, file.Name())
|
|
d := path.Join(dst, file.Name())
|
|
|
|
if file.IsDir() {
|
|
if err = Dir(s, d); err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
if err = File(s, d); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|