reGen2 Linux Release Metatool
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. #!/bin/bash
  2. # Copyright 2010-2012, Asio Software Technologies
  3. # Distributed under the terms of the GNU General Public License v3
  4. # Declare basic system variables
  5. EZNAME=$(basename ${0})
  6. EZROOT=$(dirname $(readlink -ne ${0}))
  7. # Load necessary files
  8. source /etc/profile
  9. source ${EZROOT}/libraries/common
  10. # Load EzBuild libraries & configuration
  11. loadLibraries
  12. loadConfiguration
  13. # Print EzBuild notice and parse arguments
  14. printNotice
  15. until [[ -z "${1}" ]]; do
  16. case "${1}" in
  17. -c|--cleanlog)
  18. EZOPT_CLEANLOG=true
  19. ;;
  20. -D|--tarballdate)
  21. shift
  22. if [ -z ${1} ]; then
  23. die "--tarballdate requires an additional argument!"
  24. else
  25. TARBALLDATE="${1}"
  26. fi
  27. ;;
  28. -h|--help)
  29. showEzsyncUsage
  30. ;;
  31. -l|--listmods)
  32. listModules
  33. ;;
  34. -n|--nosync)
  35. shift
  36. if [ -z ${1} ]; then
  37. die "--nosync requires an additional argument!"
  38. else
  39. EZNOSYNC=${EZNOSYNC+"$EZNOSYNC "}"${1}"
  40. fi
  41. ;;
  42. -N|--nopush)
  43. EZOPT_NOPUSH=true
  44. ;;
  45. -p|--purge)
  46. EZOPT_PURGETMP=true
  47. ;;
  48. -P|--purgeonly)
  49. EZOPT_PURGETMP=true
  50. EZOPT_PURGEONLY=true
  51. ;;
  52. -s|--syscheck)
  53. EZOPT_SYSCHECKONLY=true
  54. ;;
  55. -t|--notrigger)
  56. EZOPT_NOTRIGGER=true
  57. ;;
  58. -T|--tarballformat)
  59. shift
  60. if [ -z ${1} ]; then
  61. die "--tarballformat requires an additional argument!"
  62. else
  63. TARBALLFORMAT="${1}"
  64. fi
  65. ;;
  66. *)
  67. die "Unrecognized option ${1}"
  68. ;;
  69. esac
  70. shift
  71. done
  72. # Check system requirements
  73. printInfo "Checking system prerequisites..."
  74. checkPrerequisites
  75. [ ${?} -ne 0 ] && die "Your environment does not meet EzBuild requirements!" 1
  76. if isEnabled ${EZOPT_SYSCHECKONLY}; then
  77. printInfo "Your system meets all EzBuild requirements!"
  78. quit
  79. fi
  80. # Do not allow more than one working copy
  81. PID=$(pidof -s -o '%PPID' -x ${EZNAME})
  82. if [ ${PID} ]; then
  83. printWarn "The ${EZNAME} is already working with PID: ${PID}"
  84. printWarn "You cannot have more than one instancy running"
  85. exit 0
  86. fi
  87. # Optionally purge whole temp directory or log file only
  88. if isEnabled ${EZOPT_PURGETMP}; then
  89. printInfo "Clearing temp directory..."
  90. cleanTemp
  91. if isEnabled ${EZOPT_PURGEONLY}; then
  92. quit
  93. fi
  94. elif isEnabled ${EZOPT_CLEANLOG}; then
  95. printInfo "Clearing log file..."
  96. cleanLog
  97. fi
  98. # Initialize EzBuild environment
  99. makeCoreDirectories || die "EzBuild was unable to create all necessary directories!" 1
  100. EZNOTIFY="yes"
  101. prepareWrappers || die "EzBuild was unable to create a wrapper files!" 1
  102. export LC_ALL="C"
  103. trap 'die "Process killed! This may lead into unexpected problems!"' 1 2 3 9 15 17 18 23
  104. # Load necessary public keys
  105. printInfo "Loading public keys..."
  106. eval `keychain --noask --eval id_dsa id_rsa &> /dev/null`
  107. [ ${?} -ne 0 ] && die "EzBuild was unable to load public keys!" 1
  108. # Execute all 'presync' enabled modules
  109. if ! isEnabled ${EZOPT_NOTRIGGER}; then
  110. for MODULE in ${MODULES_PRESYNC}; do
  111. loadModule ${MODULE} "presync"
  112. RESULT=${?}
  113. if [ ${RESULT} -eq 255 ]; then
  114. printWarn "Trying to load module: ${MODULE}, that is incompatible with event: presync!"
  115. elif [ ${RESULT} -ne 0 ]; then
  116. fail "EzBuild was unable to execute module: ${MODULE}!" 255
  117. fi
  118. unloadModule
  119. done
  120. fi
  121. # Update local copy of Portage that is being built
  122. printInfo "Refreshing constructed Portage tree..."
  123. pullRepository ${PORTAGESDIR}/${PORTAGE_BUILD[0]} ${PORTAGE_BUILD[1]} ${PORTAGE_BUILD[2]} ${PORTAGE_BUILD[3]}
  124. [ ${?} -ne 0 ] && die "EzBuild was unable to refresh local copy of constructed Portage tree!" 2
  125. # Update local copy of mainline Portage
  126. if ! hasElement "mainline" ${EZNOSYNC} && ! hasElement "portage" ${EZNOSYNC}; then
  127. printInfo "Refreshing mainline Portage tree..."
  128. pullRepository ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]} ${PORTAGE_MAINLINE[1]} ${PORTAGE_MAINLINE[2]} ${PORTAGE_MAINLINE[3]}
  129. [ ${?} -ne 0 ] && die "EzBuild was unable to refresh local copy of mainline Portage tree!" 2
  130. [ -e ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/metadata/cache ] && rm -rf ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/metadata/cache
  131. [ -e ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/metadata/md5-cache ] && rm -rf ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/metadata/md5-cache
  132. echo "distfiles/*" > ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/.gitignore
  133. echo "packages/*" >> ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/.gitignore
  134. if [ ! -d ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask ]; then
  135. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask.bak &> /dev/null
  136. makeDirectory ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask
  137. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask.bak ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask/${PORTAGE_MAINLINE[0]%-*} &> /dev/null
  138. fi
  139. if [ ! -d ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.unmask ]; then
  140. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.unmask ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.unmask.bak &> /dev/null
  141. makeDirectory ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.unmask
  142. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.unmask.bak ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.unmask/${PORTAGE_MAINLINE[0]%-*} &> /dev/null
  143. fi
  144. if [ ! -d ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.use ]; then
  145. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.use ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.use.bak &> /dev/null
  146. makeDirectory ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.use
  147. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.use.bak ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.use/${PORTAGE_MAINLINE[0]%-*} &> /dev/null
  148. fi
  149. fi
  150. # Update all overlays (including the one that's optionally going to be built)
  151. SYNC_OVERLAYS=( ${MERGED_OVERLAY[*]} ${MERGED_PORTAGE[*]} )
  152. for OVERLAY in ${SYNC_OVERLAYS[*]}; do
  153. TEMP="\${$OVERLAY[*]}"
  154. CURRENT_OVERLAY=(`eval echo ${TEMP}`)
  155. if ! hasElement "${CURRENT_OVERLAY[0]}" ${EZNOSYNC}; then
  156. printInfo "Refreshing overlay: ${CURRENT_OVERLAY[0]}..."
  157. pullRepository ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]} ${CURRENT_OVERLAY[1]} ${CURRENT_OVERLAY[2]} ${CURRENT_OVERLAY[3]}
  158. [ ${?} -ne 0 ] && fail "EzBuild was unable to refresh local copy of overlay: ${CURRENT_OVERLAY[0]}!" 4
  159. fi
  160. done
  161. # Execute all 'postsync' enabled modules
  162. if ! isEnabled ${EZOPT_NOTRIGGER}; then
  163. for MODULE in ${MODULES_POSTSYNC}; do
  164. loadModule ${MODULE} "postsync"
  165. RESULT=${?}
  166. if [ ${RESULT} -eq 255 ]; then
  167. printWarn "Trying to load module: ${MODULE}, that is incompatible with event: postsync!"
  168. elif [ ${RESULT} -ne 0 ]; then
  169. fail "EzBuild was unable to execute module: ${MODULE}!" 255
  170. fi
  171. unloadModule
  172. done
  173. fi
  174. # Optionally merge data into build overlay
  175. if isSet MERGED_OVERLAY && isSet OVERLAY_BUILD; then
  176. printInfo "Merging ebuilds into Overlay..."
  177. for OVERLAY in ${MERGED_OVERLAY[*]}; do
  178. TEMP="\${$OVERLAY[*]}"
  179. CURRENT_OVERLAY=(`eval echo ${TEMP}`)
  180. mergeOverlay ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]} ${OVERLAYSDIR}/${OVERLAY_BUILD[0]} ${CURRENT_OVERLAY[4]} ${CURRENT_OVERLAY[5]} ${CURRENT_OVERLAY[6]}
  181. [ ${?} -ne 0 ] && fail "EzBuild was unable to merge ebuilds into overlay!" 8
  182. done
  183. if ! isEnabled ${EZOPT_NOPUSH}; then
  184. pushRepository ${OVERLAYSDIR}/${OVERLAY_BUILD[0]} ${OVERLAY_BUILD[1]} "Automatic overlay update [$(date +"${PUSHDATEFORMAT}")]."
  185. [ ${?} -ne 0 ] && die "Ezbuild was unable to record changes to the remote overlay repository!" 8
  186. fi
  187. fi
  188. # Merge data into build portage
  189. printInfo "Merging ebuilds into Portage..."
  190. pullRsync ${PORTAGESDIR}/${PORTAGE_BUILD[0]} ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}
  191. [ ${?} -ne 0 ] && die "EzBuild was unable to merge ebuilds into Portage tree!" 16
  192. for OVERLAY in ${MERGED_PORTAGE[*]}; do
  193. TEMP="\${$OVERLAY[*]}"
  194. CURRENT_OVERLAY=(`eval echo ${TEMP}`)
  195. mergeOverlay ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]} ${PORTAGESDIR}/${PORTAGE_BUILD[0]} ${CURRENT_OVERLAY[4]} ${CURRENT_OVERLAY[5]} ${CURRENT_OVERLAY[6]}
  196. [ ${?} -ne 0 ] && die "EzBuild was unable to merge ebuilds into Portage tree!" 16
  197. if [ -f ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]}/profiles/package.mask ]; then
  198. run "cp -apf ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]}/profiles/package.mask ${PORTAGESDIR}/${PORTAGE_BUILD[0]}/profiles/package.mask/${CURRENT_OVERLAY[0]%-*}"
  199. [ ${?} -ne 0 ] && die "EzBuild was unable to merge package.mask file into Portage tree!" 16
  200. fi
  201. if [ -f ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]}/profiles/package.unmask ]; then
  202. run "cp -apf ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]}/profiles/package.unmask ${PORTAGESDIR}/${PORTAGE_BUILD[0]}/profiles/package.unmask/${CURRENT_OVERLAY[0]%-*}"
  203. [ ${?} -ne 0 ] && die "EzBuild was unable to merge package.unmask file into Portage tree!" 16
  204. fi
  205. if [ -f ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]}/profiles/package.use ]; then
  206. run "cp -apf ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]}/profiles/package.use ${PORTAGESDIR}/${PORTAGE_BUILD[0]}/profiles/package.use/${CURRENT_OVERLAY[0]%-*}"
  207. [ ${?} -ne 0 ] && die "EzBuild was unable to merge package.use file into Portage tree!" 16
  208. fi
  209. done
  210. # Execute all 'precommit' enabled modules
  211. if ! isEnabled ${EZOPT_NOTRIGGER}; then
  212. for MODULE in ${MODULES_PRECOMMIT}; do
  213. loadModule ${MODULE} "precommit"
  214. RESULT=${?}
  215. if [ ${RESULT} -eq 255 ]; then
  216. printWarn "Trying to load module: ${MODULE}, that is incompatible with event: precommit!"
  217. elif [ ${RESULT} -ne 0 ]; then
  218. fail "EzBuild was unable to execute module: ${MODULE}!" 255
  219. fi
  220. unloadModule
  221. done
  222. fi
  223. # Regenerate Portage cache
  224. printInfo "Updating constructed Portage cache..."
  225. run "FEATURES="metadata-transfer" PORTDIR="${PORTAGESDIR}/${PORTAGE_BUILD[0]}" egencache --update --cache-dir=${ECACHEDIR} --portdir=${PORTAGESDIR}/${PORTAGE_BUILD[0]} --jobs=${MAXJOBS} --load-average=${LOADAVERAGE} --tolerant"
  226. [ ${?} -ne 0 ] && die "EzBuild was unable to regenerate cache!" 32
  227. # Optionally commit all changes to remote Portage repository
  228. if ! isEnabled ${EZOPT_NOPUSH}; then
  229. printInfo "Sending constructed Portage update..."
  230. pushRepository ${PORTAGESDIR}/${PORTAGE_BUILD[0]} ${PORTAGE_BUILD[1]} "Automatic update [$(date +"${PUSHDATEFORMAT}")]."
  231. [ ${?} -ne 0 ] && die "Ezbuild was unable to record changes to the remote Portage repository!" 64
  232. fi
  233. # Execute all 'postcommit' enabled modules
  234. if ! isEnabled ${EZOPT_NOTRIGGER}; then
  235. for MODULE in ${MODULES_POSTCOMMIT}; do
  236. loadModule ${MODULE} "postcommit"
  237. RESULT=${?}
  238. if [ ${RESULT} -eq 255 ]; then
  239. printWarn "Trying to load module: ${MODULE}, that is incompatible with event: postcommit!"
  240. elif [ ${RESULT} -ne 0 ]; then
  241. fail "EzBuild was unable to execute module: ${MODULE}!" 255
  242. fi
  243. unloadModule
  244. done
  245. fi
  246. # Finally quit the application
  247. quit