2 Commits
1.3 ... 1.1.1

Author SHA1 Message Date
Minecrell
d62180f9d6 getModuleDeps: replace Split() loop with ReplaceAllString() (MR 12)
This should do the same as far as I can tell :)

(cherry picked from commit 866f17b86f)
2021-09-20 15:16:38 -07:00
Minecrell
b7f02ff970 getModulesDep: disallow regex submatches (MR 12)
At the moment modules in modules.dep are matched even on a submatch
e.g. looking up "msm" ends up matching "snd-soc-msm8916-digital.ko"
instead of "msm.ko". To fix this, disallow submatches using ^ and $.

(cherry picked from commit 15e99c3658)
2021-09-20 15:16:33 -07:00
3 changed files with 9 additions and 48 deletions

View File

@@ -31,7 +31,7 @@ gofmt linting:
- apk -q update --repository http://dl-4.alpinelinux.org/alpine/edge/testing
- apk -q add --repository http://dl-4.alpinelinux.org/alpine/edge/testing go staticcheck
script:
- .ci/check_linting.sh
- .gitlab-ci/check_linting.sh
build:
stage: build

55
main.go
View File

@@ -86,29 +86,18 @@ func bootDeploy(workDir string, outDir string) error {
if len(kernels) == 0 {
return errors.New("Unable to find any kernels at " + filepath.Join(outDir, "vmlinuz*"))
}
// Pick a kernel that does not have suffixes added by boot-deploy
var kernFile string
for _, f := range kernels {
if strings.HasSuffix(f, "-dtb") || strings.HasSuffix(f, "-mtk") {
continue
}
kernFile = f
break
}
kernFd, err := os.Open(kernFile)
kernFile, err := os.Open(kernels[0])
if err != nil {
return err
}
defer kernFd.Close()
defer kernFile.Close()
kernFileCopy, err := os.Create(filepath.Join(workDir, "vmlinuz"))
if err != nil {
return err
}
if _, err = io.Copy(kernFileCopy, kernFd); err != nil {
if _, err = io.Copy(kernFileCopy, kernFile); err != nil {
return err
}
kernFileCopy.Close()
@@ -156,9 +145,10 @@ func getHookFiles(filesdir string) misc.StringSet {
defer f.Close()
s := bufio.NewScanner(f)
for s.Scan() {
if err := getFile(files, s.Text(), true); err != nil {
if !exists(s.Text()) {
log.Fatalf("Unable to find file %q required by %q", s.Text(), path)
}
files[s.Text()] = false
}
if err := s.Err(); err != nil {
log.Fatal(err)
@@ -242,42 +232,13 @@ func getFiles(files misc.StringSet, newFiles misc.StringSet, required bool) erro
}
func getFile(files misc.StringSet, file string, required bool) error {
// Expand glob expression
expanded, _ := filepath.Glob(file)
if len(expanded) > 0 && expanded[0] != file {
for _, path := range expanded {
if err := getFile(files, path, required); err != nil {
return err
}
}
return nil
}
fileInfo, err := os.Stat(file)
if err != nil {
if !exists(file) {
if required {
return errors.New("getFile: File does not exist :" + file)
}
return nil
}
if fileInfo.IsDir() {
// Recurse over directory contents
err := filepath.Walk(file, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
if f.IsDir() {
return nil
}
return getFile(files, path, required)
})
if err != nil {
return err
}
return nil
}
files[file] = false
// get dependencies for binaries
@@ -286,7 +247,8 @@ func getFile(files misc.StringSet, file string, required bool) error {
return nil
}
if err := getBinaryDeps(files, file); err != nil {
err := getBinaryDeps(files, file)
if err != nil {
return err
}
@@ -441,7 +403,6 @@ func getInitfsFiles(files misc.StringSet, devinfo deviceinfo.DeviceInfo) error {
"/usr/sbin/telnetd": false,
"/sbin/kpartx": false,
"/etc/deviceinfo": false,
"/usr/bin/unudhcpd": false,
}
// Hook files & scripts