aboutsummaryrefslogtreecommitdiffstats
path: root/meta-mentor-staging/classes/win_sdk_cull.bbclass
blob: 00dd5893b3930ed0d1b761d0ebd81e1a83d03d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# ---------------------------------------------------------------------------------------------------------------------
# SPDX-License-Identifier: MIT
# ---------------------------------------------------------------------------------------------------------------------

SDK_POSTPROCESS_COMMAND:prepend:sdkmingw32 = "cull_win_files;"

cull_win_files () {
    # Cull duplicates caused by case insensitive filesytems, e.g. NTFS
    cd "${SDK_OUTPUT}"
    find . >cull.filelist
    cat cull.filelist | tr '[:upper:]' '[:lower:]' | sort | uniq -d | \
        while read case_dupe; do
            # Remove all but one of each set of duplicates
            bbnote "Keeping first case duplicate '$(grep -xi "$case_dupe" cull.filelist | sed -n '1p')'"
            grep -xi "$case_dupe" cull.filelist | sed '1d' | while read actual; do
                bbwarn "Removing case duplicate '${actual#.}' for windows SDKMACHINE"
                rm -rf "$actual"
            done
        done

    # Cull paths with invalid characters
    grep -E "\\\\|\?|:|\*|\"|<|>|\|" cull.filelist | while read invalid; do
        bbwarn "Removing file with invalid characters for windows SDKMACHINE: ${invalid#.}"
        rm "$invalid"
    done
}