App-LXC-Container

 view release on metacpan or  search on metacpan

lib/App/LXC/Container/Setup.pm  view on Meta::CPAN

}

#########################################################################

=head2 B<_help_dialog> - display and run help dialog

    $self->_help_dialog();

=head3 description:

This method creates and runs the dialog with the help text.

=cut

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub _help_dialog($)
{
    my $self = shift;
    debug(3, __PACKAGE__, '::_help_dialog($self)');
    my $main = $self->{MAIN_UI};
    $main->dialog({title => txt('help')},
		  UI::Various::Text->new(text => txt('help_text')),
		  UI::Various::Button->new(text => txt('ok'),
					   code => sub{   $_[0]->destroy;   }));
}

#########################################################################

=head2 B<_init_config_dir> - initialise configuration directory

    $self->_init_config_dir();

=head3 description:

This method opens two file selection dialogues to choose the location of the
toolbox's configuration directory and creates the symbolic link to it in the
user's C<HOME> directory.  It also initialises the directory, if it is empty.

=cut

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub _init_config_dir($)
{
    my $self = shift;
    debug(2, __PACKAGE__, '::_init_config_dir($self)');

    # run initial file selection dialogues:
    my $dir = $self->_init_fs_dialog(txt('select_configuration_directory'),
				     _DEFAULT_CONF_DIR);
    $dir  or  exit 0;
    $dir =~ s|(?<=[^/])/+$||;
    my $root = $self->_init_fs_dialog(txt('select_root_directory'),
				      _DEFAULT_ROOT_DIR);
    $root  or  exit 0;
    $root =~ s|(?<=[^/])/+$||;

    # create directory, link and basic environment:
    local $_;
    my $error = [];
    -d $dir . '/conf'
	or  make_path($dir . '/conf', { chmod => 0755, error => \$error });
    @$error  and
	fatal 'aborting_after_error__1', join("\n", map{values %$_} @$error);
    ( -l _ROOT_DIR_  and  readlink(_ROOT_DIR_) eq $dir)
	or  symlink $dir, _ROOT_DIR_
	or  fatal 'can_t_link__1_to__2__3', _ROOT_DIR_, $dir, $!;
    _write_to($dir . '/.networks.lst', initial_network_list());
    _write_to($dir . '/.root_fs', $root);

    # create default configuration files:
    _create_or_compare('10-NET-default.conf', content_network_default());
    _create_or_compare('20-DEV-default.conf', content_device_default());
    _create_or_compare('30-PKG-default.packages', content_default_packages());
    _create_or_compare('31-PKG-network.packages', content_network_packages());
    _create_or_compare('40-MNT-default.mounts', content_default_mounts());
    _create_or_compare('41-MNT-network.mounts', content_network_mounts());
    _create_or_compare('50-NOT-default.filter', content_default_filter());
    _create_or_compare('60-PKG-X11.packages', content_x11_packages());
    _create_or_compare('61-MNT-X11.mounts', content_x11_mounts());
    _create_or_compare('70-PKG-audio.packages', content_audio_packages());
}

#########################################################################

=head2 _init_fs_dialog - run file-selection dialog

    $self->_init_fs_dialog($title, $directory);

=head3 parameters:

    $title              string with title of the file-selection dialog
    $directory          starting directory of file-selection dialog

=head3 description:

This method opens a file-selection dialog and runs the passed code reference
when the dialog is finished with the C<OK> button.  It contains the common
parts for C<L<_add_file|/_add_file - add item(s) to listbox via
file-selection dialog>> and C<L<_add_package|/_add_package - add item(s) to
package listbox via file-selection dialog>> below.

=cut

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub _init_fs_dialog($$$)
{
    my ($self, $title, $directory) = @_;

    my $ui_title = UI::Various::Text->new(text => $title,
					  height => 3,
					  width => 45,
					  align => 5);
    my $ui_fs =
	UI::Various::Compound::FileSelect->new(mode => 0,
					       directory => $directory,
					       height => 16,
					       width => 40);
    my $dir = undef;
    my $ui_buttons = UI::Various::Box->new(columns => 2);
    $ui_buttons->add(UI::Various::Button->new(text => txt('quit'),
					      code => sub{ $_[0]->destroy; }),



( run in 0.471 second using v1.01-cache-2.11-cpan-99c4e6809bf )