Skip to content

Commit

Permalink
[Doc] Update instrumented_libraries.md
Browse files Browse the repository at this point in the history
* Trusty->Xenial
* Avoid building as root
* Remove some hardcoded "thomasanderson" in paths

R=thestig

Bug: None
Change-Id: Ia05b5e5f7f590b07dbcfb18c1f864c57069200b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3209693
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#928973}
  • Loading branch information
tanderson-google authored and Chromium LUCI CQ committed Oct 7, 2021
1 parent e7c77a1 commit b713695
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions docs/linux/instrumented_libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ others are optional, and are currently unused.
### Setting up a chroot

Building the libraries requires `apt-get source`, so the build must be done from
an Ubuntu 14.04 environment. The preferred way is using a chroot. To get
an Ubuntu 16.04 environment. The preferred way is using a chroot. To get
started, install `debootstrap` and `schroot`. If you're running a Debian-based
distro, run:

```shell
sudo apt install debootstrap schroot
```

Create a configuration for a Trusty chroot:
Create a configuration for a Xenial chroot:

```shell
sudo $EDITOR /etc/schroot/chroot.d/trusty_amd64.conf
sudo $EDITOR /etc/schroot/chroot.d/xenial_amd64.conf
```

Add the following to the new file, replacing the instances of `thomasanderson`
with your own username.

```
[trusty_amd64]
description=Ubuntu 14.04 Trusty for amd64
directory=/srv/chroot/trusty_amd64
[xenial_amd64]
description=Ubuntu 16.04 Xenial for amd64
directory=/srv/chroot/xenial_amd64
personality=linux
root-users=thomasanderson
type=directory
Expand All @@ -39,8 +39,8 @@ users=thomasanderson
Bootstrap the chroot:

```shell
sudo mkdir -p /srv/chroot/trusty_amd64
sudo debootstrap --variant=buildd --arch=amd64 trusty /srv/chroot/trusty_amd64 http://archive.ubuntu.com/ubuntu/
sudo mkdir -p /srv/chroot/xenial_amd64
sudo debootstrap --variant=buildd --arch=amd64 xenial /srv/chroot/xenial_amd64 http://archive.ubuntu.com/ubuntu/
```

If your `$HOME` directory is not `/home` (as is the case on gLinux), then route
Expand All @@ -54,45 +54,45 @@ sudo mount --bind "$HOME" /home
Add `sources.list`:

```shell
sudo $EDITOR /srv/chroot/trusty_amd64/etc/apt/sources.list
sudo $EDITOR /srv/chroot/xenial_amd64/etc/apt/sources.list
```

Add the following contents to the file:

```
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted universe
deb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe
deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe
```

Enter the chroot and install the necessary packages:

```shell
schroot -c trusty_amd64 -u root --directory /
schroot -c xenial_amd64 -u root --directory /home/dev/chromium/src
apt update
apt install lsb-release sudo python pkg-config libgtk2.0-bin libdrm-dev nih-dbus-tool help2man
```

Add `depot_tools` to your `PATH`. For example, I have it in `~/dev/depot_tools`,
so I use:
Install library packages:

```shell
export PATH=/home/thomasanderson/dev/depot_tools/:$PATH
third_party/instrumented_libraries/scripts/install-build-deps.sh
```

Change to your src directory:

Change to a non-root user:
```shell
cd /home/thomasanderson/dev/chromium/src
exit
schroot -c xenial_amd64 -u `whoami` --directory /home/dev/chromium/src
```

Install library packages:
Add `depot_tools` to your `PATH`. For example, I have it in `~/dev/depot_tools`,
so I use:

```shell
third_party/instrumented_libraries/scripts/install-build-deps.sh
export PATH=/home/dev/depot_tools/:$PATH
```

Now we're ready to build the libraries. A clean build takes a little over 8
Expand All @@ -111,15 +111,12 @@ bucket. `dpranke@` can grant access.
# Exit the chroot.
exit

# Fix permissions.
sudo chown -R `whoami`:`groups | awk '{print $1;}'` *.tgz out/Instrumented-*

# Move files into place.
mv *.tgz third_party/instrumented_libraries/binaries

# Upload.
upload_to_google_storage.py -b chromium-instrumented-libraries third_party/instrumented_libraries/binaries/msan-chained-origins-trusty.tgz
upload_to_google_storage.py -b chromium-instrumented-libraries third_party/instrumented_libraries/binaries/msan-no-origins-trusty.tgz
upload_to_google_storage.py -b chromium-instrumented-libraries third_party/instrumented_libraries/binaries/msan-chained-origins-xenial.tgz
upload_to_google_storage.py -b chromium-instrumented-libraries third_party/instrumented_libraries/binaries/msan-no-origins-xenial.tgz
```

## Testing and uploading a CL
Expand Down

0 comments on commit b713695

Please sign in to comment.