script to recursively check for and select dependencies
- by rp.sullivan
I have written a script that does this but it is one of my first scripts ever so i am sure there is a better way:)
Let me know how you would go about doing this.
I'm looking for a simple yet efficient way to do this.
Here is some important background info:
( It might be a little confusing but hopefully by the end it will make sense. )
1) This image shows the structure/location of the relevant dirs and files.
2) The packages.file located at ./config/default/config/packages is a space delimited file.
field5 is the "package name" which i will call $a for explanations sake.
field4 is the name of the dir containing the $a.dir i will call $b
field1 shows if the package is selected or not,
"X"(capital x) for selected and "O"(capital o as in orange) for not selected.
Here is an example of what the packages.file might contain:
...
X ---3------ 104.800 database gdbm 1.8.3 / base/library CROSS 0
O -1---5---- 105.000 base libiconv 1.13.1 / base/tool CROSS 0
X 01---5---- 105.000 base pkgconfig 0.25 / base/tool CROSS 0
X -1-3------ 105.000 base texinfo 4.13a / base/tool CROSS DIETLIBC 0
O -----5---- 105.000 develop duma 2_5_15 / base/development CROSS NOPARALLEL 0
O -----5---- 105.000 develop electricfence 2_4_13 / base/development CROSS 0
O -----5---- 105.000 develop gnupth 2.0.7 / extra/development CROSS NOPARALLEL FPIC-QUIRK 0
...
3) For almost every package listed in the "packages.file" there is a corresponding ".cache file"
The .cache file for package $a would be located at ./package/$b/$a/$a.cache
The .cache files contain a list of dependencies for that particular package.
Here is an example of one of the .cache files might look like.
Note that the dependencies are field2 of lines containing "[DEP]"
These dependencies are all names of packages in the "package.file"
[TIMESTAMP] 1134178701 Sat Dec 10 02:38:21 2005
[BUILDTIME] 295 (9)
[SIZE] 11.64 MB, 191 files
[DEP] 00-dirtree
[DEP] bash
[DEP] binutils
[DEP] bzip2
[DEP] cf
[DEP] coreutils
...
So with all that in mind...
I'm looking for a shell script that:
From within the "main dir"
Looks at the ./config/default/config/packages file
and finds the "selected" packages
and reads the corresponding .cache
Then compiles a list of dependencies that excludes the already selected packages
Then selects the dependencies (by changing field1 to X) in the ./config/default/config/packages file
and repeats until all the dependencies are met
Note: The script will ultimately end up in the "scripts dir" and be called from the "main dir".
If this is not clear let me know what need clarification.
For those interested I'm playing around with T2 SDE.
If you are into playing around with linux it might be worth taking a look.