installer.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env ruby
  2. require "./lib/core"
  3. require "./lib/config"
  4. module OSPatch
  5. def check_linux_debian_distro
  6. os_release_file = "/etc/os-release"
  7. if File.exist?(os_release_file)
  8. os_release = File.read(os_release_file)
  9. ::RimeDeploy::DebianDistroLinux::DebianDistro.each do |distro|
  10. return true if os_release.include?(distro)
  11. end
  12. end
  13. return false
  14. end
  15. def check_os
  16. case RUBY_PLATFORM.downcase
  17. when /darwin/
  18. @osname = "MacOS"
  19. when /linux/
  20. if check_linux_debian_distro
  21. @osname = "DebianDistroLinux"
  22. else
  23. not_support_exit
  24. end
  25. when /mswin|win32|mingw|cygwin/
  26. @osname = "win"
  27. not_support_exit
  28. else
  29. not_support_exit
  30. end
  31. end
  32. end
  33. module RimeDeploy
  34. class Installer
  35. include OSPatch
  36. def initialize
  37. @osname = nil
  38. check_os
  39. dispatch
  40. run
  41. end
  42. def not_support_exit
  43. puts "Not support this system. Bye~"
  44. exit 0
  45. end
  46. def dispatch
  47. require "./os/#{@osname}"
  48. end
  49. def run
  50. os_prefix = @osname
  51. code = <<-CODE
  52. class #{os_prefix}JobGroup < JobGroup
  53. end
  54. mod = #{os_prefix}JobGroup.new(#{os_prefix}::Jobs, #{os_prefix}::FinishedHook)
  55. mod.call
  56. CODE
  57. instance_eval(code)
  58. end
  59. end
  60. end
  61. RimeDeploy::Installer.new