From 7ff362c9c6a73e28e3a472e33a6df8e4f8143e4e Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Sat, 24 Dec 2011 16:43:08 +1300 Subject: [PATCH] Improve the distribution download - add a simple readme - create a gzipped tar file of the download - add a dry-run option to the release script --- .gitignore | 1 - akka-kernel/src/main/dist/README | 34 ++++++++++ .../src/main/{scripts => dist/bin}/akka | 0 .../src/main/{scripts => dist/bin}/akka.bat | 0 .../src/main/dist/config}/application.conf | 0 akka-kernel/src/main/dist/deploy/README | 1 + project/Dist.scala | 64 ++++++++++------- project/scripts/find-replace | 2 +- project/scripts/release | 68 +++++++++++++++---- 9 files changed, 129 insertions(+), 41 deletions(-) create mode 100644 akka-kernel/src/main/dist/README rename akka-kernel/src/main/{scripts => dist/bin}/akka (100%) rename akka-kernel/src/main/{scripts => dist/bin}/akka.bat (100%) rename {config => akka-kernel/src/main/dist/config}/application.conf (100%) create mode 100644 akka-kernel/src/main/dist/deploy/README diff --git a/.gitignore b/.gitignore index 6effe20d91..8ec862d18c 100755 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ tags TAGS akka.tmproj reports -dist target deploy/*.jar .history diff --git a/akka-kernel/src/main/dist/README b/akka-kernel/src/main/dist/README new file mode 100644 index 0000000000..179f3c97a9 --- /dev/null +++ b/akka-kernel/src/main/dist/README @@ -0,0 +1,34 @@ + +Akka +==== + +This is the Akka 2.0-SNAPSHOT download. + +Included are all libraries, documentation, and sources for Akka. + +This download can also be used for running the Akka Microkernel. + + +Contents +-------- + +- README - this document +- bin - start scripts for the Akka Microkernel +- config - config files for microkernel applications +- deploy - deploy dir for microkernel applications +- doc - Akka documentation and Scaladoc API +- lib - all Akka jars and dependencies +- src - source jars for Akka + + +Microkernel +----------- + +This download includes everything needed for a self-contained Akka +Microkernel. See the documentation for more information about the +microkernel (see `doc/akka/docs/modules/microkernel.html`). + +There is a sample microkernel application included in this download. +Start this application with the following command: + + bin/akka sample.kernel.hello.HelloKernel diff --git a/akka-kernel/src/main/scripts/akka b/akka-kernel/src/main/dist/bin/akka similarity index 100% rename from akka-kernel/src/main/scripts/akka rename to akka-kernel/src/main/dist/bin/akka diff --git a/akka-kernel/src/main/scripts/akka.bat b/akka-kernel/src/main/dist/bin/akka.bat similarity index 100% rename from akka-kernel/src/main/scripts/akka.bat rename to akka-kernel/src/main/dist/bin/akka.bat diff --git a/config/application.conf b/akka-kernel/src/main/dist/config/application.conf similarity index 100% rename from config/application.conf rename to akka-kernel/src/main/dist/config/application.conf diff --git a/akka-kernel/src/main/dist/deploy/README b/akka-kernel/src/main/dist/deploy/README new file mode 100644 index 0000000000..9b5a79112e --- /dev/null +++ b/akka-kernel/src/main/dist/deploy/README @@ -0,0 +1 @@ +Place application jars in this directory \ No newline at end of file diff --git a/project/Dist.scala b/project/Dist.scala index 002ae63fc1..05ba20d3a8 100644 --- a/project/Dist.scala +++ b/project/Dist.scala @@ -52,10 +52,7 @@ object Dist { (baseDirectory, distSources, distUnzipped, version, distFile, streams) map { (projectBase, allSources, unzipped, version, zipFile, s) => { val base = unzipped / ("akka-" + version) - val scripts = (projectBase / "akka-kernel" / "src" / "main" / "scripts" * "*").get - val bin = base / "bin" - val configSources = projectBase / "config" - val config = base / "config" + val distBase = projectBase / "akka-kernel" / "src" / "main" / "dist" val deploy = base / "deploy" val deployReadme = deploy / "readme" val doc = base / "doc" / "akka" @@ -68,30 +65,49 @@ object Dist { val libAkka = lib / "akka" val src = base / "src" / "akka" IO.delete(unzipped) - copyFilesTo(scripts, bin, setExecutable = true) - IO.copyDirectory(configSources, config) - IO.createDirectory(deploy) - IO.write(deployReadme, "Place application jars in this directory") - IO.copyDirectory(allSources.api, api) - IO.copyDirectory(allSources.docs, docs) - copyFilesTo(allSources.docJars, docJars) - copyFilesTo(scalaLibs, lib) - copyFilesTo(akkaLibs, libAkka) - copyFilesTo(allSources.srcJars, src) - val files = unzipped ** -DirectoryFilter - val sources = files x relativeTo(unzipped) - IO.zip(sources, zipFile) - zipFile + copyDirectory(distBase, base, setExecutable = true) + copyDirectory(allSources.api, api) + copyDirectory(allSources.docs, docs) + copyFlat(allSources.docJars, docJars) + copyFlat(scalaLibs, lib) + copyFlat(akkaLibs, libAkka) + copyFlat(allSources.srcJars, src) + zip(unzipped, zipFile) } } } - def copyFilesTo(files: Seq[File], dir: File, setExecutable: Boolean = false): Unit = { - IO.createDirectory(dir) - for (file <- files) { - val target = dir / file.name - IO.copyFile(file, target) - if (setExecutable) target.setExecutable(file.canExecute, false) + def copyDirectory(source: File, target: File, overwrite: Boolean = false, preserveLastModified: Boolean = false, setExecutable: Boolean = false): Set[File] = { + val sources = (source ***) x rebase(source, target) + copyMapped(sources, overwrite, preserveLastModified, setExecutable) + } + + def copyFlat(files: Seq[File], target: File, overwrite: Boolean = false, preserveLastModified: Boolean = false, setExecutable: Boolean = false): Set[File] = { + IO.createDirectory(target) + val sources = files map { f => (f, target / f.name) } + copyMapped(sources, overwrite, preserveLastModified, setExecutable) + } + + def copyMapped(sources: Traversable[(File, File)], overwrite: Boolean, preserveLastModified: Boolean, setExecutable: Boolean): Set[File] = { + sources map { Function.tupled(copy(overwrite, preserveLastModified, setExecutable)) } toSet + } + + def copy(overwrite: Boolean, preserveLastModified: Boolean, setExecutable: Boolean)(source: File, target: File): File = { + if (overwrite || !target.exists || source.lastModified > target.lastModified) { + if (source.isDirectory) IO.createDirectory(target) + else { + IO.createDirectory(target.getParentFile) + IO.copyFile(source, target, preserveLastModified) + if (setExecutable) target.setExecutable(source.canExecute, false) + } } + target + } + + def zip(source: File, target: File): File = { + val files = source ** -DirectoryFilter + val sources = files x relativeTo(source) + IO.zip(sources, target) + target } } diff --git a/project/scripts/find-replace b/project/scripts/find-replace index d0b6035032..d1a309330e 100755 --- a/project/scripts/find-replace +++ b/project/scripts/find-replace @@ -38,7 +38,7 @@ echolog "$find_expr --> $replace_expr" # exclude directories from search -declare exclude_dirs=".git dist deploy embedded-repo lib_managed project/boot project/scripts src_managed target" +declare exclude_dirs=".git project/project project/scripts src_managed target" echolog "excluding directories: $exclude_dirs" diff --git a/project/scripts/release b/project/scripts/release index ccbad76f36..e768fd675b 100755 --- a/project/scripts/release +++ b/project/scripts/release @@ -10,9 +10,10 @@ declare -r default_path="/akka/www" declare -r release_dir="target/release" declare release_server=${default_server} declare release_path=${default_path} +declare -r unzipped_dir="target/dist/unzipped" # flags -unset run_tests +unset run_tests dry_run # get the source location for this script; handles symlinks function get_script_path { @@ -32,10 +33,11 @@ declare -r script_dir="$(cd -P "$(dirname "${script_path}")" && pwd)" function usage { cat <&2 } +# echo a dry run log message +function echodry { + echolog "(dry run) $@" +} + # fail the script with an error message function fail { echoerr "$@" @@ -62,6 +69,7 @@ while true; do -t | --run-tests ) run_tests=true; shift ;; -s | --server ) release_server=$2; shift 2 ;; -p | --path ) release_path=$2; shift 2 ;; + -n | --dry-run) dry_run=true; shift ;; * ) break ;; esac done @@ -80,6 +88,12 @@ type -P git &> /dev/null || fail "git command not found" # check for an sbt command type -P sbt &> /dev/null || fail "sbt command not found" +# check for an rsync command +type -P rsync &> /dev/null || fail "rsync command not found" + +# check for a tar command +type -P tar &> /dev/null || fail "tar command not found" + # get the current git branch function get_current_branch { local ref=$(git symbolic-ref HEAD 2> /dev/null) @@ -124,17 +138,17 @@ function git_cleanup { safely git clean -f if [ "${branch}" == "${release_branch}" ]; then safely git checkout ${initial_branch} - safely git branch -d ${release_branch} + safely git branch -D ${release_branch} local tags=$(git tag -l) [[ "${tags}" == *v${version}* ]] && safely git tag -d v${version} fi - echoerr "Cleaned up failed release" } # clean up and fail the script with an error message function bail_out { echoerr "Bailing out!" git_cleanup + echoerr "Cleaned up failed release" fail "$@" } @@ -153,7 +167,13 @@ function try { } echolog "Creating release ${version} ..." -echolog "Publishing to ${publish_path}" + +if [ $dry_run ]; then + echodry "Building everything but not pushing release" +else + echolog "Publishing to ${publish_path}" +fi + [[ $run_tests ]] && echolog "All tests will be run" # try ssh'ing to the release server @@ -184,6 +204,8 @@ fi echolog "Building the release..." try sbt build-release try cp akka-spring/src/main/resources/akka/spring/akka-*.xsd ${release_dir} +echolog "Creating gzipped tar download..." +try tar -cz -C ${unzipped_dir} -f ${release_dir}/downloads/akka-${version}.tgz akka-${version} echolog "Successfully created local release" # commit and tag this release @@ -222,14 +244,30 @@ trap arrgh_interrupt SIGHUP SIGINT SIGTERM # push the commits and tags to git origin echolog "Pushing to git origin..." -important git push origin ${release_branch} -important git push origin --tags +if [ $dry_run ]; then + echodry "Not actually pushing to git origin. Commands:" + echodry " git push origin ${release_branch}" + echodry " git push origin --tags" +else + important git push origin ${release_branch} + important git push origin --tags +fi # push the release to the server echolog "Pushing ${release_dir} to ${publish_path} ..." -important rsync -rlpvz --chmod=Dg+ws,Fg+w ${release_dir}/ ${publish_path}/ +if [ $dry_run ]; then + echodry "Not actually pushing to server. Command:" + echodry " rsync -rlpvz --chmod=Dg+ws,Fg+w ${release_dir}/ ${publish_path}/" +else + important rsync -rlpvz --chmod=Dg+ws,Fg+w ${release_dir}/ ${publish_path}/ +fi -echolog "Switching back to initial branch" -git checkout ${initial_branch} - -echolog "Successfully created release ${version}" +if [ $dry_run ]; then + git_cleanup + echodry "Successfully created release ${version}" + echodry "See ${release_dir}" +else + echolog "Switching back to initial branch" + git checkout ${initial_branch} + echolog "Successfully created release ${version}" +fi