cookutils view modules/cdeps @ rev 954

cook: remove package in taz/ is package not needed; modules/compressor: recompress *.zip files (for LibreOffice).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Aug 02 18:44:51 2017 +0300 (2017-08-02)
parents
children
line source
1 #!/bin/sh
2 #
3 # cdeps - module of the SliTaz Cook
4 # Copyright (C) SliTaz GNU/Linux - GNU GPL v3
5 #
7 . /usr/lib/slitaz/libcook.sh
10 # Search file in mirrored packages
12 search_file_mirror() {
13 busybox unlzma -c $DB/files.list.lzma | grep $1\$ | cut -d: -f1 | sort -u
14 }
17 # Search file in local wok packages
19 search_file_local() {
20 # existing packages have precedence over the package/taz folder
21 srch=$1
22 { for package in $(find $PKGS -name '*.tazpkg'); do
23 if [ -n "$(busybox cpio --to-stdout --quiet -i files.list < $package | \
24 grep /$srch\$)" ]; then
25 busybox cpio -i receipt < $package | fgrep PACKAGE | cut -d\" -f2
26 fi
27 done } | sort -u
28 }
31 # Ask in multiple choice
33 ask_multiple() {
34 local multiples first my_choice
35 multiples="$1"
36 first=$(echo "$multiples" | head -n1)
37 newline; _ 'Multiple choice:'; echo "$multiples"; newline
38 _ 'Select one [%s]: ' "$first"; read my_choice
39 found="${my_choice:-$first}"
40 }
43 # Search file in local cache (fast), local wok packages, mirrored packages
45 search_file() {
46 local srch cache missing
47 srch="$1"
48 cache='/var/cache/ldsearch.cache'
49 missing='/var/cache/missing.file'
50 touch $cache $missing
51 found=$(grep $srch $cache | cut -d$'\t' -f2)
52 if [ -z "$found" ]; then
53 found=$(search_file_local $srch)
54 if [ -n "$found" ]; then
55 if [ $(echo "$found" | wc -l) -gt 1 ]; then
56 ask_multiple "$found"
57 fi
58 echo -e "$srch\t$found" >> $cache
59 else
60 found=$(search_file_mirror $srch)
61 if [ -n "$found" ]; then
62 if [ $(echo "$found" | wc -l) -gt 1 ]; then
63 ask_multiple "$found"
64 fi
65 echo -e "$srch\t$found" >> $cache
66 else
67 echo "$srch" >> $missing
68 fi
69 fi
70 fi
71 }
78 if [ ! -d $WOK/$pkg/taz ]; then
79 _ 'Need to build "%s"' "$pkg"
80 exit 0
81 fi
83 title 'Checking depends'
84 lddlist='/tmp/lddlist'; touch $lddlist
85 missing='/var/cache/missing.file'
87 # find all deps using ldd
88 for exe in $(find $WOK/$pkg/taz -type f -perm +111); do
89 [ "x$(dd if=$exe bs=4 count=1 2>/dev/null)" == "xELF" ] && #"
90 ldd $exe | sed 's| ||' | cut -d' ' -f1 >> $lddlist
91 done
93 # remove exe/so duplicates
94 sort -u $lddlist > $lddlist.sorted
96 # search packages
97 for exefile in $(cat $lddlist.sorted); do
98 search_file $exefile
99 echo "$found" >> $lddlist.pkgs
100 echo -n '.'
101 done
102 echo
104 # remove packages duplicates
105 sort -u $lddlist.pkgs > $lddlist.final
106 sort -u $missing > $missing.final
107 rm -f $lddlist $lddlist.sorted $lddlist.pkgs $missing
108 exit 0