WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline halma

  • Jr. Member
  • **
  • Posts: 96
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: 4231
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: 96
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: 3857
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1529
Re: depfinder: script to find dependencies
« Reply #4 on: September 05, 2014, 03:26:13 AM »
Code: [Select]
EXTENSIONFILESSOURCE=/etc/sysconfig/tcedir/optional
Download a copy and keep it handy: Core book ;)

Offline halma

  • Jr. Member
  • **
  • Posts: 96
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

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 6897
    • 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.

Offline halma

  • Jr. Member
  • **
  • Posts: 96
Re: depfinder: script to find dependencies
« Reply #8 on: February 11, 2017, 10:45:28 PM »
I changed the code from the script so now you can use this script for all Tinycore Versions and Build/Arch, given by command line argument

Code: [Select]
./dependencie_finder2_pub.sh
no extension was given..
Usage: ./dependencie_finder2_pub.sh [arguments]

Arguments:
  -b, --build                Sets the build/arch, if not set the system default will be used
                             system default: x86_64
  -d, --destdir              Sets the Destination Directory, if not set the system default will be used
                             system default: /etc/sysconfig/tcedir/optional
  -e, --extension            Which extention/s you want, if you want two like mc and bash use -e mc bash
  -m, --mirror               Sets the tinycore repository, if not set the system default will be used
                             system default: ftp://192.168.234.123/6.x/x86_64/tcz
  -s, --extensionfilesource  Sets the location of the extensionfiles, if not set the system default will be used
                             system default: /etc/sysconfig/tcedir/optional
  -v, --majorversion         Sets the MajorVerion, if not set the system default will be used
                             system default: 6

Example: get a extension for Tinycore 5x x86 -e mc, commandline would be:
./dependencie_finder2_pub.sh -b x86 -v5 -d /tmp/destionationfolder

Example: get a extension for Tinycore 7x x86_64 -e mc, commandline would be:
./dependencie_finder2_pub.sh -b x86_64 -v7 -d /tmp/destionationfolder

ideas and suggestions are welcome.
Halma
« Last Edit: February 11, 2017, 10:47:40 PM by halma »
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol

Offline centralware

  • Full Member
  • ***
  • Posts: 234
Re: depfinder: script to find dependencies
« Reply #9 on: February 13, 2017, 02:03:19 AM »
@halma:
-b should default to the running version as opposed to assuming x86_64 (ie: uname -m)
-v I assume is the repo version; this should not be hard-coded to "6" but in fact can easily be scripted
Code: [Select]
$ version
8.1.5
For older TCL look in the share/doc/tc folder for the release text file to get the version number.

Offline halma

  • Jr. Member
  • **
  • Posts: 96
Re: depfinder: script to find dependencies
« Reply #10 on: February 14, 2017, 03:25:46 AM »
hi centralware,

if you use the script without any arguments, just one argument given for the extension(-e), you will get the extension for your system in Build/Arch and Version, the script automatic himself using the Build/Arch and Version on which system your are working on, in my case i still run Version 6.4 and thats may confusing someone if i say, default is 6, if you are working on Version 8 and Build/Arch is x64_86, the script should get all the arguments for your actual running system.

« Last Edit: February 14, 2017, 03:27:20 AM by halma »
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol

Offline centralware

  • Full Member
  • ***
  • Posts: 234
Re: depfinder: script to find dependencies
« Reply #11 on: February 14, 2017, 04:44:20 AM »
That makes much more sense; thank you for clarifying!

Offline halma

  • Jr. Member
  • **
  • Posts: 96
Re: depfinder: script to find dependencies
« Reply #12 on: February 16, 2017, 03:35:18 AM »
bugfix update to Version 0.1c

the argument "-e" did not take the minus character correctly, on version 01.b (pcre-dev) gets only (pcre) :(
now version 0.1c will get (pcre-dev) correct.
1 + 2 = 6  cause  10 - 6 = 78 ;-) lol