From 4268b0630532c8016997f7eead6c3b550fd3b350 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 11 Sep 2016 17:18:20 +0100 Subject: [PATCH 1/3] Fix virtual pruning by switching from state to global variable for package_deps cache --- builder | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/builder b/builder index 786fa45..2a25d3d 100755 --- a/builder +++ b/builder @@ -123,17 +123,17 @@ auto-sync = yes' > /etc/portage/repos.conf/$reponame.conf } # Input: package, depth, and atom. Package: sys-fs/foobarfs, Depth: 1 (depth of the package tree) , Atom: 1/0 (enable disable atom output) +my %package_dep_cache; sub package_deps { my $package = shift; my $depth = shift // 1; # defaults to 1 level of depthness of the tree my $atom = shift // 0; # Since we expect this sub to be called multiple times with the same arguments, cache the results - state %cache; $cache_key = "${package}:${depth}:${atom}"; - if ( !exists $cache{$cache_key} ) { - @dependencies = + if ( !exists $package_dep_cache{$cache_key} ) { + my @dependencies = qx/equery -C -q g --depth=$depth $package/; #depth=0 it's all chomp @dependencies; @@ -148,10 +148,10 @@ sub package_deps { @dependencies ); - $cache{$cache_key} = \@dependencies; + $package_dep_cache{$cache_key} = \@dependencies; } - return @{ $cache{$cache_key} }; + return @{ $package_dep_cache{$cache_key} }; } #Input: nothing @@ -178,18 +178,26 @@ sub calculate_missing { my @dependencies = package_deps( $package, $depth, 1 ); if ($prune_virtuals) { - say "[$package] Pruning dependencies of virtual packages"; my %install_dependencies = map { $_ => 1 } @dependencies; # Look for any virtuals and remove its immediate dependencies to avoid # installing multiple conflicting packages one by one - my @virtual_deps; + my @virtual_deps = (); for my $dep (@dependencies) { - push( @virtual_deps, package_deps( $dep, 1, 1 ) ) - if ( $dep =~ /^virtual\// ); + if ( $dep =~ /^virtual\// ) { + my @child_deps = package_deps($dep, 1, 1); + push( @virtual_deps, @child_deps ); + } } + + # Deduplicate the list + @virtual_deps = uniq(@virtual_deps); + + # Prune the dependencies of the virtual packages from the dependencies list for my $dep (@virtual_deps) { - $install_dependencies{$dep} = 0 if ( $dep !~ /^virtual\// ); + if ( $dep !~ /^virtual\// ) { + $install_dependencies{$dep} = 0; + } } @dependencies = grep { $install_dependencies{$_} } @dependencies; } From 6fc14f760518550d1572ae1c2e0e4b3bd91134fc Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 11 Sep 2016 17:18:49 +0100 Subject: [PATCH 2/3] Expose /vagrant from the buildbox into the docker container to aid in debugging --- sabayon-buildpackages | 1 + 1 file changed, 1 insertion(+) diff --git a/sabayon-buildpackages b/sabayon-buildpackages index ce43662..fd7f634 100755 --- a/sabayon-buildpackages +++ b/sabayon-buildpackages @@ -76,6 +76,7 @@ if [ -d "$SAB_WORKSPACE"/specs ]; then [ -e "$SAB_WORKSPACE"/specs/custom.env ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/custom.env:/opt/sabayon-build/conf/$SAB_ARCH/portage/package.env") [ -e "$SAB_WORKSPACE"/specs/custom.keywords ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/custom.keywords:/opt/sabayon-build/conf/$SAB_ARCH/portage/package.keywords/99-custom.keywords") [ -d "$SAB_WORKSPACE"/specs/env ] && docker_volumes+=(-v "$SAB_WORKSPACE/specs/env/:/opt/sabayon-build/conf/$SAB_ARCH/portage/env/") + [ -d "/vagrant" ] && docker_volumes+=(-v "/vagrant:/vagrant") fi From 632053fc2fbe53f3b63013c8f789024fb37132df Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sun, 11 Sep 2016 17:19:11 +0100 Subject: [PATCH 3/3] Print the builder docker commandline to aid in debugging --- sabayon-buildpackages | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sabayon-buildpackages b/sabayon-buildpackages index fd7f634..0786932 100755 --- a/sabayon-buildpackages +++ b/sabayon-buildpackages @@ -82,6 +82,6 @@ fi echo "Spawning the package builder container for '$@'." echo "" -#echo "docker run $DOCKER_OPTS ${docker_env[@]} ${docker_volumes[@]} $DOCKER_IMAGE $@" +echo "docker run $DOCKER_OPTS \"${docker_env[@]}\" \"${docker_volumes[@]}\" $DOCKER_IMAGE $@" docker run $DOCKER_OPTS "${docker_env[@]}" "${docker_volumes[@]}" $DOCKER_IMAGE $@