ACC SHELL
/**
* File:
* copy_files_finish.ycp
*
* Module:
* Step of base installation finish
*
* Authors:
* Jiri Srain <jsrain@suse.cz>
*
* $Id: copy_files_finish.ycp 61719 2010-04-15 15:12:45Z locilka $
*
*/
{
textdomain "installation";
import "AddOnProduct";
import "Linuxrc";
import "Installation";
import "Directory";
import "ProductControl";
import "FileUtils";
import "String";
import "WorkflowManager";
import "SystemFilesCopy";
import "ProductFeatures";
include "installation/misc.ycp";
any ret = nil;
string func = "";
map param = $[];
/* Check arguments */
if(size(WFM::Args()) > 0 && is(WFM::Args(0), string)) {
func = (string)WFM::Args(0);
if(size(WFM::Args()) > 1 && is(WFM::Args(1), map))
param = (map)WFM::Args(1);
}
y2milestone ("starting copy_files_finish");
y2debug("func=%1", func);
y2debug("param=%1", param);
void CopyAllWorkflowFiles () {
if (size (WorkflowManager::GetAllUsedControlFiles()) == 0) {
y2milestone ("No additional workflows");
return;
}
y2milestone ("Coping additional control files %1", WorkflowManager::GetAllUsedControlFiles());
list <string> workflows_list = [];
foreach (string one_filename, WorkflowManager::GetAllUsedControlFiles(), {
if (regexpmatch (one_filename, "/")) {
one_filename = regexpsub (one_filename, "^.*/(.*)", "\\1");
}
workflows_list = add (workflows_list, one_filename);
});
// Remove the directory with all additional control files (if exists)
// and create it again (empty). BNC #471454
SCR::Execute (.target.bash, sformat ("rm -rf '%1'; /bin/mkdir -p '%1'",
String::Quote (Installation::destdir + Directory::etcdir + "/control_files")));
// BNC #475516: Writing the control-files-order index 'after' removing the directory
// Control files need to follow the exact order, only those liseted here are used
SCR::Write (.target.ycp, Installation::destdir + Directory::etcdir + "/control_files/order.ycp",
workflows_list);
SCR::Execute (.target.bash, "/bin/chmod 0644 " +
"'" + String::Quote (Installation::destdir) + Directory::etcdir + "/control_files/order.ycp'");
// Now copy all the additional control files to the just installed system
foreach (string file, WorkflowManager::GetAllUsedControlFiles(), {
SCR::Execute (.target.bash, "/bin/cp '" + String::Quote (file) + "' " +
"'" + String::Quote (Installation::destdir) + Directory::etcdir + "/control_files/'");
SCR::Execute (.target.bash, "/bin/chmod 0644 " +
"'" + String::Quote (Installation::destdir) + Directory::etcdir + "/control_files/" + String::Quote (file) + "'");
});
}
// see bugzilla #328126
void CopyHardwareUdevRules () {
string udev_rules_srcdir = "/etc/udev/rules.d/";
string udev_rules_destdir = sformat ("%1%2", Installation::destdir, udev_rules_srcdir);
if (! FileUtils::Exists (udev_rules_destdir)) {
y2milestone("%1 does not exist yet, creating it", udev_rules_destdir);
WFM::Execute (.local.bash, sformat ("mkdir -p '%1'", udev_rules_destdir));
}
// udev files that should be copied
list <string> files_to_copy = [ "70-persistent-cd.rules" ];
foreach (string one_file, files_to_copy, {
string one_file_from = sformat ("%1%2", udev_rules_srcdir, one_file);
string one_file_to = sformat ("%1%2", udev_rules_destdir, one_file);
if (! FileUtils::Exists (one_file_from)) {
y2error ("Cannot copy non-existent file: %1", one_file_from);
} else if (FileUtils::Exists (one_file_to)) {
y2milestone ("File %1 exists, skipping", one_file_to);
} else {
string cmd = sformat ("cp -a '%1' '%2'", String::Quote (one_file_from), String::Quote (udev_rules_destdir));
map cmd_out = (map) WFM::Execute (.local.bash_output, cmd);
if (cmd_out["exit"]:-1 != 0) {
y2error ("Command failed '%1': %2", cmd, cmd_out);
}
}
});
}
if (func == "Info")
{
return (any)$[
"steps" : 1,
// progress step title
"title" : _("Copying files to installed system..."),
"when" : [ `installation, `update, `autoinst ],
];
}
else if (func == "Write")
{
// bugzilla #221815 and #485980
// Adding blacklisted modules into the /etc/modprobe.d/50-blacklist.conf
// This should run before the SCR::switch function
AdjustModprobeBlacklist();
// copy hardware status to installed system
y2milestone ("Copying hardware information");
WFM::Execute (.local.bash,
sformat (
// BNC #596938: Files / dirs might be symlinks
"mkdir -p '%1/var/lib/'; /bin/cp -a --recursive --dereference '/var/lib/hardware' '%1/var/lib/'",
String::Quote (Installation::destdir)
)
);
// if VNC, copy setup data
if (Linuxrc::vnc ()) {
y2milestone ("Copying VNC settings");
WFM::Execute (.local.bash,
sformat (
"/bin/cp -a '/root/.vnc' '%1/root/'",
String::Quote (Installation::destdir)
)
);
}
// --------------------------------------------------------------
// Copy /etc/install.inf into built system so that the
// second phase of the installation can find it.
Linuxrc::SaveInstallInf (Installation::destdir);
// Copy control.xml so it can be read once again during continue mode
y2milestone ("Copying YaST control file");
WFM::Execute (.local.bash,
sformat (
"/bin/cp '%1' '%2%3/control.xml' && /bin/chmod 0644 '%2%3/control.xml'",
String::Quote (ProductControl::current_control_file),
String::Quote (Installation::destdir),
String::Quote (Directory::etcdir)
)
);
// List of files used as additional workflow definitions
CopyAllWorkflowFiles();
// Copy files from inst-sys to the just installed system
// FATE #301937, items are defined in the control file
SystemFilesCopy::SaveInstSysContent();
// Remove old eula.txt
// bugzilla #208908
string eula_txt = sformat ("%1%2/eula.txt", Installation::destdir, Directory::etcdir);
if (FileUtils::Exists (eula_txt)) {
SCR::Execute (.target.remove, eula_txt);
}
// FATE #304865: Enhance YaST Modules to cooperate better handling the product licenses
string license_dir = ProductFeatures::GetStringFeature ("globals", "base_product_license_directory");
if (license_dir == nil || license_dir == "") {
license_dir = sformat ("%1%2/licenses/base/", Installation::destdir, Directory::etcdir);
y2warning ("No 'base_product_license_directory' set, using %1", license_dir);
} else {
license_dir = sformat ("%1/%2", Installation::destdir, license_dir);
y2milestone ("Using license dir: %1", license_dir);
}
// BNC #594042: Multiple license locations
list <string> license_locations = ["/usr/share/doc/licenses/", "/"];
foreach (string license_location, license_locations, {
license_location = sformat ("%1/license.tar.gz", license_location);
if (! FileUtils::Exists (license_location)) return;
// Copy licenses so it can be used in firstboot later
// bnc #396976
map cmd = (map) WFM::Execute (.local.bash_output,
sformat (
"mkdir -p '%1' && cd '%1' && rm -rf license*.*; cd '%1' && tar -xf '%2'",
String::Quote (license_dir),
String::Quote (license_location)
)
);
if (cmd["exit"]:-1 == 0) {
y2milestone ("Copying %1 to %2 was successful", license_location, license_dir);
} else {
y2error ("Copying %1 to %2 has failed: %3", license_location, license_dir, cmd);
}
break;
});
// bugzila #328126
// Copy 70-persistent-cd.rules ... if not updating
if (! Mode::update()) CopyHardwareUdevRules();
}
else
{
y2error ("unknown function: %1", func);
ret = nil;
}
y2debug("ret=%1", ret);
y2milestone("copy_files_finish finished");
return ret;
} /* EOF */
ACC SHELL 2018