eemk.in 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. #!/bin/bash
  2. . <(ffoom init)
  3. FFOO_INI_PATH="__FFOO_INI_PATH__"
  4. ffoo import core
  5. ffoo import ini
  6. ffoo import proj_ol
  7. ffoo import testing
  8. ffoo import sw
  9. ffoo import yummy
  10. ENVIRON_SCRIPT="$HOME/.eemk-env"
  11. FFOO_VERBOSE=true
  12. OL_TRY_JM=${OL_TRY_JM:-false}
  13. TEST_STATUS=0
  14. # tmp needs to be shared to children
  15. if test -d "$TMP_DIR";
  16. then # we must be child
  17. THIS_IS_CHILD=true
  18. else # we are top parent; need some setup
  19. THIS_IS_CHILD=false
  20. export TMP_DIR="$(mktemp -d)"
  21. fi
  22. [ "$(whoami)" == "root" ] || die "you need to be root"
  23. yum_install_if_needed wget
  24. fc22plus() {
  25. test "$(guess_rtag_word)" == "fc" -a 0$(guess_rtag_num) -ge 22
  26. }
  27. maybe_with_jobmanager() {
  28. debug -v OL_TRY_JM
  29. debug -c fc22plus
  30. if $OL_TRY_JM || fc22plus;
  31. then
  32. echo -DWITH-JOBMANAGER=1
  33. else
  34. echo -DWITH-JOBMANAGER=0
  35. fi
  36. }
  37. case "$1" in
  38. ## ------ ##
  39. ## COMMON ##
  40. ## ------ ##
  41. abrtbz)
  42. think "Updating abrt to internal version"
  43. save_repo_for abrtbz
  44. yum_update "abrt"
  45. ;;
  46. sl0)
  47. think "Turning off SELinux"
  48. setenforce 0
  49. sed -i~ -e 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
  50. ;;
  51. ## ------- ##
  52. ## OPENLMI ##
  53. ## ------- ##
  54. ## setup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ##
  55. olbrc)
  56. LMI_CIMOM_PORT=5989
  57. mkdir -p "$(dirname $ENVIRON_SCRIPT)"
  58. think "Adding ol environment script $ENVIRON_SCRIPT to .bashrc"
  59. {
  60. # warning: only echo if not login shell or rsync will freak out
  61. echo "shopt -q login_shell && echo setting up ol environment variables"
  62. echo "export LMI_ACCOUNT_USER='account_test_user'"
  63. echo "export LMI_ACCOUNT_GROUP='account_test_group'"
  64. echo "export LMI_CIMOM_URL='https://${HOSTNAME}:$LMI_CIMOM_PORT'"
  65. echo "export LMI_CIMOM_USERNAME='pegasus'"
  66. echo "export LMI_CIMOM_PASSWORD='blank'"
  67. echo "export LMI_CIMOM_BROKER='tog-pegasus'"
  68. echo "export LMI_RUN_DANGEROUS='1'"
  69. echo "export LMI_IND_LISTENER_PORT='15000'"
  70. echo "export PYTHONPATH='$PYTHONPATH:$PWD/openlmi-providers/src/python'"
  71. } > $ENVIRON_SCRIPT
  72. append_if_missing \
  73. "test -f $ENVIRON_SCRIPT && . $ENVIRON_SCRIPT" \
  74. /root/.bashrc
  75. ;;
  76. olconfig)
  77. $0 sl0
  78. think "Bypassing SSL verification"
  79. echo "127.0.0.1 $(hostname)" >> /etc/hosts
  80. service tog-pegasus start # to generate server.pem
  81. service tog-pegasus stop
  82. cp "/etc/Pegasus/server.pem" \
  83. "/etc/pki/ca-trust/source/anchors/remote-server.pem"
  84. update-ca-trust
  85. think "Setting pegasus password"
  86. echo "pegasus:blank" | chpasswd
  87. $0 olbrc
  88. ;;
  89. ## runtime - - - - - - - - - - - - - - - - - - - - - - - - - - - - ##
  90. olenv)
  91. . $ENVIRON_SCRIPT
  92. ;;
  93. olcs)
  94. think "Starting a simple cimserver ($(comment_cimserver))"
  95. start_cimserver
  96. ;;
  97. olrun*)
  98. $0 olcs
  99. $0 olenv
  100. iniread -p mk.run.what.$2 mk-ol.ini \
  101. | while read path;
  102. do
  103. pushd "$(dirname $path)";
  104. nosetests --nocapture -v "$(basename $path)"
  105. es=$?
  106. test $es -gt 0$TEST_STATUS && TEST_STATUS=$es
  107. popd
  108. done
  109. stop_cimserver
  110. ;;
  111. olmk*)
  112. # let's build *anything*
  113. case $2 in
  114. p|openlmi-providers)
  115. (
  116. mkdir -p openlmi-providers/build
  117. cd openlmi-providers/build
  118. cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
  119. -DWITH-FAN=0 \
  120. -DWITH-POWER=0 \
  121. -DWITH-SSSD=0 \
  122. $(maybe_with_jobmanager)
  123. make
  124. make doc
  125. make install
  126. make register-Service
  127. )
  128. ;;
  129. t|openlmi-tools)
  130. (
  131. cd openlmi-tools/cli
  132. make clean
  133. make
  134. python setup.py install || die "could not install openlmi-tools"
  135. make clean
  136. )
  137. ;;
  138. *)
  139. die "don't know how to build: $2"
  140. ;;
  141. esac
  142. ;;
  143. olyum)
  144. save_repo_for openlmi-scripts
  145. think "Installing OpenLMI software"
  146. iniread -s mk.requires.sut mk-ol.ini | any_install
  147. think "Installing testing tools"
  148. iniread -s mk.requires.test mk-ol.ini | any_install
  149. ;;
  150. OL)
  151. $0 olyum
  152. $0 olconfig
  153. ;;
  154. OLB)
  155. think "Installing build dependencies"
  156. iniread -s mk.requires.build mk-ol.ini | any_install
  157. ;;
  158. ## --------- ##
  159. ## BEAKERLIB ##
  160. ## --------- ##
  161. bkrund)
  162. TERM=xterm reset
  163. pushd "proj/$2"
  164. make run > 1
  165. es=$?
  166. test $es -gt 0$TEST_STATUS && TEST_STATUS=$es
  167. popd
  168. ;;
  169. bkrun)
  170. pushd "proj/$2"
  171. make run
  172. es=$?
  173. test $es -gt 0$TEST_STATUS && TEST_STATUS=$es
  174. popd
  175. ;;
  176. ## rpmwork - - - - - - - - - - - - - - - - - - - - - - - - - - - - ##
  177. rpmso)
  178. path=rpms/old/`arch`
  179. think "Deploying old RPMs from $path"
  180. guess_pkgnames $path | yum_preerase
  181. yum_install $path/*
  182. guess_pkgnames $path | installed_versions
  183. ;;
  184. rpmsn)
  185. path=rpms/new/`arch`
  186. think "Deploying new RPMs from $path"
  187. guess_pkgnames $path | yum_preerase
  188. yum_install $path/*
  189. guess_pkgnames $path | installed_versions
  190. ;;
  191. RH)
  192. save_repo_for beakerlib
  193. save_repo_for rhpkg
  194. save_repo_for beakerlib-redhat
  195. think "Installing system under test"
  196. iniread -s mk.requires.sut mk-bk.ini | any_install
  197. think "Installing testing tools"
  198. iniread -s mk.requires.test mk-bk.ini | any_install
  199. ;;
  200. *)
  201. usage_is "TARGET"
  202. esac
  203. if ! $THIS_IS_CHILD;
  204. then
  205. collect_artifacts artifacts
  206. rm -rf $TMP_DIR
  207. fi
  208. exit $TEST_STATUS