methods/in_common.rb
# Copy repository from ISO to local filesystem
Copy repository from ISO to local filesystem
Copy repository from ISO to local filesystem
def copy_iso(options)
  if options['verbose'] == true
    handle_output(options,"Checking:\tIf we can copy data from full repo ISO")
  end
  if options['file'].to_s.match(/sol/)
    iso_test_dir = options['mountdir']+"/repo"
    if File.directory?(iso_test_dir)
      iso_repo_dir = iso_test_dir
    else
      iso_test_dir = options['mountdir']+"/publisher"
      if File.directory?(iso_test_dir)
        iso_repo_dir = options['mountdir']
      else
        handle_output(options,"Warning:\tRepository source directory does not exist")
        if options['test'] != true
          quit(options)
        end
      end
    end
    test_dir = options['repodir']+"/publisher"
  else
    iso_repo_dir = options['mountdir']
    case options['file']
    when /CentOS|rhel|OracleLinux|Fedora/
      test_dir = options['repodir']+"/isolinux"
    when /VCSA/
      test_dir = options['repodir']+"/vcsa"
    when /VM/
      test_dir = options['repodir']+"/upgrade"
    when /install|FreeBSD/
      test_dir = options['repodir']+"/etc"
    when /coreos/
      test_dir = options['repodir']+"/coreos"
    when /SLES/
      test_dir = options['repodir']+"/suse"
    else
      test_dir = options['repodir']+"/install"
    end
  end
  if not File.directory?(options['repodir']) and not File.symlink?(options['repodir']) and not options['file'].to_s.match(/\.iso/)
    handle_output(options,"Warning:\tRepository directory #{options['repodir']} does not exist")
    if options['test'] != true
      quit(options)
    end
  end
  if not File.directory?(test_dir) or options['file'].to_s.match(/DVD2\.iso|2of2\.iso/)
    if options['file'].to_s.match(/sol/)
      if not File.directory?(iso_repo_dir)
        handle_output(options,"Warning:\tRepository source directory #{iso_repo_dir} does not exist")
        if options['test'] != true
          quit(options)
        end
      end
      message = "Copying:\t"+iso_repo_dir+" contents to "+options['repodir']
      command = "rsync -a #{iso_repo_dir}/. #{options['repodir']}"
      output  = execute_command(options,message,command)
      if options['host-os-name'].to_s.match(/SunOS/)
        message = "Rebuilding:\tRepository in "+options['repodir']
        command = "pkgrepo -s #{options['repodir']} rebuild"
        output  = execute_command(options,message,command)
      end
    else
      check_dir_exists(options,test_dir)
      message = "Copying:\t"+iso_repo_dir+" contents to "+options['repodir']
      command = "rsync -a #{iso_repo_dir}/. #{options['repodir']}"
      if options['repodir'].to_s.match(/sles_12/)
        if not options['file'].to_s.match(/2\.iso/)
          output  = execute_command(options,message,command)
        end
      else
        handle_output(options,message)
        output  = execute_command(options,message,command)
      end
    end
  end
  return
end
def copy_iso ( options ) if options [ 'verbose' ] == true handle_output ( options , "Checking:\tIf we can copy data from full repo ISO" ) end if options [ 'file' ] . to_s . match ( / sol / ) iso_test_dir = options [ 'mountdir' ] + "/repo" if File . directory? ( iso_test_dir ) iso_repo_dir = iso_test_dir else iso_test_dir = options [ 'mountdir' ] + "/publisher" if File . directory? ( iso_test_dir ) iso_repo_dir = options [ 'mountdir' ] else handle_output ( options , "Warning:\tRepository source directory does not exist" ) if options [ 'test' ] != true quit ( options ) end end end test_dir = options [ 'repodir' ] + "/publisher" else iso_repo_dir = options [ 'mountdir' ] case options [ 'file' ] when / CentOS|rhel|OracleLinux|Fedora / test_dir = options [ 'repodir' ] + "/isolinux" when / VCSA / test_dir = options [ 'repodir' ] + "/vcsa" when / VM / test_dir = options [ 'repodir' ] + "/upgrade" when / install|FreeBSD / test_dir = options [ 'repodir' ] + "/etc" when / coreos / test_dir = options [ 'repodir' ] + "/coreos" when / SLES / test_dir = options [ 'repodir' ] + "/suse" else test_dir = options [ 'repodir' ] + "/install" end end if not File . directory? ( options [ 'repodir' ] ) and not File . symlink? ( options [ 'repodir' ] ) and not options [ 'file' ] . to_s . match ( / \. iso / ) handle_output ( options , "Warning:\tRepository directory #{options['repodir']} does not exist" ) if options [ 'test' ] != true quit ( options ) end end if not File . directory? ( test_dir ) or options [ 'file' ] . to_s . match ( / DVD2 \. iso|2of2 \. iso / ) if options [ 'file' ] . to_s . match ( / sol / ) if not File . directory? ( iso_repo_dir ) handle_output ( options , "Warning:\tRepository source directory #{iso_repo_dir} does not exist" ) if options [ 'test' ] != true quit ( options ) end end message = "Copying:\t" + iso_repo_dir + " contents to " + options [ 'repodir' ] command = "rsync -a #{iso_repo_dir}/. #{options['repodir']}" output = execute_command ( options , message , command ) if options [ 'host-os-name' ] . to_s . match ( / SunOS / ) message = "Rebuilding:\tRepository in " + options [ 'repodir' ] command = "pkgrepo -s #{options['repodir']} rebuild" output = execute_command ( options , message , command ) end else check_dir_exists ( options , test_dir ) message = "Copying:\t" + iso_repo_dir + " contents to " + options [ 'repodir' ] command = "rsync -a #{iso_repo_dir}/. #{options['repodir']}" if options [ 'repodir' ] . to_s . match ( / sles_12 / ) if not options [ 'file' ] . to_s . match ( / 2 \. iso / ) output = execute_command ( options , message , command ) end else handle_output ( options , message ) output = execute_command ( options , message , command ) end end end return end
Copy repository from ISO to local filesystem
Copy repository from ISO to local filesystem
options
<not_specific>