Advertisement
Guest User

Untitled

a guest
Mar 4th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.05 KB | None | 0 0
  1. From 2f595d576661aa059c0ca1a9d9450578808a12d5 Mon Sep 17 00:00:00 2001
  2. From: Tor Lillqvist <tml@iki.fi>
  3. Date: Sun, 3 Mar 2013 12:08:44 +0200
  4. Subject: [PATCH] Add --srcdir support hack
  5.  
  6. ---
  7. bin/tinbuild2 | 24 ++++++++++-----
  8. bin/tinbuild_internals.sh | 76 +++++++++++++++++++++++------------------------
  9. bin/tinbuild_phases.sh | 2 +-
  10. 3 files changed, 55 insertions(+), 47 deletions(-)
  11.  
  12. diff --git a/bin/tinbuild2 b/bin/tinbuild2
  13. index 57d2a6c..322985e 100755
  14. --- a/bin/tinbuild2
  15. +++ b/bin/tinbuild2
  16. @@ -25,6 +25,7 @@ WATCHDOG=
  17. GERRIT_REF=
  18. DO_NOT_CLEAN=
  19. GERRIT_HOST="logerrit"
  20. +SRCDIR="."
  21.  
  22. # load the internal functions. note that
  23. # tinderbuild_internals_<uname>.sh is sourced at the tail
  24. @@ -151,14 +152,9 @@ load_profile()
  25.  
  26. sanity_check()
  27. {
  28. - g=$(git rev-parse --git-dir 2> /dev/null)
  29. + g=$((cd $SRCDIR && git rev-parse --git-dir) 2> /dev/null)
  30. if [ "$g" != ".git" ] ; then
  31. - echo "Error: The current working directory must be the root git repo"
  32. - exit 1
  33. - fi
  34. -
  35. - if [ ! -f configure.in -a ! -f configure.ac ] ; then
  36. - echo "Error: The current working directory must be the root git repo"
  37. + echo "Error: $SRCDIR must be the root git repo"
  38. exit 1
  39. fi
  40.  
  41. @@ -385,6 +381,18 @@ while [ "${1}" != "" ]; do
  42. STAGE_DIR="${arg}"
  43. fi
  44. ;;
  45. + --srcdir)
  46. + if [ -z "${has_arg}" ] ; then
  47. + shift;
  48. + arg="$1"
  49. + fi
  50. + if [ -z "${arg}" ] ; then
  51. + echo "Missing argument for option $parm" 1>&2
  52. + exit -1
  53. + else
  54. + SRCDIR="${arg}"
  55. + fi
  56. + ;;
  57. -t) # whether to run tests after the build
  58. DO_TESTS=1
  59. ;;
  60. @@ -512,7 +520,7 @@ if [ -n "$BRANCH" ] ; then
  61. TINDER_BRANCH="$BRANCH"
  62. B="$BRANCH"
  63. else
  64. - B=`git branch | grep '^\*' | sed 's/^..//' | sed 's/\//_/g'`
  65. + B=`(cd $SRCDIR && git branch) | grep '^\*' | sed 's/^..//' | sed 's/\//_/g'`
  66. TINDER_BRANCH=
  67. case "$B" in
  68.  
  69. diff --git a/bin/tinbuild_internals.sh b/bin/tinbuild_internals.sh
  70. index d0b7db5..214e38f 100644
  71. --- a/bin/tinbuild_internals.sh
  72. +++ b/bin/tinbuild_internals.sh
  73. @@ -111,15 +111,15 @@ get_commits_since_last_good()
  74. local repo=
  75. local sha=
  76.  
  77. - if [ -f .gitmodules ] ; then
  78. + if [ -f $SRCDIR/.gitmodules ] ; then
  79. head=$(head -n1 "${METADATA_DIR?}/tb_${B}_last-success-git-heads.txt")
  80. repo=$(echo ${head} | cut -d : -f 1)
  81. sha=$(echo ${head} | cut -d : -f 2)
  82. if [ "${mode?}" = "people" ] ; then
  83. - git log '--pretty=tformat:%ce' ${sha?}..HEAD
  84. + (cd $SRCDIR && git log '--pretty=tformat:%ce' ${sha?}..HEAD)
  85. else
  86. echo "==== ${repo} ===="
  87. - git log '--pretty=tformat:%h %s' ${sha?}..HEAD | sed 's/^/ /'
  88. + (cd $SRCDIR && git log '--pretty=tformat:%h %s' ${sha?}..HEAD) | sed 's/^/ /'
  89. fi
  90. else
  91. if [ -f "${METADATA_DIR?}/tb_${B}_last-success-git-heads.txt" ] ; then
  92. @@ -131,10 +131,10 @@ get_commits_since_last_good()
  93. cd clone/${repo?}
  94. fi
  95. if [ "${mode?}" = "people" ] ; then
  96. - git log '--pretty=tformat:%ce' ${sha?}..HEAD
  97. + (cd $SRCDIR && git log '--pretty=tformat:%ce' ${sha?}..HEAD)
  98. else
  99. echo "==== ${repo} ===="
  100. - git log '--pretty=tformat:%h %s' ${sha?}..HEAD | sed 's/^/ /'
  101. + (cd $SRCDIR && git log '--pretty=tformat:%h %s' ${sha?}..HEAD) | sed 's/^/ /'
  102. fi
  103. )
  104. done
  105. @@ -154,10 +154,10 @@ get_commits_since_last_bad()
  106. repo=$(echo ${head} | cut -d : -f 1)
  107. sha=$(echo ${head} | cut -d : -f 2)
  108. if [ "${mode?}" = "people" ] ; then
  109. - git log '--pretty=tformat:%ce' ${sha?}..HEAD
  110. + (cd $SRCDIR && git log '--pretty=tformat:%ce' ${sha?}..HEAD)
  111. else
  112. echo "==== ${repo} ===="
  113. - git log '--pretty=tformat:%h %s' ${sha?}..HEAD | sed 's/^/ /'
  114. + (cd $SRCDIR && git log '--pretty=tformat:%h %s' ${sha?}..HEAD) | sed 's/^/ /'
  115. fi
  116. else
  117. if [ -f tb_${B}_last-failure-git-heads.txt ] ; then
  118. @@ -169,10 +169,10 @@ get_commits_since_last_bad()
  119. cd clone/${repo?}
  120. fi
  121. if [ "${mode?}" = "people" ] ; then
  122. - git log '--pretty=tformat:%ce' ${sha?}..HEAD
  123. + (cd $SRCDIR && git log '--pretty=tformat:%ce' ${sha?}..HEAD)
  124. else
  125. echo "==== ${repo} ===="
  126. - git log '--pretty=tformat:%h %s' ${sha?}..HEAD | sed 's/^/ /'
  127. + (cd $SRCDIR && git log '--pretty=tformat:%h %s' ${sha?}..HEAD) | sed 's/^/ /'
  128. fi
  129. )
  130. done
  131. @@ -399,10 +399,10 @@ EOF
  132. collect_current_heads()
  133. {
  134. [ $V ] && echo "collect_current_head"
  135. - if [ -f .gitmodules ] ; then
  136. - echo "core:$(git rev-parse HEAD)" > "${METADATA_DIR?}/tb_${B}_current-git-heads.log"
  137. + if [ -f $SRCDIR/.gitmodules ] ; then
  138. + echo "core:$( (cd $SRCDIR && git rev-parse HEAD) )" > "${METADATA_DIR?}/tb_${B}_current-git-heads.log"
  139. else
  140. - ./g -1 rev-parse HEAD > "${METADATA_DIR?}/tb_${B}_current-git-heads.log"
  141. + (cd $SRCDIR && ./g -1 rev-parse HEAD) > "${METADATA_DIR?}/tb_${B}_current-git-heads.log"
  142. fi
  143. print_date > "${METADATA_DIR?}/tb_${B}_current-git-timestamp.log"
  144. }
  145. @@ -435,7 +435,7 @@ rotate_logs()
  146. check_for_commit()
  147. {
  148. [ $V ] && echo "pulling from the repos"
  149. - err_msgs="$( $timeout ./g pull -r 2>&1)"
  150. + err_msgs="$( (cd $SRCDIR && $timeout ./g pull -r 2>&1) )"
  151. if [ "$?" -ne "0" ] ; then
  152. printf "git repo broken - error is:\n\n$err_msgs" > error_log.log
  153. report_error owner "$(print_date)" error_log.log
  154. @@ -505,7 +505,7 @@ find_dev_install_location()
  155. position_bibisect_branch()
  156. {
  157. pushd ${ARTIFACTDIR?} > /dev/null
  158. - git checkout -q ${B?}
  159. + (cd $SRCDIR && git checkout -q ${B?})
  160. if [ "$?" -ne "0" ] ; then
  161. echo "Error could not position the bibisect repository to the branch $B" 1>&2
  162. exit 1;
  163. @@ -525,10 +525,10 @@ bibisect_post()
  164. {
  165. pushd ${ARTIFACTDIR?} > /dev/null
  166. if [ "${BIBISECT_GC}" = "Y" ] ; then
  167. - git gc
  168. + (cd $SRCDIR && git gc)
  169. fi
  170. if [ "${BIBISECT_PUSH}" = "Y" ] ; then
  171. - git push
  172. + (cd $SRCDIR && git push)
  173. fi
  174. popd > /dev/null
  175. }
  176. @@ -547,15 +547,15 @@ deliver_to_bibisect()
  177. # note: this function will exit if something is wrong
  178.  
  179. # avoid delivering the same build twice to bibisect
  180. - cc=$(git rev-list -1 HEAD)
  181. + cc=$( (cd $SRCDIR && git rev-list -1 HEAD) )
  182. if [ -f ${ARTIFACTDIR?}/commit.hash ] ; then
  183. oc="$(cat ${ARTIFACTDIR?}/commit.hash)"
  184. fi
  185. if [ "${cc}" != "${oc}" ] ; then
  186. deliver_lo_to_bibisect
  187.  
  188. - git log -1 --pretty=format:"source-hash-%H%n%n" $BUILDCOMMIT > ${ARTIFACTDIR?}/commitmsg
  189. - git log -1 --pretty=fuller $BUILDCOMMIT >> ${ARTIFACTDIR?}/commitmsg
  190. + (cd $SRCDIR && git log -1 --pretty=format:"source-hash-%H%n%n" $BUILDCOMMIT) > ${ARTIFACTDIR?}/commitmsg
  191. + (cd $SRCDIR && git log -1 --pretty=fuller $BUILDCOMMIT) >> ${ARTIFACTDIR?}/commitmsg
  192.  
  193. [ $V ] && echo "Bibisect: Include interesting logs/other data"
  194. # Include the autogen log.
  195. @@ -565,7 +565,7 @@ deliver_to_bibisect()
  196. cp tb_${B?}_build.log ${ARTIFACTDIR?}
  197.  
  198. # Make it easy to grab the commit id.
  199. - git rev-list -1 HEAD > ${ARTIFACTDIR?}/commit.hash
  200. + (cd $SRCDIR && git rev-list -1 HEAD) > ${ARTIFACTDIR?}/commit.hash
  201.  
  202. # Commit build to the local repo and push to the remote.
  203. [ $V ] && echo "Bibisect: Committing to local bibisect repo"
  204. @@ -691,14 +691,14 @@ local status="failed"
  205.  
  206. fetch_gerrit()
  207. {
  208. - GERRIT_PREV_B=`git branch | grep '^\*' | sed 's/^..//' | sed 's/\//_/g'`
  209. + GERRIT_PREV_B=`(cd $SRCDIR && git branch) | grep '^\*' | sed 's/^..//' | sed 's/\//_/g'`
  210. [ $V ] && echo "fetching gerrit path from ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF}"
  211. - git fetch -q ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF}
  212. + (cd $SRCDIR && git fetch -q ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF})
  213. if [ "$?" != "0" ] ; then
  214. retval="3"
  215. else
  216. - git checkout -q FETCH_HEAD || die "fatal error checking out gerrit ref"
  217. - git submodule -q update
  218. + (cd $SRCDIR && git checkout -q FETCH_HEAD) || die "fatal error checking out gerrit ref"
  219. + (cd $SRCDIR && git submodule -q update)
  220. [ $V ] && echo "fetched gerrit path from ssh://${GERRIT_HOST?}/core ${GERRIT_TASK_REF}"
  221. retval="0"
  222. fi
  223. @@ -759,28 +759,28 @@ run_gerrit_patch()
  224. (
  225. do_flock -x 200
  226.  
  227. - GERRIT_PREV_B=`git branch | grep '^\*' | sed 's/^..//' | sed 's/\//_/g'`
  228. + GERRIT_PREV_B=`(cd $SRCDIR && git branch) | grep '^\*' | sed 's/^..//' | sed 's/\//_/g'`
  229. [ $V ] && echo "git fetch ssh://${GERRIT_HOST?}/core $GERRIT_REF"
  230. - git fetch ssh://${GERRIT_HOST?}/core $GERRIT_REF && git checkout FETCH_HEAD || die "Error setting up the ref";
  231. + (cd $SRCDIR && git fetch ssh://${GERRIT_HOST?}/core $GERRIT_REF && git checkout FETCH_HEAD) || die "Error setting up the ref";
  232.  
  233. - echo "ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Starting Build on ${TINDER_NAME}\" $(git rev-parse HEAD)"
  234. - ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Starting Build on ${TINDER_NAME}\" $(git rev-parse HEAD) || die "error reviewing in"
  235. + echo "ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Starting Build on ${TINDER_NAME}\" $( (cd $SRCDIR && git rev-parse HEAD) )"
  236. + ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Starting Build on ${TINDER_NAME}\" $( (cd $SRCDIR && git rev-parse HEAD) ) || die "error reviewing in"
  237.  
  238. retval="0"
  239. PHASE_LIST="autogen clean make test push"
  240. do_build "gerrit"
  241.  
  242. if [ "${retval}" = "0" ] ; then
  243. - echo "ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Successful build of $(git rev-parse HEAD) on tinderbox: $TINDER_NAME\" --verified +1 $(git rev-parse HEAD)"
  244. - ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Successful build of $(git rev-parse HEAD) on tinderbox: $TINDER_NAME\" --verified +1 $(git rev-parse HEAD)
  245. + echo "ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Successful build of $( (cd $SRCDIR && git rev-parse HEAD) ) on tinderbox: $TINDER_NAME\" --verified +1 $( (cd $SRCDIR && git rev-parse HEAD) )"
  246. + ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Successful build of $( (cd $SRCDIR && git rev-parse HEAD) ) on tinderbox: $TINDER_NAME\" --verified +1 $( (cd $SRCDIR && git rev-parse HEAD) )
  247. else
  248. - echo "ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Failed build of $(git rev-parse HEAD) on tinderbox: $TINDER_NAME\" --verified -1 $(git rev-parse HEAD)"
  249. - ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Failed build of $(git rev-parse HEAD) on tinderbox: $TINDER_NAME\" --verified -1 $(git rev-parse HEAD) || die "error reviewing out"
  250. + echo "ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Failed build of $( (cd $SRCDIR && git rev-parse HEAD) ) on tinderbox: $TINDER_NAME\" --verified -1 $( (cd $SRCDIR && git rev-parse HEAD) )"
  251. + ssh ${GERRIT_HOST?} gerrit review --project core --force-message -m \"Failed build of $( (cd $SRCDIR && git rev-parse HEAD) ) on tinderbox: $TINDER_NAME\" --verified -1 $( (cd $SRCDIR && git rev-parse HEAD) ) || die "error reviewing out"
  252.  
  253. fi
  254. if [ -n "$GERRIT_PREV_B" ] ; then
  255. - git checkout "$GERRIT_PREV_B"
  256. - git submodule update
  257. + (cd $SRCDIR && git checkout "$GERRIT_PREV_B")
  258. + (cd $SRCDIR && git submodule update)
  259. fi
  260. if [ "$retval" = "0" ] ; then
  261. exit 0
  262. @@ -818,8 +818,8 @@ run_gerrit_loop()
  263. report_gerrit
  264. fi
  265. if [ -n "$GERRIT_PREV_B" ] ; then
  266. - git checkout "$GERRIT_PREV_B"
  267. - git submodule update
  268. + (cd $SRCDIR && git checkout "$GERRIT_PREV_B")
  269. + (cd $SRCDIR && git submodule update)
  270. fi
  271. if [ "$retval" = "0" ] ; then
  272. exit 0
  273. @@ -994,8 +994,8 @@ run_tb_gerrit_loop()
  274. done
  275. fi
  276. if [ -n "$GERRIT_PREV_B" ] ; then
  277. - git checkout -q "$GERRIT_PREV_B"
  278. - git submodule -q update
  279. + (cd $SRCDIR && git checkout -q "$GERRIT_PREV_B")
  280. + (cd $SRCDIR && git submodule -q update)
  281. fi
  282. if [ "${retval?}" = "0" ] ; then
  283. exit 0
  284. diff --git a/bin/tinbuild_phases.sh b/bin/tinbuild_phases.sh
  285. index 38a652c..87e1958 100644
  286. --- a/bin/tinbuild_phases.sh
  287. +++ b/bin/tinbuild_phases.sh
  288. @@ -18,7 +18,7 @@ pre_autogen()
  289. do_autogen()
  290. {
  291. if [ "${retval}" = "0" ] ; then
  292. - if ! $NICE ./autogen.sh ${DISTRO_CONFIG:+ --with-distro=${DISTRO_CONFIG}} >tb_${B}_autogen.log 2>&1 ; then
  293. + if ! $NICE $SRCDIR/autogen.sh ${DISTRO_CONFIG:+ --with-distro=${DISTRO_CONFIG}} >tb_${B}_autogen.log 2>&1 ; then
  294. report_log=tb_${B}_autogen.log
  295. report_msgs="autogen/configure failed - error is:"
  296. retval=1
  297. --
  298. 1.7.12.4 (Apple Git-37)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement