WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: depfinder: script to find dependencies  (Read 191 times)

Offline halma

  • Jr. Member
  • **
  • Posts: 59
depfinder: script to find dependencies
« on: September 04, 2014, 04:35:13 PM »
Hi,
i spent much time to get this pice of code working, may somebody else can need this, this pice of code will download the Extention himself and if present/avaible also the dependencies.
Easy to use: just input your Extention inside the code at top, without ending(s), like this for midnight commader: "EXTENSIONS=(mc)", not with .tcz*, its also possible to input more then one Extention to find like as example midnight commander and firefox will result in "EXTENSIONS=(mc firefox)"

its just code for my own soany suggestions are welcome :)

last update 05.Sep.2014 version:0.1a
Code: [Select]
#!/usr/bin/env bash
#
#
#dependencie finder v0.1a (c)Halma ~ Tinycoreforum 05.Sep.2014
#
#with this script you can find every dependencie of an extention if exists.
#
#Thanks goes to: tinypoodle,Misalf
#
#
EXTENSIONS=(mc) #put your extentions,like (mc) or for more (extention1 extention2 ext...), inside the Clips (your extention.without ending)
MIRROR="distro.ibiblio.org/tinycorelinux/5.x/x86_64/tcz" #the mirror for the extention if not on harddrive
DESTDIR=/tmp/testt #your destination directory where to save the extentions
#
#
#DO NOT CHANGE ANYTHING AFTER THIS LINE
#
#
#set -x
declare -a EXTENSIONS  # indexed array
declare -a ALLEXTENSIONS #all extensions ever added

ALLEXTENSIONS=()
EXTENSIONFILESSOURCE=/etc/sysconfig/tcedir/optional #thanks Misalf http://forum.tinycorelinux.net/index.php/topic,17454.msg104621.html#msg104621

[ -d $DESTDIR ] && rm -rf $DESTDIR
mkdir -p $DESTDIR

count=0
function1 () {

#first get the .dep file to parse
for A in ${EXTENSIONS[@]}; do
    if [ ! -f $DESTDIR/$A.tcz.dep ];then
wget $MIRROR/$A.tcz.dep -O $DESTDIR/$A.tcz.dep || rm -f $DESTDIR/$A.tcz.dep
    fi
done

for i in ${EXTENSIONS[@]}; do
    echo "start...."$count
    #if the extention has an .dep file
    if [ -f $DESTDIR/$i.tcz.dep ];then #if .dep file exists write it into an array
echo "current dep: "$i
#put new deps into array-elements
for j in $(cat $DESTDIR/$i.tcz.dep | sed -r 's/\.tcz+$//') ; do
    #check that the extention isnt allready in the ALLEXTTENSIONS array
    for h in ${ALLEXTENSIONS[@]}; do

#if $j allready exists in $ALLEXTENSIONS[@] ,skip it
if [ "$j" == "$h" ]; then
    echo "skipping: "$j
j=""
fi
    done
    echo "add dep: "$j
    EXTENSIONS+=($j)
    ALLEXTENSIONS+=($j)
done
    fi
#copy the extention files
echo "copying: "$i

for K in $i.{tcz.dep,tcz.md5.txt,tcz}; do
    if [ -f "$EXTENSIONFILESSOURCE/$K" ]; then
echo "copying :"$K
cp -f $EXTENSIONFILESSOURCE/$K $DESTDIR
    else
echo "wget ---->" $K
wget $MIRROR/$K -O $DESTDIR/$K || rm -f $DESTDIR/$K
    fi
done

#fi
echo "delete: "$i
        unset EXTENSIONS[0] #remove current array-element from array
EXTENSIONS=( "${EXTENSIONS[@]}" ) #(re)set the array
((count=count+1))
done

}

while [ $(echo ${#EXTENSIONS[@]}) -gt 0 ] ; do
echo "calle function1"
function1
done
echo ""
echo "---------"
echo "- Done! -"
echo "---------"


have phun

« Last Edit: September 05, 2014, 04:06:14 AM by halma »
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 3389
Re: depfinder: script for find dependencies
« Reply #1 on: September 04, 2014, 04:41:15 PM »
tce-load -w mc extension2 extension3

Offline halma

  • Jr. Member
  • **
  • Posts: 59
Re: depfinder: script for find dependencies
« Reply #2 on: September 04, 2014, 04:54:37 PM »
with the script above you get all needed file/s (extention+depencies) to the location as you like, your command just put all into the main tce downoad folder and its not comfortable of my usages needs, mixing files toghter... needed and unneed if you use the main tce download folder
if you like to build an Image Based Tinycore, i mean Image Based for me is.... 1)create a partition, 2)add extlinux/mbr and bootstuff .kernel, rootfs etc, 3)add extension,4)set your personal configuration
copy the image to an USB Drive and have phun , thats why i build this script
best regards
« Last Edit: September 04, 2014, 04:57:11 PM by halma »
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3840
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Misalf

  • Sr. Member
  • ****
  • Posts: 332
Re: depfinder: script to find dependencies
« Reply #4 on: September 05, 2014, 03:26:13 AM »
Code: [Select]
EXTENSIONFILESSOURCE=/etc/sysconfig/tcedir/optional

Offline halma

  • Jr. Member
  • **
  • Posts: 59
Re: depfinder: script to find dependencies
« Reply #5 on: September 05, 2014, 03:55:27 AM »
hi tinypoodle and Misalf

very good ideas ;)
script updated to v0.1a :-)

thanks
best regards
« Last Edit: September 05, 2014, 04:04:33 AM by halma »
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol

Online bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 4901
    • My Community Forum
Re: depfinder: script to find dependencies
« Reply #6 on: September 05, 2014, 07:50:39 AM »
Repository hardcoded to ibiblio.org while primary repo is repo.tinycorelinux.net However the best is to use system setting from /opt/tcemirror

Also system type (x86_64) is hard coded. It can be a command line setting in the script if one is downloding extensions for a different architecture or set automatically to the host type, see getBuild() in /etc/init.d/tc-functions
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Pats

  • Full Member
  • ***
  • Posts: 177
Re: depfinder: script to find dependencies
« Reply #7 on: September 08, 2014, 03:26:06 AM »
Hi halma,

Many have provided diff versions of their own downloader scripts previously.
tinypoodle has already pointed to one such discusion.

/opt/tcemirror contains the repo name from where you can download the extensions.
Boot code tce= can be altered to local download dire. name of your choice.
Also you can choose any mirror provided in the AppBrowser's Mirror option for faster downloads.

Also as suggested by bmarkus, instead of hard-coding the ooptions like 86_64 or the repo, it will be better to provide for command line options, so that your script can be useful for many others.

One more thing, curaga has provided one nice commandline tool for such purpose - AppBrowserCli.tcz or something like that - maybe in TC3.5 repo, which output some useful Warnings and messages. You may check it to fine-tune your script.

But I appriciate your hard-work and own efforts, to custom-build the script for your own needs. That is true Linux Spirit.
Best Luck.