Allow including initramfs-extra files in the initramfs (MR 48)
This uses a "deviceinfo_create_initfs_extra" to allow including initramfs-extra files in the initramfs and skip creating a separate initramfs-extra archive when it's set to "false". If this variable is unset, mkinitfs uses a default value of "false".
This commit is contained in:
@@ -106,12 +106,33 @@ func main() {
|
|||||||
modules.New("/usr/share/mkinitfs/modules"),
|
modules.New("/usr/share/mkinitfs/modules"),
|
||||||
modules.New("/etc/mkinitfs/modules"),
|
modules.New("/etc/mkinitfs/modules"),
|
||||||
})
|
})
|
||||||
|
initfsExtra := initramfs.New([]filelist.FileLister{
|
||||||
|
hookfiles.New("/usr/share/mkinitfs/files-extra"),
|
||||||
|
hookfiles.New("/etc/mkinitfs/files-extra"),
|
||||||
|
hookscripts.New("/usr/share/mkinitfs/hooks-extra", "/hooks-extra"),
|
||||||
|
hookscripts.New("/etc/mkinitfs/hooks-extra", "/hooks-extra"),
|
||||||
|
modules.New("/usr/share/mkinitfs/modules-extra"),
|
||||||
|
modules.New("/etc/mkinitfs/modules-extra"),
|
||||||
|
})
|
||||||
|
|
||||||
if err := initramfsAr.AddItems(initfs); err != nil {
|
if err := initramfsAr.AddItems(initfs); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
log.Println("failed to generate: ", "initramfs")
|
log.Println("failed to generate: ", "initramfs")
|
||||||
retCode = 1
|
retCode = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Include initramfs-extra files in the initramfs if not making a separate
|
||||||
|
// archive
|
||||||
|
if !devinfo.CreateInitfsExtra {
|
||||||
|
if err := initramfsAr.AddItems(initfsExtra); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
log.Println("failed to generate: ", "initramfs")
|
||||||
|
retCode = 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := initramfsAr.Write(filepath.Join(workDir, "initramfs"), os.FileMode(0644)); err != nil {
|
if err := initramfsAr.Write(filepath.Join(workDir, "initramfs"), os.FileMode(0644)); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
log.Println("failed to generate: ", "initramfs")
|
log.Println("failed to generate: ", "initramfs")
|
||||||
@@ -120,6 +141,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
misc.TimeFunc(start, "initramfs")
|
misc.TimeFunc(start, "initramfs")
|
||||||
|
|
||||||
|
if devinfo.CreateInitfsExtra {
|
||||||
//
|
//
|
||||||
// initramfs-extra
|
// initramfs-extra
|
||||||
//
|
//
|
||||||
@@ -130,14 +152,6 @@ func main() {
|
|||||||
|
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
initramfsExtraAr := archive.New(compressionFormat, compressionLevel)
|
initramfsExtraAr := archive.New(compressionFormat, compressionLevel)
|
||||||
initfsExtra := initramfs.New([]filelist.FileLister{
|
|
||||||
hookfiles.New("/usr/share/mkinitfs/files-extra"),
|
|
||||||
hookfiles.New("/etc/mkinitfs/files-extra"),
|
|
||||||
hookscripts.New("/usr/share/mkinitfs/hooks-extra", "/hooks-extra"),
|
|
||||||
hookscripts.New("/etc/mkinitfs/hooks-extra", "/hooks-extra"),
|
|
||||||
modules.New("/usr/share/mkinitfs/modules-extra"),
|
|
||||||
modules.New("/etc/mkinitfs/modules-extra"),
|
|
||||||
})
|
|
||||||
if err := initramfsExtraAr.AddItemsExclude(initfsExtra, initfs); err != nil {
|
if err := initramfsExtraAr.AddItemsExclude(initfsExtra, initfs); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
log.Println("failed to generate: ", "initramfs-extra")
|
log.Println("failed to generate: ", "initramfs-extra")
|
||||||
@@ -151,6 +165,7 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
misc.TimeFunc(start, "initramfs-extra")
|
misc.TimeFunc(start, "initramfs-extra")
|
||||||
|
}
|
||||||
|
|
||||||
// Final processing of initramfs / kernel is done by boot-deploy
|
// Final processing of initramfs / kernel is done by boot-deploy
|
||||||
if !disableBootDeploy {
|
if !disableBootDeploy {
|
||||||
|
@@ -42,6 +42,7 @@ mkinitfs reads deviceinfo values from */usr/share/deviceinfo/deviceinfo* and
|
|||||||
*/etc/deviceinfo*, in that order. The following variables
|
*/etc/deviceinfo*, in that order. The following variables
|
||||||
are *required* by mkinitfs:
|
are *required* by mkinitfs:
|
||||||
|
|
||||||
|
- deviceinfo_create_initfs_extra
|
||||||
- deviceinfo_generate_systemd_boot
|
- deviceinfo_generate_systemd_boot
|
||||||
- deviceinfo_initfs_compression
|
- deviceinfo_initfs_compression
|
||||||
- deviceinfo_initfs_extra_compression
|
- deviceinfo_initfs_extra_compression
|
||||||
|
@@ -78,12 +78,17 @@ func (b *BootDeploy) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// boot-deploy -i initramfs -k vmlinuz-postmarketos-rockchip -d /tmp/cpio -o /tmp/foo initramfs-extra
|
// boot-deploy -i initramfs -k vmlinuz-postmarketos-rockchip -d /tmp/cpio -o /tmp/foo initramfs-extra
|
||||||
cmd := exec.Command("boot-deploy",
|
args := []string{
|
||||||
"-i", "initramfs",
|
"-i", "initramfs",
|
||||||
"-k", kernFilename,
|
"-k", kernFilename,
|
||||||
"-d", b.inDir,
|
"-d", b.inDir,
|
||||||
"-o", b.outDir,
|
"-o", b.outDir,
|
||||||
"initramfs-extra")
|
}
|
||||||
|
|
||||||
|
if b.devinfo.CreateInitfsExtra {
|
||||||
|
args = append(args, "initramfs-extra")
|
||||||
|
}
|
||||||
|
cmd := exec.Command("boot-deploy", args...)
|
||||||
|
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
@@ -21,6 +21,7 @@ type DeviceInfo struct {
|
|||||||
UbootBoardname string
|
UbootBoardname string
|
||||||
GenerateSystemdBoot string
|
GenerateSystemdBoot string
|
||||||
FormatVersion string
|
FormatVersion string
|
||||||
|
CreateInitfsExtra bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads the relevant entries from "file" into DeviceInfo struct
|
// Reads the relevant entries from "file" into DeviceInfo struct
|
||||||
@@ -112,6 +113,7 @@ func (d DeviceInfo) String() string {
|
|||||||
%s: %v
|
%s: %v
|
||||||
%s: %v
|
%s: %v
|
||||||
%s: %v
|
%s: %v
|
||||||
|
%s: %v
|
||||||
}`,
|
}`,
|
||||||
"deviceinfo_format_version", d.FormatVersion,
|
"deviceinfo_format_version", d.FormatVersion,
|
||||||
"deviceinfo_", d.FormatVersion,
|
"deviceinfo_", d.FormatVersion,
|
||||||
@@ -120,5 +122,6 @@ func (d DeviceInfo) String() string {
|
|||||||
"deviceinfo_ubootBoardname", d.UbootBoardname,
|
"deviceinfo_ubootBoardname", d.UbootBoardname,
|
||||||
"deviceinfo_generateSystemdBoot", d.GenerateSystemdBoot,
|
"deviceinfo_generateSystemdBoot", d.GenerateSystemdBoot,
|
||||||
"deviceinfo_formatVersion", d.FormatVersion,
|
"deviceinfo_formatVersion", d.FormatVersion,
|
||||||
|
"deviceinfo_createInitfsExtra", d.CreateInitfsExtra,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@ func TestNameToField(t *testing.T) {
|
|||||||
{"modules_initfs", "ModulesInitfs"},
|
{"modules_initfs", "ModulesInitfs"},
|
||||||
{"deviceinfo_initfs_compression___", "InitfsCompression"},
|
{"deviceinfo_initfs_compression___", "InitfsCompression"},
|
||||||
{"deviceinfo_initfs_extra_compression", "InitfsExtraCompression"},
|
{"deviceinfo_initfs_extra_compression", "InitfsExtraCompression"},
|
||||||
|
{"deviceinfo_create_initfs_extra", "CreateInitfsExtra"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, table := range tables {
|
for _, table := range tables {
|
||||||
@@ -65,6 +66,7 @@ func TestUnmarshal(t *testing.T) {
|
|||||||
UbootBoardname: "foobar-bazz",
|
UbootBoardname: "foobar-bazz",
|
||||||
InitfsCompression: "zstd:--foo=1 -T0 --bar=bazz",
|
InitfsCompression: "zstd:--foo=1 -T0 --bar=bazz",
|
||||||
InitfsExtraCompression: "",
|
InitfsExtraCompression: "",
|
||||||
|
CreateInitfsExtra: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -4,3 +4,4 @@ deviceinfo_uboot_boardname="foobar-bazz"
|
|||||||
deviceinfo_initfs_compression="zstd:--foo=1 -T0 --bar=bazz"
|
deviceinfo_initfs_compression="zstd:--foo=1 -T0 --bar=bazz"
|
||||||
# empty option
|
# empty option
|
||||||
deviceinfo_initfs_extra_compression=""
|
deviceinfo_initfs_extra_compression=""
|
||||||
|
deviceinfo_create_initfs_extra="true"
|
||||||
|
Reference in New Issue
Block a user