cookutils diff modules/cdeps @ rev 950
cook: dot command may not search current directory first
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jul 23 12:35:12 2017 +0200 (2017-07-23) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/modules/cdeps Sun Jul 23 12:35:12 2017 +0200 1.3 @@ -0,0 +1,108 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# cdeps - module of the SliTaz Cook 1.7 +# Copyright (C) SliTaz GNU/Linux - GNU GPL v3 1.8 +# 1.9 + 1.10 +. /usr/lib/slitaz/libcook.sh 1.11 + 1.12 + 1.13 +# Search file in mirrored packages 1.14 + 1.15 +search_file_mirror() { 1.16 + busybox unlzma -c $DB/files.list.lzma | grep $1\$ | cut -d: -f1 | sort -u 1.17 +} 1.18 + 1.19 + 1.20 +# Search file in local wok packages 1.21 + 1.22 +search_file_local() { 1.23 + # existing packages have precedence over the package/taz folder 1.24 + srch=$1 1.25 + { for package in $(find $PKGS -name '*.tazpkg'); do 1.26 + if [ -n "$(busybox cpio --to-stdout --quiet -i files.list < $package | \ 1.27 + grep /$srch\$)" ]; then 1.28 + busybox cpio -i receipt < $package | fgrep PACKAGE | cut -d\" -f2 1.29 + fi 1.30 + done } | sort -u 1.31 +} 1.32 + 1.33 + 1.34 +# Ask in multiple choice 1.35 + 1.36 +ask_multiple() { 1.37 + local multiples first my_choice 1.38 + multiples="$1" 1.39 + first=$(echo "$multiples" | head -n1) 1.40 + newline; _ 'Multiple choice:'; echo "$multiples"; newline 1.41 + _ 'Select one [%s]: ' "$first"; read my_choice 1.42 + found="${my_choice:-$first}" 1.43 +} 1.44 + 1.45 + 1.46 +# Search file in local cache (fast), local wok packages, mirrored packages 1.47 + 1.48 +search_file() { 1.49 + local srch cache missing 1.50 + srch="$1" 1.51 + cache='/var/cache/ldsearch.cache' 1.52 + missing='/var/cache/missing.file' 1.53 + touch $cache $missing 1.54 + found=$(grep $srch $cache | cut -d$'\t' -f2) 1.55 + if [ -z "$found" ]; then 1.56 + found=$(search_file_local $srch) 1.57 + if [ -n "$found" ]; then 1.58 + if [ $(echo "$found" | wc -l) -gt 1 ]; then 1.59 + ask_multiple "$found" 1.60 + fi 1.61 + echo -e "$srch\t$found" >> $cache 1.62 + else 1.63 + found=$(search_file_mirror $srch) 1.64 + if [ -n "$found" ]; then 1.65 + if [ $(echo "$found" | wc -l) -gt 1 ]; then 1.66 + ask_multiple "$found" 1.67 + fi 1.68 + echo -e "$srch\t$found" >> $cache 1.69 + else 1.70 + echo "$srch" >> $missing 1.71 + fi 1.72 + fi 1.73 + fi 1.74 +} 1.75 + 1.76 + 1.77 + 1.78 + 1.79 + 1.80 + 1.81 +if [ ! -d $WOK/$pkg/taz ]; then 1.82 + _ 'Need to build "%s"' "$pkg" 1.83 + exit 0 1.84 +fi 1.85 + 1.86 +title 'Checking depends' 1.87 +lddlist='/tmp/lddlist'; touch $lddlist 1.88 +missing='/var/cache/missing.file' 1.89 + 1.90 +# find all deps using ldd 1.91 +for exe in $(find $WOK/$pkg/taz -type f -perm +111); do 1.92 + [ "x$(dd if=$exe bs=4 count=1 2>/dev/null)" == "xELF" ] && #" 1.93 + ldd $exe | sed 's| ||' | cut -d' ' -f1 >> $lddlist 1.94 +done 1.95 + 1.96 +# remove exe/so duplicates 1.97 +sort -u $lddlist > $lddlist.sorted 1.98 + 1.99 +# search packages 1.100 +for exefile in $(cat $lddlist.sorted); do 1.101 + search_file $exefile 1.102 + echo "$found" >> $lddlist.pkgs 1.103 + echo -n '.' 1.104 +done 1.105 +echo 1.106 + 1.107 +# remove packages duplicates 1.108 +sort -u $lddlist.pkgs > $lddlist.final 1.109 +sort -u $missing > $missing.final 1.110 +rm -f $lddlist $lddlist.sorted $lddlist.pkgs $missing 1.111 +exit 0