On 09/18/2011 06:40 AM, Stuart Hughes wrote:
> Hi Peter,
>
> There are currently only 2 mechanisms for inter-package dependencies
> right now. You probably know already, but for others' benefit:
>
> 1. The static .lkc stuff where in the packages.lkc you say for example:
>
> config PKG_BLUEZ_HCIDUMP
>     depends CAP_HAS_MMU
>     bool "bluez-hcidump"
>     select PKG_BLUEZ_LIBS
>
> This means if you select bluez-hcidump during configuration, it will
> also turn-on (select)  PKG_BLUEZ_LIBS.
>
> 2. Inside of the ltib script, there are also data-structures:
>
> # package config dependencies
> # re-build the key (lhs) if any of the dependents (rhs) in the list have
> changed
> $config_deps = {
>
> # package build dependencies
> # rebuild all packages in the list (rhs) if the key (lhs) has been installed
> $build_deps = { PKG_KERNEL => [ qw/PKG_MODEPS/ ],
>
> # packages install dependencies
> # re-install all the pkgs in the list (rhs) if the key (lhs) has been
> installed
> $install_deps = { PKG_SKELL => [ qw/PKG_SYSCONFIG/ ],
>                   PKG_BUSYBOX => [ qw/PKG_INETUTILS PKG_SYSKLOGD
>
> I think  you're referring to 2.
>
> It would be better to somehow bring those out to an external file and
> also be able to specify per-platform overrides/additions.
>
> I don't think it would be that hard, but it would take some time if you
> include all the testing etc that needs to be done.
>
> If you fancy trying to implement this, that would be good.  To start you
> could do something simple/hacky like including a file (perl data
> structure) as a string (if it exists) and then merging the data into the
> relevant global structures.
>
> So, for example you could have:
>
> config/platform/_target_/package_deps.pl, with something like:
>
> $config_deps = { };
> $build_deps = { };
> $install_deps = {};
>
> Of course, fill out your data structure with some content.  Then in the
> perl script say:
>
> if ( my $res = do "config/platform/_target_/package.pl@ ) {
>   _merge_results_into_globals_
> }
>
> I wish I had more time to try this out, but too busy right now.  A good
> idea though and be great if you could add this.
>
> Regards, Stuart

Stuart, sorry its taken so long to get to this but I've finally had some
time to cobble together the ability to have platform-specific package
dependencies...

Here's an example config/platform/<platform>/package-dep.pl I use:

#
# Following is a hash of hashes, pulled into LTIB via a "do" statement;
# last expression is what is returned (and is expected to be a hash).
#
# Format is top-level hash of CONFIG_DEPS, BUILD_DEPS, INSTALL_DEPS,
# each a hash of package keys with array values (containing quoted
# package keys) that are merged into $config_deps, $build_deps,
# and $install_deps respectively.
#
{
    CONFIG_DEPS => {
           PKG_X_LOADER => [ qw/X_LOADER_CONFIG_TYPE PKG_X_LOADER_BUILD_ARGS
                                X_LOADER_REPOSITORY X_LOADER_SVN_BUILD
                                X_LOADER_SCM_HEAD X_LOADER_SCM_BRANCH
                                X_LOADER_GIT_BUILD
                                X_LOADER_SCM_SKIP_UPDATE
BSP_RELEASE_LEVEL/ ],
           PKG_U_BOOT => [ qw/BOOTLOADER_SCM_HEAD BOOTLOADER_SCM_BRANCH
                                BOOTLOADER_GIT_BUILD
                                BOOTLOADER_SVN_BUILD
BOOTLOADER_SCM_RESPOITORY
                                BSP_RELEASE_LEVEL/ ],
           PKG_KERNEL => [ qw/KERNEL_SVN_BUILD KERNEL_GIT_BUILD
                                KERNEL_SCM_REPOSITORY KERNEL_SCM_SKIP_UPDATE
                                KERNEL_SCM_HEAD KERNEL_SCM_BRANCH
                                BSP_RELEASE_LEVEL/ ],
    },
};

Attached is a patch to current LTIB to do this.  My perl fu isn't much
better than it was a year ago so there's probably a better way to solve
this, but at least it works...  Hope you find it useful; I can see
extending this further to have the userspace package dependencies in
config/usrspace/package_dep.pl.

>
>
>
>
> On 16/09/11 19:41, Peter Barada wrote:
>> Stuart,
>>
>> Is there an easy way to add a dependency between packages into LTIB? 
>> Currently its hard-coded into the ltib perl script and I was wondering
>> if there's a way to have the ltib script include an optional script
>> from the platform directory (before it goes off building packages) to
>> allow a platform to specify inter-package dependencies?
>>
>> In my world I have modules/packages that depend on the kernel (and
>> each other) and figure its a lot easier to have those dependencies be
>> corralled into the platform directory as opposed to being in the ltib
>> script itself.
>>
>> I'll be glad to try out stuff, but as my perl fu is pretty weak some
>> guidance/suggestions are appreciated.
>>
>> Thanks in advance!
>>
> _______________________________________________
> LTIB home page: http://ltib.org
>
> Ltib mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/ltib


-- 
Peter Barada
[email protected]

*** ltib.~1.88.~	2012-07-23 08:44:40.000000000 -0400
--- ltib	2012-09-28 16:35:12.865806002 -0400
***************
*** 567,572 ****
--- 567,651 ----
  # get/set the platform directory
  $cf->{plat_dir} = get_plat_dir() or die;
  
+ # Pull in platform dependencies and merge them in.  Note that the platform
+ # dependency file is pulled in with "do", so the last expression in the file
+ # needs to be a hash that contains (optional) keys CONFIG_DEP, BUILD_DEP,
+ # and INSTALL_DEP, each a hash that contain package keys and values that are
+ # an array of package keys.
+ use List::MoreUtils qw/ uniq /;
+ 
+ sub merge_dependencies
+ {
+     my ($pkg_dep, $config_dep) = @_;
+     my $x;
+     my @arry1;
+     my @arry2;
+     my @arry3;
+ 
+     if ( $pkg_dep ) {
+ 	foreach my $k ( keys %$pkg_dep ) {
+ #	    print "Key: [$k]\n";
+ 	    @arry1 = @{$pkg_dep->{$k}};
+ 	    if( exists $config_dep->{$k} ) {
+ #		print "Merge key [$k] into config_dep:\n";
+ 		@arry2 = @{$config_dep->{$k}};
+ 
+ #		print "arry1: @arry1\n";
+ #		print "arry2: @arry2\n";
+ 
+ 		@arry3 = ( @{$pkg_dep->{$k}}, @{$config_dep->{$k}});
+ 		@arry3 = uniq (@arry3);
+ #		print "arry3: @arry3\n";
+ 		@{$config_dep->{$k}} = uniq ( @arry3 );
+ 	    } else {
+ 		$config_dep->{$k} = $pkg_dep->{$k};
+ 	    }
+ 
+ #	    @arry1 = @{$config_dep->{$k}};
+ #	    $x = scalar (@arry1);
+ #	    print "arry1 length: $x\n";
+ 
+ #	    foreach my $k2 ( @arry1 ) {
+ #		print "Entry [$k2]\n";
+ #	    }
+ 	}
+     }
+ }
+ 
+ sub dump_dependency
+ {
+     my ($dep) = @_;
+ 
+     if ($dep) {
+ 	foreach my $k (keys %$dep) {
+ 	    my @arry = @{$dep->{$k}};
+ 	    print "$k: @arry\n";
+ 	}
+     }
+ }
+ 
+ sub get_platform_dependencies
+ {
+     my $package_deps;
+     my $pdef_file = "$cf->{plat_dir}/platform_dep.pl";
+ 
+     $package_deps = do "$pdef_file";
+     warn "Couldn't parse $pdef_file" if $@;
+ #    warn "Couldn't do $pdef_file" unless defined $package_deps;
+ #    warn "Couldn't run $pdef_file" unless $package_deps;
+ 
+     if (defined($package_deps)) {
+ 	print "merging platform package dependencies from $cf->{plat_dir}\n";
+ 	merge_dependencies($package_deps->{CONFIG_DEPS}, $config_deps);
+ 	merge_dependencies($package_deps->{BUILD_DEPS}, $build_deps);
+ 	merge_dependencies($package_deps->{INSTALL_DEPS}, $install_deps);
+     }
+ 
+     # dump_dependency($config_deps);
+ }
+ 
+ get_platform_dependencies();
+ 
  my @rl = build_root_list();
  foreach my $n (reverse @rl) {
      print "\nProcessing root number: ", $n+1, " of ", $#rl+1, "\n",
_______________________________________________
LTIB home page: http://ltib.org

Ltib mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/ltib

Reply via email to