OLD | NEW |
---|---|
1 #!/bin/bash -e | 1 #!/bin/bash -e |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script installs Debian-derived distributions in a chroot environment. | 7 # This script installs Debian-derived distributions in a chroot environment. |
8 # It can for example be used to have an accurate 32bit build and test | 8 # It can for example be used to have an accurate 32bit build and test |
9 # environment when otherwise working on a 64bit machine. | 9 # environment when otherwise working on a 64bit machine. |
10 # N. B. it is unlikely that this script will ever work on anything other than a | 10 # N. B. it is unlikely that this script will ever work on anything other than a |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 # whether it is the beginning of a new entry. | 332 # whether it is the beginning of a new entry. |
333 sudo sed -ni '/^[[]'"${target%bit}"']$/,${:1;n;/^[[]/b2;b1;:2;p;n;b2};p' \ | 333 sudo sed -ni '/^[[]'"${target%bit}"']$/,${:1;n;/^[[]/b2;b1;:2;p;n;b2};p' \ |
334 /etc/schroot/schroot.conf | 334 /etc/schroot/schroot.conf |
335 | 335 |
336 # Download base system. This takes some time | 336 # Download base system. This takes some time |
337 if [ -z "${mirror}" ]; then | 337 if [ -z "${mirror}" ]; then |
338 grep -qs ubuntu.com /usr/share/debootstrap/scripts/"${distname}" && | 338 grep -qs ubuntu.com /usr/share/debootstrap/scripts/"${distname}" && |
339 mirror="http://archive.ubuntu.com/ubuntu" || | 339 mirror="http://archive.ubuntu.com/ubuntu" || |
340 mirror="http://ftp.us.debian.org/debian" | 340 mirror="http://ftp.us.debian.org/debian" |
341 fi | 341 fi |
342 sudo debootstrap ${archflag} "${distname}" /var/lib/chroot/"${target}" \ | 342 |
343 "$mirror" | 343 if [ -n "${http_proxy}" ]; then |
344 PROXY_FLAG="http_proxy=${http_proxy}" | |
345 else | |
346 PROXY_FLAG="" | |
347 fi | |
348 sudo ${PROXY_FLAG} debootstrap ${archflag} "${distname}" \ | |
Markus (顧孟勤)
2012/05/08 02:09:57
You could probably write this more concisely as:
Wei James(wistoch)
2012/05/08 02:47:58
done. thanks
| |
349 "/var/lib/chroot/${target}" "$mirror" | |
344 | 350 |
345 # Add new entry to /etc/schroot/schroot.conf | 351 # Add new entry to /etc/schroot/schroot.conf |
346 grep -qs ubuntu.com /usr/share/debootstrap/scripts/"${distname}" && | 352 grep -qs ubuntu.com /usr/share/debootstrap/scripts/"${distname}" && |
347 brand="Ubuntu" || brand="Debian" | 353 brand="Ubuntu" || brand="Debian" |
348 if [ -z "${chroot_groups}" ]; then | 354 if [ -z "${chroot_groups}" ]; then |
349 chroot_groups="${admin},$(id -gn)" | 355 chroot_groups="${admin},$(id -gn)" |
350 fi | 356 fi |
351 # Older versions of schroot wanted a "priority=" line, whereas recent | 357 # Older versions of schroot wanted a "priority=" line, whereas recent |
352 # versions deprecate "priority=" and warn if they see it. We don't have | 358 # versions deprecate "priority=" and warn if they see it. We don't have |
353 # a good feature test, but scanning for the string "priority=" in the | 359 # a good feature test, but scanning for the string "priority=" in the |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 >>"/var/lib/chroot/'"${target}"'/etc/apt/sources.list"' | 551 >>"/var/lib/chroot/'"${target}"'/etc/apt/sources.list"' |
546 fi | 552 fi |
547 | 553 |
548 # Add source repositories, if the user requested we do so | 554 # Add source repositories, if the user requested we do so |
549 [ "${add_srcs}" = "y" -a \ | 555 [ "${add_srcs}" = "y" -a \ |
550 -r "/var/lib/chroot/${target}/etc/apt/sources.list" ] && | 556 -r "/var/lib/chroot/${target}/etc/apt/sources.list" ] && |
551 sudo sed -i '/^deb[^-]/p | 557 sudo sed -i '/^deb[^-]/p |
552 s/^deb\([^-]\)/deb-src\1/' \ | 558 s/^deb\([^-]\)/deb-src\1/' \ |
553 "/var/lib/chroot/${target}/etc/apt/sources.list" | 559 "/var/lib/chroot/${target}/etc/apt/sources.list" |
554 | 560 |
561 # Set apt proxy if host has set http_proxy | |
562 if [ -n "${http_proxy}" ]; then | |
563 sudo sh -c ' | |
564 echo "Acquire::http::proxy \"'${http_proxy}'\";" \ | |
Markus (顧孟勤)
2012/05/08 02:09:57
While it probably is benign in this particular cas
Wei James(wistoch)
2012/05/08 02:47:58
for the syntax requirement, we need a double-quote
| |
565 >>"/var/lib/chroot/'"${target}"'/etc/apt/apt.conf"' | |
566 fi | |
567 | |
555 # Update packages | 568 # Update packages |
556 sudo "/usr/local/bin/${target%bit}" /bin/sh -c ' | 569 sudo "/usr/local/bin/${target%bit}" /bin/sh -c ' |
557 apt-get update; apt-get -y dist-upgrade' || : | 570 apt-get update; apt-get -y dist-upgrade' || : |
558 | 571 |
559 # Install a couple of missing packages | 572 # Install a couple of missing packages |
560 for i in debian-keyring ubuntu-keyring locales sudo; do | 573 for i in debian-keyring ubuntu-keyring locales sudo; do |
561 [ -d "/var/lib/chroot/${target}/usr/share/doc/$i" ] || | 574 [ -d "/var/lib/chroot/${target}/usr/share/doc/$i" ] || |
562 sudo "/usr/local/bin/${target%bit}" apt-get -y install "$i" || : | 575 sudo "/usr/local/bin/${target%bit}" apt-get -y install "$i" || : |
563 done | 576 done |
564 | 577 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 | 803 |
791 For Chrome, this probably means you want to make your "out" directory a | 804 For Chrome, this probably means you want to make your "out" directory a |
792 symbolic link that points somewhere inside of "${HOME}/chroot". | 805 symbolic link that points somewhere inside of "${HOME}/chroot". |
793 | 806 |
794 You still need to run "gclient runhooks" whenever you switch from building | 807 You still need to run "gclient runhooks" whenever you switch from building |
795 outside of the chroot to inside of the chroot. But you will find that you | 808 outside of the chroot to inside of the chroot. But you will find that you |
796 don't have to repeatedly erase and then completely rebuild all your object | 809 don't have to repeatedly erase and then completely rebuild all your object |
797 and binary files. | 810 and binary files. |
798 | 811 |
799 EOF | 812 EOF |
OLD | NEW |