reGen2 Linux Release Metatool
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

109 líneas
3.6KB

  1. #!/bin/bash
  2. # Copyright 2010-2011, Asio Software Technologies
  3. # Distributed under the terms of the GNU General Public License v2
  4. PROGRESS=/var/run/dispatch-progress
  5. # Outputs error message and aborts script execution
  6. die() {
  7. eerror $1
  8. exit $2
  9. }
  10. # Sets progress of dispatch process
  11. dispatchProgress() {
  12. export DISPATCH_STAGE=$1
  13. echo "DISPATCH_STAGE=$1" > ${PROGRESS}
  14. }
  15. # Load necessary files
  16. . /etc/profile
  17. source /etc/init.d/functions.sh
  18. # Track progress of the dispatching process
  19. [[ -e ${PROGRESS} ]] && source ${PROGRESS}
  20. export DISPATCH_STAGE=${DISPATCH_STAGE:-0}
  21. # Check if system is dispatched already or if process has been aborted
  22. if [ ${DISPATCH_STAGE} -ge 3 ]; then
  23. ewarn "Your system has been dispatched already!"
  24. ewarn "It is not recommended to re-dispatch."
  25. ewarn "Press ENTER to continue or CTRL+C to abort..."
  26. read
  27. dispatchProgress 0
  28. elif [ ${DISPATCH_STAGE} -gt 0 ]; then
  29. einfo "Resuming dispatch at stage #${DISPATCH_STAGE}..."
  30. fi
  31. # Display warning when user aborts or process gets killed
  32. trap 'die "Process killed! This may lead into unexpected problems. Be warned!" 9' ABRT INT KILL QUIT TERM
  33. # Check system requirements
  34. einfo "The process of dispatching may take a while. Please be patient..."
  35. einfo "Checking system requirements..."
  36. [[ ! -e /dev/random ]] && die "The /dev directory seems to be not mounted!"
  37. [[ ! -e /proc/mounts ]] && die "The /proc directory seems to be not mounted!"
  38. ping -c 1 google.com &> /dev/null
  39. [[ "$?" -ne "0" ]] && die "There seems to be no Internet connectivity!"
  40. # Get necessary variables
  41. einfo "Obtaining necessary variables..."
  42. export ENV_EXPORTS="GENTOO_MIRRORS PORTDIR DISTDIR PKGDIR PORTAGE_TMPDIR
  43. CFLAGS CHOST CXXFLAGS MAKEOPTS ACCEPT_KEYWORDS PROXY HTTP_PROXY
  44. FTP_PROXY FEATURES STAGE1_USE"
  45. eval $(python -c 'import portage, os, sys; sys.stdout.write("".join(["export %s=\"%s\"; [[ -z \"%s\" ]] || einfo %s=\\\"%s\\\";\n" % (k, portage.settings[k], portage.settings[k], k, portage.settings[k]) for k in os.getenv("ENV_EXPORTS").split()]))') &> /dev/null
  46. unset ENV_EXPORTS
  47. # Begin stage #0
  48. if [ ${DISPATCH_STAGE} -eq 0 ]; then
  49. einfo "Backing up files..."
  50. mkdir -p /tmp/regen2-dispatch
  51. cp -ap ${PORTDIR}/sys-apps/portage /tmp/regen2-dispatch/
  52. dispatchProgress 1
  53. fi
  54. # Begin stage #1
  55. if [ ${DISPATCH_STAGE} -eq 1 ]; then
  56. einfo "Generating manifests..."
  57. cd ${PORTDIR}/sys-apps/portage
  58. find * -maxdepth 0 -type f -name '*.ebuild' | while read FILE; do
  59. ebuild ${FILE} manifest &> /dev/null || die "Unable to generate manifest!" 1
  60. done
  61. einfo "Installing reGen2 portage..."
  62. cd ${PORTDIR}/scripts
  63. export CONFIG_PROTECT="-*"
  64. export EMERGE_DEFAULT_OPTS=""
  65. export FEATURES="${FEATURES} -collision-protect"
  66. emerge -1 --nodeps portage &> /dev/null || die "Unable to install sys-apps/portage!" 1
  67. dispatchProgress 2
  68. fi
  69. # Begin stage #2
  70. if [ ${DISPATCH_STAGE} -eq 2 ]; then
  71. einfo "Testing new portage..."
  72. export FEATURES="${FEATURES} mini-manifest"
  73. rm -rf ${PORTDIR}/sys-apps/portage
  74. cp -ap /tmp/regen2-dispatch/portage ${PORTDIR}/sys-apps/
  75. emerge -1 --nodeps portage &> /dev/null || die "reGen2 portage seems to be broken!" 2
  76. einfo "Regenerating local cache..."
  77. rm -rf /var/cache/edb/mtimedb
  78. emerge --metadata &> /dev/null || die "Unable to regenerate metadata!" 2
  79. dispatchProgress 3
  80. fi
  81. # Begin stage #3
  82. if [ ${DISPATCH_STAGE} -eq 3 ]; then
  83. einfo "Dispatching system..."
  84. emerge -1 --nodeps baselayout &> /dev/null || die "Unable to emerge baselayout!" 3
  85. emerge -1 --nodeps openrc &> /dev/null || die "Unable to emerge openrc!" 3
  86. dispatchProgress 4
  87. fi
  88. # Begin stage #4
  89. if [ ${DISPATCH_STAGE} -eq 4 ]; then
  90. einfo "Cleaning up..."
  91. rm -rf /tmp/regen2-dispatch
  92. einfo "All done!"
  93. einfo "Enjoy reGen2!"
  94. fi