把chromiumos改到32位系统下编译,可行吗?

发布于 2022-09-10 02:09:21 字数 17065 浏览 16 评论 9

make_chroot

  1. #!/bin/bash
  2. # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # This script sets up a Gentoo chroot environment. The script is passed the
  6. # path to an empty folder, which will be populated with a Gentoo stage3 and
  7. # setup for development. Once created, the password is set to PASSWORD (below).
  8. # One can enter the chrooted environment for work by running enter_chroot.sh.
  9. # Load common constants.  This should be the first executable line.
  10. # The path to common.sh should be relative to your script's location.
  11. PROG=$(basename $0)
  12. . "$(dirname "$0")/common.sh"
  13. # Check if the host machine architecture is supported.
  14. ARCHITECTURE="$(uname -m)"
  15. if [[ "$ARCHITECTURE" = "x86_64" ]]; then
  16.   echo "$PROG: $ARCHITECTURE is not supported as a host machine architecture."
  17.   exit 1
  18. fi
  19. # Script must be run outside the chroot
  20. assert_outside_chroot
  21. # Define command line flags
  22. # See http://code.google.com/p/shflags/wiki/Documentation10x
  23. DEFINE_string chroot "$DEFAULT_CHROOT_DIR"
  24.   "Destination dir for the chroot environment."
  25. DEFINE_boolean crosstool $FLAGS_FALSE "Use crosstool toolchain."
  26. DEFINE_boolean hardened $FLAGS_TRUE "Setup for a hardened toolchain."
  27. DEFINE_boolean usepkg $FLAGS_TRUE "Use binary packages to bootstrap."
  28. DEFINE_boolean delete $FLAGS_FALSE "Delete an existing chroot."
  29. DEFINE_boolean replace $FLAGS_FALSE "Overwrite existing chroot, if any."
  30. DEFINE_integer jobs -1 "How many packages to build in parallel at maximum."
  31. DEFINE_boolean fast ${FLAGS_FALSE} "Call many emerges in parallel"
  32. DEFINE_string stage3_date "2010.03.09"
  33.   "Use the stage3 with the given date."
  34. # Parse command line flags
  35. FLAGS_HELP="usage: $0 [flags]"
  36. FLAGS "$@" || exit 1
  37. eval set -- "${FLAGS_ARGV}"
  38. check_flags_only_and_allow_null_arg "$@" && set --
  39. # Only now can we die on error.  shflags functions leak non-zero error codes,
  40. # so will die prematurely if 'set -e' is specified before now.
  41. # TODO: replace shflags with something less error-prone, or contribute a fix.
  42. set -e
  43. FULLNAME="ChromeOS Developer"
  44. DEFGROUPS="eng,adm,cdrom,floppy,audio,video,portage"
  45. PASSWORD=chronos
  46. CRYPTED_PASSWD=$(perl -e 'print crypt($ARGV[0], "foo")', $PASSWORD)
  47. USEPKG=""
  48. if [[ $FLAGS_usepkg -eq $FLAGS_TRUE ]]; then
  49.   # Use binary packages. Include all build-time dependencies,
  50.   # so as to avoid unnecessary differences between source
  51.   # and binary builds.
  52.   USEPKG="--getbinpkg --usepkg --with-bdeps y"
  53. fi
  54. # Support faster build if necessary.
  55. EMERGE_CMD="emerge"
  56. if [ "$FLAGS_fast" -eq "${FLAGS_TRUE}" ]; then
  57.   CHROOT_SCRIPTS_DIR="/home/${USER}/trunk/src/scripts"
  58.   EMERGE_CMD="${CHROOT_SCRIPTS_DIR}/parallel_emerge"
  59. fi
  60. function in_chroot {
  61.   sudo chroot "$FLAGS_chroot" "$@"
  62. }
  63. function bash_chroot {
  64.   # Use $* not $@ since 'bash -c' needs a single arg
  65.   # Use -l to force source of /etc/profile (login shell)
  66.   sudo chroot "$FLAGS_chroot" bash -l -c "$*"
  67. }
  68. function cleanup {
  69.   # Clean up mounts
  70.   mount | grep "on $(readlink -f "$FLAGS_chroot")" | awk '{print $3}'
  71.     | xargs -r -L1 sudo umount
  72. }
  73. function delete_existing {
  74.   # Delete old chroot dir
  75.   if [[ -e "$FLAGS_chroot" ]]; then
  76.     echo "$PROG: Cleaning up old mount points..."
  77.     cleanup
  78.     echo "$PROG: Deleting $FLAGS_chroot..."
  79.     sudo rm -rf "$FLAGS_chroot"
  80.     echo "$PROG: Done."
  81.   fi
  82. }
  83. function init_users () {
  84.    echo "$PROG: Set timezone..."
  85.    # date +%Z has trouble with daylight time, so use host's info
  86.    if [ -f /etc/localtime ] ; then
  87.       sudo cp /etc/localtime "${FLAGS_chroot}/etc"
  88.    else
  89.    in_chroot [ -f /usr/share/zoneinfo/$TZ ] || TZ=PST8PDT
  90.      in_chroot rm -f /etc/localtime
  91.      in_chroot ln -sf /usr/share/zoneinfo/PST8PDT /etc/localtime
  92.    fi
  93.    echo "$PROG: Adding user/group..."
  94.    # Add ourselves as a user inside the chroot
  95.    in_chroot groupadd -g 5000 eng
  96.    in_chroot useradd -G ${DEFGROUPS} -g eng -u `id -u` -s
  97.      /bin/bash -m -c "${FULLNAME}" -p ${CRYPTED_PASSWD} ${USER}
  98. }
  99. function init_setup () {
  100.    echo "$PROG: Running init_setup()..."
  101.    sudo mkdir -p "${FLAGS_chroot}/usr"
  102.    sudo ln -sf "${CHROOT_TRUNK}/src/third_party/portage"
  103.      "${FLAGS_chroot}/usr/portage"
  104.    sudo mkdir -p "${FLAGS_chroot}/usr/local/portage"
  105.    sudo chmod 755 "${FLAGS_chroot}/usr/local/portage"
  106.    if [[ $FLAGS_crosstool -eq $FLAGS_TRUE ]]; then
  107.       sudo ln -sf "${CHROOT_TRUNK}/src/third_party/crosstool-overlay"
  108.         "${FLAGS_chroot}"/"${CHROOT_CROSSTOOL_OVERLAY}"
  109.    else
  110.      if [[ $FLAGS_hardened -eq $FLAGS_TRUE ]]; then
  111.        sudo ln -sf "${CHROOT_TRUNK}/src/third_party/hardened-dev"
  112.        "${FLAGS_chroot}"/"${CHROOT_HARDENED_OVERLAY}"
  113.      fi
  114.    fi
  115.    sudo ln -sf "${CHROOT_TRUNK}/src/third_party/chromiumos-overlay"
  116.      "${FLAGS_chroot}"/"${CHROOT_OVERLAY}"
  117.    # Some operations need an mtab
  118.    in_chroot ln -s /proc/mounts /etc/mtab
  119.    # Set up sudoers.  Inside the chroot, the user can sudo without a password.
  120.    # (Safe enough, since the only way into the chroot is to 'sudo chroot', so
  121.    # the user's already typed in one sudo password...)
  122.    bash_chroot "echo %adm ALL=(ALL) ALL >> /etc/sudoers"
  123.    bash_chroot "echo $USER ALL=NOPASSWD: ALL >> /etc/sudoers"
  124.    bash_chroot chmod 0440 /etc/sudoers
  125.    bash_chroot chown root:root /etc/sudoers # Fix bad group on some systems
  126.    echo "$PROG: Setting up hosts/resolv..."
  127.    # Copy config from outside chroot into chroot
  128.    sudo cp /etc/hosts "$FLAGS_chroot/etc/hosts"
  129.    sudo chmod 0644 "$FLAGS_chroot/etc/hosts"
  130.    sudo cp /etc/resolv.conf "$FLAGS_chroot/etc/resolv.conf"
  131.    sudo chmod 0644 "$FLAGS_chroot/etc/resolv.conf"
  132.    # Setup host make.conf. This includes any overlay that we may be using
  133.    # and a pointer to pre-built packages.
  134.    # TODO: This should really be part of a profile in the portage
  135.    echo "$PROG: Setting up /etc/make.*..."
  136.    sudo mv "${FLAGS_chroot}"/etc/make.conf{,.orig}
  137.    if [[ $FLAGS_crosstool -eq $FLAGS_TRUE ]]; then
  138.       sudo ln -sf "${CHROOT_CONFIG}/make-crosstool.conf.amd64-host"
  139.         "${FLAGS_chroot}/etc/make.conf"
  140.    else
  141.      if [[ $FLAGS_hardened -eq $FLAGS_TRUE ]]; then
  142.        sudo ln -sf "${CHROOT_CONFIG}/make-hardened.conf.amd64-host"
  143.        "${FLAGS_chroot}/etc/make.conf"
  144.      else
  145.        sudo ln -sf "${CHROOT_CONFIG}/make.conf.amd64-host"
  146.        "${FLAGS_chroot}/etc/make.conf"
  147.      fi
  148.    fi
  149.    sudo mv "${FLAGS_chroot}"/etc/make.profile{,.orig}
  150.    sudo ln -sf "${CHROOT_OVERLAY}/profiles/default/linux/amd64/10.0"
  151.      "${FLAGS_chroot}/etc/make.profile"
  152.    # Create make.conf.user
  153.    sudo touch "${FLAGS_chroot}"/etc/make.conf.user
  154.    # Create directories referred to by our conf files.
  155.    sudo mkdir -p "${FLAGS_chroot}/var/lib/portage/distfiles"
  156.    sudo mkdir -p "${FLAGS_chroot}/var/lib/portage/pkgs"
  157.    if [[ $FLAGS_jobs -ne -1 ]]; then
  158.      EMERGE_JOBS="--jobs=$FLAGS_jobs"
  159.    fi
  160.    # Configure basic stuff needed
  161.    in_chroot env-update
  162.    bash_chroot ls -l /etc/make.conf
  163.    bash_chroot ls -l /etc/make.profile
  164.    bash_chroot ls -l /usr/local/portage/chromiumos/profiles/default/linux/amd64/10.0
  165.    # Niceties for interactive logins ('enter_chroot.sh'); these are ignored
  166.    # when specifying a command to enter_chroot.sh.
  167.    # Warn less when apt-get installing packqages
  168.    echo "export LANG=C" >> "$FLAGS_chroot/home/$USER/.bashrc"
  169.    echo "export PS1="(cros-chroot) $PS1"" >> "$FLAGS_chroot/home/$USER/.bashrc"
  170.    chmod a+x "$FLAGS_chroot/home/$USER/.bashrc"
  171.    # Automatically change to scripts directory
  172.    echo "cd trunk/src/scripts" >> "$FLAGS_chroot/home/$USER/.bash_profile"
  173.    # Enable bash completion for build scripts
  174.    echo ". bash_completion" >> "$FLAGS_chroot/home/$USER/.bash_profile"
  175.    # Warn if attempting to use source control commands inside the chroot
  176.    for NOUSE in svn gcl gclient
  177.    do
  178.      echo "alias $NOUSE='echo In the chroot, it is a bad idea to run $NOUSE'"
  179.        >> "$FLAGS_chroot/home/$USER/.bash_profile"
  180.    done
  181.    if [[ "$USER" = "chrome-bot" ]]; then
  182.      # Copy ssh keys, so chroot'd chrome-bot can scp files from chrome-web.
  183.      cp -r ~/.ssh "$FLAGS_chroot/home/$USER/"
  184.    fi
  185. }
  186. # Handle deleting an existing environment
  187. if [[ $FLAGS_delete  -eq $FLAGS_TRUE ||
  188.       $FLAGS_replace -eq $FLAGS_TRUE ]]; then
  189.   delete_existing
  190.   [[ $FLAGS_delete -eq $FLAGS_TRUE ]] && exit 0
  191. fi
  192. CHROOT_TRUNK="${CHROOT_TRUNK_DIR}"
  193. PORTAGE="${SRC_ROOT}/third_party/portage"
  194. OVERLAY="${SRC_ROOT}/third_party/chromiumos-overlay"
  195. CONFIG_DIR="${OVERLAY}/chromeos/config"
  196. CHROOT_CONFIG="${CHROOT_TRUNK}/src/third_party/chromiumos-overlay/chromeos/config"
  197. CHROOT_OVERLAY="/usr/local/portage/chromiumos"
  198. CHROOT_STATE="${FLAGS_chroot}/etc/debian_chroot"
  199. CHROOT_HARDENED_OVERLAY="/usr/local/portage/hardened-dev"
  200. CHROOT_CROSSTOOL_OVERLAY="/usr/local/portage/crosstool-overlay"
  201. # Create the base Gentoo stage3 based on last version put in chroot
  202. STAGE3="${OVERLAY}/chromeos/stage3/stage3-i686-${FLAGS_stage3_date}.tar.bz2"
  203. if [ -f $CHROOT_STATE ] &&
  204.   ! sudo egrep -q "^STAGE3=$STAGE3" $CHROOT_STATE >/dev/null 2>&1
  205. then
  206.   echo "$PROG: STAGE3 version has changed."
  207.   delete_existing
  208. fi
  209. # Create the destination directory
  210. mkdir -p "$FLAGS_chroot"
  211. echo
  212. if [ -f $CHROOT_STATE ]
  213. then
  214.   echo "$PROG: STAGE3 already set up.  Skipping..."
  215. else
  216.   echo "$PROG: Unpacking STAGE3..."
  217.   sudo tar xjp -C "$FLAGS_chroot" -f "$STAGE3"
  218. fi
  219. # Set up users, if needed, before mkdir/mounts below
  220. [ -f $CHROOT_STATE ] || init_users
  221. echo
  222. echo "$PROG: Setting up mounts..."
  223. # Set up necessary mounts and make sure we clean them up on exit
  224. trap cleanup EXIT
  225. sudo mkdir -p "${FLAGS_chroot}/${CHROOT_TRUNK}"
  226. sudo mount --bind "${GCLIENT_ROOT}" "${FLAGS_chroot}/${CHROOT_TRUNK}"
  227. sudo mount none -t proc "$FLAGS_chroot/proc"
  228. sudo mount none -t devpts "$FLAGS_chroot/dev/pts"
  229. if [ -f $CHROOT_STATE ];then
  230.   echo "$PROG: chroot already initialized.  Skipping..."
  231. else
  232.   # run all the init stuff to setup the env
  233.   init_setup
  234. fi
  235. # Add file to indicate that it is a chroot
  236. # Add version of $STAGE3 for update checks
  237. sudo sh -c "echo STAGE3=$STAGE3 > $CHROOT_STATE"
  238. echo "$PROG: Running emerge portage"
  239. bash_chroot emerge -uNv $USEPKG portage $EMERGE_JOBS
  240. echo "$PROG: Running emerge world ccache crossdev etc ..."
  241. bash_chroot $EMERGE_CMD -uDNv $USEPKG world
  242.     ccache crossdev crossdev-wrappers sudo $EMERGE_JOBS
  243. echo "PATH=$PATH:/home/$USER/depot_tools" >>
  244.   "${FLAGS_chroot}/home/$USER/.bashrc"
  245. # Unmount trunk
  246. sudo umount "${FLAGS_chroot}/${CHROOT_TRUNK}"
  247. # Clean up the chroot mounts
  248. trap - EXIT
  249. cleanup
  250. if [[ "$FLAGS_chroot" = "$DEFAULT_CHROOT_DIR" ]]; then
  251.   CHROOT_EXAMPLE_OPT=""
  252. else
  253.   CHROOT_EXAMPLE_OPT="--chroot=$FLAGS_chroot"
  254. fi
  255. print_time_elapsed
  256. echo
  257. echo "$PROG: All set up.  To enter the chroot, run:"
  258. echo "$PROG: $ $SCRIPTS_DIR/enter_chroot.sh $CHROOT_EXAMPLE_OPT"
  259. echo ""
  260. echo "CAUTION: Do *NOT* rm -rf the chroot directory; if there are stale bind"
  261. echo "mounts you may end up deleting your source tree too.  To unmount and"
  262. echo "delete the chroot cleanly, use:"
  263. echo "$ $0 --delete $CHROOT_EXAMPLE_OPT"

