diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..2f0ee45 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,20 @@ +Makefile +Makefile.am +Makefile.am.common +Makefile.in +aclocal.m4 +config.cache +config.guess +config.h.in +config.log +config.status +config.sub +configure +configure.in +depcomp +install-sh +missing +mkinstalldirs +stamp-h +pos-installation.pot +autom4te.cache diff --git a/MAINTAINER b/MAINTAINER new file mode 100644 index 0000000..f235332 --- /dev/null +++ b/MAINTAINER @@ -0,0 +1 @@ +Lukas Ocilka diff --git a/Makefile.cvs b/Makefile.cvs new file mode 100644 index 0000000..2288c80 --- /dev/null +++ b/Makefile.cvs @@ -0,0 +1,22 @@ +# +# Makefile.cvs +# +PREFIX = /usr + +LIB = $(shell y2tool get-lib) + +configure: all + ./configure --prefix=$(PREFIX) --libdir=$(PREFIX)/$(LIB) + +all: + y2tool y2autoconf + y2tool y2automake + autoreconf --force --install + +install: configure + make + make install + +reconf: all + ./config.status --recheck + ./config.status diff --git a/RPMNAME b/RPMNAME new file mode 100644 index 0000000..235d2d5 --- /dev/null +++ b/RPMNAME @@ -0,0 +1 @@ +yast2-pos-installation diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..fb2c076 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.13.0 diff --git a/agents/.cvsignore b/agents/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/agents/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/agents/Makefile.am b/agents/Makefile.am new file mode 100644 index 0000000..985464b --- /dev/null +++ b/agents/Makefile.am @@ -0,0 +1,7 @@ +# Makefile.am for pos-installation/agents + +agent_SCRIPTS = + +scrconf_DATA = + +EXTRA_DIST = $(agent_SCRIPTS) $(scrconf_DATA) diff --git a/configure.in.in b/configure.in.in new file mode 100644 index 0000000..0a9d639 --- /dev/null +++ b/configure.in.in @@ -0,0 +1,12 @@ +## YCP module configure.in.in + +## Initialize +@YAST2-INIT-COMMON@ +@YAST2-INIT-YCP@ + +## some common checks +@YAST2-CHECKS-COMMON@ +@YAST2-CHECKS-YCP@ + +## and generate the output... +@YAST2-OUTPUT@ diff --git a/control/Makefile.am b/control/Makefile.am new file mode 100644 index 0000000..2984896 --- /dev/null +++ b/control/Makefile.am @@ -0,0 +1,12 @@ +# Makefile.am for installation/general +# +SUBDIRS = docs tests + +controldir = $(yast2dir)/control + +control_DATA = slepos_migration.xml + +EXTRA_DIST = $(control_DATA) $(product_DATA) + +include $(top_srcdir)/Makefile.am.common + diff --git a/control/README.txt b/control/README.txt new file mode 100644 index 0000000..702f3c2 --- /dev/null +++ b/control/README.txt @@ -0,0 +1,8 @@ +Here you can find description of files: + +installation.xml + - Additional workflow modifications + +slepos_migration.xml + - Configuration for POS Migration Assisten (FATE #302870) + diff --git a/control/installation.xml b/control/installation.xml new file mode 100644 index 0000000..7248026 --- /dev/null +++ b/control/installation.xml @@ -0,0 +1,67 @@ + + + + control-SLEPOS + + + + + + no + no + + + normal + installation,normal + + + + + slepos_server_selection + no + yes + + + + inst_rpmcopy + yes + yes + + + + slepos_data_migration + yes + yes + + + + + + + + + + yes + yes + + + + continue + update + + + + + congratulate + + + + slepos_data_migration + + + + + + + + diff --git a/control/slepos_migration.xml b/control/slepos_migration.xml new file mode 100644 index 0000000..1f38391 --- /dev/null +++ b/control/slepos_migration.xml @@ -0,0 +1,79 @@ + + + + + /var/adm/backup/SLEPOS_DATA/ + + + SLEPOS_DATA_ + + + false + + + 50 + + + copy + + + /var/lib/YaST2/slepos_post.pl + + + + + + directory + /yast/test/XML + /srv/SLEPOS/1/ + + + + directory + /yast/Botanicka + /srv/SLEPOS/15/ + + + + directory + /yast/CODE11/SL_11.0/zypp/ + + /srv/SLEPOS/2/ + + + + file + /yast/CODE11/Alpha6Test.xml + + /srv/SLEPOS/3 + + + + file + /yast/docs/Behavioral_Indicators_Release_2.3 + + /srv/SLEPOS/4/ + + + + directory + /tmp/some/missing/dir + /srv/SLEPOS/5/ + + + + + directory + /srv/SLEPOS/12/ + + + + + dyrectori + /tmp/ + /tmp/ + + + + diff --git a/doc/.cvsignore b/doc/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/doc/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..4777ac1 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,10 @@ +# Makefile.am for pos-installation/doc + +SUBDIRS = autodocs + +htmldir = $(docdir) + +doc_DATA = +html_DATA = + +EXTRA_DIST = $(doc_DATA) $(html_DATA) diff --git a/doc/autodocs/.cvsignore b/doc/autodocs/.cvsignore new file mode 100644 index 0000000..2f083ef --- /dev/null +++ b/doc/autodocs/.cvsignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +*.html diff --git a/doc/autodocs/Makefile.am b/doc/autodocs/Makefile.am new file mode 100644 index 0000000..6390abe --- /dev/null +++ b/doc/autodocs/Makefile.am @@ -0,0 +1,3 @@ +# Makefile.am for pos-installation/doc/autodocs + +include $(top_srcdir)/autodocs-ycp.ami diff --git a/package/.cvsignore b/package/.cvsignore new file mode 100644 index 0000000..65d0b1a --- /dev/null +++ b/package/.cvsignore @@ -0,0 +1,2 @@ +*.spec +*.bz2 diff --git a/package/yast2-pos-installation.changes b/package/yast2-pos-installation.changes new file mode 100644 index 0000000..d0c6811 --- /dev/null +++ b/package/yast2-pos-installation.changes @@ -0,0 +1,7 @@ +------------------------------------------------------------------- +Wed Oct 10 13:52:53 2007 - locilka@suse.cz + +- initial version + * POS Data Migration client + * POS Pattern Selector +- 2.13.0 diff --git a/src/.cvsignore b/src/.cvsignore new file mode 100644 index 0000000..cb59cbd --- /dev/null +++ b/src/.cvsignore @@ -0,0 +1,4 @@ +Makefile +Makefile.in +*.ybc +.dep diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..42aaa43 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,5 @@ +# +# Makefile.am for installation/src +# + +SUBDIRS = clients scripts diff --git a/src/clients/Makefile.am b/src/clients/Makefile.am new file mode 100644 index 0000000..d0b5e2b --- /dev/null +++ b/src/clients/Makefile.am @@ -0,0 +1,11 @@ +# Makefile.am for installation/general + +client_DATA = $(wildcard *.ycp) +YCPCFLAGS = -M ../modules + +EXTRA_DIST = $(client_DATA) + +install-data-local: + -install -d -m 755 $(DESTDIR)/var/lib/YaST2 + +include $(top_srcdir)/Makefile.am.common diff --git a/src/clients/slepos_data_migration.ycp b/src/clients/slepos_data_migration.ycp new file mode 100644 index 0000000..e4d317a --- /dev/null +++ b/src/clients/slepos_data_migration.ycp @@ -0,0 +1,947 @@ +{ + // Configuration + string migration_conf = "/etc/YaST2/slepos_migration.xml"; + + // Default values are defined in $migration_conf file + // Fallback values below + boolean default_do_backup = nil; + string default_backupdir = ""; + string default_backupname = ""; + integer migration_redraw_sleep = nil; + string migration_type = ""; + string slepos_migration_post_script = ""; + + // FIXME + textdomain "SLEPOS"; + + import "FileUtils"; + import "Wizard"; + import "Mode"; + import "Label"; + import "Popup"; + import "Sequencer"; + import "String"; + import "Report"; + + // Variables + + list copy_data_dirs = []; + list copy_data_files = []; + + string backup_archive = ""; + + // Functions + + integer size_kB = 1024; + integer size_MB = 1024 * 1024; + integer size_GB = 1024 * 1024 * 1024; + + string SizeInReadableFormat (integer size_in_b) { + integer current = (size_in_b / size_kB); + + // more than a kB + if (current > size_kB) { + current = (size_in_b / size_MB); + // more than a MB + if (current > size_kB) { + return sformat ("%1 GB", (size_in_b / size_MB)); + // less than a GB + } else { + return sformat ("%1 MB", current); + } + // less than a kB + } else { + return sformat ("%1 kB", current); + } + } + + void ParseOneDirItem (map one_item) { + string source = one_item["source"]:""; + string destination = one_item["destination"]:""; + + if (source == "") { + y2error (">source< not defined %1", one_item); + return; + } + + if (destination == "") { + y2error (">destination< not defined %1", one_item); + return; + } + + if (! regexpmatch (source, "/$")) { + source = source + "/"; + } + + if (! regexpmatch (destination, "/$")) { + destination = destination + "/"; + } + + if (! FileUtils::Exists (source)) { + y2warning ("Directory '%1' doesn't exist - it will not be migrated", source); + return; + } + + copy_data_dirs = add (copy_data_dirs, $[ + "source" : source, + "destination" : destination, + ]); + } + + void ParseOneFileItem (map one_item) { + string source = one_item["source"]:""; + string destination = one_item["destination"]:""; + + if (source == "") { + y2error (">source< not defined %1", one_item); + return; + } + + if (destination == "") { + y2error (">destination< not defined %1", one_item); + return; + } + + if (! regexpmatch (destination, "/$")) { + destination = destination + "/"; + } + + if (! FileUtils::Exists (source)) { + y2warning ("File '%1' doesn't exist - it will not be migrated", source); + return; + } + + copy_data_files = add (copy_data_files, $[ + "source" : source, + "destination" : destination, + ]); + } + + boolean ReadParseAndCheckXMLConfig () { + if (! FileUtils::Exists (migration_conf)) { + y2error ("Can't read migration config file!"); + return false; + } + + y2milestone ("Reading %1", migration_conf); + map conf = (map ) SCR::Read (.xml, migration_conf); + + if (migration_conf == nil) { + y2error ("Can't parse migration config file!"); + return false; + } + + foreach (map one_item, (list >) conf["itemcopies"]:[], { + if (one_item["type"]:nil == "directory") { + ParseOneDirItem (one_item); + } else if (one_item["type"]:nil == "file") { + ParseOneFileItem (one_item); + } else { + y2error ("Unknown type: %1", one_item); + } + }); + + /* --- parsing configuration --- */ + + if (conf["config","default_backupdir"]:"" != "") { + default_backupdir = conf["config","default_backupdir"]:""; + } else { + default_backupdir = "/var/adm/backup/SLEPOS_DATA/"; + } + + if (conf["config","default_backupname"]:"" != "") { + default_backupname = conf["config","default_backupname"]:""; + } else { + default_backupname = "SLEPOS_DATA_"; + } + + if (conf["config","migration_redraw_sleep"]:0 != 0) { + migration_redraw_sleep = conf["config","migration_redraw_sleep"]:50; + } else { + migration_redraw_sleep = 50; + } + + if (conf["config","migration_type"]:"" != "") { + migration_type = conf["config","migration_type"]:""; + } else { + migration_type = "copy"; + } + + if (conf["config","slepos_migration_post_script"]:"" != "") { + slepos_migration_post_script = conf["config","slepos_migration_post_script"]:""; + } else { + slepos_migration_post_script = ""; + } + + if (conf["config","default_do_backup"]:false != false) { + default_do_backup = conf["config","default_do_backup"]:false; + } else { + default_do_backup = false; + } + + /* --- parsing configuration --- */ + + y2milestone ("Dirs to migrate: %1", copy_data_dirs); + y2milestone ("Files to migrate: %1", copy_data_files); + + return true; + } + + void RedrawMigrationItems () { + list items = []; + + integer counter = -1; + + foreach (map copy_data_dir, copy_data_dirs, { + counter = counter + 1; + items[counter] = `item ( + `id (counter), + _("Directory"), + copy_data_dir["source"]:"", + copy_data_dir["destination"]:"" + ); + }); + + foreach (map copy_data_file, copy_data_files, { + counter = counter + 1; + items[counter] = `item ( + `id (counter), + _("File"), + copy_data_file["source"]:"", + copy_data_file["destination"]:"" + ); + }); + + UI::ChangeWidget (`id (`migration_items), `Items, items); + } + + void DisplayMigrationDialog () { + Wizard::SetContentsButtons ( + _("Migration Asistent"), + `VBox ( + `VSpacing (1), + `RadioButtonGroup ( + `id (`skip_or_do_migration), + `VBox ( + `Left (`RadioButton (`id (`skip_migration), `opt (`notify, `boldFont), _("&Skip Migration"))), + `Left (`RadioButton (`id (`do_migrate), `opt (`notify, `boldFont), _("&Do Migrate"), true)) + ) + ), + `VSpacing (1), + `HBox ( + `HSpacing (4), + `VBox ( + `id (`migration_allitems), + `Left (`Label (_("These directories and files will be migrated"))), + `Table ( + `id (`migration_items), + `header ( + _("Type"), + _("From"), + _("To") + ), + [] + ), + `VSpacing (0.5), + `Left (`PushButton (`id (`details), _("&Migration Details..."))) + ) + ), + `VStretch (), + `Left (`Label (_("Note: Migration can take very long time according to the current size of your data."))) + ), + _("

