repochecker/file-inspector: ZIP archive shouldn't contain Unix rootfs
This commit is contained in:
parent
bd19d31577
commit
20f5656a74
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/sync"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
|
@ -48,5 +49,42 @@ func checkZip(file *fic.EFile, exceptions *sync.CheckExceptions) (errs []error)
|
|||
log.Printf("%d files found in %q", len(r.File), file.Name)
|
||||
}
|
||||
|
||||
foundEtcDir := false
|
||||
foundHomeDir := false
|
||||
foundRootDir := false
|
||||
foundVarDir := false
|
||||
for _, file := range r.File {
|
||||
if strings.HasPrefix(file.Name, "etc") {
|
||||
foundEtcDir = true
|
||||
}
|
||||
if strings.HasPrefix(file.Name, "home") {
|
||||
foundHomeDir = true
|
||||
}
|
||||
if strings.HasPrefix(file.Name, "root") {
|
||||
foundRootDir = true
|
||||
}
|
||||
if strings.HasPrefix(file.Name, "var") {
|
||||
foundVarDir = true
|
||||
}
|
||||
}
|
||||
|
||||
nbLinuxDirFound := 0
|
||||
if foundEtcDir {
|
||||
nbLinuxDirFound += 1
|
||||
}
|
||||
if foundHomeDir {
|
||||
nbLinuxDirFound += 1
|
||||
}
|
||||
if foundRootDir {
|
||||
nbLinuxDirFound += 1
|
||||
}
|
||||
if foundVarDir {
|
||||
nbLinuxDirFound += 1
|
||||
}
|
||||
|
||||
if nbLinuxDirFound > 2 && !exceptions.HasException(":not-a-linux-rootfs") {
|
||||
errs = append(errs, fmt.Errorf("don't use a ZIP archive to store an Unix file system, prefer a tarball (:not-a-linux-rootfs)"))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue