Tiny Core Linux
General TC => Programming & Scripting - Unofficial => Topic started by: halma on September 04, 2014, 08: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
#!/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
-
tce-load -w mc extension2 extension3
-
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
-
See also
http://forum.tinycorelinux.net/index.php/topic,17106.msg102657.html#msg102657
-
EXTENSIONFILESSOURCE=/etc/sysconfig/tcedir/optional
-
hi tinypoodle and Misalf
very good ideas ;)
script updated to v0.1a :-)
thanks
best regards
-
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
-
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.
-
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
./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
-
@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
$ version
8.1.5
For older TCL look in the share/doc/tc folder for the release text file to get the version number.
-
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.
-
That makes much more sense; thank you for clarifying!
-
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.
-
For
tc@box:/home/tc# sh ./dependencie_finder2_V0.1c.sh -d openjdk-8-jdk/ -e openjdk-8-jdk.tcz
Generating error
./dependencie_finder2_V0.1c.sh: line 72: declare: not found
./dependencie_finder2_V0.1c.sh: line 73: declare: not found
./dependencie_finder2_V0.1c.sh: line 75: syntax error: unexpected "("
-
Hi ipmeel
Do you have bash.tcz installed?
-
Hi Rich,
Yes, I have installed bash.tcz. Still same errors are there.
./dependencie_finder2_V0.1c.sh: line 72: declare: not found
./dependencie_finder2_V0.1c.sh: line 73: declare: not found
./dependencie_finder2_V0.1c.sh: line 75: syntax error: unexpected "("
-
Hi ipmeel
Based on those errors it sounds like either bash.tcz is not loaded or it's not being found. Do you get a response for:
which bash
-
Hi Rich,
the output of 'which bash'
/usr/local/bin/bash
-
Hi Rich,
It was my mistake. Now made the file executable...
$ sudo chmod +x dependencie_finder2_V0.1c.sh
Now script is executing with message
---------
- Done! -
---------
but nothing is downloaded!
-
Hi Rich,
Now it is working well, thanks! The extension .tcz should not be used in command line.
So, I changed the command from...
tc@box:/home/tc# sh ./dependencie_finder2_V0.1c.sh -d openjdk-8-jdk/ -e openjdk-8-jdk.tcz
to
tc@box:/home/tc# sh ./dependencie_finder2_V0.1c.sh -d openjdk-8-jdk/ -e openjdk-8-jdk