Some help - FIXME!!!!

"), + Label::BackButton(), + Label::NextButton() + ); + + Wizard::SetTitleIcon ("yast-disk"); + + RedrawMigrationItems(); + } + + boolean ArchiveNameOK (string archive_name) { + // file doesn't exist, no problem with overwriting + if (! FileUtils::Exists (archive_name)) { + return true; + + // file already exists + } else if (FileUtils::IsFile (archive_name)) { + return (Popup::AnyQuestion ( + _("Warning"), + sformat(_("Archive %1 already exists. +Do you really want to overwrite it?"), archive_name), + _("&Yes, Overwrite"), + Label::NoButton(), + `no + )); + + // file is a directory + } else if (FileUtils::IsDirectory (archive_name)) { + Report::Error (sformat(_("Archive %1 is a directory. +Expecting file name instead."), archive_name)); + return false; + + // file is a socket, fifo, etc... + } else { + Report::Error ( + sformat (_("The file %1 is type '%2'. +It cannot be used for creating any backup archive."), archive_name, FileUtils::GetFileType (archive_name)) + ); + return false; + } + } + + void AdjustMigrationDialog () { + any current_button = (symbol) UI::QueryWidget (`id (`skip_or_do_migration), `CurrentButton); + + if (current_button == `skip_migration) { + UI::ChangeWidget (`id (`migration_allitems), `Enabled, false); + } else { + UI::ChangeWidget (`id (`migration_allitems), `Enabled, true); + } + } + + string CheckOrCreateArchiveName (string archive_name) { + // Archive Name is an existent directory + // but doesn't have a final slash + if (FileUtils::Exists (archive_name) && FileUtils::IsDirectory (archive_name) && !regexpmatch (archive_name, "/$")) { + archive_name = archive_name + "/"; + } + + // must be a directory + if (regexpmatch (archive_name, "/$")) { + map cmd = (map) WFM::Execute (.local.bash_output, "date +%Y%m%d-%H%M%S"); + list a_name_list = splitstring(cmd["stdout"]:"the_latest", "\n"); + archive_name = archive_name + default_backupname + a_name_list[0]:"" + ".tar"; + } + + return archive_name; + } + + void HandleDetailsDialog () { + if (default_do_backup && backup_archive == "") { + backup_archive = default_backupdir; + } + + UI::OpenDialog ( + `VBox ( + `Heading (_("Migration Details")), + `VSpacing (1), + `Left (`Label (_("We recommend creating a backup copy of your data +before the migration starts."))), + `VSpacing (1), + `Left (`CheckBox (`id (`do_backup), `opt (`notify), _("Create a Backup &Archive"))), + `HBox ( + `MinWidth (50, `TextEntry (`id (`backup_archive), _("Archive &Location"), backup_archive)), + `HSpacing (1), + `VBox ( + `VSpacing (1), + `PushButton (`id (`browse), _("&Browse...")) + ) + ), + `VSpacing (1), + `HBox ( + `PushButton (`id (`ok), Label::OKButton()), + `HSpacing (2), + `PushButton (`id (`cancel), Label::CancelButton()) + ) + ) + ); + + if (backup_archive == "") { + UI::ChangeWidget (`id (`do_backup), `Value, false); + UI::ChangeWidget (`id (`backup_archive), `Enabled, false); + } else { + UI::ChangeWidget (`id (`do_backup), `Value, true); + UI::ChangeWidget (`id (`backup_archive), `Enabled, true); + } + + any ret = ""; + + while (true) { + ret = UI::UserInput(); + + if (ret == `cancel) { + break; + } else if (ret == `ok) { + if ((boolean) UI::QueryWidget (`id (`do_backup), `Value)) { + backup_archive = CheckOrCreateArchiveName ((string) UI::QueryWidget (`id (`backup_archive), `Value)); + + if (backup_archive == "") { + UI::SetFocus (`backup_archive); + Report::Error (_("Please, select a directory or an archive file.")); + continue; + } + } else { + backup_archive = ""; + } + + if (ArchiveNameOK (backup_archive)) break; + + // browse button pressed + } else if (ret == `browse) { + string existdir = UI::AskForExistingDirectory ( + (backup_archive == "" ? default_backupdir : backup_archive), + _("Backup Archive File Location") + ); + UI::ChangeWidget (`id (`backup_archive), `Value, existdir); + + // checkbox "do backup" selected + } else if (ret == `do_backup) { + boolean do_backup = (boolean) UI::QueryWidget (`id (`do_backup), `Value); + UI::ChangeWidget (`id (`backup_archive), `Enabled, do_backup); + + // if selected to make a backup and no default backup dir is printed + if (do_backup && UI::QueryWidget (`id (`backup_archive), `Value) == "") { + UI::ChangeWidget (`id (`backup_archive), `Value, default_backupdir); + } + + } else { + y2error ("Uknown ret: %1", ret); + } + } + + UI::CloseDialog(); + } + + symbol HandleMigrationDialog () { + any ret = nil; + + symbol dialog_ret = `next; + + while (true) { + ret = UI::UserInput(); + + if (ret == `back) { + dialog_ret = `back; + break; + } else if (ret == `next) { + any current_button = (symbol) UI::QueryWidget (`id (`skip_or_do_migration), `CurrentButton); + + if (current_button == `skip_migration) { + y2milestone ("Migration will be skipped"); + dialog_ret = `skip; + } else { + dialog_ret = `next; + } + + break; + } else if (ret == `skip_migration || ret == `do_migrate) { + AdjustMigrationDialog(); + } else if (ret == `abort) { + if (Mode::normal()) { + if (Popup::ReallyAbort (false)) { + dialog_ret = `abort; + break; + } + } else if (Popup::ConfirmAbort (`incomplete)) { + dialog_ret = `abort; + break; + } + } else if (ret == `details) { + HandleDetailsDialog(); + } else { + y2error ("Unknown ret: %1", ret); + } + } + + return dialog_ret; + } + + void DisplayMigrationProgress () { + Wizard::SetContentsButtons ( + _("Migration in Progress"), + `VBox ( + `ReplacePoint (`id (`rp_backup), `Empty ()), + `VSpacing (2), + `ReplacePoint (`id (`rp_migration), `Empty ()), + `VStretch () + ), + _("

