add_files.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/bin/sh
  2. ## Copyright (c) 2014 Minoca Corp. All Rights Reserved.
  3. ##
  4. ## Script Name:
  5. ##
  6. ## add_files.sh
  7. ##
  8. ## Abstract:
  9. ##
  10. ## This script adds any additional files before the automation build image
  11. ## is created.
  12. ##
  13. ## Author:
  14. ##
  15. ## Evan Green 13-Jun-2014
  16. ##
  17. ## Environment:
  18. ##
  19. ## Minoca Build
  20. ##
  21. set -e
  22. if test -z "$SRCROOT"; then
  23. SRCROOT=`pwd`/src
  24. fi
  25. if test -z "$ARCH"; then
  26. echo "ARCH must be set."
  27. exit 1
  28. fi
  29. if test -z "$DEBUG"; then
  30. echo "DEBUG must be set."
  31. exit 1
  32. fi
  33. export TMPDIR=$PWD
  34. export TEMP=$TMPDIR
  35. BINROOT="$SRCROOT/$ARCH$VARIANT$DEBUG/bin"
  36. AUTOROOT=$BINROOT/apps/auto
  37. ##
  38. ## Move the created distribution images aside.
  39. ##
  40. if ! test -d "$BINROOT/distribute"; then
  41. mkdir "$BINROOT/distribute/"
  42. for file in $BINROOT/*.img $BINROOT/*.vmdk ; do
  43. if test -r "$file"; then
  44. mv $file "$BINROOT/distribute/"
  45. fi
  46. done
  47. fi
  48. ##
  49. ## Add the client script and tasks, which are needed to fetch the *next*
  50. ## set of sources and binaries. Also add any additional test binaries to the
  51. ## images.
  52. ##
  53. if ! test -d "$AUTOROOT"; then
  54. mkdir -p "$AUTOROOT"
  55. mkdir -p "$AUTOROOT/testbin"
  56. cp -v "$SRCROOT/client.py" "$AUTOROOT/client.py"
  57. cp -Rv "$SRCROOT/os/tasks/" "$AUTOROOT/"
  58. cp -v "$BINROOT/perftest" "$AUTOROOT/testbin/perftest"
  59. cp -v "$BINROOT/perflib.so" "$AUTOROOT/testbin/perflib.so"
  60. fi
  61. ##
  62. ## Copy the skeleton over so the proper environment is set up for postinst
  63. ## scripts.
  64. ##
  65. cp -Rp $BINROOT/skel/* $BINROOT/apps/
  66. ##
  67. ## Copy the script that automatically loads the Python build client.
  68. ## Manually symlink it in.
  69. ##
  70. mkdir -p "$BINROOT/apps/etc/init.d/"
  71. cp -v "$SRCROOT/os/tasks/build/autoclient.sh" "$BINROOT/apps/etc/init.d/"
  72. chmod 0755 "$BINROOT/apps/etc/init.d/autoclient.sh"
  73. for level in 2 3 4 5; do
  74. mkdir -p "$BINROOT/apps/etc/rc$level.d/"
  75. ln -s "../init.d/autoclient.sh" \
  76. "$BINROOT/apps/etc/rc$level.d/S46autoclient.sh"
  77. done
  78. for level in 0 1 6; do
  79. mkdir -p "$BINROOT/apps/etc/rc$level.d/"
  80. ln -s "../init.d/autoclient.sh" \
  81. "$BINROOT/apps/etc/rc$level.d/K64autoclient.sh"
  82. done
  83. ##
  84. ## Create a local opkg configuration that prefers the local package repository.
  85. ##
  86. package_dir="$BINROOT/packages"
  87. cp /etc/opkg/opkg.conf ./myopkg.conf.orig
  88. sed "s|src/gz main.*|src/gz local file:///$package_dir|" ./myopkg.conf.orig > \
  89. ./myopkg.conf
  90. ##
  91. ## Change Quark to i586.
  92. ##
  93. if [ "$ARCH$VARIANT" = "x86q" ]; then
  94. sed "s|i686|i586|g" ./myopkg.conf > ./myopkg.conf2
  95. mv ./myopkg.conf2 ./myopkg.conf
  96. fi
  97. ##
  98. ## Point the package repository at the build server.
  99. ##
  100. DEST="$BINROOT/apps"
  101. sed 's/www\.minocacorp\.com/10.0.1.202/' $DEST/etc/opkg/opkg.conf > opkg.tmp
  102. mv opkg.tmp $DEST/etc/opkg/opkg.conf
  103. ##
  104. ## Perform an offline install of packages needed for the build.
  105. ##
  106. PACKAGES="opkg
  107. awk
  108. binutils
  109. byacc
  110. flex
  111. gcc
  112. libgcc
  113. gzip
  114. m4
  115. make
  116. nano
  117. openssh
  118. patch
  119. perl
  120. expat
  121. python2
  122. tar
  123. wget
  124. libz
  125. acpica
  126. bzip2
  127. sqlite
  128. libiconv
  129. libncurses
  130. libreadline
  131. libopenssl
  132. libpcre
  133. ca-certificates"
  134. mkdir -p "$DEST/usr/lib/opkg/"
  135. opkg --conf=$PWD/myopkg.conf --offline-root="$DEST" update
  136. opkg --conf=$PWD/myopkg.conf --offline-root="$DEST" --force-postinstall \
  137. install $PACKAGES
  138. rm -rf "$DEST/var/opkg-lists"
  139. ##
  140. ## Hard-code in a root password so that the system can be SSHed to.
  141. ##
  142. chpasswd --root="$DEST" <<_EOF
  143. root:minoca
  144. _EOF
  145. echo Completed adding files