added isabelle remote_dmg tool;
authorwenzelm
Tue Oct 11 11:30:02 2016 +0200 (2016-10-11)
changeset 64143578e71c2c976
parent 64142 954451356017
child 64144 ef20d2da71af
added isabelle remote_dmg tool;
src/Pure/System/isabelle_tool.scala
src/Pure/Tools/remote_dmg.scala
src/Pure/build-jars
     1.1 --- a/src/Pure/System/isabelle_tool.scala	Tue Oct 11 10:43:27 2016 +0200
     1.2 +++ b/src/Pure/System/isabelle_tool.scala	Tue Oct 11 11:30:02 2016 +0200
     1.3 @@ -106,6 +106,7 @@
     1.4        Doc.isabelle_tool,
     1.5        ML_Process.isabelle_tool,
     1.6        Options.isabelle_tool,
     1.7 +      Remote_DMG.isabelle_tool,
     1.8        Update_Cartouches.isabelle_tool,
     1.9        Update_Header.isabelle_tool,
    1.10        Update_Then.isabelle_tool,
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/Pure/Tools/remote_dmg.scala	Tue Oct 11 11:30:02 2016 +0200
     2.3 @@ -0,0 +1,64 @@
     2.4 +/*  Title:      Pure/Tools/remote_dmg.scala
     2.5 +    Author:     Makarius
     2.6 +
     2.7 +Build dmg on remote Mac OS X system.
     2.8 +*/
     2.9 +
    2.10 +package isabelle
    2.11 +
    2.12 +
    2.13 +object Remote_DMG
    2.14 +{
    2.15 +  def remote_dmg(session: SSH.Session, tar_gz_file: Path, dmg_file: Path, volume_name: String = "")
    2.16 +  {
    2.17 +    session.with_tmp_dir(remote_dir =>
    2.18 +      using(session.sftp())(sftp =>
    2.19 +        {
    2.20 +          val cd = "cd " + File.bash_string(remote_dir) + "; "
    2.21 +
    2.22 +          sftp.write_file(remote_dir + "/dmg.tar.gz", tar_gz_file)
    2.23 +          session.execute(cd + "mkdir root && tar -C root -xzf dmg.tar.gz").check
    2.24 +          session.execute(
    2.25 +            cd + "hdiutil create -srcfolder root" +
    2.26 +              (if (volume_name == "") "" else " -volname " + File.bash_string(volume_name)) +
    2.27 +              " dmg.dmg").check
    2.28 +          sftp.read_file(remote_dir + "/dmg.dmg", dmg_file)
    2.29 +        }))
    2.30 +  }
    2.31 +
    2.32 +
    2.33 +  /* Isabelle tool wrapper */
    2.34 +
    2.35 +  val isabelle_tool = Isabelle_Tool("remote_dmg", "build dmg on remote Mac OS X system", args =>
    2.36 +  {
    2.37 +    Command_Line.tool0 {
    2.38 +      var port = SSH.default_port
    2.39 +      var volume_name = ""
    2.40 +
    2.41 +      val getopts = Getopts("""
    2.42 +Usage: isabelle remote_dmg [OPTIONS] USER@HOST TAR_GZ_FILE DMG_FILE
    2.43 +
    2.44 +  Options are:
    2.45 +    -p PORT      alternative SSH port (default: """ + SSH.default_port + """)
    2.46 +    -V NAME      specify volume name
    2.47 +
    2.48 +  Turn the contents of a tar.gz file into a dmg file -- produced on a remote
    2.49 +  Mac OS X system.
    2.50 +""",
    2.51 +        "p:" -> (arg => port = Value.Int.parse(arg)),
    2.52 +        "V:" -> (arg => volume_name = arg))
    2.53 +
    2.54 +      val more_args = getopts(args)
    2.55 +      val (user, host, tar_gz_file, dmg_file) =
    2.56 +        more_args match {
    2.57 +          case List(SSH.User_Host(user, host), tar_gz_file, dmg_file) =>
    2.58 +            (user, host, Path.explode(tar_gz_file), Path.explode(dmg_file))
    2.59 +          case _ => getopts.usage()
    2.60 +        }
    2.61 +
    2.62 +      val ssh = SSH.init(Options.init)
    2.63 +      using(ssh.open_session(user = user, host = host, port = port))(
    2.64 +        remote_dmg(_, tar_gz_file, dmg_file, volume_name))
    2.65 +    }
    2.66 +  })
    2.67 +}
     3.1 --- a/src/Pure/build-jars	Tue Oct 11 10:43:27 2016 +0200
     3.2 +++ b/src/Pure/build-jars	Tue Oct 11 11:30:02 2016 +0200
     3.3 @@ -124,6 +124,7 @@
     3.4    Tools/ml_statistics.scala
     3.5    Tools/news.scala
     3.6    Tools/print_operation.scala
     3.7 +  Tools/remote_dmg.scala
     3.8    Tools/simplifier_trace.scala
     3.9    Tools/task_statistics.scala
    3.10    Tools/update_cartouches.scala