Compare commits

...

24 Commits

Author SHA1 Message Date
Ettore Di Giacinto 62548482d5 Merge pull request #11 from optiz0r/feature_optional_prune_virtuals
Allow virtual dependency pruning to be controlled by env var
2016-03-28 14:40:15 +02:00
Ben Roberts cc406e3924 Allow virtual dependency pruning to be controlled by env var
Defaults to off, while the stability of virtual pruning is checked
2016-03-28 13:22:00 +01:00
Ettore Di Giacinto 5a19da9db7 Merge pull request #9 from optiz0r/feature_dont_reinstall
Don't reinstall already installed atoms
2016-03-27 20:49:32 +02:00
Ettore Di Giacinto 523146cf2b Merge pull request #10 from optiz0r/feature_control_mirrorsort
Allow controlling equo mirrorsort within the docker container
2016-03-27 20:43:43 +02:00
Ben Roberts 7bff7825d6 Allow controlling equo mirrorsort within the docker container 2016-03-27 17:39:11 +01:00
Ben Roberts 114eb47a4b Don't reinstall already installed atoms
Fixes Sabayon/community-buildspec#5
2016-03-27 17:05:50 +01:00
mudler 68841b4876 [sabayon-buildpackages] add support for FEATURES 2016-03-26 18:42:48 +01:00
mudler 267870a699 [sabayon-buildpackages] hide env variables echo 2016-03-26 12:38:02 +01:00
mudler 0831363686 [sabayon-buildpackages] adding support for distcc 2016-03-25 22:13:30 +01:00
mudler 0f776e4dd8 [builder] consider a build successfully when running with splitted emerge 2016-03-25 15:34:50 +01:00
mudler 8261606b8b [sabayon-buildpackages] adding support for ENMAN_REPOSITORIES 2016-03-25 14:24:09 +01:00
mudler 71403285a4 adding ENMAN_REPOSITORIES to supply a space-separated list of entropy repositories to add with enman 2016-03-25 14:12:21 +01:00
mudler dd53f6a35e keep our internal say() version 2016-03-23 16:01:41 +01:00
mudler 0e41fbd168 dumb fix 2016-03-23 15:55:11 +01:00
mudler ce0272bd29 enable emerge --info informations to be displayed *always* on build, it will not be parametrized on purpose 2016-03-23 15:54:24 +01:00
mudler 4eee9a7fbc [builder] adjust output 2016-03-23 15:48:49 +01:00
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
4 changed files with 89 additions and 31 deletions
+76 -26
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env perl
use Getopt::Long;
use v5.10;
no feature "say";
my $profile = $ENV{BUILDER_PROFILE} // 3;
my $jobs = $ENV{BUILDER_JOBS} // 1;
@@ -19,7 +21,10 @@ my $entropy_repository = $ENV{ENTROPY_REPOSITORY} // "main"; # Can be weekly
my $artifacts_folder = $ENV{ARTIFACTS_DIR};
my $dep_scan_depth = $ENV{DEPENDENCY_SCAN_DEPTH} // 2;
my $skip_portage_sync = $ENV{SKIP_PORTAGE_SYNC} // 0;
my $emerge_split_install = $ENV{EMERGE_SPLIT_INSTALL} // 0;
my $webrsync = $ENV{WEBRSYNC} // 0;
my $enman_repositories = $ENV{ENMAN_REPOSITORIES};
my $prune_virtuals = $ENV{PRUNE_VIRTUALS} // 0;
my $make_conf = $ENV{MAKE_CONF};
@@ -42,9 +47,29 @@ sub package_deps {
my $package = shift;
my $depth = shift // 1; # defaults to 1 level of depthness of the tree
my $atom = shift // 0;
return
map { $_ =~ s/\[.*\]|\s//g; &atom($_) if $atom; $_ }
qx/equery -C -q g --depth=$depth $package/; #depth=0 it's all
# 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 = 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
@@ -63,26 +88,27 @@ sub available_packages {
sub calculate_missing {
my $package = shift;
my $depth = shift;
my @Installed_Packages = @{+shift};
my @Available_Packages = @{+shift};
my $prune_virtuals = shift;
# 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 );
# XXX: Endless loop as for now.
# 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;
# for my $dep (@dependencies) {
# push(@virtual_deps, package_deps( $dep, 1, 1 )) if ( $dep =~ /^virtual\// );
# }
# for my $dep (@virtual_deps) {
# $install_dependencies{$dep} = 0 if ( $dep !~ /^virtual\// );
# }
# @dependencies = grep { $install_dependencies{$_} } @dependencies;
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;
for my $dep (@dependencies) {
push(@virtual_deps, package_deps( $dep, 1, 1 )) if ( $dep =~ /^virtual\// );
}
for my $dep (@virtual_deps) {
$install_dependencies{$dep} = 0 if ( $dep !~ /^virtual\// );
}
@dependencies = grep { $install_dependencies{$_} } @dependencies;
}
#taking only the 4th column of output as key of the hashmap
my %installed_packs =
@@ -93,7 +119,7 @@ sub calculate_missing {
my @to_install = grep( defined $available_packs{$_},
uniq( grep( !defined $installed_packs{$_}, @dependencies ) ) );
@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;
}
@@ -114,11 +140,12 @@ sub help {
"\t$0 app-foo/foobar --equo foo-misc/foobar --equo net-foo/foobar --layman foo --layman bar foo",
"**************************", "",
"You can supply multiple overlays as well: $0 plasma-meta --layman kde plab",
"The documentation is available at https://github.com/Sabayon/devkit",
"";
}
say
"************* IF YOU WANT TO SUPPLY ADDITIONAL ARGS TO EMERGE, pass to docker EMERGE_DEFAULT_OPTS env with your options *************";
"****************************************************";
if ( @overlays > 0 ) {
say "Overlay(s) to add";
@@ -127,11 +154,11 @@ if ( @overlays > 0 ) {
}
}
say "Installing:";
say "[*] Installing:";
say "\t* " . $_ for @ARGV;
say "* Syncing stuff for you, if it's the first time, can take a while";
say "[*] Syncing configurations files, Layman and Portage";
# Syncronizing portage configuration and adding overlays
system("echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen"); #be sure about that.
@@ -199,6 +226,10 @@ if ($use_equo && $entropy_repository eq "weekly" ) {
}
if ($use_equo) {
if ($enman_repositories and $enman_repositories ne "") {
my @enman_toadd=split(/ /,$enman_repositories);
system("enman add $_") for @enman_toadd;
}
system("equo repo mirrorsort sabayonlinux.org") if $equo_mirrorsort;
system("equo up && equo u")
}
@@ -214,16 +245,22 @@ if ($use_equo) {
my @Installed_Packages = qx/equo q list installed --quiet/;
my @Available_Packages = available_packages();
chomp(@Installed_Packages);
my %installed_packs =
map { $_ => 1 } @Installed_Packages;
# Remove any already installed packages from the list of entropy packages to install in the build spec
@equo_install = grep { ! exists $installed_packs{$_} } @equo_install;
foreach my $p (@packages) {
say "[$p] Getting the package dependencies which aren't already installed on the system.. ";
push( @packages_deps, calculate_missing( $p , $dep_scan_depth,\@Installed_Packages,\@Available_Packages) )
push( @packages_deps, calculate_missing( $p , $dep_scan_depth,\@Installed_Packages,\@Available_Packages, $prune_virtuals) )
if $equo_install_atoms;
push( @packages_deps, package_deps( $p, $dep_scan_depth, 0 ) )
if $equo_install_version;
say "[$p] Done"
}
@packages_deps = grep { defined() and length() } @packages_deps; #cleaning
say "", "[install] Installing missing dependencies with equo", @packages_deps, "";
say "", "[install] Those dependencies will be installed with equo :", @packages_deps, "";
if ($equo_split_install) {
system("equo i --bdeps $_") for (@packages_deps,@equo_install);
if (@equo_remove > 0){
@@ -236,9 +273,22 @@ if ($use_equo) {
}
}
say "* Ready to compile, finger crossed";
say "*** Ready to compile, finger crossed ***";
my $rt = system("emerge $emerge_defaults_args -j $jobs @packages");
system("emerge --info"); #always give detailed information about the building environment, helpful to debug
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!
}
$rt=0; #consider the build good anyway, like a "keep-going"
}
else {
$rt = system("emerge $emerge_defaults_args -j $jobs @packages");
}
my $return = $rt >> 8;
+7 -1
View File
@@ -24,20 +24,26 @@ docker_volumes=( -v "$OUTPUT_DIR:/usr/portage/packages" )
[ -z "$PORTAGE_CACHE" ] || docker_volumes+=(-v "$PORTAGE_CACHE:/usr/portage")
[ -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 "$USE_EQUO" ] || docker_env+=(-e "USE_EQUO=$USE_EQUO")
[ -z "$PRESERVED_REBUILD" ] || docker_env+=(-e "PRESERVED_REBUILD=$PRESERVED_REBUILD")
[ -z "$EQUO_INSTALL_ATOMS" ] || docker_env+=(-e "EQUO_INSTALL_ATOMS=$EQUO_INSTALL_ATOMS")
[ -z "$DEPENDENCY_SCAN_DEPTH" ] || docker_env+=(-e "DEPENDENCY_SCAN_DEPTH=$DEPENDENCY_SCAN_DEPTH")
[ -z "$FEATURES" ] || docker_env+=(-e "FEATURES=$FEATURES")
[ -z "$EMERGE_DEFAULTS_ARGS" ] || docker_env+=(-e "EMERGE_DEFAULTS_ARGS=$EMERGE_DEFAULTS_ARGS")
[ -z "$EQUO_INSTALL_VERSION" ] || docker_env+=(-e "EQUO_INSTALL_VERSION=$EQUO_INSTALL_VERSION")
[ -z "$EQUO_SPLIT_INSTALL" ] || docker_env+=(-e "EQUO_SPLIT_INSTALL=$EQUO_SPLIT_INSTALL")
[ -z "$ARTIFACTS_DIR" ] || docker_env+=(-e "ARTIFACTS_DIR=$ARTIFACTS_DIR")
[ -z "$ENTROPY_REPOSITORY" ] || docker_env+=(-e "ENTROPY_REPOSITORY=$ENTROPY_REPOSITORY")
[ -z "$SKIP_PORTAGE_SYNC" ] || docker_env+=(-e "SKIP_PORTAGE_SYNC=$SKIP_PORTAGE_SYNC")
[ -z "$EQUO_MIRRORSORT" ] || docker_env+=(-e "EQUO_MIRRORSORT=$EQUO_MIRRORSORT")
[ -z "$WEBRSYNC" ] || docker_env+=(-e "WEBRSYNC=$WEBRSYNC")
[ -z "$ENMAN_REPOSITORIES" ] || docker_env+=(-e "ENMAN_REPOSITORIES=$ENMAN_REPOSITORIES")
[ -z "$DISTFILES" ] || docker_volumes+=(-v "$DISTFILES:/usr/portage/distfiles")
[ -z "$ENTROPY_DOWNLOADED_PACKAGES" ] || docker_volumes+=(-v "$ENTROPY_DOWNLOADED_PACKAGES:/var/lib/entropy/client/packages")
[ -z "$DISTCC_HOSTS" ] || docker_env+=(-e "DISTCC_HOSTS=$DISTCC_HOSTS")
[ -z "${PRUNE_VIRTUALS}" ] || docker_env+=(-e "PRUNE_VIRTUALS=$PRUNE_VIRTUALS")
if [ -n "$REMOTE_OVERLAY" ]; then
git clone "$REMOTE_OVERLAY" "$TEMPDIR"
@@ -74,6 +80,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 $@
+3 -2
View File
@@ -10,6 +10,7 @@ REPOSITORY_DESCRIPTION="${REPOSITORY_DESCRIPTION:-My Sabayon repository}"
DOCKER_IMAGE="${DOCKER_IMAGE:-sabayon/eit-amd64}"
PORTAGE_ARTIFACTS="${PORTAGE_ARTIFACTS:-$SAB_WORKSPACE/portage_artifacts}"
OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/entropy_artifacts}"
DOCKER_OPTS="${DOCKER_OPTS:--ti --rm}"
args=("$@")
EDITOR=cat
@@ -88,6 +89,6 @@ function cleanup {
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}"
PORTAGE_ARTIFACTS="${PORTAGE_ARTIFACTS:-$SAB_WORKSPACE/portage_artifacts}"
OUTPUT_DIR="${OUTPUT_DIR:-$SAB_WORKSPACE/entropy_artifacts}"
DOCKER_OPTS="${DOCKER_OPTS:--ti --rm}"
args=("$@")
EDITOR=cat
@@ -86,6 +87,6 @@ function cleanup {
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