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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| [root@rk3528-openeuler22 conan]# cat ./check_conan.sh #!/usr/bin/env bash # 检查 Conan 缓存中每个包的状态(直接查 sqlite3 + 文件系统) set -euo pipefail
CONAN_HOME="${CONAN_HOME:-$HOME/.conan2}" DB="$CONAN_HOME/p/cache.sqlite3" P="$CONAN_HOME/p"
# 收集所有 tool_requires 引用 tool_pkgs=$(grep -rh 'tool_requires\s*(' "$P"/*/e/conanfile.py 2>/dev/null \ | grep -oP '[\w.+-]+/[\w.+-]+@[\w.+-]+/[\w.+-]+' | sort -u || true)
# packages 表:reference -> "hash1 hash2 ..." declare -A pkg_hashes while IFS='|' read -r ref hash; do pkg_hashes["$ref"]+="$hash " done < <(sqlite3 "$DB" "SELECT reference, path FROM packages;" 2>/dev/null || true)
echo "src:s=源码 es=补丁 bin=已编译二进制 bld=编译中间产物 R=Release D=Debug tool=被其他包用作构建工具" echo "" total=0; no_src=0
while IFS='|' read -r pkg recipe_hash; do (( total++ )) || true
# --- src --- have_s=false; have_es=false [[ -d "$P/$recipe_hash/s" ]] && have_s=true [[ -d "$P/$recipe_hash/es" ]] && have_es=true if $have_s && $have_es; then src="s+es" elif $have_s; then src="s " elif $have_es; then src="es " else src=" "; (( no_src++ )) || true fi
# --- bin / bld(带 Release/Debug 标记)--- bin_r=false; bin_d=false; bld_r=false; bld_d=false for h in ${pkg_hashes["$pkg"]:-}; do bt=$(grep -m1 '^build_type=' "$P/$h/p/conaninfo.txt" 2>/dev/null | cut -d= -f2 || true) [[ "$bt" == "Release" ]] && [[ -d "$P/$h/p" ]] && bin_r=true [[ "$bt" == "Debug" ]] && [[ -d "$P/$h/p" ]] && bin_d=true [[ "$bt" == "Release" ]] && [[ -d "$P/$h/b" ]] && bld_r=true [[ "$bt" == "Debug" ]] && [[ -d "$P/$h/b" ]] && bld_d=true done
# 格式:bin[R][D] / bld[R][D] bin=""; $bin_r && bin+="R" || bin+="-"; $bin_d && bin+="D" || bin+="-" bld=""; $bld_r && bld+="R" || bld+="-"; $bld_d && bld+="D" || bld+="-" [[ "$bin" == "--" ]] && bin=" " || true [[ "$bld" == "--" ]] && bld=" " || true
# --- tool --- echo "$tool_pkgs" | grep -qF "${pkg%%#*}" && tool="tool" || tool=" "
[[ -n "${src// /}" ]] && sym="✔" || sym="✘" echo "$sym [src:${src}] [bin:${bin}] [bld:${bld}] [${tool}] $pkg"
done < <(sqlite3 "$DB" "SELECT reference, path FROM recipes ORDER BY reference;")
echo "" echo "总计: $total 缺源码: $no_src" [root@rk3528-openeuler22 conan]#
|