Hi mocore
It sounds like the primary objective here is to break the URL up
into its basic parts.
hi rich
the goal i had in mind was to produce function to create a some sort of consistent maping (not shore this is the best term tbh)
between a(ny) tc mirror url and *some local dir*
afair because busybox wget do not support "-x, --force-directories; -nh, –no-host-directories or –cut-dirs" ,
which is just manipulating simple strings of text !
# eg ?..
# mkdir -p $(dirname $localpath)
# wget -O$localpath $remotepath
inputs: mirror-url , local-dir-path
output local-dir-path/*relevent bits of*mirror-url
eg ~in:
http://tinycorelinux.net/13.x/x86/tcz/info.lst.gz /tmp
~out: /tmp/13.x/x86/tcz/info.lst.gz
~in:http://tinycorelinux.net/14.x/x86/tcz/src/openssh/compile_openssh /test
~out: /test/14.x/x86/tcz/src/openssh/compile_openssh
which could be used to replace an more ugly/unclear/casespesific section of mk-repo-table sh/awk function
... AND potentualy other scripts
you picked a good example !!
URL="http://SomeDomain.org/TestVersion/3.x/LinuxDistros/Tinycore/13.x/x86/tcz//info.lst.gz"
the "TestVersion/3.x" would cause problem for the vercol function
using
tr -s "/"
removes any potentual double forward slash amiguity from url's , and avoids ofseting counting due to protocall "://" adding empty column
Here is what we know about the URL:
this got me thinking , that initialy aproach this from the wrong angle
cat ./mirrors |tr -s "/" | awk '{ uri=$0; split(uri,U,"/");ul=length(U);u="";for(i=3;i<ul;i++){ u=u"/"U[i] } ; print ul,u }'
and started mulling over the above
starting with what is known the mirror urls
to aquire the number of column's/slashes of server/path section to trim from the localpath
... then build up url from other known components version / arch / , ect ( afair my mk-repo-table creates url this way)
Dir is the second to last field and always equal to tcz.
when i initaly started this topic my intention was for as much generally as posible (like wget options )
so that the function could have as few asumptions as posible about the url
eg :
http://tinycorelinux.net/13.x/x86_64/release/distribution_files/modules64.gzthe cloice of awk over sh was because awk is easyer imho to read again and grok the intent