Skip to content

Commit

Permalink
fix: use correct prefix when installing SBC files
Browse files Browse the repository at this point in the history
When creating an image under non-default mount prefix, it should be
used explicitly when copying SBC files.

See siderolabs/image-factory#65

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Dec 15, 2023
1 parent 0b94550 commit 760f793
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions cmd/installer/pkg/install/install.go
Expand Up @@ -290,6 +290,7 @@ func (i *Installer) Install(ctx context.Context, mode Mode) (err error) {

if err = b.Install(runtime.BoardInstallOptions{
InstallDisk: i.options.Disk,
MountPrefix: i.options.MountPrefix,
UBootPath: i.options.BootAssets.UBootPath,
DTBPath: i.options.BootAssets.DTBPath,
RPiFirmwarePath: i.options.BootAssets.RPiFirmwarePath,
Expand Down
1 change: 1 addition & 0 deletions internal/app/machined/pkg/runtime/board.go
Expand Up @@ -15,6 +15,7 @@ type PartitionOptions struct {
// BoardInstallOptions are the board specific options for installation of various boot assets.
type BoardInstallOptions struct {
InstallDisk string
MountPrefix string
DTBPath string
UBootPath string
RPiFirmwarePath string
Expand Down
Expand Up @@ -73,7 +73,7 @@ func (b *BananaPiM64) Install(options runtime.BoardInstallOptions) (err error) {
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
Expand Down
Expand Up @@ -53,7 +53,7 @@ func (b JetsonNano) Install(options runtime.BoardInstallOptions) (err error) {
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
Expand Down
Expand Up @@ -70,7 +70,7 @@ func (l *LibretechAllH3CCH5) Install(options runtime.BoardInstallOptions) (err e
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
Expand Down
Expand Up @@ -64,7 +64,7 @@ func (n *NanoPiR4S) Install(options runtime.BoardInstallOptions) (err error) {
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

if err := os.MkdirAll(filepath.Dir(dst), 0o600); err != nil {
return err
Expand Down
Expand Up @@ -71,7 +71,7 @@ func (b Pine64) Install(options runtime.BoardInstallOptions) (err error) {
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
Expand Down
Expand Up @@ -70,7 +70,7 @@ func (r *Rock64) Install(options runtime.BoardInstallOptions) (err error) {
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
Expand Down
Expand Up @@ -70,7 +70,7 @@ func (r *Rockpi4) Install(options runtime.BoardInstallOptions) (err error) {
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
Expand Down
Expand Up @@ -69,7 +69,7 @@ func (r *Rockpi4c) Install(options runtime.BoardInstallOptions) (err error) {
}

src := filepath.Join(options.DTBPath, dtb)
dst := filepath.Join("/boot/EFI/dtb", dtb)
dst := filepath.Join(options.MountPrefix, "/boot/EFI/dtb", dtb)

err = os.MkdirAll(filepath.Dir(dst), 0o600)
if err != nil {
Expand Down
Expand Up @@ -32,17 +32,17 @@ func (r *RPiGeneric) Name() string {

// Install implements the runtime.Board.
func (r *RPiGeneric) Install(options runtime.BoardInstallOptions) (err error) {
err = copy.Dir(filepath.Join(options.RPiFirmwarePath, "boot"), "/boot/EFI")
err = copy.Dir(filepath.Join(options.RPiFirmwarePath, "boot"), filepath.Join(options.MountPrefix, "/boot/EFI"))
if err != nil {
return err
}

err = copy.File(filepath.Join(options.UBootPath, "rpi_generic/u-boot.bin"), "/boot/EFI/u-boot.bin")
err = copy.File(filepath.Join(options.UBootPath, "rpi_generic/u-boot.bin"), filepath.Join(options.MountPrefix, "/boot/EFI/u-boot.bin"))
if err != nil {
return err
}

return os.WriteFile("/boot/EFI/config.txt", configTxt, 0o600)
return os.WriteFile(filepath.Join(options.MountPrefix, "/boot/EFI/config.txt"), configTxt, 0o600)
}

// KernelArgs implements the runtime.Board.
Expand Down

0 comments on commit 760f793

Please sign in to comment.