summaryrefslogtreecommitdiffstats
path: root/src/installer/OpenSLX/OSSetup/MetaPackager
diff options
context:
space:
mode:
Diffstat (limited to 'src/installer/OpenSLX/OSSetup/MetaPackager')
-rw-r--r--src/installer/OpenSLX/OSSetup/MetaPackager/Base.pm98
-rw-r--r--src/installer/OpenSLX/OSSetup/MetaPackager/apt.pm142
-rw-r--r--src/installer/OpenSLX/OSSetup/MetaPackager/smart.pm127
-rw-r--r--src/installer/OpenSLX/OSSetup/MetaPackager/yum.pm117
-rw-r--r--src/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm122
5 files changed, 606 insertions, 0 deletions
diff --git a/src/installer/OpenSLX/OSSetup/MetaPackager/Base.pm b/src/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
new file mode 100644
index 00000000..f149d0f5
--- /dev/null
+++ b/src/installer/OpenSLX/OSSetup/MetaPackager/Base.pm
@@ -0,0 +1,98 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# Base.pm
+# - provides empty base of the OpenSLX OSSetup::MetaPackager API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::MetaPackager::Base;
+
+use strict;
+use warnings;
+
+our $VERSION = 1.01; # API-version . implementation-version
+
+use Scalar::Util qw( weaken );
+
+use OpenSLX::Basics;
+
+################################################################################
+### interface methods
+################################################################################
+sub new
+{
+ confess "Creating OpenSLX::OSSetup::MetaPackager::Base-objects directly makes no sense!";
+}
+
+sub initialize
+{
+ my $self = shift;
+ my $engine = shift;
+
+ $self->{'engine'} = $engine;
+ weaken($self->{'engine'});
+ # avoid circular reference between meta-packager and its engine
+
+ return;
+}
+
+sub initPackageSources
+{
+}
+
+sub setupPackageSource
+{
+}
+
+sub updateBasicVendorOS
+{
+}
+
+sub installPackages
+{
+}
+
+sub removePackages
+{
+}
+
+1;
+################################################################################
+
+=pod
+
+=head1 NAME
+
+OpenSLX::OSSetup::MetaPackager::Base - the base class for all OSSetup::MetaPackagers
+
+=head1 SYNOPSIS
+
+ package OpenSLX::OSSetup::MetaPackager::coolnewpkg;
+
+ use vars qw(@ISA $VERSION);
+ @ISA = ('OpenSLX::OSSetup::MetaPackager::Base');
+ $VERSION = 1.01;
+
+ use coolnewpkg;
+
+ sub new
+ {
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
+ }
+
+ # override all methods of OpenSLX::OSSetup::MetaPackager::Base in order to
+ # implement the support for a new meta-packager
+ ...
+
+I<The synopsis above outlines a class that implements a
+OSSetup::MetaPackager for the (imaginary) meta-packager B<coolnewpkg>>
+
+=cut
diff --git a/src/installer/OpenSLX/OSSetup/MetaPackager/apt.pm b/src/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
new file mode 100644
index 00000000..ecb87a35
--- /dev/null
+++ b/src/installer/OpenSLX/OSSetup/MetaPackager/apt.pm
@@ -0,0 +1,142 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# apt.pm
+# - provides apt-get-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::MetaPackager::apt;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::MetaPackager::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'name' => 'apt',
+ };
+ return bless $self, $class;
+}
+
+sub initPackageSources
+{
+ my $self = shift;
+
+ $ENV{LC_ALL} = 'POSIX';
+
+ # remove any existing sources
+ slxsystem('rm -f /etc/apt/sources.list');
+
+ # create default timezone if there isn't any
+ if (!-e '/etc/timezone') {
+ spitFile('/etc/timezone', "$openslxConfig{'default-timezone'}\n");
+ }
+
+ # create kernel config if there isn't any
+ if (!-e '/etc/kernel-img.conf') {
+ my $kernelConfig = unshiftHereDoc(<<" END-OF-HERE");
+ # Kernel image management overrides
+ # See kernel-img.conf(5) for details
+ do_symlinks = yes
+ relative_links = yes
+ do_bootloader = no
+ do_bootfloppy = no
+ do_initrd = yes
+ link_in_boot = yes
+ END-OF-HERE
+ spitFile('/etc/kernel-img.conf', $kernelConfig);
+ }
+
+ return 1;
+}
+
+sub setupPackageSource
+{
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
+
+ my $baseURL = shift @$repoURLs;
+ my $distribution = $repoInfo->{'distribution'};
+ my $components = $repoInfo->{'components'};
+
+ my $sourcesList = "deb $baseURL $distribution $components\n";
+
+ foreach my $mirrorURL (@$repoURLs) {
+ $sourcesList .= "deb $mirrorURL $distribution $components\n";
+ }
+
+ appendFile('/etc/apt/sources.list', $sourcesList);
+
+ return;
+}
+
+sub installPackages
+{
+ my $self = shift;
+ my $packages = shift;
+ my $doRefresh = shift || 0;
+
+ $packages =~ tr{\n}{ };
+
+ if ($doRefresh && slxsystem("apt-get -y update")) {
+ die _tr("unable to update repository info (%s)\n", $!);
+ }
+ if ('/var/cache/debconf/slx-defaults.dat') {
+ $ENV{DEBCONF_DB_FALLBACK}
+ = "'File{/var/cache/debconf/slx-defaults.dat}'";
+ }
+ $ENV{DEBIAN_FRONTEND} = 'noninteractive';
+ if (slxsystem("apt-get -y install $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
+ delete $ENV{DEBCONF_DB_FALLBACK};
+ delete $ENV{DEBIAN_FRONTEND};
+
+ return 1;
+}
+
+sub removePackages
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("apt-get -y remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+
+ return 1;
+}
+
+sub updateBasicVendorOS
+{
+ my $self = shift;
+
+ if (slxsystem("apt-get -y update")) {
+ die _tr("unable to update repository info (%s)\n", $!);
+ }
+ if (slxsystem("apt-get -y upgrade")) {
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
+
+ return 1;
+}
+
+1; \ No newline at end of file
diff --git a/src/installer/OpenSLX/OSSetup/MetaPackager/smart.pm b/src/installer/OpenSLX/OSSetup/MetaPackager/smart.pm
new file mode 100644
index 00000000..fc178cb7
--- /dev/null
+++ b/src/installer/OpenSLX/OSSetup/MetaPackager/smart.pm
@@ -0,0 +1,127 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# smart.pm
+# - provides smart-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::MetaPackager::smart;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::MetaPackager::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'name' => 'smart',
+ };
+ return bless $self, $class;
+}
+
+sub initPackageSources
+{
+ my $self = shift;
+
+ $ENV{LC_ALL} = 'POSIX';
+
+ # remove any existing channels
+ slxsystem("rm -f /etc/smart/channels/*");
+ if (slxsystem("smart channel -y --remove-all")) {
+ die _tr("unable to remove existing channels (%s)\n", $!);
+ }
+ return 1;
+}
+
+sub setupPackageSource
+{
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
+
+ my $repoSubdir = '';
+ if ($repoInfo->{'repo-subdir'}) {
+ $repoSubdir = "/$repoInfo->{'repo-subdir'}";
+ }
+ my $baseURL = shift @$repoURLs;
+ my $repoDescr
+ = qq[$repoName name="$repoInfo->{name}" baseurl=$baseURL$repoSubdir];
+ $repoDescr .= " type=rpm-md";
+ if (slxsystem("smart channel -y --add $repoDescr")) {
+ die _tr("unable to add channel '%s' (%s)\n", $repoName, $!);
+ }
+
+ my $mirrorDescr;
+ foreach my $mirrorURL (@$repoURLs) {
+ $mirrorDescr .= " --add $baseURL$repoSubdir $mirrorURL$repoSubdir";
+ }
+ if (defined $mirrorDescr) {
+ if (slxsystem("smart mirror $mirrorDescr")) {
+ die _tr(
+ "unable to add mirrors for channel '%s' (%s)\n",
+ $repoName, $!
+ );
+ }
+ }
+ return 1;
+}
+
+sub installPackages
+{
+ my $self = shift;
+ my $packages = shift;
+ my $doRefresh = shift || 0;
+
+ $packages =~ tr{\n}{ };
+
+ if ($doRefresh && slxsystem("smart update")) {
+ die _tr("unable to update channel info (%s)\n", $!);
+ }
+ if (slxsystem("smart install -y $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
+ return 1;
+}
+
+sub removePackages
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("smart remove -y $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+ return 1;
+}
+
+sub updateBasicVendorOS
+{
+ my $self = shift;
+
+ if (slxsystem("smart upgrade -y --update")) {
+ if ($! == 2) {
+ # file not found => smart isn't installed
+ die _tr("unable to update this vendor-os, as it seems to lack an installation of smart!\n");
+ }
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
+ return 1;
+}
+
+1; \ No newline at end of file
diff --git a/src/installer/OpenSLX/OSSetup/MetaPackager/yum.pm b/src/installer/OpenSLX/OSSetup/MetaPackager/yum.pm
new file mode 100644
index 00000000..99a10382
--- /dev/null
+++ b/src/installer/OpenSLX/OSSetup/MetaPackager/yum.pm
@@ -0,0 +1,117 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# yum.pm
+# - provides yum-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::MetaPackager::yum;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::MetaPackager::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'name' => 'yum',
+ };
+ return bless $self, $class;
+}
+
+sub initPackageSources
+{
+ my $self = shift;
+
+ $ENV{LC_ALL} = 'POSIX';
+
+ slxsystem("rm -f /etc/yum.repos.d/*");
+ slxsystem("mkdir -p /etc/yum.repos.d");
+
+ return 1;
+}
+
+sub setupPackageSource
+{
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
+
+ my $repoSubdir;
+ if (length($repoInfo->{'repo-subdir'})) {
+ $repoSubdir = "/$repoInfo->{'repo-subdir'}";
+ }
+ my $baseURL = shift @$repoURLs;
+
+ my $repoDescr
+ = "[$repoName]\nname=$repoInfo->{name}\nbaseurl=$baseURL$repoSubdir\n";
+ vlog(4,"Adding repo <",$repoName,"> with Base-URL <",$baseURL,"> and Repo-SubDir <",$repoSubdir,">");
+ foreach my $mirrorURL (@$repoURLs) {
+ $repoDescr .= " $mirrorURL$repoSubdir\n";
+ }
+ my $repoFile = "/etc/yum.repos.d/$repoName.repo";
+ spitFile($repoFile, "$repoDescr\nexclude=$excludeList\n");
+
+ return 1;
+}
+
+sub installPackages
+{
+ my $self = shift;
+ my $packages = shift;
+
+ $packages =~ tr{\n}{ };
+ if (slxsystem("mount -t proc proc proc/") != 0){die _tr("unable to mount proc/ for yum \n");};
+ if (slxsystem("yum -y install $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
+ if(slxsystem("umount proc/") != 0) {_tr("unable to umount proc/")};
+
+ return 1;
+}
+
+sub removePackages
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("yum -y remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+
+ return 1;
+}
+
+sub updateBasicVendorOS
+{
+ my $self = shift;
+ if (slxsystem("mount -t proc proc proc/") != 0){die _tr("unable to mount proc/ for yum \n");};
+ if (slxsystem("yum -y update")) {
+ if ($! == 2) {
+ # file not found => yum isn't installed
+ die _tr("unable to update this vendor-os, as it seems to lack an installation of yum!\n");
+ }
+ if(slxsystem("umount proc/") != 0) {_tr("unable to umount proc/")};
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
+ if(slxsystem("umount proc/") != 0) {_tr("unable to umount proc/")};
+ return 1;
+}
+
+1; \ No newline at end of file
diff --git a/src/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm b/src/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm
new file mode 100644
index 00000000..4bb22bde
--- /dev/null
+++ b/src/installer/OpenSLX/OSSetup/MetaPackager/zypper.pm
@@ -0,0 +1,122 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# zypper.pm
+# - provides zypper-specific overrides of the OpenSLX::OSSetup::MetaPackager API.
+# -----------------------------------------------------------------------------
+package OpenSLX::OSSetup::MetaPackager::zypper;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSSetup::MetaPackager::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### implementation
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {
+ 'name' => 'zypper',
+ };
+ return bless $self, $class;
+}
+
+sub initPackageSources
+{
+ my $self = shift;
+
+ $ENV{LC_ALL} = 'POSIX';
+
+ # remove any existing channels
+ slxsystem("rm -f /etc/zypp/repos.d/*");
+
+ return 1;
+}
+
+sub setupPackageSource
+{
+ my $self = shift;
+ my $repoName = shift;
+ my $repoInfo = shift;
+ my $excludeList = shift;
+ my $repoURLs = shift;
+
+ my $repoSubdir = '';
+ if (defined $repoInfo->{'repo-subdir'} &&
+ length($repoInfo->{'repo-subdir'})) {
+ $repoSubdir = "/$repoInfo->{'repo-subdir'}";
+ }
+ my $baseURL = shift @$repoURLs;
+
+ if ($baseURL =~ m/non-oss/) {
+ # skip non-oss repositories, cause zypper can't realy handle them
+ # correctly; zypper is deacting them with following message:
+ # "Repository type can't be determined."
+ return 1;
+ }
+
+ if (slxsystem("zypper addrepo $baseURL$repoSubdir $repoName")) {
+ die _tr("unable to add repo '%s' (%s)\n", $repoName, $!);
+ }
+
+ return 1;
+}
+
+sub installPackages
+{
+ my $self = shift;
+ my $packages = shift;
+ my $doRefresh = shift || 0;
+
+ $packages =~ tr{\n}{ };
+
+ if ($doRefresh && slxsystem("zypper --non-interactive refresh")) {
+ die _tr("unable to update repo info (%s)\n", $!);
+ }
+ if (slxsystem("zypper --non-interactive install $packages")) {
+ die _tr("unable to install selection (%s)\n", $!);
+ }
+
+ return 1;
+}
+
+sub removePackages
+{
+ my $self = shift;
+ my $pkgSelection = shift;
+
+ if (slxsystem("zypper --non-interactive remove $pkgSelection")) {
+ die _tr("unable to remove selection (%s)\n", $!);
+ }
+
+ return 1;
+}
+
+sub updateBasicVendorOS
+{
+ my $self = shift;
+
+ if (slxsystem("zypper --non-interactive update")) {
+ if ($! == 2) {
+ # file not found => zypper isn't installed
+ die _tr("unable to update this vendor-os, as it seems to lack an installation of zypper!\n");
+ }
+ die _tr("unable to update this vendor-os (%s)\n", $!);
+ }
+
+ return 1;
+}
+
+1;