booster: update to 0.10.

This commit is contained in:
travankor 2023-04-10 06:33:28 -07:00 committed by Duncan Overbruck
parent d5e7cf52dc
commit c5dc275a53
3 changed files with 128 additions and 3 deletions

View file

@ -0,0 +1,40 @@
From bc988b0c48d337d7b3447ad8a634551ca5080178 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Thu, 9 Mar 2023 14:15:21 +0100
Subject: [PATCH] generator: Fix creation of target directory
This attempts to fix a regression introduced in commit
e13aa77e49aef93cc1370a269785b471758cb546 since this commit
the `usr/lib` target directroy is not created if the host system
does not ship any files in `usr/lib` (e.g. Alpine). This causes
initramfs images generated on such systems to not be bootable
as `lib` is a symlink to the non-existend `usr/lib` then.
The problem is the current implementation:
filepath.Dir(filepath.Join(filepath.Dir(l.src), l.target))
Would return `/usr` for `{"/lib", "usr/lib"}` and hence `/usr/lib`
was never created. I believe this was intended to be:
filepath.Join(filepath.Dir(l.src), l.target)
This commit changes this accordingly and fixes booting Booster
images on Alpine.
---
generator/generator.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/generator/generator.go b/generator/generator.go
index 4a030e5..0ab135c 100644
--- a/generator/generator.go
+++ b/generator/generator.go
@@ -263,7 +263,7 @@ func appendCompatibilitySymlinks(img *Image) error {
for _, l := range symlinks {
// Ensure that target always exist which may not be the
// case if we only install files from /lib or /bin.
- targetDir := filepath.Dir(filepath.Join(filepath.Dir(l.src), l.target))
+ targetDir := filepath.Join(filepath.Dir(l.src), l.target)
if err := img.AppendDirEntry(targetDir); err != nil {
return err
}

View file

@ -0,0 +1,85 @@
From 7766b079c8fd004fee9d5eba19cb98cac568773b Mon Sep 17 00:00:00 2001
From: Anatol Pomozov <anatol.pomozov@gmail.com>
Date: Thu, 23 Mar 2023 18:49:14 -0700
Subject: [PATCH] generator: Do not rely on user's lookup order for binaries
Until now we used `exec.LookPath` golang function to lookup binaries.
This function depends on user's $PATH envvar and the order directories
specified there. This could mess with our image symlink tree.
What we want is to make sure that we lookup/add files at non-symlinked
directories first (i.e. /usr/bin).
Closes #213
---
generator/generator.go | 28 ++++++++++++++++++++++++++--
generator/generator_test.go | 6 ++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/generator/generator.go b/generator/generator.go
index 0ab135c..8f0a72f 100644
--- a/generator/generator.go
+++ b/generator/generator.go
@@ -5,7 +5,6 @@ import (
"fmt"
"net"
"os"
- "os/exec"
"path/filepath"
"time"
@@ -290,7 +289,7 @@ func (img *Image) appendExtraFiles(binaries ...string) error {
// If the given name is not an absolute path, assume that it refers
// to an executable and lookup the path to the executable using $PATH.
var err error
- f, err = exec.LookPath(f)
+ f, err = lookupPath(f)
if err != nil {
return err
}
@@ -303,6 +302,31 @@ func (img *Image) appendExtraFiles(binaries ...string) error {
return nil
}
+func lookupPath(binary string) (string, error) {
+ paths := []string{
+ "/usr/bin",
+ "/usr/sbin",
+ "/bin",
+ "/sbin",
+ "/usr/local/bin",
+ "/usr/local/sbin",
+ }
+
+ for _, p := range paths {
+ f := filepath.Join(p, binary)
+ _, err := os.Stat(f)
+ if os.IsNotExist(err) {
+ continue
+ }
+ if err != nil {
+ return "", err
+ }
+ return f, nil
+ }
+
+ return "", os.ErrNotExist
+}
+
func findFwFile(fw string) (string, error) {
supportedFwExt := []string{
"",
diff --git a/generator/generator_test.go b/generator/generator_test.go
index 57b7cce..5938cbc 100644
--- a/generator/generator_test.go
+++ b/generator/generator_test.go
@@ -550,3 +550,9 @@ func TestModprobeOptions(t *testing.T) {
}
require.Equal(t, expect, cfg.ModprobeOptions)
}
+
+func TestLookupFile(t *testing.T) {
+ path, err := lookupPath("echo")
+ require.NoError(t, err)
+ require.Equal(t, "/usr/bin/echo", path)
+}

View file

@ -1,7 +1,7 @@
# Template file for 'booster'
pkgname=booster
version=0.9
revision=2
version=0.10
revision=1
build_style=go
go_import_path=github.com/anatol/booster
hostmakedepends="git ruby-ronn"
@ -11,7 +11,7 @@ maintainer="travankor <travankor@tuta.io>"
license="MIT"
homepage="https://github.com/anatol/booster"
distfiles="https://github.com/anatol/booster/archive/${version}.tar.gz"
checksum=786b89ac5f5b6fb063ff58b490525c9fda9c6f2ae53ab06416b25993bdb72ca4
checksum=27a7e40135ceb5504438ce0a45108ef955f5ece197932acc7686fd6c0254565c
conf_files="/etc/booster.yaml"
alternatives="
initramfs:/etc/kernel.d/post-install/20-initramfs:/usr/libexec/booster/kernel-hook-postinst