summaryrefslogtreecommitdiff
path: root/solenv/bin
diff options
context:
space:
mode:
Diffstat (limited to 'solenv/bin')
-rwxr-xr-xsolenv/bin/build.pl99
-rwxr-xr-x[-rw-r--r--]solenv/bin/modules/SourceConfig.pm246
-rw-r--r--solenv/bin/modules/installer/epmfile.pm10
3 files changed, 261 insertions, 94 deletions
diff --git a/solenv/bin/build.pl b/solenv/bin/build.pl
index 5775468d0ead..442dcba26946 100755
--- a/solenv/bin/build.pl
+++ b/solenv/bin/build.pl
@@ -342,102 +342,19 @@ sub rename_file {
};
sub generate_config_file {
- my $source_config = SourceConfig -> new();
- $source_config_file = $source_config->get_config_file_path();
- my $temp_config_file = File::Temp::tmpnam($ENV{TMP});
- my @config_content_new = ();
- my $addition_message;
- my $removal_message;
- my %present_modules = ();
- if ($source_config_file) {
- open(SOURCE_CONFIG_FILE, $source_config_file);
- my @config_content = <SOURCE_CONFIG_FILE>;
- close SOURCE_CONFIG_FILE;
- my ($module_section, $repository_section);
- foreach (@config_content) {
- if ((!/^\S+/)||(/^\s*#+/)) {
- push(@config_content_new, $_);
- next;
- }
- if (/^\[repositories\]\s*(\s+#)*/) {
- if ($module_section) {
- $addition_message = add_modules_to_source_config(\%add_to_config, \@config_content_new);
- };
- $module_section = 0;
- $repository_section = 1;
- push(@config_content_new, $_);
- next;
- };
- if (/^\[modules\]\s*(\s+#)*/) {
- $module_section = 1;
- $repository_section = 0;
- push(@config_content_new, $_);
- next;
- };
- if ($module_section && /\s*(\S+)=active\s*(\s+#)*/) {
- if ($clear_config || defined $remove_from_config{$1}) {
- delete $remove_from_config{$1};
- $removal_message .= "$1 ";
- } else {
- push(@config_content_new, $_);
- if (defined $add_to_config{$1} && !$prepare) {
- push(@warnings, "Module $1 already activated in $source_config_file\n");
- delete $add_to_config{$1};
- }
- };
- } else {
- push(@config_content_new, $_);
- };
- };
- if (keys %add_to_config) {
- if (!$module_section) {
- push(@config_content_new, "[modules]\n");
- };
- $addition_message = add_modules_to_source_config(\%add_to_config, \@config_content_new);
- };
- } else {
- if ($clear_config || scalar %remove_from_config) {
- print_error('No source config file found');
- };
- $source_config_file = $source_config->get_config_file_default_path();
- push(@config_content_new, "[modules]\n");
- $addition_message = add_modules_to_source_config(\%add_to_config, \@config_content_new);
- };
- die("Cannot open $temp_config_file") if (!open(NEW_CONFIG, ">$temp_config_file"));
- print NEW_CONFIG $_ foreach (@config_content_new);
- close NEW_CONFIG;
- rename_file($temp_config_file, $source_config_file, 1);
- foreach (keys %remove_from_config) {
- push(@warnings, "Module(s) $_ not found in " . $source_config_file . "\n");
- };
- print_warnings();
- print $addition_message if ($addition_message);
- print "Module(s):\n$removal_message\nremoved from $source_config_file\n" if ($removal_message);
+ my $source_config = SourceConfig->new();
+ $source_config->add_active_modules([keys %add_to_config], 1) if (scalar %add_to_config);
+ $source_config->remove_activated_modules([keys %remove_from_config], 1) if (scalar %remove_from_config);
+ $source_config->remove_all_activated_modules() if ($clear_config);
};
-#
-# Add modules from the passed hash to the array of config strigns
-#
-sub add_modules_to_source_config {
- my ($modules_hash_ref, $config_content_new) = @_;
- my $message;
- foreach (keys %$modules_hash_ref) {
- push(@$config_content_new, "$_=active\n");
- $message .= "$_ ";
- };
- if ($message) {
- return "Module(s):\n" .$message . "\nare added to the " . $source_config_file . "\n\n";
- } else {
- return '';
- };
-};
sub start_interactive {
$pid = open(HTML_PIPE, "-|");
print "Pipe is open\n";
if ($pid) { # parent
- # make file handle non-bloking
+ # make file handle non-blocking
my $flags = '';
fcntl(HTML_PIPE, F_GETFL, $flags);
$flags |= O_NONBLOCK;
@@ -1675,7 +1592,7 @@ sub get_options {
};
sub get_module_and_buildlist_paths {
- if ($build_all_parents) {
+ if ($build_all_parents || $checkparents) {
my $source_config = SourceConfig -> new($StandDir);
$source_config_file = $source_config->get_config_file_path();
$active_modules{$_}++ foreach ($source_config->get_active_modules());
@@ -2371,7 +2288,9 @@ sub prepare_incompatible_build {
@modules_built = keys %$deps_hash;
%add_to_config = %$deps_hash;
if ($prepare) {
- generate_config_file() if ((!defined $ENV{UPDATER}) || (defined $ENV{CWS_WORK_STAMP}));
+ if ((!defined $ENV{UPDATER}) || (defined $ENV{CWS_WORK_STAMP})) {
+ SourceConfig->new()->add_active_modules([keys %add_to_config], 0);
+ }
clear_delivered();
}
my $old_output_tree = '';
diff --git a/solenv/bin/modules/SourceConfig.pm b/solenv/bin/modules/SourceConfig.pm
index 88aa226f68a9..c3503221b8fa 100644..100755
--- a/solenv/bin/modules/SourceConfig.pm
+++ b/solenv/bin/modules/SourceConfig.pm
@@ -38,10 +38,12 @@ package SourceConfig;
use strict;
use constant SOURCE_CONFIG_FILE_NAME => 'source_config';
+use constant SOURCE_CONFIG_VERSION => 2;
use Carp;
use Cwd;
use File::Basename;
+use File::Temp qw(tmpnam);
my $debug = 0;
@@ -62,20 +64,28 @@ sub new {
} else {
$source_root = $ENV{SOURCE_ROOT_DIR};
};
- $source_root = Cwd::realpath($source_root);
+ $self->{SOURCE_ROOT} = Cwd::realpath($source_root);
$self->{DEBUG} = 0;
- $self->{SOURCE_ROOT} = $source_root;
+ $self->{VERBOSE} = 0;
$self->{REPOSITORIES} = {};
+ $self->{ACTIVATED_REPOSITORIES} = {};
$self->{MODULE_PATHS} = {};
$self->{MODULE_BUILD_LIST_PATHS} = {};
$self->{ACTIVATED_MODULES} = {};
$self->{MODULE_REPOSITORY} = {};
$self->{REAL_MODULES} = {};
+ $self->{NEW_MODULES} = [];
+ $self->{REMOVE_MODULES} = {};
+ $self->{REMOVE_REPOSITORIES} = {};
+ $self->{NEW_REPOSITORIES} = [];
+ $self->{WARNINGS} = [];
+ $self->{REPORT_MESSAGES} = [];
+ $self->{CONFIG_FILE_CONTENT} = [];
if (defined $self->{USER_SOURCE_ROOT}) {
${$self->{REPOSITORIES}}{File::Basename::basename($self->{USER_SOURCE_ROOT})} = $self->{USER_SOURCE_ROOT};
};
- $self->{SOURCE_CONFIG_FILE} = get_config_file($source_root);
- $self->{SOURCE_CONFIG_DEFAULT} = $source_root .'/'.SOURCE_CONFIG_FILE_NAME;
+ $self->{SOURCE_CONFIG_FILE} = get_config_file($self->{SOURCE_ROOT});
+ $self->{SOURCE_CONFIG_DEFAULT} = $self->{SOURCE_ROOT} .'/'.SOURCE_CONFIG_FILE_NAME;
read_config_file($self);
bless($self, $class);
return $self;
@@ -83,6 +93,10 @@ sub new {
##### methods #####
+sub get_version {
+ return SOURCE_CONFIG_VERSION;
+};
+
sub get_repositories
{
my $self = shift;
@@ -249,8 +263,11 @@ sub read_config_file {
my $repository_section = 0;
my $module_section = 0;
my $line = 0;
+ my @file_content = ();
+
if (open(SOURCE_CONFIG_FILE, $self->{SOURCE_CONFIG_FILE})) {
foreach (<SOURCE_CONFIG_FILE>) {
+ push (@{$self->{CONFIG_FILE_CONTENT}}, $_);
$line++;
chomp;
next if (!/^\S+/);
@@ -270,6 +287,10 @@ sub read_config_file {
if (/\s*(\S+)=active\s*(\s+#)*/) {
if ($repository_section) {
${$self->{REPOSITORIES}}{$1} = $self->{SOURCE_ROOT} . "/$1";
+ ${$self->{ACTIVATED_REPOSITORIES}}{$1}++;
+ if (defined $ENV{UPDMINOREXT}) {
+ ${$self->{REPOSITORIES}}{$1} .= $ENV{UPDMINOREXT};
+ };
next;
}
if ($module_section) {
@@ -290,6 +311,187 @@ sub read_config_file {
};
};
+sub remove_all_activated_repositories {
+ my $self = shift;
+ $self->remove_activated_repositories([keys %{$self->{ACTIVATED_REPOSITORIES}}]);
+};
+
+sub remove_activated_repositories {
+ my $self = shift;
+ my $new_repositories_ref = shift;
+ push(@{$self->{WARNINGS}}, "\nWARNING: Empty repository list passed for removing from source_config\n") if (!scalar @$new_repositories_ref);
+ $self->{VERBOSE} = shift;
+ $self->{REMOVE_REPOSITORIES} = {};
+ foreach (@$new_repositories_ref) {
+ if (!defined ${$self->{ACTIVATED_REPOSITORIES}}{$_}) {
+ push (@{$self->{WARNINGS}}, "\nWARNING: repository $_ is not activated in ". $self->get_config_file_default_path()."\n");
+ } else {
+ ${$self->{REMOVE_REPOSITORIES}}{$_}++;
+ delete ${$self->{ACTIVATED_REPOSITORIES}}{$_};
+ };
+ };
+ generate_config_file($self);
+};
+
+sub remove_all_activated_modules {
+ my $self = shift;
+ $self->remove_activated_modules([keys %{$self->{ACTIVATED_MODULES}}]);
+};
+
+sub remove_activated_modules {
+ my $self = shift;
+ my $new_modules_ref = shift;
+ push(@{$self->{WARNINGS}}, "\nWARNING: Empty module list passed for removing from source_config\n") if (!scalar @$new_modules_ref);
+ $self->{VERBOSE} = shift;
+ $self->{REMOVE_MODULES} = {};
+ foreach (@$new_modules_ref) {
+ if (!defined ${$self->{ACTIVATED_MODULES}}{$_}) {
+ push (@{$self->{WARNINGS}}, "\nWARNING: module $_ is not activated in ". $self->get_config_file_default_path()."\n");
+ } else {
+ ${$self->{REMOVE_MODULES}}{$_}++;
+ delete ${$self->{ACTIVATED_MODULES}}{$_};
+ };
+ };
+ generate_config_file($self);
+};
+
+sub add_active_repositories {
+ my $self = shift;
+ $self->{NEW_REPOSITORIES} = shift;
+ croak('Empty module list passed for adding to source_config') if (!scalar @{$self->{NEW_REPOSITORIES}});
+ $self->{VERBOSE} = shift;
+ generate_config_file($self);
+};
+
+sub add_active_modules {
+ my $self = shift;
+ $self->{NEW_MODULES} = shift;
+ croak('Empty module list passed for adding to source_config') if (!scalar @{$self->{NEW_MODULES}});
+ $self->{VERBOSE} = shift;
+ generate_config_file($self);
+};
+
+sub add_content {
+ my $self = shift;
+ my $content = shift;
+ my $entries_to_add = shift;
+ return if (!scalar @$entries_to_add);
+ my $message;
+ my $message_part1;
+ my $warning_message;
+ my $activated_entries;
+
+ if ($entries_to_add == $self->{NEW_MODULES}) {
+ $self->{NEW_MODULES} = [];
+ $message_part1 = "Module(s):\n";
+ $activated_entries = $self->{ACTIVATED_MODULES};
+ } elsif ($entries_to_add == $self->{NEW_REPOSITORIES}) {
+ $self->{NEW_REPOSITORIES} = [];
+ $message_part1 = "Repositories:\n";
+ $activated_entries = $self->{ACTIVATED_REPOSITORIES};
+ };
+ foreach my $entry (@$entries_to_add) {
+ if (defined $$activated_entries{$entry}) {
+ $warning_message .= "$entry "
+ } else {
+ push(@$content, "$entry=active\n");
+ ${$activated_entries}{$entry}++;
+ $message .= "$entry "
+ };
+ };
+
+ push(@{$self->{REPORT_MESSAGES}}, "\n$message_part1 $message\nhave been added to the ". $self->get_config_file_default_path()."\n") if ($message);
+ push (@{$self->{WARNINGS}}, "\nWARNING: $message_part1 $warning_message\nare already added to the ". $self->get_config_file_default_path()."\n") if ($warning_message);
+};
+
+sub generate_config_file {
+ my $self = shift;
+ my @config_content_new = ();
+ my ($module_section, $repository_section);
+ my %removed_modules = ();
+ my %removed_repositories = ();
+ foreach (@{$self->{CONFIG_FILE_CONTENT}}) {
+ if (/^\[repositories\]\s*(\s+#)*/) {
+ if ($module_section) {
+ $self->add_content(\@config_content_new, $self->{NEW_MODULES});
+ };
+ $module_section = 0;
+ $repository_section = 1;
+ };
+ if (/^\[modules\]\s*(\s+#)*/) {
+ if ($repository_section) {
+ $self->add_content(\@config_content_new, $self->{NEW_REPOSITORIES});
+ };
+ $module_section = 1;
+ $repository_section = 0;
+ };
+ if ($module_section && /\s*(\S+)=active\s*(\s+#)*/) {
+ if (defined ${$self->{REMOVE_MODULES}}{$1}) {
+ $removed_modules{$1}++;
+ next;
+ };
+ }
+ if ($repository_section && /\s*(\S+)=active\s*(\s+#)*/) {
+ if (defined ${$self->{REMOVE_REPOSITORIES}}{$1}) {
+ $removed_repositories{$1}++;
+ next;
+ };
+ }
+ push(@config_content_new, $_);
+ };
+ if (scalar @{$self->{NEW_MODULES}}) {
+ push(@config_content_new, "[modules]\n") if (!$module_section);
+ $self->add_content(\@config_content_new, $self->{NEW_MODULES});
+ };
+ if (scalar @{$self->{NEW_REPOSITORIES}}) {
+ push(@config_content_new, "[repositories]\n") if (!$repository_section);
+ $self->add_content(\@config_content_new, $self->{NEW_REPOSITORIES});
+ };
+ if (scalar keys %removed_modules) {
+ my @deleted_modules = keys %removed_modules;
+ push(@{$self->{REPORT_MESSAGES}}, "\nModules: @deleted_modules\nhave been removed from the ". $self->get_config_file_default_path()."\n");
+
+ };
+ if (scalar keys %removed_repositories) {
+ my @deleted_repositories = keys %removed_repositories;
+ push(@{$self->{REPORT_MESSAGES}}, "\nRepositories: @deleted_repositories\nhave been removed from the ". $self->get_config_file_default_path()."\n");
+
+ };
+
+ # Writing file, printing warnings and reports
+
+ #check if we need to write a new file
+ my $write_needed = 0;
+ if ((scalar @{$self->{CONFIG_FILE_CONTENT}}) != (scalar @config_content_new)) {
+ $write_needed++;
+ } else {
+ foreach my $i (0 .. $#{$self->{CONFIG_FILE_CONTENT}}) {
+ if (${$self->{CONFIG_FILE_CONTENT}}[$i] ne $config_content_new[$i]) {
+ $write_needed++;
+ last;
+ };
+ };
+ };
+ if ($write_needed) {
+ my $temp_config_file = File::Temp::tmpnam($ENV{TMP});
+ die("Cannot open $temp_config_file") if (!open(NEW_CONFIG, ">$temp_config_file"));
+ print NEW_CONFIG $_ foreach (@config_content_new);
+ close NEW_CONFIG;
+ rename($temp_config_file, $self->get_config_file_default_path()) or system("mv", $temp_config_file, $self->get_config_file_default_path());
+ if (-e $temp_config_file) {
+ system("rm -rf $temp_config_file") if (!unlink $temp_config_file);
+ };
+ $self->{CONFIG_FILE_CONTENT} = \@config_content_new;
+ };
+ if ($self->{VERBOSE}) {
+ print $_ foreach (@{$self->{WARNINGS}});
+ $self->{VERBOSE} = 0;
+ };
+ $self->{WARNINGS} = [];
+ print $_ foreach (@{$self->{REPORT_MESSAGES}});
+ $self->{REPORT_MESSAGES} = [];
+};
+
##### finish #####
1; # needed by use or require
@@ -325,6 +527,10 @@ SourceConfig::new()
Creates a new instance of SourceConfig. Can't fail.
+SourceConfig::get_version()
+
+Returns version number of the module. Can't fail.
+
SourceConfig::get_repositories()
@@ -364,9 +570,35 @@ SourceConfig::is_active()
Returns 1 (TRUE) if a module is active
Returns 0 (FALSE) if a module is not active
+SourceConfig::add_active_modules($module_array_ref)
+
+Adds modules from the @$module_array_ref as active to the source_config file
+
+SourceConfig::add_active_repositories($repository_array_ref)
+
+Adds repositories from the @$repository_array_ref as active to the source_config file
+
+SourceConfig::remove_activated_modules($module_array_ref)
+
+Removes modules from the @$module_array_ref from the source_config file
+
+SourceConfig::remove_all_activated_modules()
+
+Removes all activated modules from the source_config file
+
+SourceConfig::remove_activated_repositories($repository_array_ref)
+
+Removes repositories from the @$repository_array_ref from the source_config file
+
+SourceConfig::remove_all_activated_repositories()
+
+Removes all activated repositories from the source_config file
+
+
=head2 EXPORT
SourceConfig::new()
+SourceConfig::get_version()
SourceConfig::get_repositories()
SourceConfig::get_active_modules()
SourceConfig::get_all_modules()
@@ -376,6 +608,12 @@ SourceConfig::get_module_repository($module)
SourceConfig::get_config_file_path()
SourceConfig::get_config_file_default_path()
SourceConfig::is_active($module)
+SourceConfig::add_active_modules($module_array_ref)
+SourceConfig::add_active_repositories($repository_array_ref)
+SourceConfig::remove_activated_modules($module_array_ref)
+SourceConfig::remove_all_activated_modules()
+SourceConfig::remove_activated_repositories($repository_array_ref)
+SourceConfig::remove_all_activated_repositories()
=head1 AUTHOR
diff --git a/solenv/bin/modules/installer/epmfile.pm b/solenv/bin/modules/installer/epmfile.pm
index 95f661160a0e..ffe79136b57e 100644
--- a/solenv/bin/modules/installer/epmfile.pm
+++ b/solenv/bin/modules/installer/epmfile.pm
@@ -2544,6 +2544,7 @@ sub create_packages_without_epm
my $dir = getcwd;
my $buildroot = $dir . "/" . $epmdir . "buildroot/";
$buildrootstring = "--buildroot=$buildroot";
+ mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/");
}
my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
@@ -2719,6 +2720,15 @@ sub remove_temporary_epm_files
my $returnvalue = system($systemcall);
+ $removedir = $epmdir . "BUILD";
+
+ $systemcall = "rm -rf $removedir";
+
+ installer::logger::print_message( "... $systemcall ...\n" );
+
+ $returnvalue = system($systemcall);
+
+
my $infoline = "Systemcall: $systemcall\n";
push( @installer::globals::logfileinfo, $infoline);