BUILD_IN_DOCKER 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # We can build with docker, using the a local repo by binding the local
  3. # directory to $HARVEY_LOCAL. This will then be copied to $HARVEY.
  4. # If $HARVEY_LOCAL doesn't exist, we'll clone the harvey repo to $HARVEY.
  5. HARVEY_LOCAL=/usr/local/harvey_local
  6. if [ -d $HARVEY_LOCAL ]
  7. then
  8. echo "Copying $HARVEY_LOCAL -> $HARVEY"
  9. mkdir -p $HARVEY
  10. time cp -R $HARVEY_LOCAL/* $HARVEY/
  11. else
  12. # Clone harvey (shallow for a little speed)
  13. echo "Cloning https://github.com/$HARVEY_OWNER/$HARVEY_REPO.git branch $HARVEY_BRANCH -> $HARVEY"
  14. HARVEY_OWNER=Harvey-OS
  15. HARVEY_REPO=harvey
  16. HARVEY_BRANCH=main
  17. git clone --depth 1 --single-branch --branch $HARVEY_BRANCH https://github.com/$HARVEY_OWNER/$HARVEY_REPO.git $HARVEY
  18. fi
  19. ########################################################################
  20. # Copy/build toolchains for linux host
  21. # TODO true->size is a hack to make size not fail when building - best to remove this sometime
  22. # TODO need to make our bind script handle binds of single files
  23. cp /bin/true $HARVEY_LINUX_BIN/size
  24. cp $NINECC/src/cmd/iar/o.out $HARVEY_LINUX_BIN/ar
  25. cp $PLAN9/bin/{sed,yacc,lex,awk,date,dd,rm,basename,ls} $HARVEY_LINUX_BIN
  26. cp $HARVEY/build/bind /bin
  27. # TODO Merge cmd/BUILD and BUILDTOOLCHAIN?
  28. (cd $HARVEY/sys/src && bash BUILDTOOLCHAIN)
  29. # cpp was built by BUILDTOOLCHAIN - we need to copy to /bin because pcc execs /bin/cpp
  30. cp $HARVEY_LINUX_BIN/cpp /bin
  31. # build pcc
  32. (cd $HARVEY/sys/src/cmd && bash BUILD)
  33. # Modify some mkfiles to handle binaries in subfolders
  34. # TODO not sure if this is great, since it'll alter the mkfiles in the image - maybe undo after?
  35. sed -i 's/aux\/mklatinkbd/mklatinkbd/' $HARVEY/sys/src/9/port/portmkfile $HARVEY/sys/src/9k/mk/portmkfile
  36. sed -i 's/aux\/data2s/data2s/' $HARVEY/sys/src/9/port/{mkroot,mkrootall} $HARVEY/sys/src/9k/mk/{mkroot,mkrootall}
  37. export USER=root
  38. export PATH="${HARVEY_LINUX_BIN}:${PATH}:/rc/bin:."
  39. export objtype=amd64
  40. export cputype=unix
  41. export FORCERCFORMK=1
  42. export CGO_ENABLED=0
  43. (cd $HARVEY/sys/src && bash RUN_BUILD_IN_PRIVATE_NAMESPACE)
  44. #(cd $HARVEY/sys/src && bash)