cposs.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. xargs.c
  212. chown.c
  213. init.c
  214. login/chpasswd.c
  215. login/getty.c
  216. login/groupadd.c
  217. login/groupdel.c
  218. login/login.c
  219. login/lutil.c
  220. login/lutil.h
  221. login/passwd.c
  222. login/su.c
  223. login/sulogin.c
  224. login/useradd.c
  225. login/userdel.c
  226. login/vlock.c
  227. mkfifo.c
  228. readlink.c
  229. sh/shuos.c
  230. ssdaemon.c
  231. swlib/chownutl.c
  232. swlib/uos.c
  233. telnet.c
  234. telnetd.c
  235. swlib/minocaos.c
  236. swlib/linux.c
  237. win32/swiss.exe.manifest
  238. win32/swiss.rc
  239. sh/shntos.c
  240. swlib/ntos.c"
  241. for file in $SWISS_FILES; do
  242. sed "$SED_ARG" "$APPS/swiss/$file" > "$SWISS/$file"
  243. done
  244. SWISS_EDITED_FILES="win32/w32cmds.c
  245. cmds.c
  246. uos/uoscmds.c
  247. win32/w32cmds.c"
  248. for file in $SWISS_EDITED_FILES; do
  249. sed -e '/.*DwMain.*/d' -e "$SED_ARG" "$APPS/swiss/$file" > "$SWISS/$file"
  250. done
  251. INCLUDE="$DEST/include"
  252. mkdir -p "$INCLUDE/minoca/lib"
  253. mkdir -p "$INCLUDE/minoca/kernel"
  254. INCLUDE_FILES="minoca/lib/types.h
  255. minoca/lib/status.h
  256. minoca/lib/rtl.h
  257. minoca/lib/termlib.h
  258. minoca/lib/tzfmt.h
  259. minoca/kernel/x86.inc
  260. minoca/kernel/arm.inc
  261. minoca/kernel/x64.inc"
  262. for file in $INCLUDE_FILES; do
  263. sed "$SED_ARG" "$SRCROOT/os/include/$file" > "$INCLUDE/$file"
  264. done
  265. VERSION_H="$SRCROOT/$ARCH$DEBUG/obj/os/apps/swiss/version.h"
  266. if ! [ -r "$VERSION_H" ]; then
  267. echo "Error: $VERSION_H is missing. You must build swiss first!"
  268. exit 1
  269. fi
  270. sed -e "s/#define VERSION_LICENSE .*/#define VERSION_LICENSE \"\\\\nThis \
  271. software is licensed under the the terms of the GNU General Public \
  272. License v3.\"/" \
  273. -e "s/#define VERSION_BUILD_USER .*/#define VERSION_BUILD_USER \"Minoca\"/"\
  274. -e "s/\\(#define VERSION_BUILD_STRING \"\\)[^-]*-\\(.*\\)/\1\2/" \
  275. "$VERSION_H" > "$SWISS/version.h"
  276. echo "Done copying swiss files."