Tiny Core Linux
Tiny Core Extensions => TCE Talk => Topic started by: halma on February 09, 2017, 10:31:41 AM
-
How can i check which dependency is used twice or used multiple times?
-
From memory (I have not TC running right now):
cd /etc/sysconfig/tcedir/tce/optional
grep -o '^.*$' *.dep | sort | uniq -d
(the grep -o instead of cat is because some files have no LF at the end of the file…)
-
I'm surprised we haven't seen a few options to accomplish this task already :p
not elegant, but this script gets the job done also
#!/bin/sh
# show deps listed in more than one dep file
cd /etc/sysconfig/tcedir/optional
echo "" > /tmp/dupDeps
list=$(for i in *dep; do cat $i; done)
for w in $list; do
echo $w >> /tmp/chk1
done
for f in $list; do
[ $(grep -c $f /tmp/chk1) -gt 1 ] && echo $f >> /tmp/dupDeps
done
cat /tmp/dupDeps | sort -u
echo "" > /tmp/chk1
:)
-
I launched TinyCore to check: I did some mistakes above. Here’s the correct one-liner:
grep -ho '^.*$' /etc/sysconfig/tcedir/optional/*.dep | sort | unid -d
-
I launched TinyCore to check: I did some mistakes above. Here’s the correct one-liner:
grep -ho '^.*$' /etc/sysconfig/tcedir/optional/*.dep | sort | unid -d
uniq not unid
-
In my testing of both offerings so far, neither choices are accurate. :(
from a test tce directory with 600+ tcz's
As much as I luv oneliner's, it completely missed 5 deps that were listed more than twice
and the small script produced two false negatives (eg. listed 2 x deps that were actually only listed once) but didn't appear not to miss any.
Any alternatives??
-
Just out of curiosity, just a few days ago, I wrote a little script that opens each *.dep file in the tce/optional directory, reads each line and appends the basename of the dep file to a "ped" file for each dependency listed.
In the end, example.tcz.ped will have a list of every extension that depends on example.tcz - kind of the flip side of a dep file (hence the name).
I didn't keep the script around but it was trivial to write. Really, when was the last time I actually deleted anything?
#!/bin/sh
# peds - make reverse deps lists. lem 2017-03-13
#
LIST=info.lst
cat ${LIST} |while read XT ; do {
[ -f "${XT}.dep" ] || continue
cat "${XT}.dep" |while read DEP ; do {
[ "${DEP}" = "${XT}" ] && continue
echo "${XT}" >>"${DEP}.ped"
} done
} done
-
(Thanks jls for fixing the typo)
In my testing of both offerings so far, neither choices are accurate. :(
[…]
As much as I luv oneliner's, it completely missed 5 deps that were listed more than twice
Inconceivable :P
— The `grep` command basically outputs all lines from *dep files, provided there is no non-ASCII character inside (or that the locale is in accordance with the files' encoding), and provided that busybox' grep behaves as expected.
— The `sort` command… sorts this whole list
— The `uniq` command, with the -d parameter, points out lines that appear consecutively multiple times (remember that the list is sorted).
Let's make more allowance for encoding mismatches, or for busybox possible differences… Here's another try:
find /etc/sysconfig/tcedir/optional -maxdepth 1 -name '*.dep' -exec cat {} \; -exec echo \; | tr '\r' '\n' | grep -v '^$' | env LANG=C sort | env LANG=C uniq -d