|
|
|
@@ -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,9 @@ 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 $make_conf = $ENV{MAKE_CONF};
|
|
|
|
|
|
|
|
|
@@ -42,9 +46,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
|
|
|
|
@@ -68,21 +92,19 @@ sub calculate_missing {
|
|
|
|
|
my @Available_Packages = @{+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;
|
|
|
|
|
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 +115,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 +136,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 +150,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 +222,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")
|
|
|
|
|
}
|
|
|
|
@@ -220,10 +247,9 @@ if ($use_equo) {
|
|
|
|
|
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 +262,21 @@ 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!
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$rt = system("emerge $emerge_defaults_args -j $jobs @packages");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $return = $rt >> 8;
|
|
|
|
|
|
|
|
|
|