Skip to content

Instantly share code, notes, and snippets.

@ilg-ul
Last active January 2, 2017 08:09
Show Gist options
  • Save ilg-ul/46407a070844f764dec6f27bde385797 to your computer and use it in GitHub Desktop.
Save ilg-ul/46407a070844f764dec6f27bde385797 to your computer and use it in GitHub Desktop.
Install local build tools in $HOME/opt/ (multiple Homebrew instances and TeX)
vscode.mac.command

install-opt

This is a collection of scripts, used to install optional tools, required during builds.

The strategy is to allow separate updates for separate builds, otherwise updating the tools for one build may affect other builds.

As a consequence, this means to avoid a large install with all tool needed by all builds, and to install separate sets of tools, one for each build.

A small disadvantage of this strategy is a possible duplication of tools, but disk space is not a real limitation.

The build scripts should update the PATH themselves to access the optional tools.

For manual use, for each set of tools an alias to upadate the PATH can be defined.

Download

These scripts can be downloaded from a GitHub gist (which are a kind of light git projects).

$ mkdir -p $HOME/opt
$ git clone https://gist.github.com/ilg-ul/46407a070844f764dec6f27bde385797 \
    $HOME/opt/install-opt.gist

homebrew

This Homebrew instance provides general purpose tools, like minicom.

To run the install script:

$ caffeinate bash $HOME/opt/install-opt.gist/install-homebrew.sh

The alias to add these tools to the PATH is hb.

$ alias hb='export PATH=$HOME/opt/homebrew/bin:$PATH'

homebrew-gae

This Homebrew instance provides tools used during GNU ARM Eclipse binary tools builds, like QEMU, OpenOCD and Windows Build Tools.

To run the install script:

$ caffeinate bash $HOME/opt/install-opt.gist/install-homebrew-gae.sh

The alias to add these tools to the PATH is hbg.

$ alias hbg='export PATH$HOME/opt/homebrew-gae/bin:$PATH'

homebrew-gcc

This Homebrew instance provides GCC 5 and GCC 6, used during µOS++ test builds.

To run the install script:

$ caffeinate bash $HOME/opt/install-opt.gist/install-homebrew-gcc.sh

The alias to add these tools to the PATH is hbgcc.

$ alias hbgcc='export PATH=$HOME/opt/homebrew-gcc/bin:$PATH'

homebrew-jekyll

This Homebrew instance provides Jekyll, used to generate the GitHub Pages static sites, like GNU ARM Eclipse, µOS++ IIIe/CMSIS++/POSIX++, XCDL/xPack.

To run the install script:

$ caffeinate bash $HOME/opt/install-opt.gist/install-homebrew-jekyll.sh

The alias to add these tools to the PATH is hbj.

$ alias hbj='export PATH=$HOME/opt/homebrew-jekyll/bin:$PATH'

texlive

This is a local instance of TeX Live, used to build the OpenOCD & QEMU manuals.

It generally includes the same packages as the MacTex distribution, and is very large (> 4.5 GB).

To run the install script:

$ caffeinate bash $HOME/opt/install-opt.gist/install-texlive.sh

The alias to add these tools to the PATH is tl.

$ alias tl='export PATH=$HOME/opt/texlive/bin/x86_64-darwin:$PATH'

Note 1: Homebrew blacklisted TeX, ("Installing TeX from source is weird and gross"), but, apart from size and install time, there are no other problems.

Note 2: However, due to its size, it is better to keep TeX separate from the Homebrew instances, which can now be reinstalled more easily.

