reGen2 Linux Release Metatool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.2 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  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. -h|--help)
  21. showEzsyncUsage
  22. ;;
  23. -n|--nosync)
  24. shift
  25. if [ -z ${1} ]; then
  26. die "--nosync requires an additional argument!"
  27. else
  28. EZNOSYNC=${EZNOSYNC+"$EZNOSYNC "}"${1}"
  29. fi
  30. ;;
  31. -N|--nopush)
  32. EZOPT_NOPUSH=true
  33. ;;
  34. -p|--purge)
  35. EZOPT_PURGETMP=true
  36. ;;
  37. -P|--purgeonly)
  38. EZOPT_PURGETMP=true
  39. EZOPT_PURGEONLY=true
  40. ;;
  41. -s|--syscheck)
  42. EZOPT_SYSCHECKONLY=true
  43. ;;
  44. *)
  45. die "Unrecognized option ${1}"
  46. ;;
  47. esac
  48. shift
  49. done
  50. # Check system requirements
  51. printInfo "Checking system prerequisites..."
  52. checkPrerequisites
  53. [ ${?} -ne 0 ] && die "Your environment does not meet EzBuild requirements!" 1
  54. if isEnabled ${EZOPT_SYSCHECKONLY}; then
  55. printInfo "Your system meets all EzBuild requirements!"
  56. quit
  57. fi
  58. # Do not allow more than one working copy
  59. PID=$(pidof -s -o '%PPID' -x ${EZNAME})
  60. if [ ${PID} ]; then
  61. printWarn "The ${EZNAME} is already working with PID: ${PID}"
  62. printWarn "You cannot have more than one instancy running"
  63. exit 0
  64. fi
  65. # Optionally purge whole temp directory or log file only
  66. if isEnabled ${EZOPT_PURGETMP}; then
  67. printInfo "Clearing temp directory..."
  68. cleanTemp
  69. if isEnabled ${EZOPT_PURGEONLY}; then
  70. quit
  71. fi
  72. elif isEnabled ${EZOPT_CLEANLOG}; then
  73. printInfo "Clearing log file..."
  74. cleanLog
  75. fi
  76. # Initialize EzBuild environment
  77. makeCoreDirectories || die "EzBuild was unable to create all necessary directories!" 1
  78. EZNOTIFY="yes"
  79. makeSshWrapper || die "EzBuild was unable to create a wrapper file to SSH" 1
  80. trap 'die "Process killed! This may lead into unexpected problems!"' 1 2 3 9 15 17 18 23
  81. # Load necessary public keys
  82. printInfo "Loading public keys..."
  83. eval `keychain --noask --eval id_dsa id_rsa &> /dev/null`
  84. [ ${?} -ne 0 ] && die "EzBuild was unable to load public keys!" 1
  85. # Update local copy of Portage that is being built
  86. printInfo "Refreshing local build Portage tree..."
  87. pullRepository ${PORTAGESDIR}/${PORTAGE_BUILD[0]} ${PORTAGE_BUILD[1]} ${PORTAGE_BUILD[2]} ${PORTAGE_BUILD[3]}
  88. [ ${?} -ne 0 ] && die "EzBuild was unable to refresh local copy of build Portage tree!" 2
  89. # Update local copy of mainline Portage
  90. if ! hasElement "mainline" ${EZNOSYNC} && ! hasElement "portage" ${EZNOSYNC}; then
  91. printInfo "Synchronizing mainline Portage tree..."
  92. pullRepository ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]} ${PORTAGE_MAINLINE[1]} ${PORTAGE_MAINLINE[2]} ${PORTAGE_MAINLINE[3]}
  93. [ ${?} -ne 0 ] && die "EzBuild was unable to synchronize mainline Portage tree!" 2
  94. [ -e ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/metadata/cache ] && rm -rf ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/metadata/cache
  95. echo "distfiles/*" > ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/.gitignore
  96. echo "packages/*" >> ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/.gitignore
  97. if [ ! -d ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask ]; then
  98. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask.bak &> /dev/null
  99. makeDirectory ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask
  100. mv ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask.bak ${PORTAGESDIR}/${PORTAGE_MAINLINE[0]}/profiles/package.mask/${PORTAGE_MAINLINE[0]%-*} &> /dev/null
  101. fi
  102. fi
  103. # Update all overlays (including the one that's optionally going to be built)
  104. SYNC_OVERLAYS=( ${MERGED_OVERLAY[*]} ${MERGED_PORTAGE[*]} )
  105. for OVERLAY in ${SYNC_OVERLAYS[*]}; do
  106. TEMP="\${$OVERLAY[*]}"
  107. CURRENT_OVERLAY=(`eval echo ${TEMP}`)
  108. if ! hasElement "${CURRENT_OVERLAY[0]}" ${EZNOSYNC}; then
  109. printInfo "Synchronizing overlay: ${CURRENT_OVERLAY[0]}..."
  110. pullRepository ${OVERLAYSDIR}/${CURRENT_OVERLAY[0]} ${CURRENT_OVERLAY[1]} ${CURRENT_OVERLAY[2]} ${CURRENT_OVERLAY[3]}
  111. [ ${?} -ne 0 ] && fail "EzBuild was unable to synchronize ${CURRENT_OVERLAY[0]}!" 4
  112. fi
  113. done