cposs.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. #!/bin/sh
  2. ## Copyright (c) 2016 Minoca Corp. All Rights Reserved.
  3. ##
  4. ## Script Name:
  5. ##
  6. ## cposs.sh
  7. ##
  8. ## Abstract:
  9. ##
  10. ## This script copies the swiss source to the open source repository.
  11. ##
  12. ## Author:
  13. ##
  14. ## Evan Green 18-Jan-2016
  15. ##
  16. ## Environment:
  17. ##
  18. ## Minoca Build
  19. ##
  20. set -e
  21. if test -z "$SRCROOT"; then
  22. echo "Error: SRCROOT must be set."
  23. exit 1
  24. fi
  25. if test -z "$DEST"; then
  26. DEST="$SRCROOT/swiss"
  27. if ! [ -d "$DEST" ]; then
  28. echo "Error: DEST must be set or "$DEST" must exist."
  29. exit 1
  30. fi
  31. fi
  32. APPS="$SRCROOT/os/apps"
  33. LIB="$SRCROOT/os/lib"
  34. SED_ARG='/^Copyright/,/^Module Name:/{
  35. # Print the last line normally.
  36. /^Module Name:/b
  37. # Preserve spacing.
  38. /^$/b
  39. # Normalize the Minoca copyright. Add the OSS license after the Minoca
  40. # copyright.
  41. s/Copyright[^0-9]*\([-, 0-9]*\).*/Copyright (c) \1Minoca Corp./
  42. t addlicense
  43. # Preserve other non-Minoca copyrights.
  44. /^[Cc]opyright.*/ b
  45. # Delete all other junk.
  46. d
  47. :addlicense {
  48. p # Print the Minoca copyright line.
  49. i \
  50. \
  51. This project is dual licensed. You are receiving it under the terms of the\
  52. GNU General Public License version 3 (GPLv3). Alternative licensing terms are\
  53. available. Contact info@minocacorp.com for details. See the LICENSE file at the\
  54. root of this project for complete licensing information.
  55. d
  56. }
  57. }'
  58. ROOT_FILES=".gitattributes
  59. .gitconfig"
  60. for file in $ROOT_FILES; do
  61. sed "$SED_ARG" "$SRCROOT/os/$file" > "$DEST/$file"
  62. done
  63. TERMLIB="$DEST/termlib"
  64. mkdir -p "$TERMLIB"
  65. TERMLIB_FILES="term.c"
  66. for file in $TERMLIB_FILES; do
  67. sed "$SED_ARG" "$LIB/termlib/$file" > "$TERMLIB/$file"
  68. done
  69. RTL_BASE="$DEST/rtl/base"
  70. mkdir -p "$RTL_BASE/armv7" "$RTL_BASE/x86" "$RTL_BASE/x64"
  71. RTL_BASE_FILES="crc32.c
  72. heap.c
  73. math.c
  74. print.c
  75. rbtree.c
  76. scan.c
  77. softfp.c
  78. softfp.h
  79. string.c
  80. time.c
  81. time.h
  82. timezone.c
  83. wchar.c
  84. wprint.c
  85. wscan.c
  86. wstring.c
  87. wtime.c
  88. armv7/intrinsa.S
  89. armv7/intrinsc.c
  90. armv7/rtlarch.S
  91. armv7/rtlmem.S
  92. fp2int.c
  93. x86/intrinsc.c
  94. x86/rtlarch.S
  95. x86/rtlmem.S
  96. x64/rtlarch.S
  97. x64/rtlmem.S"
  98. for file in $RTL_BASE_FILES; do
  99. sed "$SED_ARG" "$LIB/rtl/base/$file" > "$RTL_BASE/$file"
  100. done
  101. sed "$SED_ARG" "$SRCROOT/os/lib/rtl/rtlp.h" > "$DEST/rtl/rtlp.h"
  102. RTLC="$DEST/rtl/rtlc"
  103. mkdir -p "$RTLC/"
  104. RTLC_FILES="stubs.c"
  105. for file in $RTLC_FILES; do
  106. sed "$SED_ARG" "$LIB/rtl/rtlc/$file" > "$RTLC/$file"
  107. done
  108. WINCSUP="$DEST/libc/wincsup"
  109. mkdir -p "$WINCSUP/include"
  110. WINCSUP_FILES="../regexcmp.c
  111. ../regexexe.c
  112. ../regexp.h
  113. strftime.c
  114. include/regex.h"
  115. for file in $WINCSUP_FILES; do
  116. sed "$SED_ARG" "$APPS/libc/dynamic/wincsup/$file" > "$WINCSUP/$file"
  117. done
  118. SWISS="$DEST/src"
  119. mkdir -p "$SWISS/ls"
  120. mkdir -p "$SWISS/sed"
  121. mkdir -p "$SWISS/sh"
  122. mkdir -p "$SWISS/swlib"
  123. mkdir -p "$SWISS/login"
  124. mkdir -p "$SWISS/uos"
  125. mkdir -p "$SWISS/win32"
  126. SWISS_FILES="basename.c
  127. cat.c
  128. cecho.c
  129. chmod.c
  130. chroot.c
  131. cmp.c
  132. comm.c
  133. cp.c
  134. cut.c
  135. date.c
  136. dd.c
  137. diff.c
  138. dirname.c
  139. easy.c
  140. echo.c
  141. env.c
  142. expr.c
  143. find.c
  144. grep.c
  145. head.c
  146. id.c
  147. install.c
  148. kill.c
  149. ln.c
  150. ls/compare.c
  151. ls/ls.c
  152. ls/ls.h
  153. mkdir.c
  154. mktemp.c
  155. mv.c
  156. nl.c
  157. nproc.c
  158. od.c
  159. printf.c
  160. ps.c
  161. pwd.c
  162. reboot.c
  163. rm.c
  164. rmdir.c
  165. sed/sed.c
  166. sed/sed.h
  167. sed/sedfunc.c
  168. sed/sedparse.c
  169. sed/sedutil.c
  170. seq.c
  171. sh/alias.c
  172. sh/arith.c
  173. sh/builtin.c
  174. sh/exec.c
  175. sh/expand.c
  176. sh/lex.c
  177. sh/linein.c
  178. sh/parser.c
  179. sh/path.c
  180. sh/sh.c
  181. sh/sh.h
  182. sh/shos.h
  183. sh/shparse.h
  184. sh/signals.c
  185. sh/util.c
  186. sh/var.c
  187. sort.c
  188. split.c
  189. stty.c
  190. sum.c
  191. swiss.c
  192. swiss.h
  193. swisscmd.h
  194. swlib/copy.c
  195. swlib/delete.c
  196. swlib/pattern.c
  197. swlib/pwdcmd.c
  198. swlib/string.c
  199. swlib/userio.c
  200. swlib.h
  201. swlibos.h
  202. tail.c
  203. tee.c
  204. test.c
  205. time.c
  206. touch.c
  207. tr.c
  208. uname.c
  209. uniq.c
  210. wc.c
  211. which.c
  212. xargs.c
  213. chown.c
  214. init.c
  215. login/chpasswd.c
  216. login/getty.c
  217. login/groupadd.c
  218. login/groupdel.c
  219. login/login.c
  220. login/lutil.c
  221. login/lutil.h
  222. login/passwd.c
  223. login/su.c
  224. login/sulogin.c
  225. login/useradd.c
  226. login/userdel.c
  227. login/vlock.c
  228. mkfifo.c
  229. readlink.c
  230. sh/shuos.c
  231. ssdaemon.c
  232. swlib/chownutl.c
  233. swlib/uos.c
  234. telnet.c
  235. telnetd.c
  236. swlib/minocaos.c
  237. swlib/linux.c
  238. win32/swiss.exe.manifest
  239. win32/swiss.rc
  240. sh/shntos.c
  241. swlib/ntos.c"
  242. for file in $SWISS_FILES; do
  243. sed "$SED_ARG" "$APPS/swiss/$file" > "$SWISS/$file"
  244. done
  245. SWISS_EDITED_FILES="win32/w32cmds.c
  246. cmds.c
  247. uos/uoscmds.c
  248. win32/w32cmds.c"
  249. for file in $SWISS_EDITED_FILES; do
  250. sed -e '/.*DwMain.*/d' -e "$SED_ARG" "$APPS/swiss/$file" > "$SWISS/$file"
  251. done
  252. INCLUDE="$DEST/include"
  253. mkdir -p "$INCLUDE/minoca/lib"
  254. mkdir -p "$INCLUDE/minoca/kernel"
  255. INCLUDE_FILES="minoca/lib/types.h
  256. minoca/lib/status.h
  257. minoca/lib/rtl.h
  258. minoca/lib/termlib.h
  259. minoca/lib/tzfmt.h
  260. minoca/kernel/x86.inc
  261. minoca/kernel/arm.inc
  262. minoca/kernel/x64.inc"
  263. for file in $INCLUDE_FILES; do
  264. sed "$SED_ARG" "$SRCROOT/os/include/$file" > "$INCLUDE/$file"
  265. done
  266. VERSION_H="$SRCROOT/$ARCH$DEBUG/obj/os/apps/swiss/version.h"
  267. if ! [ -r "$VERSION_H" ]; then
  268. echo "Error: $VERSION_H is missing. You must build swiss first!"
  269. exit 1
  270. fi
  271. sed -e "s/#define VERSION_LICENSE .*/#define VERSION_LICENSE \"\\\\nThis \
  272. software is licensed under the the terms of the GNU General Public \
  273. License v3.\"/" \
  274. -e "s/#define VERSION_BUILD_USER .*/#define VERSION_BUILD_USER \"Minoca\"/"\
  275. -e "s/\\(#define VERSION_BUILD_STRING \"\\)[^-]*-\\(.*\\)/\1\2/" \
  276. "$VERSION_H" > "$SWISS/version.h"
  277. echo "Done copying swiss files."