Reorganize the source checkout layout
Separate tracked source from generated artifacts so the repo root stops accumulating helper scripts, manifests, and local runtime outputs. Move manual shell entrypoints under scripts/, manifests under config/, and the Firecracker API reference under docs/reference/. Make build and runtimebundle now target build/bin, build/runtime, and build/dist as the canonical source-checkout paths. Update runtime discovery, helper scripts, tests, and docs to follow the new layout while keeping legacy source-checkout runtime fallbacks for existing local bundles during migration. Validated with bash -n on the moved scripts, make build, and GOCACHE=/tmp/banger-gocache go test ./....
This commit is contained in:
parent
2362d0ae39
commit
01c7cb5e65
23 changed files with 296 additions and 186 deletions
|
|
@ -427,7 +427,7 @@ func TestAbsolutizeImageRegisterPaths(t *testing.T) {
|
|||
KernelPath: filepath.Join(".", "runtime", "vmlinux"),
|
||||
InitrdPath: filepath.Join(".", "runtime", "initrd.img"),
|
||||
ModulesDir: filepath.Join(".", "runtime", "modules"),
|
||||
PackagesPath: filepath.Join(".", "packages.void"),
|
||||
PackagesPath: filepath.Join(".", "config", "packages.void"),
|
||||
}
|
||||
|
||||
wd, err := os.Getwd()
|
||||
|
|
|
|||
|
|
@ -111,11 +111,11 @@ func TestEnsureDefaultImageReconcilesStaleUnmanagedDefaultInPlace(t *testing.T)
|
|||
ID: "default-id",
|
||||
Name: "default",
|
||||
Managed: false,
|
||||
RootfsPath: "/home/thales/projects/personal/banger/rootfs-docker.ext4",
|
||||
KernelPath: "/home/thales/projects/personal/banger/wtf/root/boot/vmlinux-6.8.0-94-generic",
|
||||
InitrdPath: "/home/thales/projects/personal/banger/wtf/root/boot/initrd.img-6.8.0-94-generic",
|
||||
ModulesDir: "/home/thales/projects/personal/banger/wtf/root/lib/modules/6.8.0-94-generic",
|
||||
PackagesPath: "/home/thales/projects/personal/banger/packages.apt",
|
||||
RootfsPath: "/home/thales/projects/personal/banger/build/runtime/rootfs-docker.ext4",
|
||||
KernelPath: "/home/thales/projects/personal/banger/build/runtime/wtf/root/boot/vmlinux-6.8.0-94-generic",
|
||||
InitrdPath: "/home/thales/projects/personal/banger/build/runtime/wtf/root/boot/initrd.img-6.8.0-94-generic",
|
||||
ModulesDir: "/home/thales/projects/personal/banger/build/runtime/wtf/root/lib/modules/6.8.0-94-generic",
|
||||
PackagesPath: "/home/thales/projects/personal/banger/build/runtime/packages.apt",
|
||||
Docker: true,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
|
|
|
|||
|
|
@ -86,14 +86,24 @@ func ResolveRuntimeDir(configuredRuntimeDir, deprecatedRepoRoot string) string {
|
|||
}
|
||||
exeDir := filepath.Dir(exe)
|
||||
if filepath.Base(exeDir) == "bin" {
|
||||
if filepath.Base(filepath.Dir(exeDir)) == "build" {
|
||||
buildRuntimeDir := filepath.Clean(filepath.Join(exeDir, "..", "runtime"))
|
||||
if HasRuntimeBundle(buildRuntimeDir) {
|
||||
return buildRuntimeDir
|
||||
}
|
||||
}
|
||||
installRuntimeDir := filepath.Clean(filepath.Join(exeDir, "..", "lib", "banger"))
|
||||
if HasRuntimeBundle(installRuntimeDir) {
|
||||
return installRuntimeDir
|
||||
}
|
||||
}
|
||||
sourceRuntimeDir := filepath.Join(exeDir, "runtime")
|
||||
if HasRuntimeBundle(sourceRuntimeDir) {
|
||||
return sourceRuntimeDir
|
||||
for _, sourceRuntimeDir := range []string{
|
||||
filepath.Join(exeDir, "build", "runtime"),
|
||||
filepath.Join(exeDir, "runtime"),
|
||||
} {
|
||||
if HasRuntimeBundle(sourceRuntimeDir) {
|
||||
return sourceRuntimeDir
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
@ -141,7 +151,7 @@ func BangerdPath() (string, error) {
|
|||
return candidate, nil
|
||||
}
|
||||
}
|
||||
return "", errors.New("bangerd binary not found next to banger; build ./cmd/bangerd")
|
||||
return "", errors.New("bangerd binary not found next to banger; run `make build`")
|
||||
}
|
||||
|
||||
func RuntimeBundleHint() string {
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ func TestResolveRuntimeDirUsesInstalledLayout(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestResolveRuntimeDirUsesSourceCheckoutRuntimeSubdir(t *testing.T) {
|
||||
func TestResolveRuntimeDirUsesBuildRuntimeForSourceCheckoutBinary(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
runtimeDir := filepath.Join(root, "runtime")
|
||||
runtimeDir := filepath.Join(root, "build", "runtime")
|
||||
createRuntimeBundle(t, runtimeDir)
|
||||
|
||||
origExecutablePath := executablePath
|
||||
|
|
@ -53,6 +53,24 @@ func TestResolveRuntimeDirUsesSourceCheckoutRuntimeSubdir(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestResolveRuntimeDirUsesBuildRuntimeForBuildBinExecutable(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
runtimeDir := filepath.Join(root, "build", "runtime")
|
||||
createRuntimeBundle(t, runtimeDir)
|
||||
|
||||
origExecutablePath := executablePath
|
||||
executablePath = func() (string, error) {
|
||||
return filepath.Join(root, "build", "bin", "banger"), nil
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
executablePath = origExecutablePath
|
||||
})
|
||||
|
||||
if got := ResolveRuntimeDir("", ""); got != runtimeDir {
|
||||
t.Fatalf("ResolveRuntimeDir() = %q, want %q", got, runtimeDir)
|
||||
}
|
||||
}
|
||||
|
||||
func createRuntimeBundle(t *testing.T, runtimeDir string) {
|
||||
t.Helper()
|
||||
metadata := runtimebundle.BundleMetadata{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue