Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: halma on February 09, 2017, 07:31:41 AM

Title: How can i check which dependency is used twice or used multiple times?
Post by: halma on February 09, 2017, 07:31:41 AM
How can i check which dependency is used twice or used multiple times?

Title: Re: How can i check which dependency is used twice or used multiple times?
Post by: theYinYeti on March 16, 2017, 09:56:29 AM
From memory (I have not TC running right now):
Code: [Select]
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…)
Title: Re: How can i check which dependency is used twice or used multiple times?
Post by: coreplayer2 on March 16, 2017, 03:50:57 PM
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
Code: [Select]
#!/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

 :)
Title: Re: How can i check which dependency is used twice or used multiple times?
Post by: theYinYeti on March 17, 2017, 12:43:05 PM
I launched TinyCore to check: I did some mistakes above. Here’s the correct one-liner:
Code: [Select]
grep -ho '^.*$' /etc/sysconfig/tcedir/optional/*.dep | sort | unid -d
Title: Re: How can i check which dependency is used twice or used multiple times?
Post by: jls on March 20, 2017, 08:45:11 AM
I launched TinyCore to check: I did some mistakes above. Here’s the correct one-liner:
Code: [Select]
grep -ho '^.*$' /etc/sysconfig/tcedir/optional/*.dep | sort | unid -d
uniq not unid
Title: Re: How can i check which dependency is used twice or used multiple times?
Post by: coreplayer2 on March 20, 2017, 12:09:37 PM
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??
Title: Re: How can i check which dependency is used twice or used multiple times?
Post by: Lee on March 20, 2017, 03:46:25 PM
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?

Code: [Select]
#!/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
Title: Re: How can i check which dependency is used twice or used multiple times?
Post by: theYinYeti on March 20, 2017, 11:50:33 PM
(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:
Code: [Select]
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