Compare commits

..

9 Commits

Author SHA1 Message Date
mudler 320f75cd46 [sabayon-buildpackages] supporting EMERGE_SPLIT_INSTALL 2016-03-23 00:19:56 +01:00
mudler e9c671b65e [builder] adding EMERGE_SPLIT_INSTALL 2016-03-23 00:19:04 +01:00
mudler e07cb53932 [sabayon-createrepo-cleanup sabayon-createrepo-remove] respect DOCKER_OPTS 2016-03-22 14:35:57 +01:00
Ettore Di Giacinto 51d7bdc968 Merge pull request #7 from optiz0r/feature_package_deps_cache
Add brackets to uniq to fix compilation error
2016-03-21 21:59:19 +01:00
Ben Roberts 79d3d5d4b5 Add brackets to uniq to fix compilation error 2016-03-21 20:54:57 +00:00
Ettore Di Giacinto 2c05cdce52 Merge pull request #6 from optiz0r/feature_package_deps_cache
Cache results of package_deps and re-enable virtual dep stripping
2016-03-20 21:01:57 +01:00
Ben Roberts a55856cb97 Revert to using locally defined uniq 2016-03-20 19:59:56 +00:00
Ben Roberts 967cd9708a Cache results of package_deps and re-enable virtual dep stripping
It's likely that some virtuals are dependencies of multiple package arguments
to builder and the depgraph would be queried multiple times. This commit
caches the results to avoid expensive duplicate shell execs and optimise for
speed.

Additionally, when calls to equery depgraph match multiple packages (e.g.
the query is for an unversioned atom, and multiple versions exist in the
portage tree), the results for all versions are returned, resulting in
duplicates. This change also strips out the duplicate entries so further
work need only be done once.

