diff options
author | Oliver Tappe | 2007-03-14 22:09:26 +0100 |
---|---|---|
committer | Oliver Tappe | 2007-03-14 22:09:26 +0100 |
commit | e7e84b0959526f4f39d409583932cd5f2b6163b1 (patch) | |
tree | 0befb495e4b67b139c549e4999a370b1928bc75b /installer | |
parent | * fixed non-local $/ in slurpFile() (diff) | |
download | core-e7e84b0959526f4f39d409583932cd5f2b6163b1.tar.gz core-e7e84b0959526f4f39d409583932cd5f2b6163b1.tar.xz core-e7e84b0959526f4f39d409583932cd5f2b6163b1.zip |
* added two checks around cloning in order to protect users from making bad
mistakes
* removed special-casing of clones, they no longer get a special name generated
automatically, you have to specify the vendor-OS name and that's what you get.
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@771 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'installer')
-rw-r--r-- | installer/OpenSLX/OSSetup/Engine.pm | 48 | ||||
-rwxr-xr-x | installer/slxos-setup | 5 |
2 files changed, 35 insertions, 18 deletions
diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index d79be75e..b07334de 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -85,13 +85,8 @@ sub initialize $self->{'vendor-os-name'} = $vendorOSName; $self->{'action-type'} = $actionType; my $distroName = $1; + my $selectionName = $2 || 'default'; $self->{'distro-name'} = $distroName; - my $selectionName = $2; - if (!length($selectionName) && $actionType ne 'clone') { - # selections for clones default to the name of the source, but - # that isn't known here, so we handle that in cloneVendorOS() - $selectionName = 'default'; - } $self->{'selection-name'} = $selectionName; if (!exists $supportedDistros{lc($distroName)}) { print _tr("Sorry, distro '%s' is unsupported.\n", $distroName); @@ -189,19 +184,40 @@ sub cloneVendorOS my $self = shift; my $source = shift; - $self->createVendorOSPath(); - - if (!length($self->{'selection-name'})) { - my $selectionName = "cloned-from-$source"; - $selectionName =~ tr[:/][_]; - # mask : and / - $selectionName =~ s[_+$][]; - # remove any trailing underscores, as they're ugly - $self->{'selection-name'} = $selectionName; - $self->{'vendor-os-name'} .= "-$selectionName"; + my $lastCloneSource; + my $cloneInfoFile = "$self->{'vendor-os-path'}/.openslx-clone-info"; + if (-e $self->{'vendor-os-path'}) { + if (!-e $cloneInfoFile) { + # oops, given vendor-os has not been cloned originally, we complain: + die _tr("The vendor-OS '%s' exists but it is no clone, refusing to clobber!\nPlease delete the folder manually, if that's really what you want...\n", + $self->{'vendor-os-path'}); + } else { + my $cloneInfo = slurpFile($cloneInfoFile); + if ($cloneInfo =~ m[^source\s*=\s*(.+?)\s*$]ims) { + $lastCloneSource = $1; + } + if ($source ne $lastCloneSource) { + # protect user from confusing sources (still allowed, though): + my $yes = _tr('yes'); + my $no = _tr('no'); + print _tr("Last time this vendor-OS was cloned, it has been cloned from '%s', now you specified a different source: '%s'\nWould you still like to proceed(%s/%s)? ", + $lastCloneSource, $source, $yes, $no); + my $answer = <STDIN>; + exit 5 unless $answer =~ m[^\s*$yes]i; + } + } } + $self->createVendorOSPath(); + $self->clone_fetchSource($source); + if ($source ne $lastCloneSource) { + open(CLONE_INFO, "> $cloneInfoFile") + or die _tr("unable to create clone-info file '%s', giving up! (%s)\n", + $cloneInfoFile); + print CLONE_INFO "source=$source"; + close CLONE_INFO; + } vlog 0, _tr("Vendor-OS <%s> cloned succesfully.\n", $self->{'vendor-os-name'}); diff --git a/installer/slxos-setup b/installer/slxos-setup index ebac759a..bd279dcd 100755 --- a/installer/slxos-setup +++ b/installer/slxos-setup @@ -202,8 +202,9 @@ that distribution. If you pass an unknown selection, you will see a list of the selections that are available. -In clone-mode, leaving the selection empty will cause slxos-setup to generate -a special name for the vendor-os, like '<distro>-cloned-from-<rsync-source>'. +In clone-mode, it is a good idea to specify some unqiue string as the selection +part of the vendor-os-name, such that you will easily recognize the vendor-OS +at a later stage. We recommend something like '-cloned-from-<name-of-rsync-source>'. =back |