Compare commits

...

19 Commits

Author SHA1 Message Date
mudler 99cae9c7d1 [sabayon-createrepo] don't import keys if already exists 2016-04-07 16:09:09 +02:00
mudler d0df62c8f6 [sabayon-createrepo] signing old packages before injecting new ones 2016-04-06 21:48:28 +02:00
mudler 6ee7ef7845 [builder] show in logs the devkit version 2016-03-29 19:07:48 +02:00
mudler b212b4ce8b [sabayon-buildpackages builder] support for REPOSITORY_NAME and ENMAN_ADD_SELF 2016-03-29 18:58:46 +02:00
mudler c7fce5fd62 [builder] adding revdep-rebuild in preserved_rebuild phase. if an user enables it, it is sane to call also revdep-rebuild 2016-03-29 18:23:20 +02:00
mudler 330eb6faef [builder] adding notes on why we do safe_call during equo install phases 2016-03-29 12:18:07 +02:00
mudler 1e993271ec [builder] code cleanup 2016-03-29 12:07:50 +02:00
mudler 4a1e3e1f41 [builder] use safe_call for system calls that are vital. If they don't succeds they will bail out the build 2016-03-29 12:07:37 +02:00
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
3 changed files with 144 additions and 86 deletions
+133 -82
View File
@@ -17,19 +17,27 @@ my $equo_install_atoms = $ENV{EQUO_INSTALL_ATOMS} // 1;
my $equo_install_version = $ENV{EQUO_INSTALL_VERSION} // 0;
my $equo_split_install = $ENV{EQUO_SPLIT_INSTALL} // 0;
my $equo_mirrorsort = $ENV{EQUO_MIRRORSORT} // 1;
my $entropy_repository = $ENV{ENTROPY_REPOSITORY} // "main"; # Can be weekly, main, testing
my $entropy_repository = $ENV{ENTROPY_REPOSITORY}
// "main"; # Can be weekly, main, testing
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 $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 $repository_name = $ENV{REPOSITORY_NAME};
my $enman_add_self = $ENV{ENMAN_ADD_SELF} // 1;
my $make_conf = $ENV{MAKE_CONF};
my @overlays;
GetOptions( 'layman|overlay:s{,}' => \@overlays, 'equo|install:s{,}' => \@equo_install,'equorm|remove:s{,}' => \@equo_remove );
GetOptions(
'layman|overlay:s{,}' => \@overlays,
'equo|install:s{,}' => \@equo_install,
'equorm|remove:s{,}' => \@equo_remove
);
if ( @ARGV == 0 ) {
help();
@@ -41,29 +49,38 @@ $ENV{LC_ALL} = "en_US.UTF-8"; #here be dragons
# A barely print replacement
sub say { print join( "\n", @_ ) . "\n"; }
sub safe_call {
my $cmd = shift;
my $rt = system($cmd);
my $return = $rt >> 8;
exit($return) if ($rt);
}
# Input: package, depth, and atom. Package: sys-fs/foobarfs, Depth: 1 (depth of the package tree) , Atom: 1/0 (enable disable atom output)
sub package_deps {
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;
# Since we expect this sub to be called multiple times with the same arguments, cache the results
# 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
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.
# 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);
sort
grep { $_ }
map { $_ =~ s/\[.*\]|\s//g; &atom($_) if $atom; $_ }
@dependencies
);
$cache{$cache_key} = \@dependencies;
}
@@ -85,26 +102,31 @@ sub available_packages {
# Input: package (sys-fs/foobarfs)
# Output: Array of packages to be installed, that aren't installed in a Sabayon machine
sub calculate_missing {
my $package = shift;
my $depth = shift;
my @Installed_Packages = @{+shift};
my @Available_Packages = @{+shift};
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
my @dependencies = package_deps( $package, $depth, 1 );
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\// );
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;
}
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 =
@@ -114,8 +136,9 @@ sub calculate_missing {
# removing from packages the one that are already installed and keeping only the available in the entropy repositories
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;
@to_install = grep { length } @to_install;
say "[$package] packages that will be installed with equo: @to_install"
if @to_install > 0;
return @to_install;
}
@@ -133,15 +156,14 @@ sub uniq {
sub help {
say "-> You should feed me with something", "", "Examples:", "",
"\t$0 app-text/tree", "\t$0 plasma-meta --layman kde", "",
"\t$0 app-foo/foobar --equo foo-misc/foobar --equo net-foo/foobar --layman foo --layman bar foo",
"\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
"****************************************************";
say "****************************************************";
if ( @overlays > 0 ) {
say "Overlay(s) to add";
@@ -158,14 +180,11 @@ 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.
system(
"cd /etc/portage/;git checkout master; git stash; git pull"
);
system("cd /etc/portage/;git checkout master; git stash; git pull");
if (`uname -m` eq "x86_64\n"){
system(
"cd /etc/portage/;rm -rfv make.conf;ln -s make.conf.amd64 make.conf"
);
if ( `uname -m` eq "x86_64\n" ) {
system(
"cd /etc/portage/;rm -rfv make.conf;ln -s make.conf.amd64 make.conf");
}
system("echo 'y' | layman -f -a $_") for @overlays;
@@ -197,14 +216,16 @@ auto-sync = no' > /etc/portage/repos.conf/local.conf
system("mkdir -p /usr/portage/distfiles/git3-src");
unless($skip_portage_sync == 1){
# sync portage and overlays
system("layman -S");
if($webrsync == 1){
system("emerge-webrsync");
} else {
system("emerge --sync");
}
unless ( $skip_portage_sync == 1 ) {
# sync portage and overlays
system("layman -S");
if ( $webrsync == 1 ) {
system("emerge-webrsync");
}
else {
system("emerge --sync");
}
}
# preparing for MOAR automation
@@ -212,22 +233,26 @@ qx|eselect profile set $profile|;
qx{ls /usr/portage/licenses -1 | xargs -0 > /etc/entropy/packages/license.accept}
; #HAHA
if ($use_equo && $entropy_repository eq "weekly" ) {
qx|equo repo disable sabayonlinux.org|;
qx|equo repo enable sabayon-weekly|;
} elsif( $use_equo && $entropy_repository eq "testing") {
qx|equo repo disable sabayon-weekly|;
qx|equo repo enable sabayonlinux.org|;
qx|equo repo enable sabayon-limbo|;
if ( $use_equo && $entropy_repository eq "weekly" ) {
qx|equo repo disable sabayonlinux.org|;
qx|equo repo enable sabayon-weekly|;
}
elsif ( $use_equo && $entropy_repository eq "testing" ) {
qx|equo repo disable sabayon-weekly|;
qx|equo repo enable sabayonlinux.org|;
qx|equo repo enable sabayon-limbo|;
}
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")
if ( $enman_repositories and $enman_repositories ne "" ) {
my @enman_toadd = split( / /, $enman_repositories );
safe_call("enman add $_") for @enman_toadd;
}
system("enman add $repository_name")
if ( $enman_add_self and $repository_name and $repository_name ne "" );
system("equo repo mirrorsort sabayonlinux.org") if $equo_mirrorsort;
system("equo up && equo u");
}
system("cp -rf $make_conf /etc/portage/make.conf") if $make_conf;
@@ -241,41 +266,66 @@ 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) )
if $equo_install_atoms;
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,
$prune_virtuals
)
) if $equo_install_atoms;
push( @packages_deps, package_deps( $p, $dep_scan_depth, 0 ) )
if $equo_install_version;
}
@packages_deps = grep { defined() and length() } @packages_deps; #cleaning
say "", "[install] Those dependencies will be installed 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){
system("equo rm --nodeps $_") for (@equo_remove);
safe_call("equo i --bdeps $_")
for ( @packages_deps, @equo_install )
; ## bail out here, if installs fails. emerge will compile a LOT of stuff
if ( @equo_remove > 0 ) {
system("equo rm --nodeps $_") for (@equo_remove);
}
}
else {
system("equo i --bdeps @packages_deps @equo_install") if ( @packages_deps > 0 or @equo_install > 0);
system("equo rm --nodeps @equo_remove") if (@equo_remove > 0);
safe_call("equo i --bdeps @packages_deps @equo_install")
if ( @packages_deps > 0 or @equo_install > 0 )
; ## bail out here, if installs fails. emerge will compile a LOT of stuff
system("equo rm --nodeps @equo_remove") if ( @equo_remove > 0 );
}
}
say "*** Ready to compile, finger crossed ***";
system("emerge --info"); #always give detailed information about the building environment, helpful to debug
system("emerge --info")
; #always give detailed information about the building environment, helpful to debug
say "Devkit version:";
system("equo s -vq app-misc/sabayon-devkit");
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!
}
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");
$rt = system("emerge $emerge_defaults_args -j $jobs @packages");
}
my $return = $rt >> 8;
@@ -283,6 +333,7 @@ my $return = $rt >> 8;
if ($preserved_rebuild) {
system("emerge -j $jobs --buildpkg \@preserved-rebuild");
system("revdep-rebuild");
}
+8 -1
View File
@@ -30,15 +30,22 @@ docker_volumes=( -v "$OUTPUT_DIR:/usr/portage/packages" )
[ -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")
[ -z "$REPOSITORY_NAME" ] || docker_env+=(-e "REPOSITORY_NAME=$REPOSITORY_NAME")
[ -z "$ENMAN_ADD_SELF" ] || docker_env+=(-e "ENMAN_ADD_SELF=$ENMAN_ADD_SELF")
if [ -n "$REMOTE_OVERLAY" ]; then
git clone "$REMOTE_OVERLAY" "$TEMPDIR"
@@ -75,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 $@
+3 -3
View File
@@ -61,12 +61,12 @@ else
echo "Yes" | eit init --quick \$repo
fi
[ -f "/etc/entropy/mykeys/key.pub" ] && [ -f "/etc/entropy/mykeys/private.key" ] && { eit key status \$repo; } \
eit key import \$repo /etc/entropy/mykeys/private.key /etc/entropy/mykeys/key.pub && { eit key sign \$repo || true; }
echo "Yes" | eit inject \${built_pkgs} || { echo "ouch unable to inject" && exit 3; }
echo "Yes Yes Yes" | eit commit --quick
[ -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 || true; }
eit push --quick --force
EOF