double-z
7/19/2016 - 3:12 PM

Habitat Notes

Habitat Notes

Habitat Notes

Things I'm learning while using Habitat, written down so I remember them.

Cache artifacts in a Mac studio

export HAB_DOCKER_OPTS="-v /Users/nathansmith/.hab/cache/artifacts /hab/studios/src/hab/cache/artifacts"

Find reverse dependencies for a package

From the core-plans directory run

find . -name plan.sh | bin/build-dependent-order.rb $pkg_origin/$pkg_name

Get the directory of the script you're running in bash

get_script_dir () {
  SOURCE="${BASH_SOURCE[0]}"
  while [ -h "$SOURCE" ]; do
    DIR="$(cd -P "$( dirname "$SOURCE" )" && pwd)"
    SOURCE="$(readlink "$SOURCE")"
    [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
  done
  (cd -P "$(dirname "$SOURCE")" && pwd)
}

(based on http://www.ostricher.com/2014/10/the-right-way-to-get-the-directory-of-a-bash-script/)

Ignore a ShellCheck rule

# shellcheck disable=SC2002

Make the "don't run bundler as root" warning go away

export BUNDLE_SILENCE_ROOT_WARNING=1

"No space left on device" error on Docker for Mac

rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

This will probably wipe out any container's you've previously downloaded. You can also try resizing this image but it's faster just to delete it.

See https://forums.docker.com/t/no-space-left-on-device-error/10894/3

Set CA cert path for Git

When using something that does Git over HTTPS, the Git executable can't find the CA certs. Put this in your do_prepare:

git config --global http.sslCAInfo "$(pkg_path_for cacerts)/ssl/certs/cacert.pem"

(you need a build dep on core/cacerts)

Turn off the NPM spinner

On NPM 2 (with Node <= 4):

npm config set spin=false

On NPM 3 (with Node >= 5):

npm config set progress=false

Detect systemd

[[ (-f /proc/1/comm) && ($(cat /proc/1/comm) = "systemd") ]]

or not systemd:

[[ (! -f /proc/1/comm) || (! $(cat /proc/1/comm) = "systemd") ]]

Which services are running on which ports?

hab pkg exec core/net-tools netstat --tcp --udp --listening --program