install.nimf 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #? stdtmpl(subsChar = '?') | standard
  2. #proc generateInstallScript(c: ConfigData): string =
  3. # result = "#! /bin/sh\n# Generated by niminst\n"
  4. # var proj = c.name.toLowerAscii
  5. set -e
  6. if [ $# -eq 1 ] ; then
  7. # if c.cat[fcUnixBin].len > 0:
  8. if test -f ?{c.cat[fcUnixBin][0].toUnix}
  9. then
  10. echo "?c.displayName build detected"
  11. else
  12. echo "Please build ?c.displayName before installing it"
  13. exit 1
  14. fi
  15. # end if
  16. case $1 in
  17. "--help"|"-h"|"help"|"h")
  18. echo "?c.displayName installation script"
  19. echo "Usage: [sudo] sh install.sh DIR"
  20. echo "Where DIR may be:"
  21. echo " /usr/bin"
  22. echo " /usr/local/bin"
  23. echo " /opt"
  24. echo " <some other dir> (treated similar to '/opt')"
  25. echo "To deinstall, use the command:"
  26. echo "sh deinstall.sh DIR"
  27. exit 1
  28. ;;
  29. "/usr/bin")
  30. bindir=/usr/bin
  31. configdir=/etc/?proj
  32. libdir=/usr/lib/?proj
  33. docdir=/usr/share/?proj/doc
  34. datadir=/usr/share/?proj/data
  35. nimbleDir="/opt/nimble/pkgs/?c.nimblePkgName-?c.version"
  36. ;;
  37. "/usr/local/bin")
  38. bindir=/usr/local/bin
  39. configdir=/etc/?proj
  40. libdir=/usr/local/lib/?proj
  41. docdir=/usr/local/share/?proj/doc
  42. datadir=/usr/local/share/?proj/data
  43. nimbleDir="/opt/nimble/pkgs/?c.nimblePkgName-?c.version"
  44. ;;
  45. "/opt")
  46. bindir="/opt/?proj/bin"
  47. configdir="/opt/?proj/config"
  48. libdir="/opt/?proj/lib"
  49. docdir="/opt/?proj/doc"
  50. datadir="/opt/?proj/data"
  51. nimbleDir="/opt/nimble/pkgs/?c.nimblePkgName-?c.version"
  52. mkdir -p /opt/?proj
  53. mkdir -p $bindir
  54. mkdir -p $configdir
  55. ;;
  56. *)
  57. bindir="$1/?proj/bin"
  58. configdir="$1/?proj/config"
  59. libdir="$1/?proj/lib"
  60. docdir="$1/?proj/doc"
  61. datadir="$1/?proj/data"
  62. nimbleDir="$1/?proj"
  63. mkdir -p $1/?proj
  64. mkdir -p $bindir
  65. mkdir -p $configdir
  66. ;;
  67. esac
  68. mkdir -p $libdir
  69. mkdir -p $docdir
  70. mkdir -p $configdir
  71. mkdir -p $nimbleDir/
  72. echo "copying files..."
  73. #var createdDirs = newStringTable()
  74. #for cat in {fcConfig..fcLib, fcNimble}:
  75. # for f in items(c.cat[cat]):
  76. # var mk = splitFile(f.skipRoot).dir
  77. # if cat != fcNimble:
  78. # mk = unixDirVars[cat] & "/" & mk
  79. # else:
  80. # mk = "$nimbleDir" / splitFile(f).dir
  81. # end if
  82. # if mk.len > 0 and not createdDirs.hasKey(mk):
  83. # createdDirs[mk] = "true"
  84. mkdir -p ?{mk.toUnix}
  85. # end if
  86. # end for
  87. #end for
  88. #for f in items(c.cat[fcUnixBin]):
  89. cp ?f.toUnix $bindir/?f.skipRoot.toUnix
  90. chmod 755 $bindir/?f.skipRoot.toUnix
  91. #end for
  92. #for f in items(c.cat[fcConfig]):
  93. cp ?f.toUnix $configdir/?f.skipRoot.toUnix
  94. chmod 644 $configdir/?f.skipRoot.toUnix
  95. #end for
  96. #for f in items(c.cat[fcData]):
  97. if [ -f ?f.toUnix ]; then
  98. cp ?f.toUnix $datadir/?f.skipRoot.toUnix
  99. chmod 644 $datadir/?f.skipRoot.toUnix
  100. fi
  101. #end for
  102. #for f in items(c.cat[fcDoc]):
  103. if [ -f ?f.toUnix ]; then
  104. cp ?f.toUnix $docdir/?f.skipRoot.toUnix
  105. chmod 644 $docdir/?f.skipRoot.toUnix
  106. fi
  107. #end for
  108. #for f in items(c.cat[fcLib]):
  109. cp ?f.toUnix $libdir/?f.skipRoot.toUnix
  110. chmod 644 $libdir/?f.skipRoot.toUnix
  111. #end for
  112. #for f in items(c.cat[fcNimble]):
  113. cp ?f.toUnix $nimbleDir/?f.toUnix
  114. chmod 644 $nimbleDir/?f.toUnix
  115. #end for
  116. cp ?{c.nimblePkgName}.nimble $nimbleDir/?{c.nimblePkgName}.nimble
  117. chmod 644 $nimbleDir/?{c.nimblePkgName}.nimble
  118. echo "installation successful"
  119. else
  120. echo "?c.displayName installation script"
  121. echo "Usage: [sudo] sh install.sh DIR"
  122. echo "Where DIR may be:"
  123. echo " /usr/bin"
  124. echo " /usr/local/bin"
  125. echo " /opt"
  126. echo " <some other dir> (treated similar to '/opt')"
  127. echo "To deinstall, use the command:"
  128. echo "sh deinstall.sh DIR"
  129. exit 1
  130. fi