复制代码

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

独﹏钓一江月 2022-09-20 03:41:15

回复 8# qing

    我是去年才出来那会儿编译的,变化到没去注意过.不好意思.

疾风者 2022-09-20 03:37:58

回复 6# prolj

     具体哪部分呢。。

从来不烧饼 2022-09-20 03:15:46

回复 7# snail_314

    以前是可以。现在新的变了。。说说你是什么时候编译过的。。

从来不烧饼 2022-09-20 03:13:50

我就在x86 32bit平台下遍过啊,还跑了的,没什么问题啊

幻梦 2022-09-20 02:25:05

不是我说的,我只感冒其中的client部分。

半透明的墙 2022-09-19 20:35:38
  1. >>> Emerging (1 of 1) chromeos-base/kernel-headers-0.0.1-r1 from chromiumos for /build/x86-generic/
  2. * CPV:  chromeos-base/kernel-headers-0.0.1-r1
  3. * REPO: chromiumos
  4. * USE:  elibc_glibc kernel_linux userland_GNU x86
  5. >>> Unpacking source...
  6. * Using kernel files: /home/qing/trunk/src/third_party/kernel/files
  7. >>> Source unpacked in /build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/work
  8. >>> Preparing source in /build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/work/kernel-headers-0.0.1 ...
  9. >>> Source prepared.
  10. >>> Configuring source in /build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/work/kernel-headers-0.0.1 ...
  11. * Nothing to configure.
  12. >>> Source configured.
  13. >>> Compiling source in /build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/work/kernel-headers-0.0.1 ...
  14. * Nothing to compile.
  15. >>> Source compiled.
  16. >>> Test phase [not enabled]: chromeos-base/kernel-headers-0.0.1-r1
  17. >>> Install kernel-headers-0.0.1-r1 into /build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/image/ category chromeos-base
  18. make -j1 ARCH=i386 CROSS_COMPILE=i686-pc-linux-gnu- INSTALL_HDR_PATH=/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/image//usr headers_install
  19.   CHK     include/linux/version.h
  20.   UPD     include/linux/version.h
  21.   HOSTCC  scripts/basic/fixdep
  22. In file included from /build/x86-generic/usr/include/bits/posix1_lim.h:157,
  23.                  from /build/x86-generic/usr/include/limits.h:145,
  24.                  from /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include-fixed/limits.h:122,
  25.                  from /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include-fixed/syslimits.h:7,
  26.                  from /usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include-fixed/limits.h:11,
  27.                  from scripts/basic/fixdep.c:114:
  28. /build/x86-generic/usr/include/bits/local_lim.h:39:26: error: linux/limits.h: No such file or directory
  29. In file included from /build/x86-generic/usr/include/sys/socket.h:40,
  30.                  from /build/x86-generic/usr/include/netinet/in.h:25,
  31.                  from /build/x86-generic/usr/include/arpa/inet.h:23,
  32.                  from scripts/basic/fixdep.c:116:
  33. /build/x86-generic/usr/include/bits/socket.h:364:24: error: asm/socket.h: No such file or directory
  34. scripts/basic/fixdep.c: In function 'use_config':
  35. scripts/basic/fixdep.c:204: error: 'PATH_MAX' undeclared (first use in this function)
  36. scripts/basic/fixdep.c:204: error: (Each undeclared identifier is reported only once
  37. scripts/basic/fixdep.c:204: error: for each function it appears in.)
  38. scripts/basic/fixdep.c:204: warning: unused variable 's'
  39. scripts/basic/fixdep.c: In function 'parse_dep_file':
  40. scripts/basic/fixdep.c:304: error: 'PATH_MAX' undeclared (first use in this function)
  41. scripts/basic/fixdep.c:304: warning: unused variable 's'
  42. make[1]: *** [scripts/basic/fixdep] Error 1
  43. make: *** [scripts_basic] Error 2
  44. * ERROR: chromeos-base/kernel-headers-0.0.1-r1 failed:
  45. *   (no error message)
  46. *
  47. * Call stack:
  48. *     ebuild.sh, line  54:  Called src_install
  49. *   environment, line 890:  Called die
  50. * The specific snippet of code:
  51. *       emake ARCH=$(tc-arch-kernel) CROSS_COMPILE="${CHOST}-" INSTALL_HDR_PATH="${D}"/usr headers_install || die;
  52. *
  53. * If you need support, post the output of 'emerge --info =chromeos-base/kernel-headers-0.0.1-r1',
  54. * the complete build log and the output of 'emerge -pqv =chromeos-base/kernel-headers-0.0.1-r1'.
  55. * This ebuild is from an overlay named 'chromiumos': '/home/qing/trunk/src/third_party/chromiumos-overlay/'
  56. * The complete build log is located at '/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/temp/build.log'.
  57. * The ebuild environment file is located at '/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/temp/environment'.
  58. * S: '/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/work/kernel-headers-0.0.1'
  59. >>> Failed to emerge chromeos-base/kernel-headers-0.0.1-r1 for /build/x86-generic/, Log file:
  60. >>>  '/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/temp/build.log'
  61. * Messages for package chromeos-base/kernel-headers-0.0.1-r1 merged to /build/x86-generic/:
  62. * Using kernel files: /home/qing/trunk/src/third_party/kernel/files
  63. * Nothing to configure.
  64. * Nothing to compile.
  65. * ERROR: chromeos-base/kernel-headers-0.0.1-r1 failed:
  66. *   (no error message)
  67. *
  68. * Call stack:
  69. *     ebuild.sh, line  54:  Called src_install
  70. *   environment, line 890:  Called die
  71. * The specific snippet of code:
  72. *       emake ARCH=$(tc-arch-kernel) CROSS_COMPILE="${CHOST}-" INSTALL_HDR_PATH="${D}"/usr headers_install || die;
  73. *
  74. * If you need support, post the output of 'emerge --info =chromeos-base/kernel-headers-0.0.1-r1',
  75. * the complete build log and the output of 'emerge -pqv =chromeos-base/kernel-headers-0.0.1-r1'.
  76. * This ebuild is from an overlay named 'chromiumos': '/home/qing/trunk/src/third_party/chromiumos-overlay/'
  77. * The complete build log is located at '/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/temp/build.log'.
  78. * The ebuild environment file is located at '/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/temp/environment'.
  79. * S: '/build/x86-generic/tmp/portage/chromeos-base/kernel-headers-0.0.1-r1/work/kernel-headers-0.0.1'

复制代码

小梨窩很甜 2022-09-19 11:05:33

/usr/local/bin/emerge-x86-generic kernel-headers

英雄似剑 2022-09-18 05:16:37

回复 2# prolj

    谁说的。。今天做到 setup_board --board=x86-generic

>>> Emerging (1 of 1) chromeos-base/kernel-headers-0.0.1-r1 from chromiumos for /build/x86-generic/

卡住了。。

千仐 2022-09-16 22:36:57

google博客上有人说可行,你可以搜一下。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文