http://ads.buzzcity.net/adpage.php?partnerid=40096
分类: LINUX
2010-11-30 13:42:43
Note: When you produce a Chromium OS image, you need to fulfill the various attribution requirements of the third party licenses. Currently, the images generated by a build don't automatically do this for you. You'll need to modify .
sudo
access (root access is needed to run the chroot
command and modify the mount table). NOTE: You shouldn't run any of
the commands here as root--the commands themselves will run sudo to get
root access when needed.sudo aptitude install git gitk git-gui
git gui
) and revision history browser (gitk
).ssh
connection. That means we need to setup a ssh key. Create a key using ssh-keygen
. You will be asked for a password. Please provide one in order to protect your key. Don't worry, with the keychain
program (see below) you won't need to enter this password very often.ssh-keygen -t rsa -f ~/.ssh/chromium
~/.bashrc
file:eval `keychain --eval ~/.ssh/chromium`
keychain
command yourself now so that your current terminal will have access.~/.ssh/config
file:
Host gitrw.chromium.org
Port 9222
User git
IdentityFile %d/.ssh/chromium
# The remaining lines are optimizations for faster sync times. They
# are not strictly necessary
# NOTE: You should _NOT_ have ControlMaster and ControlPath lines
# here. The repo tool handles setting up ControlMaster and
# ControlPath and if you have something here it could potentially
# conflict with repo's configuration.
# Turn off negotiations that don't make sense for sync connections
GSSAPIAuthentication no
GSSAPIKeyExchange no
PasswordAuthentication no
RSAAuthentication yes
ForwardX11 no
ForwardX11Trusted no
ForwardAgent no
HostbasedAuthentication no
RhostsRSAAuthentication no
Protocol 2
# Prefer faster ciphers and MACs.
Ciphers arcfour256,aes128-ctr,aes192-ctr,aes256-ctr
MACs umac-64@openssh.com,hmac-md5,hmac-sha1
${HOME}/chromiumos
, and this seems fairly common among Chromium OS developers. I would suggest placing your source there, and all commands in this document assume that. If you feel strongly, feel free to put your own source elsewhere.mkdir -p
/usr/local/path/to/source/chromiumosln -s /usr/local/path/to/source/chromiumos ${HOME}/chromiumos
mkdir -p ${HOME}/chromiumos
${HOME}/trunk
(and the instructions suggested this for a while). Having the source in ${HOME}/trunk
allows you to have some sloppiness later (you can enter the same
commands inside the build chroot and outside). That may be convenient,
but is dangerous because it might lead to you submitting a change to a
build script that works on your machine, but doesn't work on someone
else's machine (who doesn't have the code in ${HOME}/trunk
).repo
, it is effectively a wrapper for the that helps deal with a large number of git repositories. You already installed repo
when you installed depot_tools
above.cd ${HOME}/chromiumos
repo init -u
repo sync
cd ${HOME}/chromiumos
repo init -u ssh://git@gitrw.chromium.org:9222/manifest
repo sync
repo
command to use the minilayout by appending -m minilayout.xml
to the repo init
line above. It is the author's advice that you not do this. It makes
grepping for source code very difficult (though it does optimize your
repo sync a bit).repo init -u [-m minilayout.xml]
-b 0.9.94.T
)${HOME}/chromiumos
(or wherever your source lives), the commands to setup the chroot are:cd src/scripts
./make_chroot --replace
--replace
flag above will actually delete any old chroot that might have been present and re-create a new one. If you don't pass in --replace, the make_chroot
command will attempt to "fixup" your existing chroot. I've heard this
is not particularly well tested at the moment, so you probably shouldn't
do it unless someone tells you to.src/scripts
directory:./enter_chroot.sh
sudo
command (entering the chroot requires root privileges), then print out a
bunch of messages. Once it is done, that terminal is in the chroot and
you'll be in the ~/trunk/src/scripts
directory (where most build commands live).src/scripts
directory is the same src/scripts
directory as you were in before you entered the chroot, even though it
looks like a different location. That's because when you enter the
chroot, the "~/trunk
"
directory in the chroot is mounted such that it points to the main
Chromium OS directory. This means that changes that you make to the
source code outside of the chroot immediately take effect inside the
chroot../make_chroot --delete
to do it properly. Using rm -rf
could end up deleting your source tree.~/trunk/src/overlays
:x86-generic
to whatever board you want to build for):BOARD=x86-generic
~/trunk/src/scripts
directory):./setup_board --board=${BOARD} --force
/build/${BOARD}
.--default
" flag to setup_board
, it will place the board name in the file ~/trunk/src/scripts/.default_board
(it does the same as echo ${BOARD} > ~/trunk/src/scripts/.default_board
). This will make it so that you don't need to specify a --board
argument to all future commands. We don't do that in these
instructions so that you can explicitly see what commands are actually
board-specific.--force
into this command and you've already setup/built for this board
previously, it will fail. You can only setup a board that does not yet
exist. The --force
flag will delete the /build/${BOARD}
directory and setup a new board. Like enter_chroot.sh
, most people only re-run setup_board
when told to (AKA they don't re-run it even after a repo sync
).sudo rm -rf /build/${BOARD}
sudo
command) by logging in with the shared user account: chronos. You should set a password for this user by entering this command from inside the ~/trunk/src/scripts directory:./set_shared_user_password.sh
shared_user_password.txt
" file in your src/scripts
directory. src/scripts
"
directory is the same physical directory both inside and outside the
chroot (not colored purple here to emphasize that). That means that, even if you completely recreate your chroot, you don't have to run this command again. The only time you'd ever need to run it again is if you sync down fresh source code../enable_localaccount.sh USERNAME
./build_packages
--board=${BOARD} --oldchromebinarymake all
in a
standard Makefile system. This command is supposed to handle
incremental builds, so you will want to run it whenever you change
something and need it rebuilt (or after you run repo sync
).cros_workon
). If you are working on a package, build_packages will build using your local sources. See below for information about cros_workon.--oldchromebinary
flag is not strictly necessary but will make your build faster in some
rare instances (when the Chrome/Chromium browser has recently been
revved) at the cost of a slightly older version of Chrome/Chromium.
This may become the default in the future.--nowithdev
, --nowithautotest
, etc), you shouldn't use them (even if you don't plan on building a developer / test image). There are some that can cause some hard-to-debug differences if you use one of these options.build_packages
step is done, you're ready to make an image by running this command from inside the ~/trunk/src/scripts directory:./build_image --board=${BOARD} --withdev --noenable_rootfs_verification
~/trunk/src/build/images/${BOARD}/versionNum/
(where versionNum will actually be a version number). The most recent image produced for a given board will be symlinked to ~/trunk/src/build/images/${BOARD}/latest.build_image
, it will create a files that take up over 4GB of space (!).cd ~/trunk/src/build/images/${BOARD}/latest
./unpack_partitions.sh chromiumos_image.bin
mkdir -p rootfs
sudo mount -o loop part_3 rootfs
exit
this chroot when you're done.sudo chroot
~/trunk/src/build/images/${BOARD}/latest/rootfscd ~/trunk/src/build/images/${BOARD}/latest
ROOTA_START=`grep 'ROOT-A' unpack_partitions.sh | awk '{print $2;}'`
mkdir -p rootfs
sudo mount -o loop,offset=$((512 * ${ROOTA_START})) chromiumos_image.bin rootfs
src/scripts/mount_gpt_image.sh
. Rewrite the above using that script../image_to_usb.sh --board=${BOARD}
/dev/sdc
), you're ready to re-enter the command with a --to parameter (you should replace ${MY_USB_KEY_LOCATION} with the one for your disk, like /dev/sdc
):./image_to_usb.sh --board=${BOARD} --to=${MY_USB_KEY_LOCATION}
--from
.shell
command to get the shell prompt. NOTE: you don't need to enter the chronos password here, though you will still need the password if you want to use the sudo
command./usr/sbin/chromeos-install
kvm
(which uses qemu images) by entering this command from the ~/trunk/src/scripts directory:./image_to_vm.sh --board=${BOARD}
--format=vmware
and --format=virtualbox
options. --from
and --to
parameters.chromeos-base/chromeos-chrome
ebuilds contain a step for verifying that the libcros
API is still compatible with the revision of Chromium being built. In
order for the ebuild to find the header files you'll need to "work on"
the chromeos-chrome/libcros
package. Do the following from within the ~/trunk/src/scripts directory:# You only need to do this once!
./cros_workon start chromeos-base/libcros
repo sync
# If you want to always build from source you can export the variables:
export CHROME_ORIGIN=LOCAL_SOURCE
export FEATURES="-usersandbox"
export USE="-build_tests"
./build_packages
# If you want to only emerge the browser:
USE="-build_tests" FEATURES="-usersandbox" CHROME_ORIGIN=LOCAL_SOURCE emerge-${BOARD} chromeos-base/chromeos-chrome
./start_devserver
--board=${BOARD} --client_prefix ChromeOSUpdateEngine --noenable_rootfs_verification
for gmerge to work (right?).ebuild
for the package lives in the src/third_party/chromiumos-overlay
or src/overlays/overlay-${BOARD}
directories.9999.ebuild
.cros-workon
class.KEYWORD
in the ebuild containing this architecture name (like "x86
")../cros_workon --board=${BOARD} list --all
chromeos-wm
):./cros_workon --board=${BOARD} start ${PACKAGE_NAME}
9999
version of the ebuild
instead of the stable, committed version.minilayout
when you did your repo init
, this will add a clause to your .repo/local_manifest.xml
to tell repo
to sync down the source code for this package next time you do a repo sync
.minilayout
,
but is probably a good idea in any case to make sure that you're
working with the latest code (it'll help avoid merge conflicts later).
You'll want to run this from outside the chroot, anywhere under your ~/chromiumos
directory:repo sync
if you run repo sync inside your chroot ensure your email is configured right in git (git config -l
). If your local commit email differs from your git config email address or if your git config email address is unset a "repo sync" will discard your local commits. Themake_chroot
/enter_chroot
commands have been enhanced to copy your global git config into the chroot, so this should just work.
equery-${BOARD} which
${PACKAGE_NAME}/home/.../trunk/src/third_party/chromiumos-overlay/chromeos-base/chromeos-wm/chromeos-wm-9999.ebuild
/home/.../trunk/src/third_party/chromiumos-overlay/chromeos-base/chromeos-wm/chromeos-wm-0.0.1-r134.ebuild
git
repo it's under):ebuild-${BOARD} `equery-${BOARD} which ${PACKAGE_NAME}
` info
CROS_WORKON_SRCDIR="/home/.../trunk/src/platform/window_manager"
CROS_WORKON_PROJECT="window_manager"
ALL_PACKAGES=`./cros_workon --board=${BOARD} list --all`
for package in ${ALL_PACKAGES}; dorepo
/git
and git-cl
,
you should always create a local branch whenever you make a change.
You can run the command to do this from outside the chroot (anywhere
under your ~/chromiumos
directory) or from within the chroot. In the command, you'll want to replace ${CROS_WORKON_PROJECT} with the project name you found in the previous step and replace ${BRANCH_NAME} with a name that is meaningful to you and describes this change (nobody else will see this name):repo start ${BRANCH_NAME} ${CROS_WORKON_PROJECT}
./bin/cros_workon_make --board=${BOARD} ${PACKAGE_NAME}
./bin/cros_workon_make --board=${BOARD} ${PACKAGE_NAME} --tests
cros_workon_make --help
to see other options that are supported.git
and git cl
ones) will open up an editor. You probably will want to do one of these three commands (depending on your favorite editor). nano
is a reasonable editor:export EDITOR='nano'
vi
:export EDITOR='vi'
emacs
(and don't want an XWindow to open up every time you do something):export EDITOR='emacs -nw'
.bashrc
(or similar file) too.git
. Full documentation of how to use git is
a bit beyond this guide, but you might be able to commit them by
running something like this command from the project directory:git commit -a
git-cl
command will grab all of your previous descriptions, but you will have a chance to edit them.git cl upload
git cl upload
command will bring up a text editor.
What you write here is important, since it will get sent to the code
review server. The first line should be a short description of your
change. Later lines can contain more descriptions. The text editor
will also be populated with BUG= and TEST= lines. BUG=bug-tracker:number
.
If this change is related to more than one tracker issue, you can list
them all separated with commas. You can get a tracker name by looking
in the upper-left corner in the tracker page.# Enter a description of the change.
# This will displayed on the codereview site.
# The first line will also be used as the subject of the review.
Here's a SHORT, one-line summary of my change.
And here is more details
...this can be as long as I want.
BUG=chromium-os:99999, chromium:88888
TEST=Ran all the white box tests
git-cl
stores the code review "issue number" as meta data on your git branch. That means that each git branch is associated with one and only one code review. If you do a second git cl upload on your branch, it will amend your previous code review, not start another one.git cl push
repo sync
before the git cl push
to make sure that nothing is broken. This could cause a merge conflict. TODO: Some short desc of how to deal with merge conflicts?repo start
another branch, then later come back to this branch by doing git checkout ${BRANCH_NAME}
from within a directory associated with this project.git cl issue 0
.cros_workon
that you're done by running this from inside the ~/trunk/src/scripts directory:./cros_workon --board=${BOARD} stop ${PACKAGE_NAME}
-9999.ebuild
and to stop forcing a build from source every time.repo abandon ${BRANCH_NAME} ${CROS_WORKON_PROJECT}
repo abandon
command, it will throw out any local changes across all projects. You might also want to look at git branch -D
or repo prune
.minilayout
, doing a cros_workon stop won't remove your source code. It will continue to stay on your hard disk and get synced down.cros_workon
steps. Specifically, note that you still need the repo start
step.src/scripts
)ebuild
files themselves (like the ones under src/third_party/chromiumos-overlay
)--board=${BOARD}
parameter can also be passed a --host
parameters. That will make the commands affect the host (AKA the chroot) rather than the board.cros_workon --host
will say that you want to build a package used in the chroot from source.make_chroot
script, remember that
most developers won't get your change for a long time. People tend to
build their chroot once, then never again. I believe that we're moving
away from having the make_chroot script do much.emerge-${BOARD}
. For example, if you want to build dash to test on your device:emerge-${BOARD} dash
$ mkdir cros_0.9.110.B/ && cd cros_0.9.110.B/
$ repo init -u-b [-m minilayout.xml]
$ #...follow steps above to edit/modify files i.e repo sync, cros_work start, repo start etc.
$ git cherry-pick -x#To pull in changes that exist on another branch (TIP: git has all the objects from all branches)
$ git log # to verify the SHA1 exists on the branch.
$ git cl upload #A new issue will be created for this branch commit
$ git cl push # Make sure you have tested on your new branch - just cherry-picking doesn't guarantee it will build on the new branch
emerge
inside the chroot it will use wget
to fetch packages. This wget process is run as the portage
user, and if that user is unable to talk on the network it will be
unable to resolve hostnames, among other things. This can happen if the
machine is using a local firewall service such as UncomplicatedFireWall
(ufw
package on Ubuntu) that limits network traffic to a specific set of users.$ sudo iptables -L ufw-after-output | grep owner
ACCEPT all -- anywhere anywhere owner UID match root
ACCEPT all -- anywhere anywhere owner UID match yourname
portage
user to the list of allowed users. First, create the user on the build machine:sudo useradd -d /var/tmp/portage -N -s /bin/false portage
/etc/ufw/after.rules and /etc/ufw/after6.rules
:# allow outbound connections by portage user for building chromiumos
-A ufw-after-output -m owner --uid-owner portage -j ACCEPT
sudo restart ufw
./image_to_usb.sh --board=${BOARD} --test_image --to=${MY_USB_KEY_LOCATION}
./image_to_vm.sh --board=${BOARD}
--test_image --statefulfs_size
parameter.
Otherwise, certain autotest scenarios will run out of stateful
partition disk space since its default size on ChromeOS image files is
equal to rootfs size of 2G.mod_image_for_test.sh
script directly. That will cause the script, by default, to modify your existing chromiumos_image.bin for
test. I don't see a lot of good reason to do this, unless you are low
on disk space and know that you won't ever need the non-modified image.git
repository Rtests_${testname}
into the IUSE_TESTS
variable. Prefix your test with a +
if you want it to be enabled by default.cros_workon start X
. Mysterious failures mode will occur otherwise.USE=
" output. The command tells emerge
to "pretend" to build the tests and print out verbose output. You'll want to replace ${EBUILD_NAME} with the name of an ebuild
containing tests (see just below), like autotest-tests:emerge-${BOARD} -pv ${EBUILD_NAME}
chromeos-base/autotest-tests
- the default set of tests, that did not fall anywhere elsechromeos-base/chromeos-chrome
- chrome tests; the tests that are part of chromeqemacs
. The qemacs editor
is available, even on release images (though to get to the shell,
remember that you need to be in developer mode). Yes, it's not vi
. Yes, it's not nano
. ...but at least it's something. Some future version of Chromium OS may include vi (maybe even instead of qemacs) through busybox
.busybox
on a USB key or an SD Card. I formatted by USB key with ext3
and named it utils
(and that is assumed in these instructions) using the Disk Utility that
comes with Ubuntu (go to the System menu at the top of the screen, then
Administration). Since busybox is
built as part of a normal build (it's used in the factory image), you
can copy it to your USB key like this (run from outside the chroot):sudo chown root.root /media/utils
sudo chmod o+rx /media/utils
sudo cp ~/chromiumos/chroot/build/${BOARD}/bin/busybox /media/utils/
sudo chmod o+rx /media/utils/busybox
for cmd in less vi zip zcat; do
sudo ln -s busybox /media/utils/
$cmd
done
sudo umount /media/utils
/media/utils
. You can get access to your commands with:sudo mount -o remount,exec /media/utils
export PATH="$PATH:/media/utils"
~/.bashrc
:if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
~/.bashrc
:[ -f "$HOME/etc/bash_completion" ] && . "$HOME/etc/bash_completion"
~/.bash_profile
: export PS1='\h:\W$(__git_ps1 "(%s)") \u\$ '
fetch = "ssh://gitrw.chromium.org"
review = "" />
name = "nameofgitrepo"
remote = "private" />
repo manifest -o tmp.xml
to dump your current manifest to see an example. More documentation on the manifest file format is available on the .repo branches
command.repo
and git-cl
are not really optimized for this workflow. Why?repo start ${BRANCH_NAME} ${CROS_WORKON_PROJECT}
repo start
to do this one. Remember, that I'm assuming ${CROS_WORKON_PROJECT}
is the name of your project.repo start ${BRANCH_NAME}_A ${CROS_WORKON_PROJECT}
cd `repo forall ${CROS_WORKON_PROJECT} -c 'pwd'`
git cherry-pick
. First, use git log
to figure out what changes you want:git log ${BRANCH_NAME}
--format=short
):commit d7b250822f98bda19f62072555beb66602bed29d
Author: Me
Change 4
commit 0c577cee881471d6509c91eba8eeeb0c8bec1551
Author: Me
Change 3
commit 0a7285d2d09159e540fb89f086f58a457b5f583f
Author: Me
Change 2
commit dd1ee8d9a9d3148cf4403c339ab18f094304d2fa
Author: Me
Change 1
git cherry-pick
to pick the changes you want. ...so if I wanted change #1 and #3, I could do:git cherry-pick dd1ee8d9a9d3148cf4403c339ab18f094304d2fa
git cherry-pick 0c577cee881471d6509c91eba8eeeb0c8bec1551
git branch ${BRANCH_NAME}_B ${BRANCH_NAME}_A
git checkout
${BRANCH_NAME}_Bgit cherry-pick 0a7285d2d09159e540fb89f086f58a457b5f583f
git cherry-pick d7b250822f98bda19f62072555beb66602bed29d
git diff
command you can do to verify that:git diff ${BRANCH_NAME}..${BRANCH_NAME}_B
git checkout ${BRANCH_NAME}_A
git cl upload
git checkout ${BRANCH_NAME}_B
git cl upload ${BRANCH_NAME}_A # sends diff from
${BRANCH_NAME}_A
to
${BRANCH_NAME}_B
git checkout ${BRANCH_NAME}_A
# ... make changes ...
git checkout ${BRANCH_NAME}_B
git rebase
${BRANCH_NAME}_A # Incorporate branch A's changes into branch Bgit checkout ${BRANCH_NAME}_B
# ... make changes ...
git cl upload ${BRANCH_NAME}_A # sends diff from
${BRANCH_NAME}_A
to
${BRANCH_NAME}_B
git checkout ${BRANCH_NAME}_A
git cl push
git checkout cros/master
git pull
git checkout ${BRANCH_NAME}_B
git rebase --onto cros/master ${BRANCH_NAME}_A
--withdev
" and others
talk about switching your hardware to "developer mode". It turns out
that, for most things, the two actions both enable the same set of
things (like the shell command in crosh). Thus, we refer to either as
being in "developer mode"./bin/cros_boot_mode
developer
. It will also make the file /mnt/stateful_partition/.developer_mode
appear.
--withdev
will create a file called /root/.dev_mode
(in addition to adding a whole bunch of useful developer tools to your stateful partition). The presence of the /root/.dev_mode file
will enable developer mode and also prevent wiping of the stateful
partition when you switch your hardware between developer mode and
release mode.--noenable_rootfs_verification
. If you have questions about this option, you might find answers here.