Some help - FIXME!!!!

"), + Label::BackButton(), + Label::NextButton() + ); + + Wizard::SetTitleIcon ("yast-disk"); + } + + symbol InitialDialog () { + DisplayMigrationDialog(); + + symbol init_dialog_ret = HandleMigrationDialog(); + y2milestone ("InitDialog: %1", init_dialog_ret); + + return init_dialog_ret; + } + + integer backup_stats_dirs = 0; + integer backup_stats_files = 0; + string backup_stats_show = ""; + + integer backup_stats_dirs_last = 0; + integer backup_stats_files_last = 0; + + void UpdateBackupScreen () { + // no change + if (backup_stats_dirs == backup_stats_dirs_last && backup_stats_files == backup_stats_files_last) + return; + + backup_stats_dirs_last = backup_stats_dirs; + backup_stats_files_last = backup_stats_files; + + UI::ReplaceWidget ( + `id (`rp_backup), + `VBox ( + `Left (`Label (`opt (`boldFont), _("Backup statistics:"))), + `Left (`Label ( + sformat ( + "Current: %1\nTotal directories: %2\nTotal files: %3", + backup_stats_show, + backup_stats_dirs, + backup_stats_files + ) + )) + ) + ); + } + + void FinishBackupScreen () { + UI::ReplaceWidget ( + `id (`rp_backup), + `VBox ( + `Left (`Label (`opt (`boldFont), _("Backup statistics:"))), + `Left (`Label ( + sformat ( + "Total directories: %1\nTotal files: %2", + backup_stats_dirs, + backup_stats_files + ) + )), + `Left (`Label (`opt (`boldFont), _("Done"))) + ) + ); + } + + integer migrated_stats_dirs = 0; + integer migrated_stats_files = 0; + integer migrated_stats_size = 0; + string migrated_stats_show = ""; + + integer migrated_stats_dirs_last = 0; + integer migrated_stats_files_last = 0; + + void UpdateMigrationScreen () { + // no change + if (migrated_stats_dirs == migrated_stats_dirs_last && migrated_stats_files == migrated_stats_files_last) + return; + + migrated_stats_dirs_last = migrated_stats_dirs; + migrated_stats_files_last = migrated_stats_files; + + UI::ReplaceWidget ( + `id (`rp_migration), + `VBox ( + `Left (`Label (`opt (`boldFont), _("Migration statistics:"))), + `Left (`Label ( + sformat ( + "Current: %1\nTotal files: %2\nTotal size: %3", + migrated_stats_show, + migrated_stats_files, + SizeInReadableFormat (migrated_stats_size) + ) + )) + ) + ); + } + + void FinishMigrationScreen () { + UI::ReplaceWidget ( + `id (`rp_migration), + `VBox ( + `Left (`Label (`opt (`boldFont), _("Migration statistics:"))), + `Left (`Label ( + sformat ( + "Total files: %1\nTotal size: %2", + migrated_stats_files, + SizeInReadableFormat (migrated_stats_size) + ) + )), + `Left (`Label (`opt (`boldFont), _("Done"))) + ) + ); + } + + void AbortedMigrationScreen () { + UI::ReplaceWidget ( + `id (`rp_migration), + `VBox ( + `Left (`Label (`opt (`boldFont), _("Migration statistics:"))), + `Left (`Label ( + sformat ( + "Total files: %1", + migrated_stats_files + ) + )), + `Left (`Label (`opt (`boldFont), _("Aborted"))) + ) + ); + } + + boolean AbortBackup (any widget_id) { + if (widget_id != `abort) return false; + + if (Mode::normal()) { + return Popup::ReallyAbort (false); + } else { + return Popup::ConfirmAbort (`incomplete); + } + } + + boolean AbortMigration (any widget_id) { + if (widget_id != `abort) return false; + + if (Mode::normal()) { + return Popup::ReallyAbort (false); + } else { + return Popup::ConfirmAbort (`incomplete); + } + } + + boolean CreateBackupArchive () { + UI::ReplaceWidget ( + `id (`rp_backup), + `Left (`Label (_("Creating backup archive..."))) + ); + + string list_of_files_and_dirs = ""; + string one_item = ""; + + // dirs at first + foreach (map copy_data_dir, copy_data_dirs, { + one_item = copy_data_dir["source"]:""; + + if (one_item == "") { + y2error ("Invalid 'source': %1", copy_data_dir); + return; + } + + list_of_files_and_dirs = list_of_files_and_dirs + sformat (" '%1'", String::Quote (one_item)); + }); + + // then files + foreach (map copy_data_file, copy_data_files, { + one_item = copy_data_file["source"]:""; + + if (one_item == "") { + y2error ("Invalid 'source': %1", copy_data_file); + return; + } + + list_of_files_and_dirs = list_of_files_and_dirs + sformat (" '%1'", String::Quote (one_item)); + }); + + if (list_of_files_and_dirs == "") { + y2milestone ("Nothing to backup"); + return false; + } + + // at first the target directory needs to be created if it doesn't exist + string archive_dir = backup_archive; + integer position = findlastof (archive_dir, "/"); + archive_dir = substring (archive_dir, 0, position + 1); + + string cmd = sformat ( + "mkdir -p '%1'; tar -cvSf '%2' %3", + String::Quote (archive_dir), + String::Quote (backup_archive), + list_of_files_and_dirs + ); + y2milestone ("Executing: %1", cmd); + + SCR::Execute(.background.run_output_err, cmd); + + backup_stats_dirs = 0; + backup_stats_files = 0; + backup_stats_show = ""; + + while ((boolean) SCR::Read(.background.output_open) || (boolean) (SCR::Read(.background.newlines) > 0)) { + any widget_id = UI::PollInput(); + + if (AbortBackup(widget_id)) { + integer kill_count = 10; + while (kill_count > 0) { + kill_count = kill_count - 1; + if ((boolean) SCR::Execute (.background.kill)) break; + sleep (1000); + } + } + + if ((integer) SCR::Read (.background.newlines) > 0) { + list lines = (list ) SCR::Read (.background.newout); + + foreach (string line, lines, { + if (regexpmatch (line, "/$")) { + backup_stats_dirs = backup_stats_dirs + 1; + } else { + backup_stats_files = backup_stats_files + 1; + } + backup_stats_show = line; + }); + } + + UpdateBackupScreen (); + sleep (migration_redraw_sleep); + } + + FinishBackupScreen (); + y2milestone ("Result: %1", SCR::Read (.background.status)); + + return true; + } + + boolean migration_aborted = false; + + boolean MigrateFromTo (string source, string target) { + if (source == "") { + y2error ("Invalid 'source': %1", source); + return false; + } + + if (target == "") { + y2error ("Invalid 'target': %1", target); + return false; + } + + // '/tmp/aaa/' -> '/tmp/aaa/.' + if (regexpmatch (source, "/$")) source = source + "."; + + string cmd = ""; + if (migration_type == "move") { + cmd = sformat ( + "mkdir -p '%2'; mv -vf '%1' '%2'", + String::Quote (source), + String::Quote (target) + ); + } else { + cmd = sformat ( + "mkdir -p '%2'; cp -avrf '%1' '%2'", + String::Quote (source), + String::Quote (target) + ); + } + + y2milestone ("Executing: %1", cmd); + + SCR::Execute(.background.run_output_err, cmd); + + string target_filename = ""; + + while ((boolean) SCR::Read (.background.output_open) || (boolean) (SCR::Read (.background.newlines) > 0)) { + any widget_id = UI::PollInput(); + + if (AbortMigration (widget_id)) { + migration_aborted = true; + integer kill_count = 10; + while (kill_count > 0) { + kill_count = kill_count - 1; + if ((boolean) SCR::Execute (.background.kill)) break; + sleep (1000); + } + } + + if ((integer) SCR::Read (.background.newlines) > 0) { + list lines = (list ) SCR::Read (.background.newout); + + foreach (string line, lines, { + if (regexpmatch (line, "^`.*' -> `.*'$")) { + target_filename = line; + target_filename = regexpsub (line, "^`.*' -> `(.*)'$", "\\1"); + migrated_stats_size = migrated_stats_size + (integer) SCR::Read (.target.size, target_filename); + + line = regexpsub (line, "^`(.*) -> `.*'$", "\\1"); + } else if (regexpmatch (line, "^removed `.*'$")) { + return; + } else { + y2error ("Unknown line type: >%1<", line); + } + + if (regexpmatch (line, "/$")) { + migrated_stats_dirs = migrated_stats_dirs + 1; + } else { + migrated_stats_files = migrated_stats_files + 1; + } + + migrated_stats_show = line; + }); + } + + UpdateMigrationScreen (); + sleep (migration_redraw_sleep); + } + + y2milestone ("Result: %1", SCR::Read (.background.status)); + } + + boolean MigrateData () { + UI::ReplaceWidget ( + `id (`rp_migration), + `Left (`Label (_("Migrating data..."))) + ); + + migrated_stats_dirs = 0; + migrated_stats_files = 0; + migrated_stats_show = ""; + + string source = ""; + string target = ""; + + migration_aborted = false; + + // dirs at first + foreach (map copy_data_dir, copy_data_dirs, { + if (migration_aborted) { + y2milestone ("Aborted!"); + break; + } + + source = copy_data_dir["source"]:""; + target = copy_data_dir["destination"]:""; + + y2milestone ("Migrating: %1", copy_data_dir); + MigrateFromTo (source, target); + }); + + // then files + foreach (map copy_data_file, copy_data_files, { + if (migration_aborted) { + y2milestone ("Aborted!"); + break; + } + + source = copy_data_file["source"]:""; + target = copy_data_file["destination"]:""; + + y2milestone ("Migrating: %1", copy_data_file); + MigrateFromTo (source, target); + }); + + if (migration_aborted) { + AbortedMigrationScreen (); + } else { + FinishMigrationScreen (); + sleep (3000); + } + + return (migration_aborted == false); + } + + symbol MigrationDialog () { + DisplayMigrationProgress(); + + Wizard::DisableBackButton(); + Wizard::DisableNextButton(); + Wizard::EnableAbortButton(); + + if (backup_archive != "") { + CreateBackupArchive(); + } + + MigrateData(); + + Wizard::DisableAbortButton(); + Wizard::EnableBackButton(); + Wizard::EnableNextButton(); + + any ret = ""; + symbol dialog_ret = `next; + + while (true) { + ret = UI::UserInput(); + + if (ret == `back) { + dialog_ret = `back; + break; + } else if (ret == `next) { + dialog_ret = `next; + break; + // e.g., `cancel + } else { + y2error ("Unknow ret: %1", ret); + } + } + + Wizard::EnableAbortButton(); + + return dialog_ret; + } + + symbol MigrationPostScript () { + if (! FileUtils::Exists (slepos_migration_post_script)) { + y2warning ("Script '%1' doesn't exist, skipping...", slepos_migration_post_script); + return `next; + } + + Wizard::SetContentsButtons ( + _("Migration Asistent"), + `VBox ( + `Label (_("Running post-migration script...")) + ), + _("

