build-root-filesystem.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #!/bin/sh
  2. set -e
  3. # HACK: Get rid of old "qs" binaries still lying around from before it was renamed.
  4. rm -f ../Userland/qs
  5. die() {
  6. echo "die: $*"
  7. exit 1
  8. }
  9. if [ "$(id -u)" != 0 ]; then
  10. die "this script needs to run as root"
  11. fi
  12. printf "creating initial filesystem structure... "
  13. for dir in bin etc proc mnt tmp; do
  14. mkdir -p mnt/$dir
  15. done
  16. chmod 1777 mnt/tmp
  17. echo "done"
  18. printf "setting up device nodes... "
  19. mkdir -p mnt/dev
  20. mkdir -p mnt/dev/pts
  21. mknod -m 666 mnt/dev/fb0 b 29 0
  22. mknod mnt/dev/tty0 c 4 0
  23. mknod mnt/dev/tty1 c 4 1
  24. mknod mnt/dev/tty2 c 4 2
  25. mknod mnt/dev/tty3 c 4 3
  26. mknod mnt/dev/ttyS0 c 4 64
  27. mknod mnt/dev/ttyS1 c 4 65
  28. mknod mnt/dev/ttyS2 c 4 66
  29. mknod mnt/dev/ttyS3 c 4 67
  30. mknod -m 666 mnt/dev/random c 1 8
  31. mknod -m 666 mnt/dev/null c 1 3
  32. mknod -m 666 mnt/dev/zero c 1 5
  33. mknod -m 666 mnt/dev/full c 1 7
  34. mknod -m 666 mnt/dev/debuglog c 1 18
  35. mknod mnt/dev/keyboard c 85 1
  36. mknod mnt/dev/psaux c 10 1
  37. mknod -m 666 mnt/dev/audio c 42 42
  38. mknod -m 666 mnt/dev/ptmx c 5 2
  39. mknod mnt/dev/hda b 3 0
  40. mknod mnt/dev/hdb b 3 1
  41. mknod mnt/dev/hdc b 4 0
  42. mknod mnt/dev/hdd b 4 1
  43. ln -s /proc/self/fd/0 mnt/dev/stdin
  44. ln -s /proc/self/fd/1 mnt/dev/stdout
  45. ln -s /proc/self/fd/2 mnt/dev/stderr
  46. echo "done"
  47. printf "installing base system... "
  48. cp -R ../Base/* mnt/
  49. cp -R ../Root/* mnt/
  50. cp kernel.map mnt/
  51. echo "done"
  52. printf "installing users... "
  53. mkdir -p mnt/home/anon
  54. mkdir -p mnt/home/nona
  55. cp ../ReadMe.md mnt/home/anon/
  56. chown -R 100:100 mnt/home/anon
  57. chown -R 200:200 mnt/home/nona
  58. echo "done"
  59. printf "installing userland... "
  60. find ../Userland/ -type f -executable -exec cp {} mnt/bin/ \;
  61. chmod 4755 mnt/bin/su
  62. echo "done"
  63. printf "installing applications... "
  64. cp ../Applications/About/About mnt/bin/About
  65. cp ../Applications/FileManager/FileManager mnt/bin/FileManager
  66. cp ../Applications/FontEditor/FontEditor mnt/bin/FontEditor
  67. cp ../Applications/IRCClient/IRCClient mnt/bin/IRCClient
  68. cp ../Applications/SystemMonitor/SystemMonitor mnt/bin/SystemMonitor
  69. cp ../Applications/Taskbar/Taskbar mnt/bin/Taskbar
  70. cp ../Applications/Terminal/Terminal mnt/bin/Terminal
  71. cp ../Applications/TextEditor/TextEditor mnt/bin/TextEditor
  72. cp ../Applications/HexEditor/HexEditor mnt/bin/HexEditor
  73. cp ../Applications/PaintBrush/PaintBrush mnt/bin/PaintBrush
  74. cp ../Applications/QuickShow/QuickShow mnt/bin/QuickShow
  75. cp ../Applications/Piano/Piano mnt/bin/Piano
  76. cp ../Applications/SystemDialog/SystemDialog mnt/bin/SystemDialog
  77. cp ../Applications/ChanViewer/ChanViewer mnt/bin/ChanViewer
  78. cp ../Applications/Calculator/Calculator mnt/bin/Calculator
  79. cp ../Applications/SoundPlayer/SoundPlayer mnt/bin/SoundPlayer
  80. cp ../Applications/DisplayProperties/DisplayProperties mnt/bin/DisplayProperties
  81. cp ../Applications/Welcome/Welcome mnt/bin/Welcome
  82. cp ../Applications/Help/Help mnt/bin/Help
  83. cp ../Applications/Browser/Browser mnt/bin/Browser
  84. cp ../Demos/HelloWorld/HelloWorld mnt/bin/HelloWorld
  85. cp ../Demos/HelloWorld2/HelloWorld2 mnt/bin/HelloWorld2
  86. cp ../Demos/WidgetGallery/WidgetGallery mnt/bin/WidgetGallery
  87. cp ../Demos/Fire/Fire mnt/bin/Fire
  88. cp ../DevTools/HackStudio/HackStudio mnt/bin/HackStudio
  89. cp ../DevTools/VisualBuilder/VisualBuilder mnt/bin/VisualBuilder
  90. cp ../DevTools/Inspector/Inspector mnt/bin/Inspector
  91. cp ../Games/Minesweeper/Minesweeper mnt/bin/Minesweeper
  92. cp ../Games/Snake/Snake mnt/bin/Snake
  93. cp ../Servers/LookupServer/LookupServer mnt/bin/LookupServer
  94. cp ../Servers/SystemServer/SystemServer mnt/bin/SystemServer
  95. cp ../Servers/WindowServer/WindowServer mnt/bin/WindowServer
  96. cp ../Servers/AudioServer/AudioServer mnt/bin/AudioServer
  97. cp ../Servers/TTYServer/TTYServer mnt/bin/TTYServer
  98. cp ../Servers/TelnetServer/TelnetServer mnt/bin/TelnetServer
  99. cp ../Servers/ProtocolServer/ProtocolServer mnt/bin/ProtocolServer
  100. cp ../Shell/Shell mnt/bin/Shell
  101. echo "done"
  102. printf "installing shortcuts... "
  103. ln -s FileManager mnt/bin/fm
  104. ln -s HelloWorld mnt/bin/hw
  105. ln -s HelloWorld2 mnt/bin/hw2
  106. ln -s IRCClient mnt/bin/irc
  107. ln -s Minesweeper mnt/bin/ms
  108. ln -s Shell mnt/bin/sh
  109. ln -s Snake mnt/bin/sn
  110. ln -s Taskbar mnt/bin/tb
  111. ln -s VisualBuilder mnt/bin/vb
  112. ln -s WidgetGallery mnt/bin/wg
  113. ln -s TextEditor mnt/bin/te
  114. ln -s HexEditor mnt/bin/he
  115. ln -s PaintBrush mnt/bin/pb
  116. ln -s QuickShow mnt/bin/qs
  117. ln -s Piano mnt/bin/pi
  118. ln -s SystemDialog mnt/bin/sd
  119. ln -s ChanViewer mnt/bin/cv
  120. ln -s Calculator mnt/bin/calc
  121. ln -s Inspector mnt/bin/ins
  122. ln -s SoundPlayer mnt/bin/sp
  123. ln -s Help mnt/bin/help
  124. ln -s Browser mnt/bin/br
  125. ln -s HackStudio mnt/bin/hs
  126. ln -s modload mnt/bin/m
  127. echo "done"
  128. mkdir -p mnt/boot/
  129. cp kernel mnt/boot/
  130. cp TestModule.o mnt/
  131. # Run local sync script, if it exists
  132. if [ -f sync-local.sh ]; then
  133. sh sync-local.sh
  134. fi