WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How can i check which dependency is used twice or used multiple times?  (Read 3460 times)

Offline halma

  • Full Member
  • ***
  • Posts: 164
How can i check which dependency is used twice or used multiple times?

1 + 2 = 6  cause  10 - 6 = 78 ;-) lol

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
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…)

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
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

 :)

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
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

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
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
dCore user

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
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??
« Last Edit: March 20, 2017, 04:30:23 PM by coreplayer2 »

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
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
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
(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
« Last Edit: March 21, 2017, 03:57:20 AM by theYinYeti »