Some help - FIXME!!!!

"), + Label::BackButton(), + Label::NextButton() + ); + + Wizard::DisableAbortButton(); + Wizard::SetTitleIcon ("yast-disk"); + + y2milestone ("Running: %1", slepos_migration_post_script); + map cmd = (map) SCR::Execute (.target.bash_output, slepos_migration_post_script); + y2milestone ("Ret: %1", cmd); + + Wizard::EnableAbortButton(); + + return `next; + } + + // main() + + map aliases = $[ + "initial" : ``( InitialDialog () ), + "migrate" : ``( MigrationDialog() ), + "postscript" : ``( MigrationPostScript() ), + ]; + + map sequence = $[ + "ws_start" : "initial", + "initial" : $[ + `next : "migrate", + `skip : `next, + `abort : `abort, + ], + "migrate" : $[ + `next : "postscript", + `abort : `abort, + ], + "postscript" : $[ + `next : `next, + `abort : `abort, + ], + ]; + + Wizard::CreateDialog(); + + if (! ReadParseAndCheckXMLConfig()) { + Report::Error (sformat ( + _("Unable to read migration configuration from %1"), + migration_conf + )); + return `next; + } + + any ret = Sequencer::Run (aliases, sequence); + y2milestone ("Sequencer::Run %1", ret); + + Wizard::CloseDialog(); + + return (symbol) ret; +} \ No newline at end of file diff --git a/src/clients/slepos_server_selection.ycp b/src/clients/slepos_server_selection.ycp new file mode 100644 index 0000000..ce92ec2 --- /dev/null +++ b/src/clients/slepos_server_selection.ycp @@ -0,0 +1,188 @@ +/** + */ + +{ + // FIXME + textdomain "SLEPOS"; + + import "Wizard"; + import "Label"; + import "Popup"; + import "Installation"; + import "Mode"; + import "Report"; + import "Stage"; + import "PackageCallbacks"; + + if (Mode::normal()) + Wizard::CreateDialog(); + + list > list_of_patterns = [ + $[ + "label" : _("Admin Server Installation"), + "name" : "SLEPOS_Server_Admin", + "icon" : "/usr/share/icons/hicolor/32x32/apps/yast-powertweak.png", + ], + $[ + "label" : _("Branch Server Installation"), + "name" : "SLEPOS_Server_Branch", + "icon" : "/usr/share/icons/hicolor/32x32/apps/yast-iscsi-server.png", + ], + $[ + "label" : _("Image Server Installation"), + "name" : "SLEPOS_Image_Server", + "icon" : "/usr/share/icons/hicolor/32x32/apps/yast-instserver.png", + ], + ]; + + list all_patterns_in_selection = []; + + void InitTargetNow () { + Pkg::SourceStartManager (true); + Pkg::TargetInit (Installation::destdir, false); + } + + string GetPatternLabel (string pattern_name) { + string pattern_label = pattern_name; + + foreach (map one_pattern, list_of_patterns, { + if (one_pattern["name"]:nil == pattern_name) { + pattern_label = one_pattern["label"]:pattern_name; + break; + } + }); + + return pattern_label; + } + + boolean HandleSelectedRadioButton () { + string current_button = (string) UI::QueryWidget (`id (`selected_pattern), `CurrentButton); + + if (current_button == "detailed") { + InitTargetNow(); + any ret = WFM::call ("inst_packages", [`patterns]); + + // user didn't accept the pattern selector + if (ret != `accept) { + return false; + } else { + return true; + } + } else if (regexpmatch (current_button, "^pattern: .*$")) { + InitTargetNow(); + + foreach (string pattern_neutral, all_patterns_in_selection, { + list > current_pattern_state = Pkg::ResolvableProperties (pattern_neutral, `pattern, ""); + if (size (current_pattern_state) == 0) { + y2error ("No such pattern: %1", pattern_neutral); + return; + } + Pkg::ResolvableNeutral (pattern_neutral, `pattern, (Stage::initial() ? true:false)); + }); + + string pattern_to_select = regexpsub (current_button, "^pattern: (.*)$", "\\1"); + + if (Pkg::ResolvableInstall (pattern_to_select, `pattern) == true) { + Pkg::PkgSolve (false); + return true; + } else { + Report::Error (sformat(_("Unable to select pattern '%1'"), GetPatternLabel (pattern_to_select))); + return false; + } + } else { + y2error ("Unknown current button: %1", current_button); + return false; + } + } + + term CreateRadioButtonTerm (string pattern_name, string pattern_label, string pattern_icon) { + return `HBox ( + `HWeight ( + 1, + `Right (pattern_icon == "" ? `Empty() : `Image (pattern_icon, "")) + ), + `HSpacing (2), + `HWeight ( + 2, + `Left (`RadioButton ( + `id (pattern_name), + pattern_label + )) + ) + ); + } + + term term_patterns = `VBox (); + + foreach (map one_pattern, list_of_patterns, { + all_patterns_in_selection = add (all_patterns_in_selection, one_pattern["name"]:""); + + term_patterns = add ( + term_patterns, + CreateRadioButtonTerm ( + sformat ("pattern: %1", one_pattern["name"]:""), + one_pattern["label"]:"", + one_pattern["icon"]:"" + ) + ); + term_patterns = add (term_patterns, `VSpacing (0.7)); + }); + + term_patterns = add (term_patterns, `VSpacing (1)); + term_patterns = add ( + term_patterns, + CreateRadioButtonTerm ( + "detailed", + _("Detailed Selection"), + "" + ) + ); + + Wizard::SetContentsButtons ( + _("Server Pattern Selection"), + `RadioButtonGroup ( + `id (`selected_pattern), + `opt (`notify), + term_patterns + ), + _("

