src/Pure/System/components.scala
changeset 79978 2cc5182cbb08
parent 79977 612f0bb14124
child 79981 bdea4eccd8d5
equal deleted inserted replaced
79977:612f0bb14124 79978:2cc5182cbb08
    33   }
    33   }
    34 
    34 
    35 
    35 
    36   /* platforms */
    36   /* platforms */
    37 
    37 
    38   private val family_platforms: Map[Platform.Family, List[String]] =
    38   sealed case class Platforms(family_platforms: Map[String, List[String]]) {
    39     Map(
    39     def purge(preserve: List[Platform.Family]): String => Boolean = {
    40       Platform.Family.linux_arm -> List("arm64-linux", "arm64_32-linux"),
    40       val preserve_platform =
    41       Platform.Family.linux -> List("x86_64-linux", "x86_64_32-linux"),
    41         Set.from(
    42       Platform.Family.macos ->
    42           for {
    43         List("arm64-darwin", "arm64_32-darwin", "x86_64-darwin", "x86_64_32-darwin"),
    43             family <- preserve.iterator
    44       Platform.Family.windows ->
    44             platform <- family_platforms(family.toString).iterator
    45         List("x86_64-cygwin", "x86_64-windows", "x86_64_32-windows", "x86-windows"))
    45           } yield platform)
    46 
    46       (name: String) => family_platforms.isDefinedAt(name) && !preserve_platform(name)
    47   private val platform_names: Set[String] =
    47     }
    48     Set("x86-linux", "x86-cygwin") ++ family_platforms.iterator.flatMap(_._2)
    48   }
    49 
    49 
    50   def platform_purge(platforms: List[Platform.Family]): String => Boolean = {
    50   val default_platforms: Platforms =
    51     val preserve =
    51     Platforms(
    52       (for {
    52       Map(
    53         family <- platforms.iterator
    53         Platform.Family.linux_arm.toString ->
    54         platform <- family_platforms(family)
    54           List("arm64-linux", "arm64_32-linux"),
    55       } yield platform).toSet
    55         Platform.Family.linux.toString ->
    56     (name: String) => platform_names(name) && !preserve(name)
    56           List("x86_64-linux", "x86_64_32-linux"),
    57   }
    57         Platform.Family.macos.toString ->
       
    58           List("arm64-darwin", "arm64_32-darwin", "x86_64-darwin", "x86_64_32-darwin"),
       
    59         Platform.Family.windows.toString ->
       
    60           List("x86_64-cygwin", "x86_64-windows", "x86_64_32-windows", "x86-windows"),
       
    61         "obsolete" -> List("x86-linux", "x86-cygwin")))
    58 
    62 
    59 
    63 
    60   /* component collections */
    64   /* component collections */
    61 
    65 
    62   def static_component_repository: String =
    66   def static_component_repository: String =
    97   ): Unit = {
   101   ): Unit = {
    98     for {
   102     for {
    99       name <- ssh.read_dir(base_dir)
   103       name <- ssh.read_dir(base_dir)
   100       dir = base_dir + Path.basic(name)
   104       dir = base_dir + Path.basic(name)
   101       if is_component_dir(dir)
   105       if is_component_dir(dir)
   102     } Directory(dir, ssh = ssh).clean(platforms = platforms, progress = progress)
   106     } Directory(dir, ssh = ssh).clean(preserve = platforms, progress = progress)
   103   }
   107   }
   104 
   108 
   105   def resolve(
   109   def resolve(
   106     base_dir: Path,
   110     base_dir: Path,
   107     name: String,
   111     name: String,
   130     val unpack_dir = target_dir getOrElse base_dir
   134     val unpack_dir = target_dir getOrElse base_dir
   131     unpack(unpack_dir, archive, ssh = ssh, progress = progress)
   135     unpack(unpack_dir, archive, ssh = ssh, progress = progress)
   132 
   136 
   133     if (clean_platforms.isDefined) {
   137     if (clean_platforms.isDefined) {
   134       Directory(unpack_dir + Path.basic(name), ssh = ssh).
   138       Directory(unpack_dir + Path.basic(name), ssh = ssh).
   135         clean(platforms = clean_platforms.get, progress = progress)
   139         clean(preserve = clean_platforms.get, progress = progress)
   136     }
   140     }
   137 
   141 
   138     if (clean_archives) {
   142     if (clean_archives) {
   139       progress.echo("Removing " + quote(archive_name))
   143       progress.echo("Removing " + quote(archive_name))
   140       ssh.delete(archive)
   144       ssh.delete(archive)
   203       ssh.make_directory(etc)
   207       ssh.make_directory(etc)
   204       this
   208       this
   205     }
   209     }
   206 
   210 
   207     def clean(
   211     def clean(
   208       platforms: List[Platform.Family] = Platform.Family.list,
   212       platforms: Platforms = default_platforms,
       
   213       preserve: List[Platform.Family] = Platform.Family.list,
   209       progress: Progress = new Progress
   214       progress: Progress = new Progress
   210     ): Unit = {
   215     ): Unit = {
   211       val purge = platform_purge(platforms)
   216       val purge = platforms.purge(preserve)
   212       for {
   217       for {
   213         name <- ssh.read_dir(path)
   218         name <- ssh.read_dir(path)
   214         dir = Path.basic(name)
   219         dir = Path.basic(name)
   215         if purge(name) && ssh.is_dir(path + dir)
   220         if purge(name) && ssh.is_dir(path + dir)
   216       } {
   221       } {