diff --git a/etc/build.props b/etc/build.props --- a/etc/build.props +++ b/etc/build.props @@ -1,29 +1,29 @@ title = AFP/Tools module = $AFP_BASE/tools/lib/classes/afp_tools.jar requirements = \ env:ISABELLE_SCALA_JAR \ $ISABELLE_CI_EXTRAS_JAR sources = \ - tools/admin/afp_build_hugo.scala \ + tools/admin/afp_component_hugo.scala \ tools/migration/afp_migrate_metadata.scala \ tools/migration/afp_obfuscate_emails.scala \ tools/afp_build.scala \ tools/afp_check_metadata.scala \ tools/afp_check_roots.scala \ tools/afp_dependencies.scala \ tools/afp_release.scala \ tools/afp_site_gen.scala \ tools/afp_submit.scala \ tools/afp_structure.scala \ tools/afp_tool.scala \ tools/hugo.scala \ tools/metadata.scala \ tools/rake.scala \ tools/utils.scala \ tools/web_app.scala resources = \ tools/SmartStoplist.txt:SmartStoplist.txt \ tools/migration/public_suffix_list.dat:public_suffix_list.dat services = \ afp.Tools \ afp.CI_Builds diff --git a/tools/admin/afp_build_hugo.scala b/tools/admin/afp_component_hugo.scala rename from tools/admin/afp_build_hugo.scala rename to tools/admin/afp_component_hugo.scala --- a/tools/admin/afp_build_hugo.scala +++ b/tools/admin/afp_component_hugo.scala @@ -1,118 +1,118 @@ package afp import isabelle._ -object AFP_Build_Hugo { +object AFP_Component_Hugo { val default_mirror = "https://github.com/gohugoio/hugo/releases/download/v0.88.1" def make_component_name(version: String): String = "hugo-" + version def make_archive_name(release: String, platform: Platform.Family): String = { val arch = platform match { case isabelle.Platform.Family.linux => "Linux-64bit" case isabelle.Platform.Family.macos => "macOS-64bit" case _ => error("Unsupported platform: " + platform) } "hugo_extended_" + release + "_" + arch + ".tar.gz" } def build_hugo( progress: Progress = new Progress, mirror: String = default_mirror, target_dir: Path = Path.current ): Unit = { Isabelle_System.with_tmp_dir("hugo") { tmp_dir => /* component */ val Version = """^.*?v([^/]+)$""".r val version = mirror match { case Version(version) => version case _ => error("Failed to determine component version from " + quote(mirror)) } val component = make_component_name(version) val component_dir = Isabelle_System.new_directory(target_dir.absolute + Path.basic(component)) progress.echo("Component " + component_dir) /* platform */ val platform_name = proper_string(Isabelle_System.getenv("ISABELLE_PLATFORM64")) getOrElse error("No 64bit platform") val platform_dir = Isabelle_System.make_directory(component_dir + Path.basic(platform_name)) /* archive */ val platform = Platform.Family.values.find(Platform.Family.standard(_) == platform_name).get val archive_name = make_archive_name(version, platform) /* download */ val archive_path = tmp_dir + Path.basic(archive_name) val download_url = mirror + "/" + archive_name Isabelle_System.download_file(download_url, archive_path, progress = progress) Isabelle_System.bash("tar xzf " + File.bash_path(archive_path), cwd = tmp_dir.file).check /* install */ Isabelle_System.copy_file(tmp_dir + Path.explode("hugo"), platform_dir) Isabelle_System.copy_file(tmp_dir + Path.explode("LICENSE"), component_dir) /* settings */ val etc_dir = Isabelle_System.make_directory(component_dir + Path.basic("etc")) File.write(etc_dir + Path.basic("settings"), """# -*- shell-script -*- :mode=shellscript: ISABELLE_HUGO="$COMPONENT/$ISABELLE_PLATFORM64" """) /* README */ File.write(component_dir + Path.basic("README"), "This Isabelle components provides a hugo extended " + version + """ component from """ + mirror + """ Fabian """ + Date.Format.date(Date.now()) + "\n") } } - val isabelle_tool = Isabelle_Tool("afp_build_hugo", "build afp hugo component", + val isabelle_tool = Isabelle_Tool("afp_component_hugo", "build afp hugo component", Scala_Project.here, { args => var target_dir = Path.current var mirror = default_mirror val getopts = Getopts(""" -Usage: isabelle afp_build_hugo [OPTIONS] +Usage: isabelle afp_component_hugo [OPTIONS] Options are: -D DIR target directory (default ".") -U URL release mirror (default """ + mirror + """) Build extended hugo component. """, "D:" -> (arg => target_dir = Path.explode(arg)), "U:" -> (arg => mirror = arg)) getopts(args) val progress = new Console_Progress() build_hugo(progress = progress, mirror = mirror, target_dir = target_dir) }) } \ No newline at end of file diff --git a/tools/afp_tool.scala b/tools/afp_tool.scala --- a/tools/afp_tool.scala +++ b/tools/afp_tool.scala @@ -1,22 +1,22 @@ package afp import isabelle._ import afp.migration.{AFP_Migrate_Metadata, AFP_Obfuscate_Emails} class Admin_Tools extends Isabelle_Scala_Tools( AFP_Migrate_Metadata.isabelle_tool, AFP_Obfuscate_Emails.isabelle_tool, - AFP_Build_Hugo.isabelle_tool, + AFP_Component_Hugo.isabelle_tool, ) class Tools extends Isabelle_Scala_Tools( AFP_Site_Gen.isabelle_tool, AFP_Check_Roots.isabelle_tool, AFP_Check_Metadata.isabelle_tool, AFP_Dependencies.isabelle_tool, AFP_Release.isabelle_tool, AFP_Submit.isabelle_tool )