Some help - FIXME!!!!

"), + Label::BackButton(), + Label::NextButton() + ); + + Wizard::SetTitleIcon ("yast-software"); + + any ret = nil; + + symbol dialog_ret = `next; + + while (true) { + ret = UI::UserInput(); + + if (ret == `next) { + dialog_ret = `next; + if (HandleSelectedRadioButton()) { + break; + } else { + continue; + } + } else if (ret == `back) { + dialog_ret = `back; + break; + } else if (ret == `abort || ret == `cancel) { + if (Popup::ConfirmAbort (`incomplete)) { + dialog_ret = `abort; + break; + } else { + continue; + } + } else { + y2error ("Unhandled ret: %1", ret); + } + } + + if (Mode::normal()) + Wizard::CloseDialog(); + + return dialog_ret; +} diff --git a/src/scripts/Makefile.am b/src/scripts/Makefile.am new file mode 100644 index 0000000..1954f9d --- /dev/null +++ b/src/scripts/Makefile.am @@ -0,0 +1,8 @@ +# Makefile.am for installation/general + +client_DATA = $(wildcard *.*) + +install-data-local: + -install -d -m 755 $(DESTDIR)/var/lib/YaST2 + +include $(top_srcdir)/Makefile.am.common diff --git a/src/scripts/slepos_post.pl b/src/scripts/slepos_post.pl new file mode 100755 index 0000000..f4d4788 --- /dev/null +++ b/src/scripts/slepos_post.pl @@ -0,0 +1,9 @@ +#!/usr/bin/perl -w + +print "Aha\n"; + +sleep (2); + +warn "Ahaaaaaaa\n"; + +exit 0; diff --git a/testsuite/.cvsignore b/testsuite/.cvsignore new file mode 100644 index 0000000..24f1e26 --- /dev/null +++ b/testsuite/.cvsignore @@ -0,0 +1,11 @@ +Makefile +Makefile.in +site.exp +*.sum +*.log +tmp.out* +tmp.err* +tmp.log* +config +run +*.test diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am new file mode 100644 index 0000000..d9b12b0 --- /dev/null +++ b/testsuite/Makefile.am @@ -0,0 +1,21 @@ +# +# Makefile.am for .../testsuite +# +# Do not edit this file (Makefile.am) as it will be overwritten! +# + +AUTOMAKE_OPTIONS = dejagnu +EXTRA_DIST = $(wildcard tests/*.out) $(wildcard tests/*.err) $(wildcard tests/*.ycp) $(wildcard tests/*.yh) + +testsuite_prepare = @ydatadir@/testsuite/Makefile.testsuite + +all-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) + +clean-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) clean + +check-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) check + +# EOF diff --git a/testsuite/tests/.cvsignore b/testsuite/tests/.cvsignore new file mode 100644 index 0000000..e69de29 diff --git a/yast2-pos-installation.spec.in b/yast2-pos-installation.spec.in new file mode 100644 index 0000000..0224ae8 --- /dev/null +++ b/yast2-pos-installation.spec.in @@ -0,0 +1,31 @@ +@HEADER-COMMENT@ + +@HEADER@ +Requires: yast2 +BuildRequires: perl-XML-Writer update-desktop-files yast2 yast2-devtools yast2-testsuite + +BuildArchitectures: noarch + +Summary: Configuration of pos-installation + +%description +- + +@PREP@ + +@BUILD@ + +@INSTALL@ + +@CLEAN@ + +%files +%defattr(-,root,root) +%dir @yncludedir@/pos-installation +@yncludedir@/pos-installation/* +@clientdir@/pos-installation.ycp +@clientdir@/pos-installation_*.ycp +@moduledir@/PosInstallation.* +@moduledir@/PosInstallation2.* +@desktopdir@/pos-installation.desktop +%doc @docdir@