?? RIGHT := 110 ??
?? NEWTITLE := 'INSTALL_SOFTWARE Utility: RAP$DISPLAY_JOB_LOG_TO_CMD_LOG Interface.' ??
MODULE ram$display_job_log_to_cmd_log;

{ PURPOSE:
{   This module contains the interface that displays the job log to the
{   installation command log.
{
{ DESIGN:
{   The compiled module resides in RAF$LIBRARY.
{
{ NOTES:
{

?? NEWTITLE := 'Global Declarations Referenced by This Module', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc rac$command_log_name
*copyc rat$installation_identifier
*copyc rat$path
?? POP ??
*copyc clp$include_line
*copyc clp$trimmed_string_size
*copyc rap$set_file_retention
?? OLDTITLE ??
?? NEWTITLE := '[XDCL] rap$display_job_log_to_cmd_log', EJECT ??

{ PURPOSE:
{   This interface creates a permanent copy of the job log by displaying the
{   job log to the command log associated with an installation event.
{
{ DESIGN:
{   This interface takes the installation logs path and installation
{   identifier passed in to determine the path to the command log.  When the
{   installation identifier has been defined it is assumed that the
{   installation identifier catalog that will contain the command log has
{   been created.  Otherwise, the interface returns without any further
{   processing.
{
{   The job log is displayed into the command log file using an SCL command.
{   Therefore a command line is built and included.
{
{   A retention period of 7 days is placed on the log file.
{
{ NOTES:
{

  PROCEDURE [XDCL] rap$display_job_log_to_cmd_log
    (    installation_logs: rat$path;
         installation_identifier: rat$installation_identifier;
     VAR status: ost$status);


    CONST
      retention_period = 7;

    VAR
      command_line: string (osc$max_string_size),
      command_line_length: integer,
      log_file: rat$path;


    status.normal := TRUE;

    IF installation_identifier = osc$null_name THEN
      RETURN;
    IFEND;

    { Assemble the path to the command log file under the installation identifier catalog.

    STRINGREP (log_file.path, log_file.size, installation_logs.path (1, installation_logs.size), '.',
          installation_identifier (1, clp$trimmed_string_size (installation_identifier)), '.',
          rac$command_log_name);

    { Build the SCL command line and perform the command.

    STRINGREP (command_line, command_line_length, '$system.display_log do=last o=', log_file.
          path (1, log_file.size));

    clp$include_line (command_line (1, command_line_length), TRUE, osc$null_name, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    { Set retention date on the log file just created.

    rap$set_file_retention (log_file.path (1, log_file.size), retention_period, status);

  PROCEND rap$display_job_log_to_cmd_log;
MODEND ram$display_job_log_to_cmd_log;
