@@ -785,6 +785,16 @@ func parseMelangeYaml(fsys fs.FS) (*config.Configuration, error) {
785
785
786
786
func usrmergeLinter (ctx context.Context , _ * config.Configuration , _ string , fsys fs.FS ) error {
787
787
paths := []string {}
788
+ dirs := []string {"sbin" , "bin" , "usr/sbin" , "lib" , "lib64" }
789
+
790
+ pathInDir := func (path string , dirs ... string ) bool {
791
+ for _ , d := range dirs {
792
+ if path == d || strings .HasPrefix (path , d + "/" ) {
793
+ return true
794
+ }
795
+ }
796
+ return false
797
+ }
788
798
789
799
err := fs .WalkDir (fsys , "." , func (path string , d fs.DirEntry , err error ) error {
790
800
if err := ctx .Err (); err != nil {
@@ -798,21 +808,19 @@ func usrmergeLinter(ctx context.Context, _ *config.Configuration, _ string, fsys
798
808
return filepath .SkipDir
799
809
}
800
810
801
- // If it's not a directory of interest just skipp the whole tree
802
- if path != "." && ! strings .HasPrefix (path , "sbin" ) && ! strings .HasPrefix (path , "bin" ) && ! strings .HasPrefix (path , "usr/sbin" ) {
803
- if d .IsDir () && path != "usr" {
804
- return filepath .SkipDir
805
- }
811
+ // If it's not a directory of interest just skip the whole tree
812
+ if ! (path == "." || path == "usr" || pathInDir (path , dirs ... )) {
813
+ return filepath .SkipDir
806
814
}
807
815
808
- if path == "sbin" || path == "bin" || path == "usr/sbin" {
816
+ if slices . Contains ( dirs , path ) {
809
817
if d .IsDir () || d .Type ().IsRegular () {
810
818
paths = append (paths , path )
811
819
return nil
812
820
}
813
821
}
814
822
815
- if strings . HasPrefix (path , "sbin/" ) || strings . HasPrefix ( path , "bin/" ) || strings . HasPrefix ( path , "usr/sbin/" ) {
823
+ if pathInDir (path , dirs ... ) {
816
824
paths = append (paths , path )
817
825
}
818
826
0 commit comments