This uses perl 5.10's `state` variables, so adds the appropriate use. Since
Sabayon ships only perl 5.20, this should not be an issue.
2016-03-20 19:43:20 +00:00
mudler 566e4603c8 [sabayon-createrepo] sign won't return true also if succeeds but repos have to be synced 2016-03-18 17:53:38 +01:00
5 changed files with 57 additions and 21 deletions
+49 -16
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env perl #!/usr/bin/env perl
use Getopt::Long; use Getopt::Long;
use v5.10;
my $profile = $ENV{BUILDER_PROFILE} // 3; my $profile = $ENV{BUILDER_PROFILE} // 3;
my $jobs = $ENV{BUILDER_JOBS} // 1; my $jobs = $ENV{BUILDER_JOBS} // 1;
@@ -19,6 +20,7 @@ my $entropy_repository = $ENV{ENTROPY_REPOSITORY} // "main"; # Can be weekly
my $artifacts_folder = $ENV{ARTIFACTS_DIR}; my $artifacts_folder = $ENV{ARTIFACTS_DIR};
my $dep_scan_depth = $ENV{DEPENDENCY_SCAN_DEPTH} // 2; my $dep_scan_depth = $ENV{DEPENDENCY_SCAN_DEPTH} // 2;
my $skip_portage_sync = $ENV{SKIP_PORTAGE_SYNC} // 0; my $skip_portage_sync = $ENV{SKIP_PORTAGE_SYNC} // 0;
my $emerge_split_install = $ENV{EMERGE_SPLIT_INSTALL} // 0;
my $webrsync = $ENV{WEBRSYNC} // 0; my $webrsync = $ENV{WEBRSYNC} // 0;
my $make_conf = $ENV{MAKE_CONF}; my $make_conf = $ENV{MAKE_CONF};
@@ -42,9 +44,29 @@ sub package_deps {
my $package = shift; my $package = shift;
my $depth = shift // 1; # defaults to 1 level of depthness of the tree my $depth = shift // 1; # defaults to 1 level of depthness of the tree
my $atom = shift // 0; my $atom = shift // 0;
return
map { $_ =~ s/\[.*\]|\s//g; &atom($_) if $atom; $_ } # Since we expect this sub to be called multiple times with the same arguments, cache the results
qx/equery -C -q g --depth=$depth $package/; #depth=0 it's all state %cache;
$cache_key = "${package}:${depth}:${atom}";
if ( ! exists $cache{$cache_key} ) {
@dependencies = qx/equery -C -q g --depth=$depth $package/; #depth=0 it's all
chomp @dependencies;
# If an unversioned atom is given, equery returns results for all versions in the portage tree
# leading to duplicates. The sanest thing to do is dedup the list. This gives the superset of all
# possible dependencies, which isn't perfectly accurate but should be good enough. For completely
# accurate results, pass in a versioned atom.
@dependencies = uniq(
sort
grep { $_ }
map { $_ =~ s/\[.*\]|\s//g; &atom($_) if $atom; $_ }
@dependencies);
$cache{$cache_key} = \@dependencies;
}
return @{ $cache{$cache_key} };
} }
#Input: nothing #Input: nothing
@@ -71,18 +93,17 @@ sub calculate_missing {
say "[$package] Getting the package dependencies and the installed packages"; say "[$package] Getting the package dependencies and the installed packages";
my @dependencies = package_deps( $package, $depth, 1 ); my @dependencies = package_deps( $package, $depth, 1 );
# XXX: Endless loop as for now. my %install_dependencies = map { $_ => 1 } @dependencies;
# my %install_dependencies = map { $_ => 1 } @dependencies; # Look for any virtuals and remove its immediate dependencies to avoid
# # Look for any virtuals and remove its immediate dependencies to avoid # installing multiple conflicting packages one by one
# # installing multiple conflicting packages one by one my @virtual_deps;
# my @virtual_deps; for my $dep (@dependencies) {
# for my $dep (@dependencies) { push(@virtual_deps, package_deps( $dep, 1, 1 )) if ( $dep =~ /^virtual\// );
# push(@virtual_deps, package_deps( $dep, 1, 1 )) if ( $dep =~ /^virtual\// ); }
# } for my $dep (@virtual_deps) {
# for my $dep (@virtual_deps) { $install_dependencies{$dep} = 0 if ( $dep !~ /^virtual\// );
# $install_dependencies{$dep} = 0 if ( $dep !~ /^virtual\// ); }
# } @dependencies = grep { $install_dependencies{$_} } @dependencies;
# @dependencies = grep { $install_dependencies{$_} } @dependencies;
#taking only the 4th column of output as key of the hashmap #taking only the 4th column of output as key of the hashmap
my %installed_packs = my %installed_packs =
@@ -93,7 +114,7 @@ sub calculate_missing {
my @to_install = grep( defined $available_packs{$_}, my @to_install = grep( defined $available_packs{$_},
uniq( grep( !defined $installed_packs{$_}, @dependencies ) ) ); uniq( grep( !defined $installed_packs{$_}, @dependencies ) ) );
@to_install=grep { length } @to_install; @to_install=grep { length } @to_install;
# say "[$package] packages that will be installed with equo: @to_install" if @to_install>0; say "[$package] packages that will be installed with equo: @to_install" if @to_install>0;
return @to_install; return @to_install;
} }
@@ -238,6 +259,18 @@ if ($use_equo) {
say "* Ready to compile, finger crossed"; say "* Ready to compile, finger crossed";
my $rt;
if ($emerge_split_install) {
for my $pack (@packages){
my $tmp_rt=system("emerge $emerge_defaults_args -j $jobs $pack");
$rt=$tmp_rt if ($? == -1 or $? & 127 or !$rt); # if one fails, the build should be considered failed!
}
}
else {
$rt = system("emerge $emerge_defaults_args -j $jobs @packages");
}
my $rt = system("emerge $emerge_defaults_args -j $jobs @packages"); my $rt = system("emerge $emerge_defaults_args -j $jobs @packages");
my $return = $rt >> 8; my $return = $rt >> 8;
+1
View File
@@ -24,6 +24,7 @@ docker_volumes=( -v "$OUTPUT_DIR:/usr/portage/packages" )
[ -z "$PORTAGE_CACHE" ] || docker_volumes+=(-v "$PORTAGE_CACHE:/usr/portage") [ -z "$PORTAGE_CACHE" ] || docker_volumes+=(-v "$PORTAGE_CACHE:/usr/portage")
[ -z "$BUILDER_PROFILE" ] || docker_env+=(-e "BUILDER_PROFILE=$BUILDER_PROFILE") [ -z "$BUILDER_PROFILE" ] || docker_env+=(-e "BUILDER_PROFILE=$BUILDER_PROFILE")
[ -z "$EMERGE_SPLIT_INSTALL" ] || docker_env+=(-e "EMERGE_SPLIT_INSTALL=$EMERGE_SPLIT_INSTALL")
[ -z "$BUILDER_JOBS" ] || docker_env+=(-e "BUILDER_JOBS=$BUILDER_JOBS") [ -z "$BUILDER_JOBS" ] || docker_env+=(-e "BUILDER_JOBS=$BUILDER_JOBS")
[ -z "$USE_EQUO" ] || docker_env+=(-e "USE_EQUO=$USE_EQUO") [ -z "$USE_EQUO" ] || docker_env+=(-e "USE_EQUO=$USE_EQUO")
[ -z "$PRESERVED_REBUILD" ] || docker_env+=(-e "PRESERVED_REBUILD=$PRESERVED_REBUILD") [ -z "$PRESERVED_REBUILD" ] || docker_env+=(-e "PRESERVED_REBUILD=$PRESERVED_REBUILD")
+1 -1
View File
@@ -65,7 +65,7 @@ echo "Yes" | eit inject \${built_pkgs} || { echo "ouch unable to inject" && exit
echo "Yes Yes Yes" | eit commit --quick echo "Yes Yes Yes" | eit commit --quick
[ -f "/etc/entropy/mykeys/key.pub" ] && [ -f "/etc/entropy/mykeys/private.key" ] &&\ [ -f "/etc/entropy/mykeys/key.pub" ] && [ -f "/etc/entropy/mykeys/private.key" ] &&\
eit key import \$repo /etc/entropy/mykeys/private.key /etc/entropy/mykeys/key.pub && eit key sign \$repo eit key import \$repo /etc/entropy/mykeys/private.key /etc/entropy/mykeys/key.pub && { eit key sign \$repo || true; }
eit push --quick --force eit push --quick --force
+3 -2
View File
@@ -10,6 +10,7 @@ REPOSITORY_DESCRIPTION="${REPOSITORY_DESCRIPTION:-My Sabayon repository}"
DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/eit-amd64}" DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/eit-amd64}"
PORTAGE_ARTIFACTS="${PORTAGE_ARTIFACTS:-$SAB_WORKSPACE/portage_artifacts}" PORTAGE_ARTIFACTS="${PORTAGE_ARTIFACTS:-$SAB_WORKSPACE/portage_artifacts}"
OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/entropy_artifacts}" OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/entropy_artifacts}"
DOCKER_OPTS="${DOCKER_OPTS:--ti --rm}"
args=("$@") args=("$@")
EDITOR=cat EDITOR=cat
@@ -88,6 +89,6 @@ function cleanup {
trap cleanup EXIT trap cleanup EXIT
echo "docker run --rm --entrypoint /bin/bash ${docker_env[@]} ${docker_volumes[@]} -ti $DOCKER_IMAGE /sabayon/bin/create_repo.sh" echo "docker run $DOCKER_OPTS --entrypoint /bin/bash ${docker_env[@]} ${docker_volumes[@]} $DOCKER_IMAGE /sabayon/bin/create_repo.sh"
docker run --rm --entrypoint /bin/bash "${docker_env[@]}" "${docker_volumes[@]}" -ti $DOCKER_IMAGE /sabayon/bin/create_repo.sh || true docker run $DOCKER_OPTS --entrypoint /bin/bash "${docker_env[@]}" "${docker_volumes[@]}" $DOCKER_IMAGE /sabayon/bin/create_repo.sh || true
+3 -2
View File
@@ -10,6 +10,7 @@ REPOSITORY_DESCRIPTION="${REPOSITORY_DESCRIPTION:-My Sabayon repository}"
DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/eit-amd64}" DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/eit-amd64}"
PORTAGE_ARTIFACTS="${PORTAGE_ARTIFACTS:-$SAB_WORKSPACE/portage_artifacts}" PORTAGE_ARTIFACTS="${PORTAGE_ARTIFACTS:-$SAB_WORKSPACE/portage_artifacts}"
OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/entropy_artifacts}" OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/entropy_artifacts}"
DOCKER_OPTS="${DOCKER_OPTS:--ti --rm}"
args=("$@") args=("$@")
EDITOR=cat EDITOR=cat
@@ -86,6 +87,6 @@ function cleanup {
trap cleanup EXIT trap cleanup EXIT
echo "docker run --rm --entrypoint /bin/bash ${docker_env[@]} ${docker_volumes[@]} -ti $DOCKER_IMAGE /sabayon/bin/create_repo.sh" echo "docker run $DOCKER_OPTS --entrypoint /bin/bash ${docker_env[@]} ${docker_volumes[@]} $DOCKER_IMAGE /sabayon/bin/create_repo.sh"
docker run --rm --entrypoint /bin/bash "${docker_env[@]}" "${docker_volumes[@]}" -ti $DOCKER_IMAGE /sabayon/bin/create_repo.sh || true docker run $DOCKER_OPTS --entrypoint /bin/bash "${docker_env[@]}" "${docker_volumes[@]}" $DOCKER_IMAGE /sabayon/bin/create_repo.sh || true