Jun's Blog

Output, activities, memo and etc.

How to use host os directory from chroot (mock) environment.

On Fedora Project's work, a chroot environment is usually used to build and test. The environment is called "mock" environment.

As I often forget the way, I save it to this page.

There are 2 ways.

1. Using mount --bind

Use below command.

$ mount --bind <old_dir> <new_dir>

The /path/to/root/mnt directory is /mnt in the mock (chroot) environment.

Create a directory to mount a directory.

$ sudo mkdir /var/lib/mock/fedora-rawhide-x86_64/root/mnt/foo

Mounting the directory, it can be referred in the mock (chroot) environment.

$ cd /path/to/foo
$ sudo mount --bind . /var/lib/mock/fedora-rawhide-x86_64/mnt/foo

2. Using mock's mount plugin

2nd way is limited to the mock command. But it's easier way.

The document is here [1].

You can set it for example in $HOME/.config/mock.cfg. This directory is auto-mounted when doing login to the mock environment.

config_opts['plugin_conf']['bind_mount_enable'] = True
config_opts['plugin_conf']['bind_mount_opts']['dirs'].append(('/host_os/path/to/foo', '/mnt/foo' ))

That's all.

References

Travis CI: A better alternative of travis_wait to output the command stdout

I found a better way to run heavy command, seeing a code [1] by chance.

If the command does not output log to stdout or stderr for 10 minutes, the job stops. The popular practice to prevent it is like this. But the problem is this command does not output while processing the command.

.travis.yml

script:
  - travis_wait 40 heavy_command 

And below is a better way.

script:
  # Ping stdout every 9 minutes or Travis kills build,
  # while travis_wait does not show the command output while processing.
  # https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received
  - |
    while sleep 9m; do
      echo "====[ $SECONDS seconds still running ]===="
    done &
  - heavy_command 

$SECONDS shows the processing running time. It seems that is reserved environment variable by Travis CI.

References