4 Commits
2.2 ... 2.2.1

Author SHA1 Message Date
Clayton Craft
2ec78bfcfc mkinitfs: print error when failure to rm tmp dir, and make it non-fatal (MR 40)
This prints the error when the work dir can't be removed. This also
changes mkinitfs so that it does't fail in this situation.

The reasoning for this change in behavior is that mkinitfs returning
non-zero will signal to the caller that there's potentially a problem
with configuring boot-related stuff on their system, and a failure to rm
the work dir is just noise. If the cause of that failure is a deeper
problem, the log message should help figure it out.

fixes #35
2023-08-24 17:13:15 -07:00
Clayton Craft
fedf55b573 filelist/*: support comment lines starting with # (MR 41) 2023-08-24 17:11:47 -07:00
Clayton Craft
30681d2f0a filelist/*: skip empty lines (MR 41)
fixes #36
2023-08-24 17:11:22 -07:00
Clayton Craft
74de5f9798 mkinitfs: handle errors from archive.AddItems (MR 41) 2023-08-24 17:10:12 -07:00
5 changed files with 43 additions and 6 deletions

View File

@@ -80,8 +80,8 @@ func main() {
defer func() {
e := os.RemoveAll(workDir)
if e != nil && err == nil {
err = e
retCode = 1
log.Println(e)
log.Println("unable to remove temporary work directory")
}
}()
@@ -108,7 +108,12 @@ func main() {
modules.New(strings.Fields(devinfo.ModulesInitfs), "/usr/share/mkinitfs/modules"),
modules.New([]string{}, "/etc/mkinitfs/modules"),
})
initramfsAr.AddItems(initfs)
if err := initramfsAr.AddItems(initfs); 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 {
log.Println(err)
log.Println("failed to generate: ", "initramfs")
@@ -136,7 +141,12 @@ func main() {
modules.New([]string{}, "/etc/mkinitfs/modules-extra"),
osksdl.New(devinfo.MesaDriver),
})
initramfsExtraAr.AddItemsExclude(initfsExtra, initfs)
if err := initramfsExtraAr.AddItemsExclude(initfsExtra, initfs); err != nil {
log.Println(err)
log.Println("failed to generate: ", "initramfs-extra")
retCode = 1
return
}
if err := initramfsExtraAr.Write(filepath.Join(workDir, "initramfs-extra"), os.FileMode(0644)); err != nil {
log.Println(err)
log.Println("failed to generate: ", "initramfs-extra")

View File

@@ -100,6 +100,9 @@ create/manage. mkinitfs reads configuration from */usr/share/mkinitfs* first, an
path(s) under the relevant directory in */etc/mkinitfs*, and changing
the destination path.
Any lines in these files that start with *#* are considered comments, and
skipped.
## /usr/share/mkinitfs/hooks, /etc/mkinitfs/hooks
## /usr/share/mkinitfs/hooks-extra*, /etc/mkinitfs/hooks-extra
@@ -121,12 +124,18 @@ create/manage. mkinitfs reads configuration from */usr/share/mkinitfs* first, an
Modules are installed in the initramfs archive under the same path they
exist on the system where mkinitfs is executed.
Any lines in these files that start with *#* are considered comments, and
skipped.
## /usr/share/mkinitfs/dirs, /etc/mkinitfs/dirs
Files with the *.dirs* extension in these directories are lists of
directories to create within the initramfs. There is no *-extra* variant,
since directories are of negligible size.
Any lines in these files that start with *#* are considered comments, and
skipped.
# BOOT-DEPLOY
After generating archives, mkinitfs will execute *boot-deploy*, using *$PATH* to

View File

@@ -6,6 +6,7 @@ import (
"log"
"os"
"path/filepath"
"strings"
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/filelist"
)
@@ -44,6 +45,10 @@ func (h *HookDirs) List() (*filelist.FileList, error) {
s := bufio.NewScanner(f)
for s.Scan() {
dir := s.Text()
if len(dir) == 0 || strings.HasPrefix(dir, "#") {
continue
}
files.Add(dir, dir)
}
}

View File

@@ -58,7 +58,12 @@ func slurpFiles(fd io.Reader) (*filelist.FileList, error) {
s := bufio.NewScanner(fd)
for s.Scan() {
src, dest, has_dest := strings.Cut(s.Text(), ":")
line := s.Text()
if len(line) == 0 || strings.HasPrefix(line, "#") {
continue
}
src, dest, has_dest := strings.Cut(line, ":")
fFiles, err := misc.GetFiles([]string{src}, true)
if err != nil {

View File

@@ -95,6 +95,9 @@ func slurpModules(fd io.Reader, modDir string) (*filelist.FileList, error) {
s := bufio.NewScanner(fd)
for s.Scan() {
line := s.Text()
if len(line) == 0 || strings.HasPrefix(line, "#") {
continue
}
dir, file := filepath.Split(line)
if file == "" {
// item is a directory
@@ -194,7 +197,12 @@ func getModuleDeps(modName string, modulesDep io.Reader) ([]string, error) {
s := bufio.NewScanner(modulesDep)
for s.Scan() {
fields := strings.Fields(s.Text())
line := s.Text()
if len(line) == 0 || strings.HasPrefix(line, "#") {
continue
}
fields := strings.Fields(line)
if len(fields) == 0 {
continue
}