#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
# Remove the initial space and instead use '\n'.
IFS=$'\n\t'
# -----------------------------------------------------------------------------
echo
echo "Checking if Xcode Command Line Tools are installed..."
xcodebuild -version
# -----------------------------------------------------------------------------
HB_PREFIX=${HB_PREFIX:-"$HOME/opt/homebrew-gae"}
export HOMEBREW_NO_EMOJI=1
echo "Recreating \"${HB_PREFIX}\"..."
rm -rf "${HB_PREFIX}"
mkdir -p "${HB_PREFIX}"
PATH=${HB_PREFIX}/bin:$PATH
# -----------------------------------------------------------------------------
bash -c "(curl -L https://github.com/Homebrew/homebrew/tarball/master | \
tar -x -v --strip 1 -C "${HB_PREFIX}" -f -)"
brew --version
echo "Updating homebrew..."
rm -rf "${HB_PREFIX}/share/doc/homebrew"
brew update
# -----------------------------------------------------------------------------
brew install automake
brew install cmake
brew install pkgconfig
# Required by QEMU
brew install gettext
brew link gettext --force
# makeinfo required to build openOCD & QEMU manuals.
brew install texinfo
brew link texinfo --force
# -----------------------------------------------------------------------------
# To use Homebrew, add something like this to ~/.profile
echo alias hbg=\'export PATH=${HB_PREFIX}/bin:\$PATH\'
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
# Remove the initial space and instead use '\n'.
IFS=$'\n\t'
# -----------------------------------------------------------------------------
echo
echo "Checking if Xcode Command Line Tools are installed..."
xcodebuild -version
# -----------------------------------------------------------------------------
HB_PREFIX=${HB_PREFIX:-"$HOME/opt/homebrew-gcc"}
export HOMEBREW_NO_EMOJI=1
echo "Recreating \"${HB_PREFIX}\"..."
rm -rf "${HB_PREFIX}"
mkdir -p "${HB_PREFIX}"
PATH=${HB_PREFIX}/bin:$PATH
# -----------------------------------------------------------------------------
bash -c "(curl -L https://github.com/Homebrew/homebrew/tarball/master | \
tar -x -v --strip 1 -C "${HB_PREFIX}" -f -)"
brew --version
echo "Updating homebrew..."
rm -rf "${HB_PREFIX}/share/doc/homebrew"
brew update
brew tap homebrew/versions
# -----------------------------------------------------------------------------
brew install gcc5
brew install gcc6
# -----------------------------------------------------------------------------
# To use Homebrew, add something like this to ~/.profile
echo alias hbgcc=\'export PATH=${HB_PREFIX}/bin:\$PATH\'
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
# Remove the initial space and instead use '\n'.
IFS=$'\n\t'
# -----------------------------------------------------------------------------
HB_PREFIX=${HB_PREFIX:-"$HOME/opt/homebrew-gcc5clt"}
export HOMEBREW_NO_EMOJI=1
echo "Recreating \"${HB_PREFIX}\"..."
rm -rf "${HB_PREFIX}"
mkdir -p "${HB_PREFIX}"
PATH=${HB_PREFIX}/bin:$PATH
# -----------------------------------------------------------------------------
bash -c "(curl -L https://github.com/Homebrew/homebrew/tarball/master | \
tar -x -v --strip 1 -C "${HB_PREFIX}" -f -)"
brew --version
echo "Updating homebrew..."
rm -rf "${HB_PREFIX}/share/doc/homebrew"
brew update
brew tap homebrew/versions
# -----------------------------------------------------------------------------
brew install gcc5
# brew install gcc6
# -----------------------------------------------------------------------------
# To use Homebrew, add something like this to ~/.profile
echo alias hbgcc=\'export PATH=${HB_PREFIX}/bin:\$PATH\'
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
# Remove the initial space and instead use '\n'.
IFS=$'\n\t'
# -----------------------------------------------------------------------------
echo
echo "Checking if Xcode Command Line Tools are installed..."
xcodebuild -version
# -----------------------------------------------------------------------------
HB_PREFIX=${HB_PREFIX:-"$HOME/opt/homebrew-jekyll"}
export HOMEBREW_NO_EMOJI=1
echo "Recreating \"${HB_PREFIX}\"..."
rm -rf "${HB_PREFIX}"
mkdir -p "${HB_PREFIX}"
PATH=${HB_PREFIX}/bin:$PATH
# -----------------------------------------------------------------------------
bash -c "(curl -L https://github.com/Homebrew/homebrew/tarball/master | \
tar -x -v --strip 1 -C "${HB_PREFIX}" -f -)"
brew --version
echo "Updating homebrew..."
rm -rf "${HB_PREFIX}/share/doc/homebrew"
brew update
# -----------------------------------------------------------------------------
brew install ruby
ruby --version
gem install jekyll --verbose
jekyll --version
gem install bundler --verbose
bundler --version
# -----------------------------------------------------------------------------
# To use Homebrew, add something like this to ~/.profile
echo alias hbj=\'export PATH=${HB_PREFIX}/bin:\$PATH\'
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is anything but empty.
else
DEBUG=""
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
# Remove the initial space and instead use '\n'.
IFS=$'\n\t'
# -----------------------------------------------------------------------------
HB_PREFIX=${HB_PREFIX:-"$HOME/opt/homebrew"}
export HOMEBREW_NO_EMOJI=1
echo "Recreating \"${HB_PREFIX}\"..."
rm -rf "${HB_PREFIX}"
mkdir -p "${HB_PREFIX}"
PATH=${HB_PREFIX}/bin:$PATH
bash -c "(curl -L https://github.com/Homebrew/homebrew/tarball/master | \
tar -x -v --strip 1 -C "${HB_PREFIX}" -f -)"
brew --version
echo "Updating homebrew..."
rm -rf "${HB_PREFIX}/share/doc/homebrew"
brew update
# -----------------------------------------------------------------------------
brew install minicom gdb tree
# -----------------------------------------------------------------------------
# To use Homebrew, add something like this to ~/.profile
echo alias hb=\'export PATH=${HB_PREFIX}/bin:\$PATH\'
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Safety settings (see https://gist.github.com/ilg-ul/383869cbb01f61a51c4d).
if [[ ! -z ${DEBUG} ]]
then
set ${DEBUG} # Activate the expand mode if DEBUG is -x.
else
DEBUG=""
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
# Remove the initial space and instead use '\n'.
IFS=$'\n\t'
# -----------------------------------------------------------------------------
# This script installs a local instance of TeX Live (https://tug.org/texlive/).
tl_url=http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tl_archive_name="install-tl-unx.tar.gz"
tl_archive_path="$HOME/Downloads/${tl_archive_name}"
tl_folder="/tmp/install-tl"
# The install destination folder.
texlive_prefix="${HOME}/opt/texlive"
# -----------------------------------------------------------------------------
# Download the install tools.
if [ ! -f "${tl_archive_path}" ]
then
curl -L "${tl_url}" -o "${tl_archive_path}"
fi
rm -rf "${tl_folder}"
mkdir -p "${tl_folder}"
# Unpack the install tools.
tar x -v -C "${tl_folder}" --strip-components 1 -f "${tl_archive_path}"
# -----------------------------------------------------------------------------
if [ -d "${texlive_prefix}" ]
then
rm -rf "${texlive_prefix}.bak"
# Backup previous install.
mv "${texlive_prefix}" "${texlive_prefix}.bak"
fi
mkdir -p "${texlive_prefix}"
# -----------------------------------------------------------------------------
# Create the texlive.profile used to automate the install.
tmp_profile=$(mktemp)
# Note: __EOF__ is not quoted to allow local substitutions.
cat <<__EOF__ >> "${tmp_profile}"
# texlive.profile, copied from MacTex
TEXDIR ${texlive_prefix}
TEXMFCONFIG ~/.texlive/texmf-config
TEXMFHOME ~/texmf
TEXMFLOCAL ${texlive_prefix}/texmf-local
TEXMFSYSCONFIG ${texlive_prefix}/texmf-config
TEXMFSYSVAR ${texlive_prefix}/texmf-var
TEXMFVAR ~/.texlive/texmf-var
# binary_universal-darwin 1
binary_universal-darwin 0
binary_x86_64-darwin 1
collection-basic 1
collection-bibtexextra 1
collection-binextra 1
collection-context 1
collection-fontsextra 1
collection-fontsrecommended 1
collection-fontutils 1
collection-formatsextra 1
collection-games 1
collection-genericextra 1
collection-genericrecommended 1
collection-htmlxml 1
collection-humanities 1
collection-langafrican 1
collection-langarabic 1
collection-langchinese 1
collection-langcjk 1
collection-langcyrillic 1
collection-langczechslovak 1
collection-langenglish 1
collection-langeuropean 1
collection-langfrench 1
collection-langgerman 1
collection-langgreek 1
collection-langindic 1
collection-langitalian 1
collection-langjapanese 1
collection-langkorean 1
collection-langother 1
collection-langpolish 1
collection-langportuguese 1
collection-langspanish 1
collection-latex 1
collection-latexextra 1
collection-latexrecommended 1
collection-luatex 1
collection-mathextra 1
collection-metapost 1
collection-music 1
collection-omega 1
collection-pictures 1
collection-plainextra 1
collection-pstricks 1
collection-publishers 1
collection-science 1
collection-texworks 1
collection-xetex 1
in_place 0
option_adjustrepo 0
option_autobackup 1
option_backupdir tlpkg/backups
option_desktop_integration 1
option_doc 1
option_file_assocs 1
option_fmt 1
option_letter 1
option_menu_integration 1
option_path 0
option_post_code 1
option_src 1
option_sys_bin /usr/local/bin
option_sys_info /usr/local/share/info
option_sys_man /usr/local/share/man
option_w32_multi_user 1
option_write18_restricted 1
portable 0
__EOF__
# -----------------------------------------------------------------------------
# https://www.tug.org/texlive/doc/install-tl.html
# Prevent power saving mode.
time caffeinate "${tl_archive_path}/install-tl" \
-no-gui -lang en \
-profile "${tmp_profile}"
# -----------------------------------------------------------------------------
rm "${tmp_profile}"
echo
echo "Done."
# -----------------------------------------------------------------------------
# texlive.profile written on Mon May 23 04:53:01 2016 UTC
# It will NOT be updated and reflects only the
# installation profile at installation time.
selected_scheme scheme-full
TEXDIR /usr/local/texlive/2016
TEXMFCONFIG ~/Library/texlive/2016/texmf-config
TEXMFHOME ~/Library/texmf
TEXMFLOCAL /usr/local/texlive/texmf-local
TEXMFSYSCONFIG /usr/local/texlive/2016/texmf-config
TEXMFSYSVAR /usr/local/texlive/2016/texmf-var
TEXMFVAR ~/Library/texlive/2016/texmf-var
binary_universal-darwin 1
binary_x86_64-darwin 1
collection-basic 1
collection-bibtexextra 1
collection-binextra 1
collection-context 1
collection-fontsextra 1
collection-fontsrecommended 1
collection-fontutils 1
collection-formatsextra 1
collection-games 1
collection-genericextra 1
collection-genericrecommended 1
collection-htmlxml 1
collection-humanities 1
collection-langafrican 1
collection-langarabic 1
collection-langchinese 1
collection-langcjk 1
collection-langcyrillic 1
collection-langczechslovak 1
collection-langenglish 1
collection-langeuropean 1
collection-langfrench 1
collection-langgerman 1
collection-langgreek 1
collection-langindic 1
collection-langitalian 1
collection-langjapanese 1
collection-langkorean 1
collection-langother 1
collection-langpolish 1
collection-langportuguese 1
collection-langspanish 1
collection-latex 1
collection-latexextra 1
collection-latexrecommended 1
collection-luatex 1
collection-mathextra 1
collection-metapost 1
collection-music 1
collection-omega 1
collection-pictures 1
collection-plainextra 1
collection-pstricks 1
collection-publishers 1
collection-science 1
collection-texworks 1
collection-xetex 1
in_place 0
option_adjustrepo 0
option_autobackup 1
option_backupdir tlpkg/backups
option_desktop_integration 1
option_doc 1
option_file_assocs 1
option_fmt 1
option_letter 1
option_menu_integration 1
option_path 0
option_post_code 1
option_src 1
option_sys_bin /usr/local/bin
option_sys_info /usr/local/share/info
option_sys_man /usr/local/share/man
option_w32_multi_user 1
option_write18_restricted 1
portable 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment