diff options
Diffstat (limited to 'scripts/sstate-sysroot-cruft.sh')
| -rwxr-xr-x | scripts/sstate-sysroot-cruft.sh | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/scripts/sstate-sysroot-cruft.sh b/scripts/sstate-sysroot-cruft.sh deleted file mode 100755 index b2002badfb..0000000000 --- a/scripts/sstate-sysroot-cruft.sh +++ /dev/null | |||
| @@ -1,191 +0,0 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # Copyright OpenEmbedded Contributors | ||
| 4 | # | ||
| 5 | # SPDX-License-Identifier: GPL-2.0-only | ||
| 6 | # | ||
| 7 | # Used to find files installed in sysroot which are not tracked by sstate manifest | ||
| 8 | |||
| 9 | # Global vars | ||
| 10 | tmpdir= | ||
| 11 | |||
| 12 | usage () { | ||
| 13 | cat << EOF | ||
| 14 | Welcome to sysroot cruft finding utility. | ||
| 15 | $0 <OPTION> | ||
| 16 | |||
| 17 | Options: | ||
| 18 | -h, --help | ||
| 19 | Display this help and exit. | ||
| 20 | |||
| 21 | --tmpdir=<tmpdir> | ||
| 22 | Specify tmpdir, will use the environment variable TMPDIR if it is not specified. | ||
| 23 | Something like /OE/oe-core/tmp-eglibc (no / at the end). | ||
| 24 | |||
| 25 | --whitelist=<whitelist-file> | ||
| 26 | Text file, each line is regular expression for paths we want to ignore in resulting diff. | ||
| 27 | You can use diff file from the script output, if it contains only expected exceptions. | ||
| 28 | '#' is used as regexp delimiter, so you don't need to prefix forward slashes in paths. | ||
| 29 | ^ and $ is automatically added, so provide only the middle part. | ||
| 30 | Lines starting with '#' are ignored as comments. | ||
| 31 | All paths are relative to "sysroots" directory. | ||
| 32 | Directories don't end with forward slash. | ||
| 33 | EOF | ||
| 34 | } | ||
| 35 | |||
| 36 | # Print error information and exit. | ||
| 37 | echo_error () { | ||
| 38 | echo "ERROR: $1" >&2 | ||
| 39 | exit 1 | ||
| 40 | } | ||
| 41 | |||
| 42 | while [ -n "$1" ]; do | ||
| 43 | case $1 in | ||
| 44 | --tmpdir=*) | ||
| 45 | tmpdir=`echo $1 | sed -e 's#^--tmpdir=##' | xargs readlink -e` | ||
| 46 | [ -d "$tmpdir" ] || echo_error "Invalid argument to --tmpdir" | ||
| 47 | shift | ||
| 48 | ;; | ||
| 49 | --whitelist=*) | ||
| 50 | fwhitelist=`echo $1 | sed -e 's#^--whitelist=##' | xargs readlink -e` | ||
| 51 | [ -f "$fwhitelist" ] || echo_error "Invalid argument to --whitelist" | ||
| 52 | shift | ||
| 53 | ;; | ||
| 54 | --help|-h) | ||
| 55 | usage | ||
| 56 | exit 0 | ||
| 57 | ;; | ||
| 58 | *) | ||
| 59 | echo "Invalid arguments $*" | ||
| 60 | echo_error "Try '$0 -h' for more information." | ||
| 61 | ;; | ||
| 62 | esac | ||
| 63 | done | ||
| 64 | |||
| 65 | # sstate cache directory, use environment variable TMPDIR | ||
| 66 | # if it was not specified, otherwise, error. | ||
| 67 | [ -n "$tmpdir" ] || tmpdir=$TMPDIR | ||
| 68 | [ -n "$tmpdir" ] || echo_error "No tmpdir found!" | ||
| 69 | [ -d "$tmpdir" ] || echo_error "Invalid tmpdir \"$tmpdir\"" | ||
| 70 | |||
| 71 | OUTPUT=${tmpdir}/sysroot.cruft.`date "+%s"` | ||
| 72 | |||
| 73 | # top level directories | ||
| 74 | WHITELIST="[^/]*" | ||
| 75 | |||
| 76 | # generated by base-passwd recipe | ||
| 77 | WHITELIST="${WHITELIST} \ | ||
| 78 | .*/etc/group-\? \ | ||
| 79 | .*/etc/passwd-\? \ | ||
| 80 | " | ||
| 81 | # generated by pseudo-native | ||
| 82 | WHITELIST="${WHITELIST} \ | ||
| 83 | .*/var/pseudo \ | ||
| 84 | .*/var/pseudo/[^/]* \ | ||
| 85 | " | ||
| 86 | |||
| 87 | # generated by package.bbclass:SHLIBSDIRS = "${PKGDATA_DIR}/${MLPREFIX}shlibs" | ||
| 88 | WHITELIST="${WHITELIST} \ | ||
| 89 | .*/shlibs \ | ||
| 90 | .*/pkgdata \ | ||
| 91 | " | ||
| 92 | |||
| 93 | # generated by python | ||
| 94 | WHITELIST="${WHITELIST} \ | ||
| 95 | .*\.pyc \ | ||
| 96 | .*\.pyo \ | ||
| 97 | .*/__pycache__ \ | ||
| 98 | " | ||
| 99 | |||
| 100 | # generated by lua | ||
| 101 | WHITELIST="${WHITELIST} \ | ||
| 102 | .*\.luac \ | ||
| 103 | " | ||
| 104 | |||
| 105 | # generated by sgml-common-native | ||
| 106 | WHITELIST="${WHITELIST} \ | ||
| 107 | .*/etc/sgml/sgml-docbook.bak \ | ||
| 108 | " | ||
| 109 | |||
| 110 | # generated by php | ||
| 111 | WHITELIST="${WHITELIST} \ | ||
| 112 | .*/usr/lib/php5/php/.channels \ | ||
| 113 | .*/usr/lib/php5/php/.channels/.* \ | ||
| 114 | .*/usr/lib/php5/php/.registry \ | ||
| 115 | .*/usr/lib/php5/php/.registry/.* \ | ||
| 116 | .*/usr/lib/php5/php/.depdb \ | ||
| 117 | .*/usr/lib/php5/php/.depdblock \ | ||
| 118 | .*/usr/lib/php5/php/.filemap \ | ||
| 119 | .*/usr/lib/php5/php/.lock \ | ||
| 120 | " | ||
| 121 | |||
| 122 | # generated by toolchain | ||
| 123 | WHITELIST="${WHITELIST} \ | ||
| 124 | [^/]*-tcbootstrap/lib \ | ||
| 125 | " | ||
| 126 | |||
| 127 | # generated by useradd.bbclass | ||
| 128 | WHITELIST="${WHITELIST} \ | ||
| 129 | [^/]*/home \ | ||
| 130 | [^/]*/home/xuser \ | ||
| 131 | [^/]*/home/xuser/.bashrc \ | ||
| 132 | [^/]*/home/xuser/.profile \ | ||
| 133 | [^/]*/home/builder \ | ||
| 134 | [^/]*/home/builder/.bashrc \ | ||
| 135 | [^/]*/home/builder/.profile \ | ||
| 136 | " | ||
| 137 | |||
| 138 | # generated by image.py for WIC | ||
| 139 | # introduced in oe-core commit 861ce6c5d4836df1a783be3b01d2de56117c9863 | ||
| 140 | WHITELIST="${WHITELIST} \ | ||
| 141 | [^/]*/imgdata \ | ||
| 142 | [^/]*/imgdata/[^/]*\.env \ | ||
| 143 | " | ||
| 144 | |||
| 145 | # generated by fontcache.bbclass | ||
| 146 | WHITELIST="${WHITELIST} \ | ||
| 147 | .*/var/cache/fontconfig/ \ | ||
| 148 | " | ||
| 149 | |||
| 150 | SYSROOTS="`readlink -f ${tmpdir}`/sysroots/" | ||
| 151 | |||
| 152 | mkdir ${OUTPUT} | ||
| 153 | find ${tmpdir}/sstate-control -name \*.populate-sysroot\* -o -name \*.populate_sysroot\* -o -name \*.package\* | xargs cat | grep sysroots | \ | ||
| 154 | sed 's#/$##g; s#///*#/#g' | \ | ||
| 155 | # work around for paths ending with / for directories and multiplied // (e.g. paths to native sysroot) | ||
| 156 | sort | sed "s#^${SYSROOTS}##g" > ${OUTPUT}/master.list.all.txt | ||
| 157 | sort -u ${OUTPUT}/master.list.all.txt > ${OUTPUT}/master.list.txt # -u because some directories are listed for more recipes | ||
| 158 | find ${tmpdir}/sysroots/ | \ | ||
| 159 | sort | sed "s#^${SYSROOTS}##g" > ${OUTPUT}/sysroot.list.txt | ||
| 160 | |||
| 161 | diff ${OUTPUT}/master.list.all.txt ${OUTPUT}/master.list.txt > ${OUTPUT}/duplicates.txt | ||
| 162 | diff ${OUTPUT}/master.list.txt ${OUTPUT}/sysroot.list.txt > ${OUTPUT}/diff.all.txt | ||
| 163 | |||
| 164 | grep "^> ." ${OUTPUT}/diff.all.txt | sed 's/^> //g' > ${OUTPUT}/diff.txt | ||
| 165 | for item in ${WHITELIST}; do | ||
| 166 | sed -i "\\#^${item}\$#d" ${OUTPUT}/diff.txt; | ||
| 167 | echo "${item}" >> ${OUTPUT}/used.whitelist.txt | ||
| 168 | done | ||
| 169 | |||
| 170 | if [ -s "$fwhitelist" ] ; then | ||
| 171 | cat $fwhitelist >> ${OUTPUT}/used.whitelist.txt | ||
| 172 | cat $fwhitelist | grep -v '^#' | while read item; do | ||
| 173 | sed -i "\\#^${item}\$#d" ${OUTPUT}/diff.txt; | ||
| 174 | done | ||
| 175 | fi | ||
| 176 | # too many false positives for directories | ||
| 177 | # echo "Following files are installed in sysroot at least twice" | ||
| 178 | # cat ${OUTPUT}/duplicates | ||
| 179 | |||
| 180 | RESULT=`cat ${OUTPUT}/diff.txt | wc -l` | ||
| 181 | |||
| 182 | if [ "${RESULT}" != "0" ] ; then | ||
| 183 | echo "ERROR: ${RESULT} issues were found." | ||
| 184 | echo "ERROR: Following files are installed in sysroot, but not tracked by sstate:" | ||
| 185 | cat ${OUTPUT}/diff.txt | ||
| 186 | else | ||
| 187 | echo "INFO: All files are tracked by sstate or were explicitly ignored by this script" | ||
| 188 | fi | ||
| 189 | |||
| 190 | echo "INFO: Output written in: ${OUTPUT}" | ||
| 191 | exit ${RESULT} | ||
