Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3be4345ae4 | |||
| 286533e74e | |||
| a3f9796c6d | |||
| 1921cae295 | |||
| 3322c5aa17 | |||
| 95ffe4d49d | |||
| 59855f3bb1 | |||
| d151a77e51 | |||
| 8fda356c53 |
@@ -15,24 +15,25 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use URI;
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use v5.10;
|
use v5.10;
|
||||||
no feature "say";
|
no feature "say";
|
||||||
use Storable 'dclone';
|
use Storable 'dclone';
|
||||||
|
|
||||||
my $profile = $ENV{BUILDER_PROFILE} // 16;
|
my $profile = $ENV{BUILDER_PROFILE} // 16;
|
||||||
my $jobs = $ENV{BUILDER_JOBS} // 1;
|
my $jobs = $ENV{BUILDER_JOBS} // 1;
|
||||||
my $use_equo = $ENV{USE_EQUO} // 1;
|
my $use_equo = $ENV{USE_EQUO} // 1;
|
||||||
my $preserved_rebuild = $ENV{PRESERVED_REBUILD} // 0;
|
my $preserved_rebuild = $ENV{PRESERVED_REBUILD} // 0;
|
||||||
my $emerge_defaults_args = $ENV{EMERGE_DEFAULTS_ARGS}
|
my $emerge_defaults_args = $ENV{EMERGE_DEFAULTS_ARGS}
|
||||||
// "--accept-properties=-interactive --q --oneshot --complete-graph --buildpkg";
|
// "--accept-properties=-interactive --quiet --oneshot --complete-graph --buildpkg";
|
||||||
$ENV{FEATURES} = $ENV{FEATURES}
|
$ENV{FEATURES} = $ENV{FEATURES}
|
||||||
// "parallel-fetch protect-owned compressdebug splitdebug -userpriv";
|
// "parallel-fetch protect-owned compressdebug splitdebug -userpriv";
|
||||||
|
|
||||||
my $equo_install_atoms = $ENV{EQUO_INSTALL_ATOMS} // 1;
|
my $equo_install_atoms = $ENV{EQUO_INSTALL_ATOMS} // 1;
|
||||||
my $equo_install_version = $ENV{EQUO_INSTALL_VERSION} // 0;
|
my $equo_install_version = $ENV{EQUO_INSTALL_VERSION} // 0;
|
||||||
my $equo_split_install = $ENV{EQUO_SPLIT_INSTALL} // 0;
|
my $equo_split_install = $ENV{EQUO_SPLIT_INSTALL} // 0;
|
||||||
my $equo_mirrorsort = $ENV{EQUO_MIRRORSORT} // 1;
|
my $equo_mirrorsort = $ENV{EQUO_MIRRORSORT} // 1;
|
||||||
my $entropy_repository = $ENV{ENTROPY_REPOSITORY}
|
my $entropy_repository = $ENV{ENTROPY_REPOSITORY}
|
||||||
// "main"; # Can be weekly, main, testing
|
// "main"; # Can be weekly, main, testing
|
||||||
my $artifacts_folder = $ENV{ARTIFACTS_DIR};
|
my $artifacts_folder = $ENV{ARTIFACTS_DIR};
|
||||||
@@ -40,6 +41,11 @@ 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 $emerge_split_install = $ENV{EMERGE_SPLIT_INSTALL} // 0;
|
||||||
my $webrsync = $ENV{WEBRSYNC} // 0;
|
my $webrsync = $ENV{WEBRSYNC} // 0;
|
||||||
|
# Define git tarball url to use instead of webrsync or emerge --sync
|
||||||
|
my $portage_git_url = $ENV{PORTAGE_GIT_URL} // "";
|
||||||
|
# Define supported tarball types: github|gitlab
|
||||||
|
my $portage_git_service = $ENV{PORTAGE_GIT_SRV} // "github";
|
||||||
|
my $portage_git_branch = $ENV{PORTAGE_GIT_BRANCH} // "master";
|
||||||
my $enman_repositories = $ENV{ENMAN_REPOSITORIES};
|
my $enman_repositories = $ENV{ENMAN_REPOSITORIES};
|
||||||
my $emerge_remove = $ENV{EMERGE_REMOVE};
|
my $emerge_remove = $ENV{EMERGE_REMOVE};
|
||||||
my $remove_enman_repositories = $ENV{REMOVE_ENMAN_REPOSITORIES};
|
my $remove_enman_repositories = $ENV{REMOVE_ENMAN_REPOSITORIES};
|
||||||
@@ -128,6 +134,11 @@ sub parse_overlays {
|
|||||||
map { $_ =~ s/.*?\:\://g; $_ } grep {/\:\:/} @{ dclone( \@_ ) };
|
map { $_ =~ s/.*?\:\://g; $_ } grep {/\:\:/} @{ dclone( \@_ ) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub hook_script {
|
||||||
|
my $s = shift;
|
||||||
|
_system("chmod +x ${s};${s}") if -e $s;
|
||||||
|
}
|
||||||
|
|
||||||
sub add_portage_repository {
|
sub add_portage_repository {
|
||||||
my $repo = $_[0];
|
my $repo = $_[0];
|
||||||
my $reponame;
|
my $reponame;
|
||||||
@@ -262,6 +273,12 @@ sub calculate_missing {
|
|||||||
return @to_install;
|
return @to_install;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub portage_perms {
|
||||||
|
my $dir = shift;
|
||||||
|
_system("chown -R portage:portage $dir");
|
||||||
|
_system("chmod -R ug+w,a+rX $dir");
|
||||||
|
}
|
||||||
|
|
||||||
# Input : complete gentoo package (sys-fs/foobarfs-1.9.2)
|
# Input : complete gentoo package (sys-fs/foobarfs-1.9.2)
|
||||||
# Output: atom form (sys-fs/foobarfs)
|
# Output: atom form (sys-fs/foobarfs)
|
||||||
sub atom { s/-[0-9]{1,}.*$//; }
|
sub atom { s/-[0-9]{1,}.*$//; }
|
||||||
@@ -331,6 +348,39 @@ sub compile_packs {
|
|||||||
return $compiled;
|
return $compiled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub fetch_portage_from_git {
|
||||||
|
|
||||||
|
my ( $url, $srv, $branch ) = @_;
|
||||||
|
|
||||||
|
$url = substr($url, 0, length($url)-1) unless substr($url, -1) cmp "/";
|
||||||
|
my $uri = URI->new($url);
|
||||||
|
my $base = ( $uri->path_segments )[-1];
|
||||||
|
|
||||||
|
say "==== Fetching $srv Portage for branch $branch ====";
|
||||||
|
|
||||||
|
if ( $srv and $srv eq "gitlab" ) {
|
||||||
|
$url .= "/-/archive/$branch/$base-$branch.tar.gz";
|
||||||
|
} else {
|
||||||
|
$url .= "/archive/$branch.tar.gz";
|
||||||
|
}
|
||||||
|
|
||||||
|
_system( "wget -O /tmp/portage.tar.gz $url" );
|
||||||
|
_system( "mkdir /tmp/portage ; tar xzf /tmp/portage.tar.gz -C /tmp/portage" );
|
||||||
|
|
||||||
|
# Avoid to remove /usr/portage for use case where I have already
|
||||||
|
# files under /usr/portage/distfiles or /usr/portage/packages to use.
|
||||||
|
my @excluded_dirs = (
|
||||||
|
"'distfiles'",
|
||||||
|
"'packages'"
|
||||||
|
);
|
||||||
|
my $rsync_opts = "-a --delete --delete-during --recursive -d -A -H";
|
||||||
|
$rsync_opts .= " --exclude $_" foreach @excluded_dirs;
|
||||||
|
|
||||||
|
_system( "rsync $rsync_opts /tmp/portage/$base-$branch/ /usr/portage/" );
|
||||||
|
|
||||||
|
_system( "rm -rf /tmp/portage " );
|
||||||
|
}
|
||||||
|
|
||||||
sub help {
|
sub help {
|
||||||
say "-> You should feed me with something", "", "Examples:", "",
|
say "-> You should feed me with something", "", "Examples:", "",
|
||||||
"\t$0 app-text/tree", "\t$0 plasma-meta --layman kde", "",
|
"\t$0 app-text/tree", "\t$0 plasma-meta --layman kde", "",
|
||||||
@@ -383,8 +433,7 @@ system("echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen"); #be sure about that.
|
|||||||
if ( $remote_conf_portdir ne "" ) {
|
if ( $remote_conf_portdir ne "" ) {
|
||||||
_system("rm -rf /etc/portage");
|
_system("rm -rf /etc/portage");
|
||||||
_system("git clone $remote_conf_portdir /etc/portage");
|
_system("git clone $remote_conf_portdir /etc/portage");
|
||||||
_system("chown -R portage:portage /etc/portage");
|
portage_perms('/etc/portage');
|
||||||
_system("chmod -R ug+w,a+rX /etc/portage");
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_system("cd /etc/portage/;git checkout master; git stash; git pull");
|
_system("cd /etc/portage/;git checkout master; git stash; git pull");
|
||||||
@@ -394,9 +443,8 @@ else {
|
|||||||
if ( $remote_portdir ne "" ) {
|
if ( $remote_portdir ne "" ) {
|
||||||
_system("rm -rf /usr/portage");
|
_system("rm -rf /usr/portage");
|
||||||
_system("git clone $remote_portdir /usr/portage");
|
_system("git clone $remote_portdir /usr/portage");
|
||||||
_system("chown -R portage:portage /usr/portage");
|
|
||||||
_system("chmod -R ug+w,a+rX /usr/portage");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_system("mkdir /var/lib/layman") if ( !-d "/var/lib/layman" );
|
_system("mkdir /var/lib/layman") if ( !-d "/var/lib/layman" );
|
||||||
_system("touch /var/lib/layman/make.conf && layman-updater -R")
|
_system("touch /var/lib/layman/make.conf && layman-updater -R")
|
||||||
if ( !-e "/var/lib/layman/make.conf" );
|
if ( !-e "/var/lib/layman/make.conf" );
|
||||||
@@ -423,8 +471,7 @@ else {
|
|||||||
chomp(@FILE);
|
chomp(@FILE);
|
||||||
$reponame = $FILE[0];
|
$reponame = $FILE[0];
|
||||||
}
|
}
|
||||||
_system("chown -R portage:portage /usr/local/portage");
|
portage_perms('/usr/local/portage');
|
||||||
_system("chmod -R 755 /usr/local/portage");
|
|
||||||
|
|
||||||
qx{
|
qx{
|
||||||
echo '[$reponame]
|
echo '[$reponame]
|
||||||
@@ -450,16 +497,21 @@ if ( $remove_remote_overlay and $remove_remote_overlay ne "" ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_system("mkdir -p /usr/portage/distfiles/git3-src");
|
_system("mkdir -p /usr/portage/distfiles/git3-src");
|
||||||
|
portage_perms('/usr/portage');
|
||||||
|
|
||||||
unless ( $skip_portage_sync == 1 ) {
|
unless ( $skip_portage_sync == 1 ) {
|
||||||
|
|
||||||
# sync portage and overlays
|
# sync portage and overlays
|
||||||
_system("layman -S");
|
_system("layman -S");
|
||||||
if ( $webrsync == 1 ) {
|
if ( $portage_git_url ne "" and $portage_git_branch ne "" ) {
|
||||||
|
fetch_portage_from_git( $portage_git_url, $portage_git_service,
|
||||||
|
$portage_git_branch );
|
||||||
|
}
|
||||||
|
elsif ( $webrsync == 1 ) {
|
||||||
_system("emerge-webrsync");
|
_system("emerge-webrsync");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_system("emerge --sync");
|
_system("emerge --sync --quiet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +667,7 @@ if ($use_equo) {
|
|||||||
say "", "[install] Those dependencies will be installed with equo :",
|
say "", "[install] Those dependencies will be installed with equo :",
|
||||||
@packages_deps, "";
|
@packages_deps, "";
|
||||||
if ($equo_split_install) {
|
if ($equo_split_install) {
|
||||||
safe_call("equo i $equo_install_args --bdeps '$_'")
|
_system("equo i $equo_install_args --bdeps '$_'")
|
||||||
for ( @packages_deps, @equo_install )
|
for ( @packages_deps, @equo_install )
|
||||||
; ## bail out here, if installs fails. emerge will compile a LOT of stuff
|
; ## bail out here, if installs fails. emerge will compile a LOT of stuff
|
||||||
if ( @equo_remove > 0 and !$pretend ) {
|
if ( @equo_remove > 0 and !$pretend ) {
|
||||||
@@ -626,7 +678,7 @@ if ($use_equo) {
|
|||||||
else {
|
else {
|
||||||
my @p = map {"'$_'"} ( @packages_deps, @equo_install );
|
my @p = map {"'$_'"} ( @packages_deps, @equo_install );
|
||||||
my @r = map {"'$_'"} @equo_remove;
|
my @r = map {"'$_'"} @equo_remove;
|
||||||
safe_call("equo i $equo_install_args --bdeps @p")
|
_system("equo i $equo_install_args --bdeps @p")
|
||||||
if ( @p > 0 )
|
if ( @p > 0 )
|
||||||
; ## bail out here, if installs fails. emerge will compile a LOT of stuff
|
; ## bail out here, if installs fails. emerge will compile a LOT of stuff
|
||||||
_system("equo rm --nodeps @r") if ( @r > 0 );
|
_system("equo rm --nodeps @r") if ( @r > 0 );
|
||||||
@@ -643,7 +695,8 @@ if ( $emerge_remove and $emerge_remove ne "" ) {
|
|||||||
_system("emerge -C '$_'") for split( / /, $emerge_remove );
|
_system("emerge -C '$_'") for split( / /, $emerge_remove );
|
||||||
}
|
}
|
||||||
|
|
||||||
_system("chmod +x /pre-script;./pre-script") if -e "/pre-script";
|
hook_script("./pre-script");
|
||||||
|
hook_script("/pre-script");
|
||||||
|
|
||||||
loud "Compilation phase start";
|
loud "Compilation phase start";
|
||||||
|
|
||||||
@@ -668,12 +721,25 @@ else {
|
|||||||
$return = $rt >> 8;
|
$return = $rt >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
loud "Compilation phase end";
|
if ( @injected_packages > 0 ) {
|
||||||
|
my $res = compile_packs( "injected_targets", @injected_packages );
|
||||||
|
loud "Compilation summary for injected_targets";
|
||||||
|
foreach my $k ( keys %{$res} ) {
|
||||||
|
my $c = $res->{$k} >> 8;
|
||||||
|
if ( $c != 0 ) {
|
||||||
|
say "$k : build failed ( Exit: $c )";
|
||||||
|
$return = 1 unless $keep_going;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
say "$k : build succeeded";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# best effort -B
|
loud "Compilation phase end (Exit: $return)";
|
||||||
compile_packs( "injected_targets", @injected_packages );
|
|
||||||
|
|
||||||
_system("chmod +x /post-script;./post-script") if -e "/post-script";
|
hook_script("./post-script");
|
||||||
|
hook_script("/post-script");
|
||||||
|
|
||||||
if ( $preserved_rebuild and !$pretend ) {
|
if ( $preserved_rebuild and !$pretend ) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user